Sample integration project for Cashfree Payment Gateway's Cordova SDK, facilitating seamless and secure payment processing within your Cordova application.
- Android
- Cordova
Install the plugin
cd your-project-folder
cordova plugin add cordova-plugin-cashfree-pg
You will need to generate a sessionID from your backend and pass it to app while initiating payments.
API Doc Link - https://docs.cashfree.com/reference/createorder
Note: This API is called only from your backend as it uses secretKey. Thus this API should never be called from App.
const dropPaymentObject = {
"components": ["CARD", "UPI", "NB", "WALLET", "PAY_LATER"], //optional
"theme": { //optional
"navigationBarBackgroundColor": "#E64A19",
"navigationBarTextColor": "#FFFFFF",
"buttonBackgroundColor": "#FFC107",
"buttonTextColor": "#FFFFFF",
"primaryTextColor": "#212121",
"secondaryTextColor": "#757575"
},
"session": { //required
"payment_session_id": "order_session_id",
"orderID": "order_id",
"environment": "SANDBOX" // "SANDBOX" or "PRODUCTION"
}
}
const upiPaymentObject = {
"theme": { //optional
"navigationBarBackgroundColor": "#E64A19", //ios
"navigationBarTextColor": "#FFFFFF", //ios
"buttonBackgroundColor": "#FFC107", //ios
"buttonTextColor": "#FFFFFF", //ios
"primaryTextColor": "#212121",
"secondaryTextColor": "#757575", //ios
"backgroundColor": "#FFFFFF"
},
"session": { //required
"payment_session_id": "order_session_id",
"orderID": "order_id",
"environment": "SANDBOX" // "SANDBOX" or "PRODUCTION"
}
}
const webPaymentObject = {
"theme": { //optional
"navigationBarBackgroundColor": "#E64A19",
"navigationBarTextColor": "#FFFFFF"
},
"session": { //required
"payment_session_id": "order_session_id",
"orderID": "order_id",
"environment": "SANDBOX" // "SANDBOX" or "PRODUCTION"
}
}
Set the callback on the creation of your payment page.
const callbacks = {
onVerify: function (result) {
console.log("This is in the Application Verify: " + result);
const orderId = result.orderID;
},
onError: function (error){
console.log("This is in the Application Error: " + error);
const orderID = error.orderID
const status = error.status
const code = error.code
const type = error.type
const message = error.message
}
}
CFPaymentGateway.setCallback(callbacks) // onLoad of the Page
CFPaymentGateway.doDropPayment(dropPaymentObject)
CFPaymentGateway.doWebCheckoutPayment(webPaymentObject)
CFPaymentGateway.doUPIPayment(upiPaymentObject)
If you have questions, concerns, bug reports, etc, you can reach out to us using one of the following
- File an issue in this repository's Issue Tracker.
- Send a message in our discord channel. Join our discord server to get connected instantly.
- Send an email to [email protected]
For general instructions on how to contribute please refer to CONTRIBUTING.