PayTabs Node.js Package makes integration with the PayTabs payment gateway very easy by providing a ready-made payment class that handles the card entry, and billing & shipping information and completes the missing details.


This article 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". All you have to do is to follow the below steps to initiate a Hosted Payment Page via this package: 

  • As we already initiated the"paytabs" object and set the configs on a 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 transaction_details = [
        transaction.type,
        transaction.class
    ];
    
    let cart_details = [
        cart.id,
        cart.currency,
        cart.amount,
        cart.description
    ];
    
    let customer_details = [
        customer.name,
        customer.email,
        customer.phone,
        customer.street,
        customer.city,
        customer.state,
        customer.country,
        customer.zip,
        customer.IP
    ];
    
    let shipping_address = customer_details;
    
    let response_URLs = [
        url.response,
        url.callback
    ];
    
    let lang = "ar";
    
    paymentPageCreated = function ($results) {
        console.log($results);
    }
    
    let frameMode = true;
    
    paytabs.createPaymentPage(
        paymentMethods,
        transaction_details,
        cart_details,
        customer_details,
        shipping_address,
        response_URLs,
        lang,
        paymentPageCreated,
        frameMode
    );







⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The Node.js Packge Integration Manual" solution article. 
        
And to get familiar with the rest of the steps regarding the previous step
"Step 2 - Configure the integration method" kindly click here. And to get familiar with the rest of the steps regarding the current step "Step 3 - Initiating the payment" click here.
        
 And to navigate to the next step in the integration process "Step 4 - Accepting the payment" kindly click here.