Merge pull request #14945 from chdecultot/gocardless_corrections

Gocardless improvement and  payment request correction
This commit is contained in:
Saurabh 2018-07-26 11:41:43 +05:30 committed by GitHub
commit f86224e6f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 11 deletions

View File

@ -244,10 +244,10 @@ class PaymentRequest(Document):
success_url = shopping_cart_settings.payment_success_url
if success_url:
redirect_to = ({
"Orders": "orders",
"Invoices": "invoices",
"My Account": "me"
}).get(success_url, "me")
"Orders": "/orders",
"Invoices": "/invoices",
"My Account": "/me"
}).get(success_url, "/me")
else:
redirect_to = get_url("/orders/{0}".format(self.reference_name))

View File

@ -145,11 +145,11 @@ class GoCardlessSettings(Document):
if self.flags.status_changed_to == "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
try:
custom_redirect_to = frappe.get_doc(self.data.reference_doctype,
self.data.reference_docname).run_method("on_payment_authorized", self.flags.status_changed_to)
custom_redirect_to = frappe.get_doc(self.data.get('reference_doctype'),
self.data.get('reference_docname')).run_method("on_payment_authorized", self.flags.status_changed_to)
except Exception:
frappe.log_error(frappe.get_traceback())

View File

@ -9,7 +9,7 @@
{% endblock %}
{%- block page_content -%}
<p class='lead text-center centered'>
<p class='lead text-center'>
<span class='gocardless-loading'>{{ _("Loading Payment System") }}</span>
</p>

View File

@ -9,7 +9,7 @@
{% endblock %}
{%- block page_content -%}
<p class='lead text-center centered'>
<p class='lead text-center'>
<span class='gocardless-loading'>{{ _("Payment Confirmation") }}</span>
</p>

View File

@ -36,10 +36,15 @@ def confirm_payment(redirect_flow_id, reference_doctype, reference_docname):
"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 = {
"mandate": redirect_flow.links.mandate,
"customer": redirect_flow.links.customer,
"redirect_to": redirect_flow.confirmation_url,
"redirect_to": confirmation_url,
"redirect_message": "Mandate successfully created",
"reference_doctype": reference_doctype,
"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)
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:
frappe.log_error(e, "GoCardless Payment Error")