From 8d9996fa666e5a5e29c9946099422fa83cd1558f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 4 Oct 2016 16:11:16 +0530 Subject: [PATCH] [fixes] for razorpay --- payments/templates/includes/razorpay_checkout.js | 10 +--------- payments/templates/pages/payment-cancel.html | 6 +++--- payments/templates/pages/payment-failed.html | 8 ++++---- payments/templates/pages/payment-success.html | 9 +++++---- payments/templates/pages/razorpay_checkout.py | 13 ++++--------- 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/payments/templates/includes/razorpay_checkout.js b/payments/templates/includes/razorpay_checkout.js index ce2f792..6ab5501 100644 --- a/payments/templates/includes/razorpay_checkout.js +++ b/payments/templates/includes/razorpay_checkout.js @@ -5,7 +5,6 @@ $(document).ready(function(){ "amount": cint({{ amount }} * 100), // 2000 paise = INR 20 "name": "{{ title }}", "description": "{{ description }}", - "image": "{{ brand_image }}", "handler": function (response){ razorpay.make_payment_log(response, options, "{{ reference_doctype }}", "{{ reference_docname }}"); }, @@ -14,14 +13,7 @@ $(document).ready(function(){ "email": "{{ payer_email }}", "order_id": "{{ order_id }}" }, - "notes": { - "doctype": "{{ doctype }}", - "name": "{{ name }}", - "payment_request": "{{ name }}" // backward compatibility - }, - "theme": { - "color": "#4B4C9D" - } + "notes": {{ frappe.form_dict|json }} }; var rzp = new Razorpay(options); diff --git a/payments/templates/pages/payment-cancel.html b/payments/templates/pages/payment-cancel.html index 3a10a2b..83da017 100644 --- a/payments/templates/pages/payment-cancel.html +++ b/payments/templates/pages/payment-cancel.html @@ -1,12 +1,12 @@ {% extends "templates/web.html" %} -{% block title %}Make Payment{% endblock %} +{% block title %}{{ _("Payment Cancelled") }}{% endblock %} {%- block header -%} -

Payment Cancelled

+

{{ _("Payment Cancelled") }}

{% endblock %} {%- block page_content -%} -

You have cancelled your payment.

+

{{ _("You have cancelled the payment") }}


Back to home page

{% endblock %} diff --git a/payments/templates/pages/payment-failed.html b/payments/templates/pages/payment-failed.html index 4fbda9c..92f676b 100644 --- a/payments/templates/pages/payment-failed.html +++ b/payments/templates/pages/payment-failed.html @@ -1,12 +1,12 @@ {% extends "templates/web.html" %} -{% block title %}Payment Failed{% endblock %} +{% block title %}{{ _("Payment Failed") }}{% endblock %} {%- block header -%} -

Payment Failed

+

{{ _("Payment Failed") }}

{% endblock %} {%- block page_content -%} -

Your payment has failed. Do you mind trying again?

-

Back to Home

+

{{ _("Oops. Your payment has failed.") }}

+

{{ frappe.form_dict.redirect_message or _("Continue") }}

{% endblock %} diff --git a/payments/templates/pages/payment-success.html b/payments/templates/pages/payment-success.html index 3afb406..2d8397f 100644 --- a/payments/templates/pages/payment-success.html +++ b/payments/templates/pages/payment-success.html @@ -1,12 +1,13 @@ {% extends "templates/web.html" %} -{% block title %}Payment Success{% endblock %} +{% block title %}{{ _("Payment Success") }}{% endblock %} {%- block header -%} -

Payment Success

+

{{ _("Payment Success") }}

{% endblock %} {%- block page_content -%} -

Your payment has succeeded.

-

Back to Home

+

{{ _("Your payment was successfully accepted") }}

+

{{ frappe.form_dict.redirect_message or _("Continue") }}

{% endblock %} diff --git a/payments/templates/pages/razorpay_checkout.py b/payments/templates/pages/razorpay_checkout.py index 78d65dd..8d80617 100644 --- a/payments/templates/pages/razorpay_checkout.py +++ b/payments/templates/pages/razorpay_checkout.py @@ -17,13 +17,8 @@ expected_keys = ('amount', 'title', 'description', 'reference_doctype', 'referen def get_context(context): context.no_cache = 1 context.api_key = Controller().get_settings().api_key - + installed_apps = frappe.get_installed_apps() - - if 'erpnext' in installed_apps: - context.brand_image = "/assets/erpnext/images/erp-icon.svg" - else: - context.brand_image = '/assets/frappe_theme/img/erp-icon.svg' # all these keys exist in form_dict if not (set(expected_keys) - set(frappe.form_dict.keys())): @@ -40,14 +35,14 @@ def get_context(context): @frappe.whitelist(allow_guest=True) def make_payment(razorpay_payment_id, options, reference_doctype, reference_docname): data = {} - + if isinstance(options, basestring): data = json.loads(options) - + data.update({ "razorpay_payment_id": razorpay_payment_id, "reference_docname": reference_docname, "reference_doctype": reference_doctype }) - + return Controller().create_request(data)