style: use snake case

This commit is contained in:
Shivam Mishra 2019-11-19 13:01:04 +05:30
parent f1005d9dae
commit 2aacbf46db

View file

@ -1,14 +1,14 @@
/* HOW-TO
Razorpay Payment
Razorpay Payment
1. Include checkout script in your code
1. Include checkout script in your code
<script type="text/javascript" src="/assets/js/checkout.min.js"></script>
2. Create the Order controller in your backend
2. Create the Order controller in your backend
def get_razorpay_order(self):
controller = get_payment_gateway_controller("Razorpay")
payment_details = {
"amount": 300,
...
@ -39,13 +39,13 @@ Razorpay Payment
};
razorpay = new frappe.checkout.razorpay(options)
razorpay.onOpen = () => {
razorpay.on_open = () => {
<SCRIPT TO RUN WHEN MODAL OPENS>
}
razorpay.onSuccess = () => {
razorpay.on_success = () => {
<SCRIPT TO RUN ON PAYMENT SUCCESS>
}
razorpay.onFail = () => {
razorpay.on_fail = () => {
<SCRIPT TO RUN ON PAYMENT FAILURE>
}
razorpay.init() // Creates the order and opens the modal
@ -62,10 +62,10 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
init() {
frappe.run_serially([
() => this.getKey(),
() => this.makeOrder(),
() => this.prepareOptions(),
() => this.setupHandler(),
() => this.get_key(),
() => this.make_order(),
() => this.prepare_options(),
() => this.setup_handler(),
() => this.show()
]);
}
@ -73,12 +73,12 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
show() {
this.razorpay = new Razorpay(this.options);
this.razorpay.once('ready', (response) => {
this.onOpen && this.onOpen(response);
this.on_open && this.on_open(response);
})
this.razorpay.open();
}
getKey() {
get_key() {
return new Promise(resolve => {
frappe.call("frappe.integrations.doctype.razorpay_settings.razorpay_settings.get_api_key").then(res => {
this.key = res.message;
@ -87,7 +87,7 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
});
}
makeOrder() {
make_order() {
return new Promise(resolve => {
frappe.call("frappe.integrations.doctype.razorpay_settings.razorpay_settings.get_order", {
doctype: this.doctype,
@ -99,7 +99,7 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
});
}
orderSuccess(response) {
order_success(response) {
frappe.call("frappe.integrations.doctype.razorpay_settings.razorpay_settings.order_payment_success", {
integration_request: this.order.integration_request,
params: {
@ -110,17 +110,17 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
})
}
orderFail(response) {
order_fail(response) {
frappe.call( "frappe.integrations.doctype.razorpay_settings.razorpay_settings.order_payment_failure", {
integration_request: this.order.integration_request,
params: response
})
}
prepareOptions() {
prepare_options() {
this.options = {
"key": this.key,
"amount": this.order.amount_due,
"amount": this.order.amount_due,
"currency": this.order.currency,
"name": this.name,
"description": this.description,
@ -132,15 +132,15 @@ frappe.require('https://checkout.razorpay.com/v1/checkout.js').then(() => {
};
}
setupHandler() {
setup_handler() {
this.options.handler = (response) => {
if (response.error) {
this.orderFail(response);
this.onFail && this.onFail(response);
this.order_fail(response);
this.on_fail && this.on_fail(response);
}
else if (response.razorpay_payment_id) {
this.orderSuccess(response);
this.onSuccess && this.onSuccess(response);
this.order_success(response);
this.on_success && this.on_success(response);
}
}
}