Pay With Saved Token

πŸ“˜

Now you've received your customer's card token (retrieved using callbacks), in order to perform recurring payments with this token, use this API found in this guide.

Prerequisites:

Please ask your technical contact for a recurring payment setup, you should receive extra integration ID in your dashboard.

πŸ‘

Download the Postman collection from this link

Setup:

First, you will follow the normal API Payment flow as provided in the documentation link, but there will be a new parameter added for the 3rd request (Payment Key Request):

the new parameter is "token" that will hold the customer card token that you've already got from the callback.

Also, make sure to use your recurring integration ID for this step.

Third Request Example body:

{
  "auth_token": "{{AUTH_TOKEN}}",
  "amount_cents": "100", 
  "expiration": 3600, 
  "order_id":{{ORDER_ID}},
  "billing_data": {
    "apartment": "803", 
    "email": "[email protected]", 
    "floor": "42", 
    "first_name": "Clifford", 
    "street": "Ethan Land", 
    "building": "8028", 
    "phone_number": "+86(8)9135210487", 
    "shipping_method": "PKG", 
    "postal_code": "01898", 
    "city": "Jaskolskiburgh", 
    "country": "CR", 
    "last_name": "Nicolas", 
    "state": "Utah"
  }, 
  "currency": "PKR", 
  "integration_id": 213,
  "token":"d20d94...8000687835c3f1a9da9", //the new Parameter (Must be added)
  "lock_order_when_paid": "false"
}

The Pay Request

URL: https://pakistan.paymob.com/api/acceptance/payments/pay
method: POST
source: Merchant server
content-type: JSON

EXAMPLE BODY:

{   "source": 
			{     
        "identifier": "d20d94...8000687835c3f1a9da9",     
        "subtype": "TOKEN"   
      },  
 "payment_token": "ZXlKMGVYQWlULjRi2T2..."
}

Sample Response:

{
  "type": "TRANSACTION",
  "obj": {
    "id": 78,
    "pending": false,
    "amount_cents": 100,
    "success": true,
    "is_auth": false,
    "is_capture": false,
    "is_standalone_payment": true,
    "is_voided": false,
    "is_refunded": false,
    "is_3d_secure": false,
    "integration_id": 1,
    "profile_id": 1,
    "has_parent_transaction": false,
    "order": {
      "id": 94,
      "created_at": "2016-12-26T06:49:16.651010Z",
      "delivery_needed": false,
      "merchant": {
        "id": 1,
        "created_at": "2016-11-17T15:02:53.646620Z",
        "phones": [
          "011111111111",
          "012324151432"
        ],
        "company_emails": [
          "[email protected]",
          "[email protected]"
        ],
        "company_name": "Wuckert, Zieme and Dach",
        "state": "Oklahoma",
        "country": "Oman",
        "city": "Port Arvillachester",
        "postal_code": "83372",
        "street": "Walker Ramp"
      },
      "collector": null,
      "amount_cents": 100,
      "shipping_data": {
        "id": 73,
        "first_name": "Clifford",
        "last_name": "Nicolas",
        "street": "Ethan Land",
        "building": "8028",
        "floor": "42",
        "apartment": "803",
        "city": "Jaskolskiburgh",
        "state": "Utah",
        "country": "CR",
        "email": "[email protected]",
        "phone_number": "+86(8)9135210486",
        "postal_code": "01898",
        "extra_description": "",
        "shipping_method": "UNK",
        "order_id": 94,
        "order": 94
      },
      "currency": "PKR",
      "is_payment_locked": true,
      "merchant_order_id": null,
      "wallet_notification": null,
      "paid_amount_cents": 0,
      "items": []
    },
    "created_at": "2016-12-26T06:49:16.680871Z",
    "transaction_processed_callback_responses": [],
    "currency": "PKR",
    "source_data": {
      "sub_type": "MasterCard",
      "pan": "2346",
      "type": "card"
    },
    "data": {
      "merchant_txn_ref": "1_6b30848c28c455de9bcb0c693e9f85a3",
      "card_num": null,
      "avs_result_code": "Unsupported",
      "order_info": "[email protected]",
      "merchant": "TEST290510EGP",
      "avs_acq_response_code": "Unsupported",
      "transaction_no": "2000004112",
      "batch_no": "20161226",
      "message": "Approved",
      "txn_response_code": "0",
      "secure_hash": "DF6CF1D9CFF09F9C6AE1EC86F6ED4BFE4E5BAE8CE7705ED05E61A264839FEA7A",
      "card_type": "MC",
      "receipt_no": "636117634097",
      "created_at": "2016-12-26T06:49:19.593479",
      "currency": "PKR",
      "klass": "VPCPayment",
      "authorize_id": "634097",
      "amount": "100",
      "acq_response_code": "00",
      "command": "pay",
      "gateway_integration_pk": 1
    },
    "payment_key_claims": {
      "exp": 1482770369,
      "currency": "PKR",
      "amount_cents": 100,
      "user_id": 2,
      "card_integration_id": 1,
      "shipping_data": {
        "state": "Utah",
        "country": "CR",
        "first_name": "Clifford",
        "last_name": "Nicolas",
        "postal_code": "01898",
        "floor": "42",
        "city": "Jaskolskiburgh",
        "street": "Ethan Land",
        "building": "8028",
        "phone_number": "+86(8)9135210486",
        "extra_description": "",
        "shipping_method": "PKG",
        "apartment": "803",
        "email": "[email protected]"
      }
    },
    "error_occured": false,
    "owner": 2,
    "parent_transaction": null
  }
}