Pre-authorization

Pre-authorization is a workflow where the merchant can pre-authorize an amount from customers bank account and only accept that money once they have fulfilled the order.

📘

Payment instruments

We support pre-authorized workflow on Cards and UPI. Please reach out to [email protected] to enable this workflow for your account.

Once the pre-authorization workflow is activated for your account, you will need to ensure that you capture or void every eligible payment on this workflow.

Step 1 (Payment)

If the pre-authorization workflow is enabled for your account, you might need to provide additional details to Cashfree in the /orders/pay request. This is specific to UPI (and you don't need to send these details for card based pre-authorization workflow).
In case of UPI, once you have created the order, you will need to call Order Paywith the following details.

The following parameters have been added to the upi object - authorize_only, authorization. The authorization object contains the following attributes

  1. approve_by - The time by when customer needs to approve this one time mandate request
  2. start_time - The time when the mandate should start
  3. end_time - The time until when the mandate hold will be on customer's bank account. You can call capture and void until this time.

UPI Collect

curl --request POST \
  --url https://api.cashfree.com/pg/orders/sessions \
  --header 'Content-Type: application/json' \
  --data '{
	"payment_session_id": "HTIdYxfOYgqKyYM3rLCZ",
	"payment_method" : {
		"upi" : { 
			"channel": "collect",
			"upi_id": "rohit@okicici",
			"authorize_only": true,
			"authorization" : {
          "approve_by": "2022-02-08T19:20:12+05:30",
          "start_time": "2022-02-09T12:34:34Z",
          "end_time": "2022-02-10T12:34:34Z"
       }			
		}
	}
}'
{
	"payment_method": "upi",
	"channel": "collect",
	"action": "custom",
	"data": {
		"url": null,
		"payload": null,
		"content_type": null,
		"method": null
	},
	"cf_payment_id": 749079622
}

UPI Intent

curl --request POST \
  --url https://api.cashfree.com/pg/orders/sessions \
  --header 'Content-Type: application/json' \
  --data '{
	"payment_session_id": "HTIdYxfOYgqKyYM3rLCZ",
	"payment_method" : {
		"upi" : { 
			"channel": "link",
			"authorize_only": true,
			"authorization" : {
          "approve_by": "2022-02-08T19:20:12+05:30",
          "start_time": "2022-02-09T12:34:34Z",
          "end_time": "2022-02-10T12:34:34Z"
       }			
		}
	}
}'
{
  "action": "custom",
  "cf_payment_id": 2333615254,
  "channel": "link",
  "data": {
    "url": null,
    "payload": {
      "bhim": "bhim://upi/mandate?pa=MerchantVPA@Bank&pn=MerchantName&tr=transactionref1234&am=5.00&cu=INR&orgid=400011&mc=4722&purpose=01&tn=Cashfree%20Payments&validitystart=19122023&validityend=28122023&amrule=MAX&recur=ONETIME&rev=N&share=Y&block=Y&txnType=CREATE&mode=13",
      "default": "upi://mandate?pa=MerchantVPA@Bank&pn=MerchantName&tr=transactionref1234&am=5.00&cu=INR&orgid=400011&mc=4722&purpose=01&tn=Cashfree%20Payments&validitystart=19122023&validityend=28122023&amrule=MAX&recur=ONETIME&rev=N&share=Y&block=Y&txnType=CREATE&mode=13",
      "gpay": "tez://upi/mandate?pa=MerchantVPA@Bank&pn=MerchantName&tr=transactionref1234&am=5.00&cu=INR&orgid=400011&mc=4722&purpose=01&tn=Cashfree%20Payments&validitystart=19122023&validityend=28122023&amrule=MAX&recur=ONETIME&rev=N&share=Y&block=Y&txnType=CREATE&mode=13",
      "paytm": "paytmmp://upi/mandate?pa=MerchantVPA@Bank&pn=MerchantName&tr=transactionref1234&am=5.00&cu=INR&orgid=400011&mc=4722&purpose=01&tn=Cashfree%20Payments&validitystart=19122023&validityend=28122023&amrule=MAX&recur=ONETIME&rev=N&share=Y&block=Y&txnType=CREATE&mode=13",
      "phonepe": "phonepe://upi/mandate?pa=MerchantVPA@Bank&pn=MerchantName&tr=transactionref1234&am=5.00&cu=INR&orgid=400011&mc=4722&purpose=01&tn=Cashfree%20Payments&validitystart=19122023&validityend=28122023&amrule=MAX&recur=ONETIME&rev=N&share=Y&block=Y&txnType=CREATE&mode=13",
      "web": "https://api.cashfree.com/pg/view/upi/25hg94m.ZUlx19KgZ48TXh82GrsNamC20vVw0QVK17xLE2BFOo.708f026c-5f7d-4c49-9"
    },
    "content_type": null,
    "method": null
  },
  "payment_amount": 5,
  "payment_method": "upi"
}


