Cashfree.js
cashfree
object. The three main steps of integrating Cashfree Element components:
create()
methodmount()
methodpay()
methodcheckout()
cashfree.checkout
will return a Promise
that resolves with either result.error
when there is an error or result.redirect
when there is redirection
create()
create()
to initialize a cashfree component for your HTML page.
create
takes two arguments. The first argument is the component name of type string
. You can find all the names of the components we provide here.object
. It contains details about the behavior and look of the component. Find all the details for options
object here
mount()
mount()
to mount the component.
component.mount(querySelector)
pay()
pay()
to begin payment flow for a component. Not all components are payable. Check all the components here. The pay method takes in a paymentOption object.
cashfree.pay
will return a Promise
.
Upon success, the promise will resolve with result.paymentMessage
if the user has opted for a non redirection flow. example UPI, QR. Upon redirection, the promise will resolve with result.redirect
If the payment fails, the Promise
will resolve with an result.error
. error.type
will describe the failure. In some cases you can directly show the error.message to your user. Please refer here for the types
cashfree.pay
may take several seconds to complete. During that time, you
should disable user interaction and show a waiting indicator like a spinner.
If you receive an error result, you should be sure to show that error to the
customer, re-enable user interaction, and hide the waiting indicator.version()
cashfree.js
your site is using. This is helpful in understanding features available for a version. By default we will always upgrade your sdk to the latest version. But in some cases your customer’s browser might cache the javascript for some amount of time. In that case your customers will not get the latest version. Checkout all versions here