From 9606520064c351386bca75a6e0de39638324d8d9 Mon Sep 17 00:00:00 2001 From: Rohan Date: Thu, 26 Aug 2021 21:47:00 +0530 Subject: [PATCH] fix: use Stripe's Price API for plan-price information (#26107) * fix: use Stripe's new Plan API for price information * patch: use inbuilt function to rename field * fix: patch call Co-authored-by: Ankush Menat Co-authored-by: Nabin Hait (cherry picked from commit 16eed07a0fb34b8d0ad042ed18d79a1123cc6076) # Conflicts: # erpnext/accounts/doctype/subscription_plan/subscription_plan.json # erpnext/erpnext_integrations/stripe_integration.py # erpnext/patches.txt --- .../subscription_plan/subscription_plan.json | 4 +++ .../stripe_integration.py | 29 +++++++++++++++++++ erpnext/patches.txt | 3 ++ 3 files changed, 36 insertions(+) diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.json b/erpnext/accounts/doctype/subscription_plan/subscription_plan.json index 563df79eec7..c7a797e28f4 100644 --- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.json +++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.json @@ -148,7 +148,11 @@ } ], "links": [], +<<<<<<< HEAD "modified": "2021-12-10 15:24:15.794477", +======= + "modified": "2021-08-13 10:53:44.205774", +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) "modified_by": "Administrator", "module": "Accounts", "name": "Subscription Plan", diff --git a/erpnext/erpnext_integrations/stripe_integration.py b/erpnext/erpnext_integrations/stripe_integration.py index b12adc1d3df..d4655c64f75 100644 --- a/erpnext/erpnext_integrations/stripe_integration.py +++ b/erpnext/erpnext_integrations/stripe_integration.py @@ -1,6 +1,11 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +<<<<<<< HEAD +======= +import stripe + +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) import frappe import stripe from frappe import _ @@ -23,6 +28,7 @@ def create_stripe_subscription(gateway_controller, data): except Exception: frappe.log_error(frappe.get_traceback()) +<<<<<<< HEAD return { "redirect_to": frappe.redirect_to_message( _("Server Error"), @@ -31,6 +37,14 @@ def create_stripe_subscription(gateway_controller, data): ), ), "status": 401, +======= + return{ + "redirect_to": frappe.redirect_to_message( + _('Server Error'), + _("It seems that there is an issue with the server's stripe configuration. In case of failure, the amount will get refunded to your account.") + ), + "status": 401 +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) } @@ -44,12 +58,17 @@ def create_subscription_on_stripe(stripe_settings): customer = stripe.Customer.create( source=stripe_settings.data.stripe_token_id, description=stripe_settings.data.payer_name, +<<<<<<< HEAD email=stripe_settings.data.payer_email, +======= + email=stripe_settings.data.payer_email +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) ) subscription = stripe.Subscription.create(customer=customer, items=items) if subscription.status == "active": +<<<<<<< HEAD stripe_settings.integration_request.db_set("status", "Completed", update_modified=False) stripe_settings.flags.status_changed_to = "Completed" @@ -58,6 +77,16 @@ def create_subscription_on_stripe(stripe_settings): frappe.log_error("Subscription N°: " + subscription.id, "Stripe Payment not completed") except Exception: stripe_settings.integration_request.db_set("status", "Failed", update_modified=False) +======= + stripe_settings.integration_request.db_set('status', 'Completed', update_modified=False) + stripe_settings.flags.status_changed_to = "Completed" + + else: + stripe_settings.integration_request.db_set('status', 'Failed', update_modified=False) + frappe.log_error('Subscription N°: ' + subscription.id, 'Stripe Payment not completed') + except Exception: + stripe_settings.integration_request.db_set('status', 'Failed', update_modified=False) +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) frappe.log_error(frappe.get_traceback()) return stripe_settings.finalize_request() diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e81892bd14f..16623553fe9 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -301,10 +301,13 @@ erpnext.patches.v13_0.update_export_type_for_gst #2021-08-16 erpnext.patches.v13_0.update_tds_check_field #3 erpnext.patches.v13_0.update_recipient_email_digest erpnext.patches.v13_0.shopify_deprecation_warning +<<<<<<< HEAD erpnext.patches.v13_0.add_custom_field_for_south_africa #2 erpnext.patches.v13_0.rename_discharge_ordered_date_in_ip_record erpnext.patches.v13_0.remove_bad_selling_defaults erpnext.patches.v13_0.trim_whitespace_from_serial_nos # 16-01-2022 +======= +>>>>>>> 16eed07a0f (fix: use Stripe's Price API for plan-price information (#26107)) erpnext.patches.v13_0.migrate_stripe_api erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries execute:frappe.reload_doc("erpnext_integrations", "doctype", "TaxJar Settings")