Initiate Agreement Payments (Repeat Billing)
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.
Repeat billing is a feature that enables merchants to automatically send invoices to their customers at set intervalsβweekly, monthly, or annuallyβfor subscription products or services. This feature is available through our Merchant dashboard.
You can learn more about how you can initiate and manage your Repeat Billing payment through PayTabs merchant dashboard by clicking hereRepeat Billing & Repeat Invoicing
Please note that to create any Repeat Billing agreements, you must have a secure terms and conditions URL set up in your PayTabs profile. If you haven't done this yet, please reach out to your account manager or customer care and provide them with the URL so they can configure it for you. If you don't follow the steps outlined in this manual for setting up the URL, your request may be denied.
The Endpoint and Related Postman Collectionβ
In this tutorial, we will rely on the PayTabs Hosted Payment Page API Endpoint, mentioned on PayTabs API endpoints postman collection, which you can access from PayTabs Postman APIs Collection. The endpoint will need to be accessed with a POST request on the below-mentioned URL
POST | {{domain}}/payment/request |
---|
Please note that not using the proper endpoint URL {domain} will lead to authentication issues within your responses. To find the your proper domain you can read ourWhat is my (Region)/(endpoint URL)?tutorial article.
- KSA
- UAE
- Egypt
- Oman
- Jordan
- Kuwait
- Global
https://secure.paytabs.sa/payment/request
https://secure.paytabs.com/payment/request
https://secure-egypt.paytabs.com/payment/request
https://secure-oman.paytabs.com/payment/request
https://secure-jordan.paytabs.com/payment/request
https://secure-kuwait.paytabs.com/payment/request
https://secure-global.paytabs.com/payment/request
Request Parametersβ
- The Minimum Required Parameters
- The Available Optional Parameters
To create a Repeat Billing agreement using our APIs, you need to include not only the general required parameters mentioned earlier but also some additional parameters specific to the agreement. Below are all the parameters needed for the Repeat Billing Agreement payment:
Parameter | Data Type | Min | Max | Required |
---|---|---|---|---|
| INT | Accept only valid profile number. | β | |
The merchant Profile ID you can get from your PayTabs dashboard. For more information please check our How to get your account information from PT2 Dashboard? solution article. To know more about this parameter please click here. | ||||
| ||||
| INT | Valid string from this enum list: sale auth void release capture refund register | β | |
The identification of the type of the transaction. To know more about these types please check our What is the "tran_type" (transaction type)? solution article. To know more about this parameter please click here. | ||||
| ||||
| STRING | Valid string from this list ecom recurring moto | β | |
The identification of the category/class this transaction will follow, such as eCommerce, Recurring, etc. To know more about these types please check our What is the "tran_class" (transaction class)? solution article. To know more about this parameter please click here. | ||||
| ||||
| STRING | 1 | 64 | β |
Indicates the cart/order id at the merchant end, to easily relate the PayTabs transaction to. To know more about this parameter please click here. | ||||
| ||||
| STRING | 1 | 128 | β |
Indicates the cart/order description at the merchant end, to easily relate the PayTabs transaction to. To know more about this parameter please click here. | ||||
| ||||
| STRING | 1 | 128 | β |
Indicates the transaction currency, which the customer will be charged with. To know more about this parameter please click here. | ||||
| ||||
| DECIMAL | 0.01 | 9999999999.99 | β |
Indicates the amount of the transaction the customer is about to be charged. Both min and max values are subjected to the merchant transaction limits. To know more about this parameter please click here. | ||||
| ||||
| Object | N/A | β | |
This object will contain the agreement parameters that will specify all the agreement details and options. | ||||
| ||||
Nested Parameter | Data Type | Min | Max | Required |
| STRING | N/A | N/A | β |
This parameter indicates the agreement description which you can use to distinguish your agreements and you can also use it as a title for your agreement. | ||||
| ||||
| STRING | N/A | N/A | β |
This parameter indicates the currency that this agreement will be initiated in and you need to make sure that this is the same currency that you have passed inside the cart_currency parameter and that this currency is configured in your PayTabs profile. | ||||
| ||||
| Decimal | N/A | N/A | β |
This parameter indicates the initial amount that you will be requesting your customer to pay in this agreement, and you need to make sure that it is the same amount as the one you passed inside the cart_amount parameter. | ||||
| ||||
| Decimal | N/A | N/A | β |
This parameter indicates the repeated amount the you want to charge your customer with at the specified time intervals that you will be passing in the below parameters. | ||||
| ||||
| Decimal | N/A | N/A | β |
This parameter indicates if you want to charge your customer with a final amount after completing the whole agreement payments. Note that this will not be applicable to unlimited term agreements (when setting the "repeat_terms" to 0). | ||||
| ||||
| Int | N/A | N/A | β |
This parameter indicates the number of times you want to repeat the payment or charge your customers and here you will be repeating the charge of the amount specified in the "repeat_amount" parameter. Note that if you passed 0 to this parameter, it means that you will be initiating an open agreement that will keep charging the customer forever or until you cancel the agreement through your dashboard. | ||||
| ||||
| Int | 1 | 3 | β |
This parameter indicates the interval period that you want to initiate your agreement to be repeated at (days, week, month). 1 => Day , 2 => Week , 3 => Month. | ||||
| ||||
| Int | N/A | N/A | β |
This parameter indicates the number of times you want to pass between charging intervals. | ||||
| ||||
| Date | N/A | N/A | β |
This parameter indicates the due date for the first payment after the initial payment created once you initiate the request. | ||||
|
Parameter | Data Type | Min | Max | Required |
---|---|---|---|---|
| STRING | N/A | 255 Characters (Valid URL) | β |
The return URL is the URL that PayTabs will redirect the customer to after he finishes the payment process (whether it's authenticated or not). It will redirect the customer with a POST response that is sent with the client/cardholder redirection through his browser containing the basic transaction information once the payment process ends (whether the customer cancels, paid, or failed to pay). It depends on the customer's actions, which means if the customer closes the browser right after the payment without waiting to be redirected back to your system, you will not receive this response. What is the Return URL vs the Callback URL? To know more about this parameter please click here. | ||||
| ||||
| STRING | N/A | 255 Characters (Valid URL) | β |
The callback response is a server-to-server POST response that is sent (to a pre-defined HTTPS URL) with the full detailed transaction information once the payment process has ended (whether the customer cancels, paid, or failed to pay). It does not depend on the customer's actions; the response will be sent anyway. What is the Return URL vs the Callback URL? To know more about this parameter please click here. | ||||
| ||||
| BOOLEAN | β | ||
Indicates whether to hide shipping and billing information or not from the payment page. Note: The customer details are still required and must be passed in case any of the details are missing or passed with invalid values; the hide_shipping option will be ignored, and the cardholder will be required to enter any of the missing details on the payment page. To know more about this parameter please click here. | ||||
| ||||
| Object | β | ||
Indicates the customer details for this payment. If provided, the payment page will be prefilled with the provided data. To know more about this parameter please click here. | ||||
| ||||
Nested Parameter | Data Type | Min | Max | Required |
| STRING | 3 | 128 | β |
| STRING | N/A | N/A | β |
| STRING | N/A | N/A | β |
| STRING | 3 | 128 | β |
| STRING | 3 | 128 | β |
| STRING | 2 | 2 | β |
| STRING | N/A | N/A | β |
| STRING | N/A | N/A | β |
| STRING | Either en or ar | β | |
Indicates the payment page displaying language. To know more about this parameter please click here. | ||||
| ||||
| INT | Valid Theme ID (from PayTabs dashboard) | β | |
Allows you to choose between your list of themes that have been created on your PayTabs dashboard. This chosen theme will be applied to the created payment page. | ||||
| ||||
| Object | β | ||
For more customizations, you can pass to the Transaction API request your own "user-defined fields" up to 9 fields, and accordingly, you would receive those fields in the callback response. To know more about this parameter please click here. | ||||
| ||||
Nested Parameter | Data Type | Min | Max | Required |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | 1 | 255 | β |
| STRING | Pass one of the following list:
| β | |
The tokenization format the generated token should follow. Hosted Payment Page APIs | Token Based Transactions . To know more about this parameter please click here. | ||||
| ||||
| BOOLEAN | β | ||
For showing the βsave this cardβ option on the payment page. To know more about this parameter please click here. | ||||
| ||||
| STRING | 3 Characters | 3 Characters | β |
Indicates an alternative currency that you want to display your amount with it in your payment page. This will allow you to display the approximate amount of the payment cart amount in this alternative currency for this transaction.. | ||||
| ||||
| STRING | Pass one or more of the following list: click here | β | |
To know more about this parameter please click here. | ||||
|
Request & Response Payload Samplesβ
- Required Parameters Sample Payloads
- Optional Parameters Sample Payloads
- Request Payload
- Response Payload
{
"profile_id": 79010,
"tran_type": "sale",
"tran_class": "ecom",
"cart_id": "cart_11111",
"cart_currency": "SAR",
"cart_amount": 12.3,
"cart_description": "Description of the items/services",
"agreement":
{
"agreement_description": "Test agreement",
"agreement_currency": "SAR", /* Must match transaction request currency */
"initial_amount": 12.3, /* Must match transaction request amount */
"repeat_amount": 100,
"final_amount": 70, /* Not applicable to unlimited term agreements */
"repeat_terms": 3,
"repeat_period": 1,
"repeat_every": 4, /* e.g. every 1 week, or every 4 days etc */
"first_installment_due_date": "05/May/2024" /* Cannot be on or before today */
}
}
{
"tran_ref": "TST2412801866182",
"tran_type": "Sale",
"cart_id": "cart_11111",
"cart_description": "Description of the items/services",
"cart_currency": "SAR",
"cart_amount": "12.30",
"tran_total": "0",
"return": "none",
"redirect_url": "https://secure.paytabs.com/payment/wr/5CC9E2AE82E6180563763B9A2D1D1A68D2270F4BFF3AA15293E759F7",
"serviceId": 2,
"profileId": xxxxx,
"merchantId": xxxxx,
"trace": "PMNT0402.663A27B7.000D1F33"
}
- Request Payload
- Response Payload
{
"profile_id":"**Your profile ID**",
"tran_type":"sale",
"tran_class":"ecom",
"cart_description":"Description of the items/services",
"cart_id":"Unique order reference00",
"cart_amount":25000.2,
"cart_currency":"SAR",
"paypage_lang":"en",
"return":"** Valid Return URL **",
"callback":"** Valid callback URL **",
"customer_details":{
"name":"FirstName LastName",
"email":"[email protected]",
"phone":"0522222222",
"street1":"address street",
"city":"cc",
"state":"C",
"country":"AE",
"zip":"12345"
},
"shipping_details":{
"name":"FirstName LastName",
"email":"[email protected]",
"phone":"971555555555",
"street1":"street2",
"city":"dubai",
"state":"dubai",
"country":"AE",
"zip":"54321"
},
"agreement": {
"agreement_description": "Test agreement",
"agreement_currency": "SAR", /* Must match transaction request currency */
"initial_amount": 12.3, /* Must match transaction request amount */
"repeat_amount": 100,
"final_amount": 70, /* Not applicable to unlimited term agreements */
"repeat_terms": 3,
"repeat_period": 1,
"repeat_every": 2, /* e.g. every 1 week, or every 4 days etc */
"first_installment_due_date": "08/May/2024" /* Cannot be on or before today */
},
"user_defined":{
"test":"UDF1 Test",
"test2":"UDF2 Test",
"udf3":"UDF3 Test",
"udf4":"UDF4 Test",
"udf5":"UDF5 Test",
"udf6":"UDF6 Test",
"udf7":"UDF7 Test",
"udf8":"UDF8 Test",
"udf9":"UDF9 Test"
},
"card_discounts":[
{
"discount_cards":"41111,520000",
"discount_amount":"30.00",
"discount_percent":"25",
"discount_title":"30.00 SAR and 25% discount on cards starts with 41111, 520000",
} ],
"config_id":2188,
"card_filter":"411111",
"card_filter_title":"Only accept cards start with 41111",
"tokenise":2,
"show_save_card":true,
"hide_shipping":true,
"donation_mode":true,
"cart_min":5,
"cart_max":10,
"framed":true,
"framed_return_top":true,
"framed_return_parent":true
}
{
"tran_ref":"TST223XXXXXXXXXX",
"tran_type":"Sale",
"cart_id":"Unique order reference00",
"cart_description":"Description of the items/services",
"cart_currency":"SAR",
"cart_amount":"0.00",
"tran_currency":"",
"tran_total":"0",
"callback":"** callback URL **",
"return":"** return URL **",
"redirect_url":"https://secure.paytabs.com/payment/page/595AXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"customer_details":
{
"name":"first last",
"email":"[email protected]",
"phone":"0522222222",
"street1":"address street",
"city":"cc",
"state":"AZ",
"country":"AE",
"ip":"197.47.93.193"
},
"shipping_details":
{
"name":"name1 last1",
"email":"[email protected]",
"phone":"971555555555",
"street1":"street2",
"city":"dubai",
"state":"DU",
"country":"AE"
},
"serviceId":2,
"profileId":100181,
"merchantId":46656,
"trace":"PMNT0403.63A99D49.0003A345"
}
The Payment Page Experienceβ
As mentioned in Hosted Payment Page | Payment Workflow, by creating the payment page, you will receive the redirect URL "redirect_url" within the response, which you will use to redirect your client to this payment page. Once you have redirected your client, the client browser will display the following page to the client.

The Merchant Dashboard Page Experienceβ
ONCE and ONLY if the customer completes the above payment, a new agreement will be created in your merchant dashboard and you will be able to manage and view all the agreement history, related transactions, and invoices. If you are looking to learn how you can manage your agreement, you should visit ourRepeat Billing & Repeat Invoicingarticle.
