I want to add paystack bank validator to gravity form

I want to integrate Flutterwave bank account validation into a Gravity Form. When a user enters a bank code and account number, I will add an HTML button:

<button type="button" id="verify-account-button">Verify Account</button>

When the user clicks this button, the account name should automatically be displayed in the “Full Name” field using the Flutterwave API. I tried implementing this, but it did not work.

Can you help fix the issue?

jQuery(document).ready(function($) {
    $('#verify-account-button').on('click', function(e) {
        e.preventDefault();

        // Get the values from the form fields
        var bankCode = $('.input_bank_code').val(); // Bank Code
        var accountNumber = $('.input_account_number').val(); // Account Number

        // Make the API request to Flutterwave
        $.ajax({
            url: 'https://api.flutterwave.com/v3/accounts/resolve',
            type: 'POST',
            headers: {
                'Authorization': 'Bearer FLW_SECRET_KEY' // Replace with your Flutterwave Secret Key
            },
            data: {
                account_number: accountNumber,
                account_bank: bankCode
            },
            success: function(response) {
                if (response.status === "success") {
                    // Populate the full name field with the account holder's name
                    $('.input_full_name').val(response.data.account_name);
                } else {
                    alert('Account verification failed');
                }
            },
            error: function(error) {
                console.log(error);
                alert('Error validating account.');
            }
        });
    });
});

i also add this code to theme function.php

function ensure_jquery_is_loaded() {
    wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'ensure_jquery_is_loaded');

pls help with my decision

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.