[fixes] handle cancled payment requests
This commit is contained in:
parent
0a0c78729f
commit
a940b6d149
@ -52,7 +52,7 @@ class PaymentRequest(Document):
|
|||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
def send_payment_request(self):
|
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:
|
if self.payment_url:
|
||||||
frappe.db.set_value(self.doctype, self.name, "status", "Initiated")
|
frappe.db.set_value(self.doctype, self.name, "status", "Initiated")
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ def make_payment_request(**args):
|
|||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
if args.cart:
|
if args.cart:
|
||||||
generate_payemnt_request(pr.name)
|
generate_payment_request(pr.name)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
if not args.cart:
|
if not args.cart:
|
||||||
@ -199,12 +199,18 @@ def get_print_format_list(ref_doctype):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def generate_payemnt_request(name):
|
def generate_payment_request(name):
|
||||||
doc = frappe.get_doc("Payment Request", name)
|
doc = frappe.get_doc("Payment Request", name)
|
||||||
if doc.gateway == "PayPal":
|
if doc.docstatus not in [0, 2]:
|
||||||
from paypal_integration.express_checkout import set_express_checkout
|
if doc.gateway == "PayPal":
|
||||||
payment_url = set_express_checkout(doc.amount, doc.currency, {"doctype": doc.doctype,
|
from paypal_integration.express_checkout import set_express_checkout
|
||||||
"docname": doc.name})
|
payment_url = set_express_checkout(doc.amount, doc.currency, {"doctype": doc.doctype,
|
||||||
|
"docname": doc.name})
|
||||||
|
|
||||||
frappe.local.response["type"] = "redirect"
|
frappe.local.response["type"] = "redirect"
|
||||||
frappe.local.response["location"] = payment_url
|
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)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user