Paytabs provides you with a collection of API endpoints which used to process all payments, regardless of if they are through either your own payment pages, the managed payment pages, or if you are using the hosted payment pages.  


This article is dedicated to the clarification of the payment_token parameter. The payment token is exclusively used with the Managed-Form integration type to create payment requests.


To understand more about how to generate the payment token check the article Managed Form | Initiating the payment | Part (1) - Frontend



In this article, you will be going to know:


Specifications 


The Parameter Tag/Namepayment_token
JSON Example
{
    "payment_token": "DhDdxmft7x6nkMVzKgtk"
}
JavaScript
Data TypeString
Required
  Required exclusively with Managed-Form integration type 
Validation Rules

Valid Token that was generated earlier with a client end request using the paylib.js

Max Length



Usage Workflow


Based on the Token-Based transactions mentioned in our Step 3.3 - PT2 API Endpoints | Token-Based Transactions solution article, you will need to set the "payment_token" as shown below:


The Request payload 


The below sample request payload will show you how you can pass the above-mentioned parameters, which are needed to be passed with valid values to perform a request.

{
    "profile_id": "987654",
    "tran_type": "sale",
    "tran_class": "ecom",
    "cart_id": "CART#1001",
    "cart_currency": "USD",
    "cart_amount": 500,
    "cart_description": "Description of the items/services",
    "customer_details": {
        "name": "Mohammed EL Rayes",
        "email": "[email protected]",
        "phone": "+201234567890",
        "street1": "address street",
        "city": "Cairo",
        "state": "CAI",
        "country": "EG",
        "zip": "45555",
        "ip": "1.1.1.1"
    },
    "payment_token": "Dh4r8Jwt7x6tPMVzKgtk"
}


The Response payload


Once the managed form request is validated and initiated, you will receive the following response,  There are two scenarios that would change the workflow.



If the card does NOT require 3DSecure authentication from the cardholder and issuer side, You will receive a response like the following:

{
    "tran_ref": "TST2233401397769",
    "tran_type": "Sale",
    "cart_id": "CART#1001",
    "cart_description": "Description of the items/services",
    "cart_currency": "USD",
    "cart_amount": "500.00",
    "tran_currency": "USD",
    "tran_total": "500.00",
    "return": "none",
    "customer_details": {
        "name": "Mohammed EL Rayes",
        "email": "[email protected]",
        "phone": "+201234567890",
        "street1": "address street",
        "city": "Cairo",
        "state": "C",
        "country": "EG",
        "zip": "45555",
        "ip": "1.1.1.1"
    },
    "payment_result": {
        "response_status": "A",
        "response_code": "G17534",
        "response_message": "Authorised",
        "transaction_time": "2022-11-30T14:12:14Z"
    },
    "payment_info": {
        "payment_method": "Visa",
        "card_type": "Credit",
        "card_scheme": "Visa",
        "payment_description": "4111 11## #### 1111",
        "expiryMonth": 12,
        "expiryYear": 2022
    },
    "serviceId": 8,
    "profileId": 81784,
    "merchantId": 31237,
    "trace": "PMNT0403.638764BE.000037CC"
}

You can notice that the payment is already made, A transaction has been created, and you are already receiving the payment results, unlike the following scenario, since the issuer required no 3DSecure, the transaction had been created.



  • The 3DSecured Cards


If the card does require the 3DSecure authentication from the cardholder and issuer side, You will receive a response like the following:

{
    "tran_ref": "TST2233401397780",
    "tran_type": "Sale",
    "cart_id": "CART#1001",
    "cart_description": "Description of the items/services",
    "cart_currency": "USD",
    "cart_amount": "500.00",
    "tran_currency": "USD",
    "tran_total": "500.00",
    "return": "none",
    "redirect_url": "https://secure-egypt.paytabs.com/payment/page/5974A26182E411E56CCD5245D4EBC0787AF379E9E450E3D8B8E555CF/redirect",
    "customer_details": {
        "name": "Mohammed EL Rayes",
        "email": "[email protected]",
        "phone": "+201234567890",
        "street1": "address street",
        "city": "Cairo",
        "state": "C",
        "country": "EG",
        "zip": "45555",
        "ip": "1.1.1.1"
    },
    "payment_info": {
        "payment_method": "Visa",
        "card_type": "Credit",
        "card_scheme": "Visa",
        "payment_description": "4000 00## #### 0002",
        "expiryMonth": 12,
        "expiryYear": 2022
    },
    "serviceId": 8,
    "profileId": 81784,
    "merchantId": 31237,
    "trace": "PMNT0404.63876778.00003813"
}


Regarding PT2 API Endpoints | Payment workflow | Managed Form by initiating the payment, and if the card is 3DSecured, you will receive the redirect URL (redirect_url) within the response. Use this URL to redirect your client browser to the issuer 3DSecure page.