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 Card Discounts (card_discounts) parameter. "card_discounts" is one of the optional parameters that the request should have, which provides discounts for some of your valued customers via the property card_discounts, which contains an array of objects each object for a specific range of customers cards discounts.
In this article, you will be going to know:
Specifications
Card Discounts []
The Parameter Tag/Name card_discounts JSON Example Data Type Array of objects Required ❌Validation Rules - Must be an Array of objects.
- The array can have one object or more.
- Each object must have the properties discount_cards, discount_amount or discount_percent, and discount_title
Card Discounts [ Discounts Cards ]
The Parameter Tag/Name card_discounts[]. discount_cards JSON Example Data Type STRING Required ❌ (Required only within card_discounts object)Validation Rules - Can't be empty.
- Must provide a comma-separated list of card prefixes
- Each card discount cards prefix must be between 4 and 10 digits
Max Length 255 Character Card Discounts [ Discounts Amount ]
The Parameter Tag/Name card_discounts[].discount_amount JSON Example Data Type DECIMAL Required ❌ (Required only within card_discounts object if the discount_percent not present )Validation Rules - Can't be empty.
- Accept only digits
Min Length 0.01 Max Length 9999999999.99 Card Discounts [ Discounts Percent ]
The Parameter Tag/Name card_discounts[].discount_percent JSON Example Data Type STRING Required ❌ (Required only within card_discounts object if the discount_amount not present )Validation Rules - Can't be empty or zero
Max Length 0.01 Min Length 100 Card Discounts [ Discounts Title ]
The Parameter Tag/Name card_discounts[]. discount_title JSON Example Data Type STRING Required ❌ (Required only within card_discounts object)Validation Rules - Can't be empty.
Max Length 255 Character
Usage Workflow
Along with the required parameters mentioned in our Step 3 - PT2 API Endpoints | Initiating the payment solution article, you will need to set the "card_discounts" as shown below:
Sample Request Payload
Sample Response Payload
Sample IPN/Callback Response Payload (After Payment)
Once the payment is completed by any of the cards eligible for the discount, you will receive in the Callback/IPN response the actual transaction amount after applying the discount in a paramter called tran_total (the actual amount deducted from the customer) along with the cart_amount are the requested amount.
Also you will receive the card details which includes the used card prefixes in payment_info object in the Callback/IPN response and query transaction API response
The Expected Parameter Behaviors
After redirecting the customer to the payment page, PayTabs will compare the customer's card number if its eligible, then a discount will apply to the transaction amount as shown below:
The expected behaviors according to the passed value are:
Passing both discount_percent and discount_amount in the same transaction request.
In this case, PayTabs will sum the total of both discounts percent/amount and apply it to the requested amount, as shown below: