Preauth API

Cashfree payment gateway now supports Pre Auth on credit/debit card transactions. Pre Auth flow allows you to authorize any amount of funds from your customer’s card and capture these funds (or any part of it) at a later time. This is different from typical credit/debit card transactions where capture of funds happens immediately after transaction is authorized.

Casfree PG also allows you to void authorization or any transactions that haven’t been captured yet. This will deauthorize all the fund or the transaction and credit it back to the customer’s card immediately. Both void and capture can also be done manually on the merchant dashboard.

Note:

  • You can initiate a capture, void call only once per transaction. It should be done within 7 days from the date of transaction.

  • Captured transactions can’t be made void or vice versa.

  • Any amount blocked for transactions that are not captured within the 7 day period will be sent back to the customer.

  • Amount blocked for transactions will be sent back to the customer account immediately when you mark transactions as void.

  • Captured amount will be settled during the next settlement cycle

Capture API

This endpoint allows you to capture a transaction.

Request Configuration

Type

Value

HTTP Method

POST

URL

/api/v1/order/capture

Content-Type

application/x-www-form-urlencoded

Post Parameters

Parameter

Description

appId

Your app Id

secretKey

Your secret key

referenceId

The referenceId of the successful transaction that needs to be captured(Integer)

idemKey

A unique Id generated by the caller to ensure single invocation of the capture API(Alphanumeric)

captureAmount

The amount that needs to be captured. If this field is not included the full amount or the transaction will be captured (Decimal) (Optional)

Sample Request and Response

Request
Response - Capture Success
Response - Failed Capture
Request
curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded'
-d
'appId=MTA2OTkyMDE1ODE0NDIyNTExNjYjIz&secretKey=63ca0b83c8ca85d73f
ff9c3fd29a7c87e292fd63&referenceId=3890&idemKey=3890sdfas&c
aptureAmount=1' 'https://test.cashfree.com/api/v1/order/capture'
Response - Capture Success
{
“status”:”OK”,
“capturedAmount”:1,
"captureStatus": "SUCCESS"
“authId”:1,
“message”:”Capture Success ul”
}
Response - Failed Capture
{
“status”:”ERROR”,
“message”:”Already Captured Transaction”
}

Successful Response Description

  • capturedAmount is the fund captured by this request

  • captureStatus will either be SUCCESS or PENDING depending on whether the capture is pending or is confirmed

  • authId is a unique id generated by Cashfree for this request

Void Authorization API

This endpoint allows you to void authorization or an uncaptured transaction.

Request Configuration

Type

Value

HTTP Method

POST

URL

/api/v1/order/void

Content-Type

application/x-www-form-urlencoded

Post Parameters

Parameter

Description

appId

Your app Id

secretKey

Your secret key

referenceId

The referenceId of the successful transaction that needs to be captured(Integer)

idemKey

A unique Id generated by the caller to ensure single invocation of the capture API(Alphanumeric)

Sample Request and Response

Request
Response - Void Success
Response - Void Failed
Request
curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded'
-d
'appId=MTA2OTkyMDE1ODE0NDIyNTExNjYjI&secretKey=63ca0b83c8ca85d73ff
f9c3fd29a7c87e292fd63&referenceId=3892&idempotencyKey=3892asdf'
'https://test.cashfree.com/api/v1/order/void'
Response - Void Success
{
“status”:”OK”,
“authId”: 72,
“message”:”Void Successful”,
"voidStatus": "SUCCESS"
}
Response - Void Failed
{
“status”:”ERROR”,
“message”:”Can only void successful transaction”
}

Successful Response Description

  • authId is a unique id generated by Cashfree for this request.

Capture Status API

This endpoint allows you to get the capture status for any order.

Request Configuration

Type

Value

HTTP Method

POST

URL

/api/v1/captureStatus

Content-Type

application/x-www-form-urlencoded

Post Params

Parameter

Description

appId

Your app Id

secretKey

Your secret key

referenceId

The referenceId of the successful transaction that needs to be captured (Integer)

Sample Request and Response

Request
Response - Success
Response - Fail
Request
curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded'
-d
'appId=MTA2OTkyMDE1ODE0NDIyNTExNjYjI&secretKey=63ca0b83c8ca85d73ff
f9c3fd29a7c87e292fd63&orderId=123''https://test.cashfree.com/api/v
1/captureStatus'
Response - Success
"status":"OK",
"message":"Capture Status",
"captureType":"CAPTURE",
"captureStatus": "SUCCESS"
}
Response - Fail
{“status”:”ERROR”,“message”:”Transaction does not exist”}

Successful Response Description

All possible values for captureType and captureStatus are:

CaptureType

CaptureStatus

Description

CAPTURE

SUCCESS

Transaction has been successfully captured

CAPTURE

PENDING

Capture has been attempted but pending

CAPTURE

FAILED

Capture failed

VOID

SUCCESS

Transaction has been successfully marked void

VOID

PENDING

Void is pending

VOID

FAILED

Void failed

NONE

UNCAPTURED

Capture/Void not initiated