mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 22:19:18 +00:00
Merge pull request #14945 from chdecultot/gocardless_corrections
Gocardless improvement and payment request correction
This commit is contained in:
@@ -244,10 +244,10 @@ class PaymentRequest(Document):
|
|||||||
success_url = shopping_cart_settings.payment_success_url
|
success_url = shopping_cart_settings.payment_success_url
|
||||||
if success_url:
|
if success_url:
|
||||||
redirect_to = ({
|
redirect_to = ({
|
||||||
"Orders": "orders",
|
"Orders": "/orders",
|
||||||
"Invoices": "invoices",
|
"Invoices": "/invoices",
|
||||||
"My Account": "me"
|
"My Account": "/me"
|
||||||
}).get(success_url, "me")
|
}).get(success_url, "/me")
|
||||||
else:
|
else:
|
||||||
redirect_to = get_url("/orders/{0}".format(self.reference_name))
|
redirect_to = get_url("/orders/{0}".format(self.reference_name))
|
||||||
|
|
||||||
|
|||||||
@@ -145,11 +145,11 @@ class GoCardlessSettings(Document):
|
|||||||
|
|
||||||
if self.flags.status_changed_to == "Completed":
|
if self.flags.status_changed_to == "Completed":
|
||||||
status = 'Completed'
|
status = 'Completed'
|
||||||
if self.data.reference_doctype and self.data.reference_docname:
|
if 'reference_doctype' in self.data and 'reference_docname' in self.data:
|
||||||
custom_redirect_to = None
|
custom_redirect_to = None
|
||||||
try:
|
try:
|
||||||
custom_redirect_to = frappe.get_doc(self.data.reference_doctype,
|
custom_redirect_to = frappe.get_doc(self.data.get('reference_doctype'),
|
||||||
self.data.reference_docname).run_method("on_payment_authorized", self.flags.status_changed_to)
|
self.data.get('reference_docname')).run_method("on_payment_authorized", self.flags.status_changed_to)
|
||||||
except Exception:
|
except Exception:
|
||||||
frappe.log_error(frappe.get_traceback())
|
frappe.log_error(frappe.get_traceback())
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{%- block page_content -%}
|
{%- block page_content -%}
|
||||||
<p class='lead text-center centered'>
|
<p class='lead text-center'>
|
||||||
<span class='gocardless-loading'>{{ _("Loading Payment System") }}</span>
|
<span class='gocardless-loading'>{{ _("Loading Payment System") }}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{%- block page_content -%}
|
{%- block page_content -%}
|
||||||
<p class='lead text-center centered'>
|
<p class='lead text-center'>
|
||||||
<span class='gocardless-loading'>{{ _("Payment Confirmation") }}</span>
|
<span class='gocardless-loading'>{{ _("Payment Confirmation") }}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,15 @@ def confirm_payment(redirect_flow_id, reference_doctype, reference_docname):
|
|||||||
"session_token": frappe.session.user
|
"session_token": frappe.session.user
|
||||||
})
|
})
|
||||||
|
|
||||||
|
confirmation_url = redirect_flow.confirmation_url
|
||||||
|
gocardless_success_page = frappe.get_hooks('gocardless_success_page')
|
||||||
|
if gocardless_success_page:
|
||||||
|
confirmation_url = frappe.get_attr(gocardless_success_page[-1])(reference_doctype, reference_docname)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"mandate": redirect_flow.links.mandate,
|
"mandate": redirect_flow.links.mandate,
|
||||||
"customer": redirect_flow.links.customer,
|
"customer": redirect_flow.links.customer,
|
||||||
"redirect_to": redirect_flow.confirmation_url,
|
"redirect_to": confirmation_url,
|
||||||
"redirect_message": "Mandate successfully created",
|
"redirect_message": "Mandate successfully created",
|
||||||
"reference_doctype": reference_doctype,
|
"reference_doctype": reference_doctype,
|
||||||
"reference_docname": reference_docname
|
"reference_docname": reference_docname
|
||||||
@@ -53,7 +58,7 @@ def confirm_payment(redirect_flow_id, reference_doctype, reference_docname):
|
|||||||
gateway_controller = get_gateway_controller(reference_docname)
|
gateway_controller = get_gateway_controller(reference_docname)
|
||||||
frappe.get_doc("GoCardless Settings", gateway_controller).create_payment_request(data)
|
frappe.get_doc("GoCardless Settings", gateway_controller).create_payment_request(data)
|
||||||
|
|
||||||
return {"redirect_to": redirect_flow.confirmation_url}
|
return {"redirect_to": confirmation_url}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
frappe.log_error(e, "GoCardless Payment Error")
|
frappe.log_error(e, "GoCardless Payment Error")
|
||||||
|
|||||||
Reference in New Issue
Block a user