Capture

The capture workflow helps you to capture the payment and move it from customers bank account to your bank account.

curl --request POST \
  --url https://api.cashfree.com/pg/orders/:order_id/authorization \
  --header 'Content-Type: application/json' \
  --header 'x-api-version: <<api_version>>' \
  --header 'x-client-id: <<app_id>>' \
  --header 'x-client-secret: <<secret_key>>' \
  --data '{
  "action": "CAPTURE",
  "amount": "2.00"
}'
{
	"auth_id": "203924176048",
	"authorization": {
		"action": "CAPTURE",
		"status": "SUCCESS",
		"captured_amount": 2.00,
		"start_time": "2022-02-09T18:04:34+05:30",
		"end_time": "2022-02-10T18:04:34+05:30",
		"approve_by": "2022-02-08T19:20:12+05:30"
	},
	"bank_reference": "203924176048",
	"cf_payment_id": 7079622,
	"entity": "payment",
	"is_captured": false,
	"order_amount": 3.00,
	"order_id": "order_184824oxmihLPJhERptCzgR08YGOan2",
	"payment_amount": 3.00,
	"payment_currency": "INR",
	"payment_group": "upi",
	"payment_message": "PRE_AUTH|Transaction initiated",
	"payment_method": {
		"upi": {
			"channel": "collect",
			"upi_id": "rohit@okicici"
		}
	},
	"payment_status": "SUCCESS",
	"payment_time": "2022-02-08T14:31:56+05:30"
}

❗️

Partial capture

We support partial capture for UPI and card payments.

Void

The void workflow helps you to refund the payment back to the customer and not bear any cost on it. Please note that you can only void the entire payment.

curl --request POST \
  --url https://api.cashfree.com/pg/orders/:order_id/authorization \
  --header 'Content-Type: application/json' \
  --header 'x-api-version: <<api_version>>' \
  --header 'x-client-id: <<app_id>>' \
  --header 'x-client-secret: <<secret_key>>' \
  --data '{
  "action": "VOID"
}'
{
	"auth_id": null,
	"authorization": {
		"action": "VOID",
		"status": "SUCCESS",
		"captured_amount": null,
		"start_time": "2022-02-09T18:04:34+05:30",
		"end_time": "2022-02-10T18:04:34+05:30",
		"approve_by": "2022-02-08T19:20:12+05:30"
	},
	"bank_reference": "203924193623",
	"cf_payment_id": 749235871,
	"entity": "payment",
	"is_captured": false,
	"order_amount": 3.00,
	"order_id": "order_184824pANPV12CVRkdxHi3mrPZ9KOcg",
	"payment_amount": 3.00,
	"payment_currency": "INR",
	"payment_group": "upi",
	"payment_message": "PRE_AUTH|Transaction initiated",
	"payment_method": {
		"upi": {
			"channel": "collect",
			"upi_id": "rsedwardian@okicici"
		}
	},
	"payment_status": "VOID",
	"payment_time": "2022-02-08T16:15:23+05:30"
}