Looking to provide discounts for some of your valued customers ? then this article is for you.


In this article you will be going to know about:


Postman Endpoint Collection


For the purposes of this article, you will need to use the following postman endpoints collection for testing and integrating, for proceeding with this please click here.



Payment Flow


To provide discounts for specific customers, the following section should be passed in any Transaction API. 


You can provide a comma-separated list of card prefixes (usually first 6, can be up to the first 11)



Once the transaction is completed in any of the cards, you will receive in the Callback/IPN response the tran_ref of this transaction


ValueDescription
discount_cardsprovide a comma-separated list of card prefixes (usually first 6, can be up to first 11)
discount_amountThe actual discount that should be deducted from the cart_amount
discount_titleDescription of the discount that will be displayed for the customer on the hosted payment page


{
  "card_discounts": [
    {
      "discount_cards": "411111,520000",
      "discount_amount": "50",
      "discount_title": "50 USD (25%) discount on cards ABC Bank Cards"
    },
    {
      "discount_cards": "4000",
      "discount_amount": "25",
      "discount_title": "25 USD (12.5%) discount on cards Mashreq Bank Cards"
    }
  ]
}


Sample Request Payload


Post{{domain}}/payment/request


{
  "profile_id": "profile_id",
  "tran_type": "sale",
  "tran_class": "ecom",
  "cart_id": "cart_11111",
  "cart_currency": "USD",
  "cart_amount": 200,
  "cart_description": "Description of the items/services",
  "return": "https://webhook.site/4b3af623-085f-4b82-ab22-cb6cedeba218",
  "callback": "https://webhook.site/4b3af623-085f-4b82-ab22-cb6cedeba218",
  "paypage_lang": "en",
  "hide_shipping": true,
  "customer_details": {
    "name": "first last",
    "email": "[email protected]",
    "phone": "0522222222",
    "street1": "address street",
    "city": "dubai",
    "state": "du",
    "country": "AE",
    "zip": "12345",
    "ip": "1.1.1.1"
  },
  "card_discounts": [
    {
      "discount_cards": "4111,5200",
      "discount_amount": "50",
      "discount_title": "50 USD (25%) discount on ABC Bank Cards"
    },
    {
      "discount_cards": "4000",
      "discount_amount": "25",
      "discount_title": "25 USD (12.55%) discount on Mashreq Bank Cards"
    }
  ]
}

Sample Response Payload

{
  "tran_ref": "TST2110900147558",
  "tran_type": "Sale",
  "cart_id": "cart_11111",
  "cart_description": "Description of the items/services",
  "cart_currency": "USD",
  "cart_amount": "200.00",
  "callback": "https://webhook.site/4b3af623-085f-4b82-ab22-cb6cedeba218",
  "return": "https://webhook.site/4b3af623-085f-4b82-ab22-cb6cedeba218",
  "redirect_url": "https://secure-egypt.paytabs.com/payment/page/5A8E868F82E417EE38AF55217319684031D33FE93EAFB51F0407237B",
  "customer_details": {
    "name": "first last",
    "email": "[email protected]",
    "phone": "0522222222",
    "street1": "address street",
    "city": "dubai",
    "state": "DU",
    "country": "AE",
    "ip": "1.1.1.1"
  }
}

Post Payment Response


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 tran_total, 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


Sample Response Payload (Callback/IPN)


{
  "tran_ref": "TST2110900147558",
  "merchant_id": 3469,
  "profile_id": 65945,
  "cart_id": "cart_11111",
  "cart_description": "Description of the items/services",
  "cart_currency": "EGP",
  "cart_amount": "200.00",
  "tran_currency": "EGP",
  "tran_total": "150.00",
  "tran_type": "Sale",
  "tran_class": "ECom",
  "customer_details": {
    "name": "first last",
    "email": "[email protected]",
    "phone": "0522222222",
    "street1": "address street",
    "city": "dubai",
    "state": "DU",
    "country": "AE",
    "ip": "196.219.145.121"
  },
  "payment_result": {
    "response_status": "A",
    "response_code": "G19871",
    "response_message": "Authorised",
    "cvv_result": " ",
    "avs_result": " ",
    "transaction_time": "2021-04-19T08:11:11Z"
  },
  "payment_info": {
    "payment_method": "Visa",
    "card_type": "Credit",
    "card_scheme": "Visa",
    "payment_description": "4111 11## #### 1111",
    "expiryMonth": 11,
    "expiryYear": 2023,
    "IssuerCountry": "",
    "IssuerName": ""
  }
}