From ade29ece7c2c51eafcf5a9d2d523ce3c522b60fe Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Thu, 8 Apr 2021 10:16:47 +0530 Subject: [PATCH] fix: Webform checkout (#12756) Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> --- payments/templates/pages/stripe_checkout.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/payments/templates/pages/stripe_checkout.py b/payments/templates/pages/stripe_checkout.py index 8375181..142d5b3 100644 --- a/payments/templates/pages/stripe_checkout.py +++ b/payments/templates/pages/stripe_checkout.py @@ -26,7 +26,7 @@ def get_context(context): context['amount'] = fmt_money(amount=context['amount'], currency=context['currency']) - if frappe.db.get_value(context.reference_doctype, context.reference_docname, "is_a_subscription"): + if is_a_subscription(context.reference_doctype, context.reference_docname): payment_plan = frappe.db.get_value(context.reference_doctype, context.reference_docname, "payment_plan") recurrence = frappe.db.get_value("Payment Plan", payment_plan, "recurrence") @@ -60,7 +60,7 @@ def make_payment(stripe_token_id, data, reference_doctype=None, reference_docnam gateway_controller = get_gateway_controller(reference_doctype,reference_docname) - if frappe.db.get_value(reference_doctype, reference_docname, 'is_a_subscription'): + if is_a_subscription(reference_doctype, reference_docname): reference = frappe.get_doc(reference_doctype, reference_docname) data = reference.create_subscription("stripe", gateway_controller, data) else: @@ -68,3 +68,8 @@ def make_payment(stripe_token_id, data, reference_doctype=None, reference_docnam frappe.db.commit() return data + +def is_a_subscription(reference_doctype, reference_docname): + if not frappe.get_meta(reference_doctype).has_field('is_a_subscription'): + return False + return frappe.db.get_value(reference_doctype, reference_docname, "is_a_subscription") \ No newline at end of file