Checkout Options

You can set the checkoutOptions in the following way.

let checkoutOptions = {
    paymentSessionId: "your-payment-session-id",
    mode: "sandbox",
    returnUrl: "https://test.cashfree.com/pgappsdemos/v3success.php?myorder={order_id}"
}

checkoutOptions.paymentSessionId

typestring
Required

To make payment you will need a paymentSessionId, you can get this by making a create order API call to POST /orders. Please make sure you are using the correct hostname for the environment you want to process the payment for. In the response of POST /orders you will find payment_session_id. Note that this is a backend call so you will need to have a server. Read how to generate payment_session_id here

checkoutOptions.mode

typestring
Required

It can be either sandbox or production depending upon the URL you used for creating payment_session_id -

  • https://api.cashfree.com/pg/orders - then it will be production

  • https://sandbox.cashfree.com/pg/orders - then it will be sandbox

checkoutOptions.returnUrl

typestring
Required

This is the url where your customers will be redirected after they have complete the payment. The returnURL has to have a wild card entry {order_id}. Cashfree will replace {order_id} with the actual order id that was used to create the order. Let us suppose your order_id is myorder123 and you have specified https://yourhost.com/{order_id} as your returnUrl then cashfree will redirect your customer to https://yourhost.com/myorder123. You can extract the order id here and call get order to confirm the payment status. Read more here. The checkout() promise resolves with {redirect: true}

checkoutOptions.redirectTarget

typestring
OPTIONAL

We also provide a way for you to decide how to redirect your customer. This takes all the values that are valid for hyperlink. Default is _self

ValueDescription
_blankOpens the linked document in a new window or tab
_selfOpens the linked document in the same frame as it was clicked (this is default)
_parentOpens the linked document in the parent frame
_topOpens the linked document in the full body of the window
_framename_Opens the linked document in the named iframe

checkoutOptions.redirectDelay

typestring
OPTIONAL

Using this option you can set a delay before redirecting your customer. This might be useful in case you want to run certain logic before the redirection