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.
Tokenization is the process of protecting sensitive data by replacing it with an algorithmically generated number called a token. This can be used to allow returning customers to purchase without re-entering credit card details (recurring), such as monthly subscription fees. In this article, we will walk you through the series of steps you need to create a token via our API payment request.
In this article, you will be going to know about:
The Endpoint and Related Postman Collection
In this tutorial, we will rely on the PayTabs invoices API Endpoint, mentioned on the PayTabs API endpoints postman collection, which you can access from here. The endpoint will need to be accessed with a POST request on the below-mentioned URL
Post | {{domain}}/payment/request |
Or
Post | {{domain}}/payment/invoice |
Please note that not using the proper endpoint URI {{domain}} will lead to authentication issues within your responses. To find the your proper domain you can read our What Is My (Region)/(endpoint URL)? solution article.
Create a Payment Request
The first thing you need to create a token is to create a basic payment request with the required information via any integration type that suits your business needs more, as mentioned in the previous step, "Step 3.2 - Initiating the Payment Request", but with including the below parameters as a MUST among the original request payload.
The Required Parameters
To initiate a tokenized payment request, you need to include these parameters to allow PayTabs to tokenize the customer card and send you this token back in the response. The specification of these required parameters is clarified below:
Parameter | Data Type | Min | Max | Required | Purpose |
STRING | Accept only one of the following: 2=>Hex32 3=>AlphaNum20 4=>Digit22 5=>Digit16 6=>AlphaNum32 | ✔ | The tokenization format the generated token should follow To know more about this parameter please click here. |
Note that in order for you to recieve the tokenized details you need to include either th "return" or the "call_back" parameters. You can learn more about them in our What is the Return URL vs the Callback URL solution article
Sample 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.
Sample Response Payload
Sample Response Payload via Return
After the customer processes the payment, the return URL will have the raw content with the token ONLY IF the payment was processed successfully.
Sample Response Payload via Callback/IPN
If the callback URL or IPN service is enabled, the sent JSON response will have the token, as shown below
⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The PT2 API Endpoints 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.