Skip to main content

Initiating the payment

PayTabs provides you with the backend packages that make the integrating with PayTabs payment gateway very easy by providing ready-made classes that handle the payment process.

This manual is dedicated to walking you through how to initiate the payment/request payload using the configuration options and parameters that have already been clarified in the previous step, "Step 2 - Configure the integration method". Please follow the below steps to initiate a Hosted Payment Page via this package:



  • First thing, assigning the PayTabs Node.js module paytabs_pt2 to a variable and set the configs as mentioned on the previous step.

    const PayTabs = require('paytabs_pt2');

    PayTabs.setConfig( profileID, serverKey, region);
  • Then, you MUST call the createPaymentPage() function to initiate the payment page along with passing the payment, transaction, cart, URLs, customer, and shipping details to initiate a pre-filled payment page with your provided information.

    let paymentMethods = ["all"];

    let transactionDetails = [
    transaction.type,
    transaction.class
    ];

    let cartDetails = [
    cart.id,
    cart.currency,
    cart.amount,
    cart.description
    ];

    let customerDetails = [
    customer.name,
    customer.email,
    customer.phone,
    customer.street,
    customer.city,
    customer.state,
    customer.country,
    customer.zip,
    customer.IP
    ];

    let shippingDetails = customer_details; // If both are the same, otherwise set the shipping details.

    let response_URLs = [
    url.response,
    url.callback
    ];

    let lang = "ar";

    callback = function ($results) {
    console.log($results);
    }

    let frameMode = true;

    PayTabs.createPaymentPage(
    paymentMethods,
    transactionDetails,
    cartDetails,
    customerDetails,
    shippingDetails,
    responseURLs,
    lang,
    callback,
    frameMode
    );

To get to know each function and its passed parameters, kindly check the below:

We are glad to be always in help. We aim to serve you better each time. As such, please spare a minute to share feedback about your recent experience with PayTabs Developers , on Trustpilot, or Google Reviews.