Skip to content

Instantly share code, notes, and snippets.

@basilcf

basilcf/inline.html

Last active Nov 14, 2018
Embed
What would you like to do?
Code Example for Merchant Hosted Cashfree Inline Payment page (https://docs.cashfree.com/docs/hosted/guide/#inline-mode)
<!-- Place the below div on your html -->
<div id="payment-div"></div>
<!-- Paste below code base before the closing tag(</body>) of body element -->
<script src="https://www.cashfree.com/assets/cashfree.sdk.v1.2.js" type="text/javascript"></script>
<script type="text/javascript">
(function() {
var data = {};
data.orderId = "1234";
data.orderAmount = 450;
data.customerName = "Seth";
data.customerPhone = "900XXXXX21";
data.customerEmail = "example@example.com";
data.returnUrl = "https://mysite.com/payment/response";
data.notifyUrl = "https://mysite.com/payment/notify";
data.appId = "<your_app_id>";
data.paymentToken = "<payment_token>";
var callback = function (event) {
var eventName = event.name;
switch(eventName) {
case "PAYMENT_REQUEST":
console.log(event.message);
break;
default:
console.log(event.message);
};
}
var config = {};
config.layout = {view: "inline", container: "payment-div", width: "600"};
config.mode = "TEST"; //use PROD when you go live
var response = CashFree.init(config);
if (response.status == "OK") {
CashFree.makePayment(data, callback);
} else {
//handle error
console.log(response.message);
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment