Pre Auth with Cashfree Payment Gateway v 1.3.0

Introduction

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. </br>

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 on Usage

  • You can initiate capture call only once per transaction. It should be done within 7 days from the date of transaction
  • You can initiate void authorization 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
  • Transactions that are not captured within the 7 day period will be refunded back to the customer
  • Voiding authorization will be refunded immediately back to the customer
  • Captured amount will be settled during the next settlement cycle

Capture API

This endpoint allows you to capture transaction

Request Configuration

Type Value
HTTP Method POST
URL /api/v1/order/capture
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)
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:

curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded'
-d
'appId=MTA2OTkyMDE1ODE0NDIyNTExNjYjIz&secretKey=63ca0b83c8ca85d73f
ff9c3fd29a7c87e292fd63&referenceId=3890&idempotencyKey=3890sdfas&c
aptureAmount=1' 'https://test.cashfree.com/api/v1/order/capture'

Sample Response

Successful Capture

{
 “status”:”OK”,
 “capturedAmount”:1,
 "captureStatus": "SUCCESS"
 “authId”:1,
 “message”:”Capture Success ul”
}

    Description:
  • capturedAmount is the fund captured by this request
  • captureStatus will either be SUCCESS or PENDING depending on whether the capture is pending
  • authId is a unique id generated by Cashfree or this request

Failed Capture

{
 “status”:”ERROR”,
 “message”:”Already Captured Transaction”
}

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 Params

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:

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'

Sample Response

Successful Void

{

“status”:”OK”,
 “authId”: 72,
 “message”:”Void Successful”,
 "voidStatus": "SUCCESS"
}
    Description:
  • authId is a unique id generated by Cashfree or this request

Failed Void

{
 “status”:”ERROR”,
 “message”:”Can only void successful transaction”
}

Capture Status API

This endpoint allows you to get the capture status o 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:

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'

Sample Response

Successful call

 "status":"OK",
 "message":"Capture Status",
 "captureType":"CAPTURE",
 "captureStatus": "SUCCESS"
}

Description: All possible values or 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 void
VOID PENDING Void is pending
VOID FAILED Void failed
NONE UNCAPTURED Capture/Void not initiated

Failed call


{“status”:”ERROR”,“message”:”Transaction does not exist”}