Skip to content

Commit

Permalink
fix(payments): early error if payment request is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Oct 14, 2023
1 parent f4a294c commit 31bbdf2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ def validate_subscription_details(self):
)

def on_submit(self):
self.payment_gateway_validation()

if self.payment_request_type == "Outward":
self.db_set("status", "Initiated")
return
elif self.payment_request_type == "Inward":
self.db_set("status", "Requested")

send_mail = self.payment_gateway_validation() if self.payment_gateway else None
send_mail = bool(self.payment_gateway)
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)

if (
Expand Down Expand Up @@ -164,14 +166,11 @@ def make_invoice(self):
si.submit()

def payment_gateway_validation(self):
try:
controller = _get_payment_gateway_controller(self.payment_gateway)
if hasattr(controller, "on_payment_request_submission"):
return controller.on_payment_request_submission(self)
else:
return True
except Exception:
return False
controller = _get_payment_gateway_controller(self.payment_gateway)
if hasattr(controller, "on_payment_request_submission"):
return controller.on_payment_request_submission(self)
else:
return True

def set_payment_request_url(self):
if self.payment_account and self.payment_channel != "Phone":
Expand Down

0 comments on commit 31bbdf2

Please sign in to comment.