[fixes] handle cancled payment requests
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index ccc2b3a..6d1ea97 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -52,7 +52,7 @@
si.submit()
def send_payment_request(self):
- self.payment_url = get_url("/api/method/erpnext.accounts.doctype.payment_request.payment_request.generate_payemnt_request?name={0}".format(self.name))
+ self.payment_url = get_url("/api/method/erpnext.accounts.doctype.payment_request.payment_request.generate_payment_request?name={0}".format(self.name))
if self.payment_url:
frappe.db.set_value(self.doctype, self.name, "status", "Initiated")
@@ -153,7 +153,7 @@
pr.submit()
if args.cart:
- generate_payemnt_request(pr.name)
+ generate_payment_request(pr.name)
frappe.db.commit()
if not args.cart:
@@ -199,12 +199,18 @@
}
@frappe.whitelist(allow_guest=True)
-def generate_payemnt_request(name):
+def generate_payment_request(name):
doc = frappe.get_doc("Payment Request", name)
- if doc.gateway == "PayPal":
- from paypal_integration.express_checkout import set_express_checkout
- payment_url = set_express_checkout(doc.amount, doc.currency, {"doctype": doc.doctype,
- "docname": doc.name})
+ if doc.docstatus not in [0, 2]:
+ if doc.gateway == "PayPal":
+ from paypal_integration.express_checkout import set_express_checkout
+ payment_url = set_express_checkout(doc.amount, doc.currency, {"doctype": doc.doctype,
+ "docname": doc.name})
- frappe.local.response["type"] = "redirect"
- frappe.local.response["location"] = payment_url
+ frappe.local.response["type"] = "redirect"
+ frappe.local.response["location"] = payment_url
+ else:
+ frappe.respond_as_web_page(_("Invalid Payment Request"),
+ _("Payment Request has been canceled by vendor"), success=False,
+ http_status_code=frappe.ValidationError.http_status_code)
+
\ No newline at end of file