diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 6b504fa1..159d3ca3 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -50,5 +50,5 @@ jobs: - name: Run Semgrep rules run: | - pip install semgrep==0.97.0 + pip install semgrep==1.90.0 semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness diff --git a/payments/payment_gateways/doctype/stripe_settings/stripe_settings.py b/payments/payment_gateways/doctype/stripe_settings/stripe_settings.py index 816b77e9..bb1bc677 100644 --- a/payments/payment_gateways/doctype/stripe_settings/stripe_settings.py +++ b/payments/payment_gateways/doctype/stripe_settings/stripe_settings.py @@ -276,9 +276,9 @@ def finalize_request(self): return {"redirect_to": redirect_url, "status": status} -def get_gateway_controller(doctype, docname): - reference_doc = frappe.get_doc(doctype, docname) - gateway_controller = frappe.db.get_value( - "Payment Gateway", reference_doc.payment_gateway, "gateway_controller" - ) +def get_gateway_controller(doctype, docname, payment_gateway=None): + if not payment_gateway: + reference_doc = frappe.get_doc(doctype, docname) + payment_gateway = reference_doc.payment_gateway + gateway_controller = frappe.db.get_value("Payment Gateway", payment_gateway, "gateway_controller") return gateway_controller diff --git a/payments/templates/includes/stripe_checkout.js b/payments/templates/includes/stripe_checkout.js index 0a0aa706..7f37e96b 100644 --- a/payments/templates/includes/stripe_checkout.js +++ b/payments/templates/includes/stripe_checkout.js @@ -39,7 +39,8 @@ function setOutcome(result) { "stripe_token_id": result.token.id, "data": JSON.stringify({{ frappe.form_dict|json }}), "reference_doctype": "{{ reference_doctype }}", - "reference_docname": "{{ reference_docname }}" + "reference_docname": "{{ reference_docname }}", + "payment_gateway": "{{ payment_gateway }}" }, callback: function(r) { if (r.message.status == "Completed") { diff --git a/payments/templates/pages/stripe_checkout.py b/payments/templates/pages/stripe_checkout.py index c57d39c4..7572002e 100644 --- a/payments/templates/pages/stripe_checkout.py +++ b/payments/templates/pages/stripe_checkout.py @@ -20,8 +20,8 @@ "reference_docname", "payer_name", "payer_email", - "order_id", "currency", + "payment_gateway", ) @@ -32,8 +32,9 @@ def get_context(context): if not (set(expected_keys) - set(list(frappe.form_dict))): for key in expected_keys: context[key] = frappe.form_dict[key] - - gateway_controller = get_gateway_controller(context.reference_doctype, context.reference_docname) + gateway_controller = get_gateway_controller( + context.reference_doctype, context.reference_docname, context.payment_gateway + ) context.publishable_key = get_api_key(context.reference_docname, gateway_controller) context.image = get_header_image(context.reference_docname, gateway_controller) @@ -71,12 +72,14 @@ def get_header_image(doc, gateway_controller): @frappe.whitelist(allow_guest=True) -def make_payment(stripe_token_id, data, reference_doctype=None, reference_docname=None): +def make_payment( + stripe_token_id, data, reference_doctype=None, reference_docname=None, payment_gateway=None +): data = json.loads(data) data.update({"stripe_token_id": stripe_token_id}) - gateway_controller = get_gateway_controller(reference_doctype, reference_docname) + gateway_controller = get_gateway_controller(reference_doctype, reference_docname, payment_gateway) if is_a_subscription(reference_doctype, reference_docname): reference = frappe.get_doc(reference_doctype, reference_docname) diff --git a/pyproject.toml b/pyproject.toml index 1dbe5220..a102875d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,8 @@ readme = "README.md" dynamic = ["version"] dependencies = [ "paytmchecksum~=1.7.0", - "razorpay~=1.2.0", - "stripe~=2.56.0", + "razorpay~=1.4.2", + "stripe~=10.12.0", "braintree~=4.20.0", "pycryptodome>=3.18.0,<4.0.0", "gocardless-pro~=1.22.0",