Search for Resources and Solutions

How to make Ajax calls from a Payments gateway

The Ajax's call for Payments gateways is same like for Midrub's Apps and Components. I've invented it first for the Midrub's Apps and after extended to all Midrub's features because it's easy to use and works very well.

Below you can see a simple Ajax's request:

    // Create an object with form data
    var data = {
        action: 'process_payment'

    // Make ajax call
    Main.ajax_call(url + 'user/payment-ajax/baintree', 'GET', data, 'payment_response');

The code above has:

  • process_payment - php's method.
  • url + 'user/payment-ajax/baintree' - endpoint and payment-ajax is important for a Payment gateway call.
  • GET - method used
  • payment_response - contains the name of the method which will catch the response. 

Ajax's response looks like this:

    Main.methods.payment_response = function (status, data) {

        // Verify if the success response exists
        if (status === 'success') {

        } else {


The Ajax's requests are simple in Midrub and a smart developer can create his.

Was this article helpful?