Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(payments): early error if payment request is invalid #37503

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(payments): early error if payment request is invalid
  • Loading branch information
blaggacao committed Oct 30, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6d7475a17331483f55e1afae01a3ac995704624e
17 changes: 8 additions & 9 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
@@ -88,13 +88,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 (
@@ -159,14 +161,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":
15 changes: 14 additions & 1 deletion erpnext/accounts/doctype/payment_request/test_records.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
[
{
"doctype": "DocType",
"module": "Accounts",
"custom": 1,
"fields": [{"label": "Name", "fieldname": "name", "fieldtype": "Data"}],
"name": "Test Gateway Settings"
},
{
"doctype": "Test Gateway Settings",
"name": "_Test Gateway Controller"
},
{
"doctype": "Payment Gateway",
"gateway": "_Test Gateway"
"gateway": "_Test Gateway",
"gateway_settings": "Test Gateway Settings",
"gateway_controller": "_Test Gateway Controller"
},
{
"doctype": "Payment Gateway Account",
Loading