From b4d01ff8ee40b0d3a5ed70b3bb10d10b7f7e259d Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 31 May 2019 18:36:55 +0530 Subject: [PATCH] fix: ignore if profile already in cancelled state --- .../integrations/doctype/paypal_settings/paypal_settings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frappe/integrations/doctype/paypal_settings/paypal_settings.py b/frappe/integrations/doctype/paypal_settings/paypal_settings.py index de15650cb6..3eacff0b9d 100644 --- a/frappe/integrations/doctype/paypal_settings/paypal_settings.py +++ b/frappe/integrations/doctype/paypal_settings/paypal_settings.py @@ -367,7 +367,11 @@ def manage_recurring_payment_profile_status(profile_id, action, args, url): response = make_post_request(url, data=args) - if response.get("ACK")[0] != "Success": + # error code 11556 indicates profile is not in active state(or already cancelled) + # thus could not cancel the subscription. + # thus raise exception only if error code not quals to 11556 + + if response.get("ACK")[0] != "Success" and response.get("L_ERRORCODE0", [])[0] != '11556': frappe.throw(_("Failed while amending subscription")) @frappe.whitelist(allow_guest=True)