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


TABLE OF CONTENTS


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


Value
Description
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 Alinma 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@domain.com",
    "phone": "0522222222",
    "street1": "address street",
    "city": "Riyadh",
    "state": "Riyadh",
    "country": "SA",
    "zip": "12345",
    "ip": "1.1.1.1"
  },
  "card_discounts": [
    {
      "discount_cards": "4111,5200",
      "discount_amount": "50",
      "discount_title": "50 USD (25%) discount on Alinma Bank Cards"
    },
    {
      "discount_cards": "4000",
      "discount_amount": "25",
      "discount_title": "25 USD (12.55%) discount on XYZ Bank Cards"
    }
  ]
}


Sample Response Payload

{
  "tran_ref": "SFT2110900147558",
  "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.clickpay.com.sa/payment/page/5A8E868F82E417EE38AF55217319684031D33FE93EAFB51F0407237B",
  "customer_details": {
    "name": "first last",
    "email": "email@domain.com",
    "phone": "0522222222",
    "street1": "address street",
    "city": "Riyadh",
    "state": "Riyadh",
    "country": "SA",
    "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": "SFT2110900147558",
  "merchant_id": 3469,
  "profile_id": 65945,
  "cart_id": "cart_11111",
  "cart_description": "Description of the items/services",
  "cart_currency": "SAR",
  "cart_amount": "200.00",
  "tran_currency": "SAR",
  "tran_total": "150.00",
  "tran_type": "Sale",
  "tran_class": "ECom",
  "customer_details": {
    "name": "first last",
    "email": "email@domain.com",
    "phone": "0522222222",
    "street1": "address street",
    "city": "Riyadh",
    "state": "Riyadh",
    "country": "SA",
    "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": ""
  }
}



..