How to check ACH Bank Account is valid or not in Stripe.

ACH Bank

Today I am going to explain to you How to check ACH Bank Account is valid or not in Stripe. if it is a verified account then we will get a success message otherwise it will not using Stripe and Laravel.


Step 1: First Create a Blade file.

After Create a blade file put your HTML code into this file.

<div id="ach_bank_div" class="ach_bank">
        <div class="form-group text-input-group ach-checked-field">
            <div class="input-group">
                <label for="account_name" class="col-form-label">Account Holder Name<span class="text-danger">*</span></label>
                <input type="text" class="account-name" name='account_holder_name' autocomplete="off" id="account_holder_name">
                <span class="text-danger accountnameValidate"></span>
            </div>
            <div class="input-group">
                <label for="account_type" class="col-form-label">Account Type<span class="text-danger">*</span></label>
                <select name="account_holder_type" class="form-control account-type" id="account_holder_type">
                    <option value="individual">Individual</option>
                    <option value="company">Company</option>          
                </select>
                <span class="text-danger accounttypeValidate"></span>
            </div>
            <div class="input-group">
                <label for="account_number" class="col-form-label">Account Number<span class="text-danger">*</span></label>
                <input type="number" class="account_number" name="account_number" autocomplete="off" id="account_number" placeholder="000123456789">
                <span class="text-danger accountnumberValidate"></span>
            </div>
            <div class="input-group">
                <label for="routing_number" class="col-form-label">Routing Number<span class="text-danger">*</span></label>
                <input type="number" class="routing_number" name="routing_number" autocomplete="off" id="routing_number" placeholder="110000000">
                <span class="text-danger routingnumberValidate"></span>
            </div>
        </div>
        <div id="paymentResponse_bank"></div>
    </div>


Step 2: Insert JS into your Html

// Create an instance of the Stripe object
    // Set your publishable API key
    var stripe = Stripe('{{ env("STRIPE_PUBLISH_KEY") }}');
       
    // Create an instance of elements
    var elements = stripe.elements();

var bankAccountData = {
                    country: 'us',
                    currency: 'usd',
                    routing_number : document.getElementById('routing_number').value,
                    account_number : document.getElementById('account_number').value,
                    account_holder_name: document.getElementById('account_holder_name').value,
                    account_holder_type: $('.account-type').find('.current').html(),
                };
                var resultContainer_Bank = document.getElementById('paymentResponse_bank');
                stripe.createToken('bank_account', bankAccountData).then(function (result) {
                    if (result.error) {
                        resultContainer_Bank.innerHTML = '<p class="text-center text-danger font-italic">' + result.error.message + '</p>';
                    } else {
                        stripeTokenHandlerBank(result.token);
                    }
                });

function stripeTokenHandlerBank(token) {
        var form = document.getElementById('form id enter here');
        // Insert the token ID into the form so it gets submitted to the server
        var hiddenInput = document.createElement('input');
        hiddenInput.setAttribute('type', 'hidden');
        hiddenInput.setAttribute('name', 'stripebankToken');
        hiddenInput.setAttribute('value', token.id);
        form.appendChild(hiddenInput);
        form.submit();
        // Submit the form
    }

Now you can test with Stripe Ach testing Bank Account number and routing numbers like 110000000 (Routing Number) and 000123456789 (Account Number)

I hope it will help to Integrate Stripe ACH Bank Manual Collecting amount from the Customer. In the Next Tutorial, I will explain to How to Send Money through ACH bank on the Server-side and Payment will successful.

About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!