Gocardless improvement and payment request correction
This commit is contained in:
parent
69fa808def
commit
9d09343e57
@ -226,10 +226,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))
|
||||
|
||||
|
@ -85,7 +85,7 @@ class GoCardlessSettings(Document):
|
||||
return get_url("./integrations/gocardless_checkout?{0}".format(urlencode(kwargs)))
|
||||
|
||||
def create_payment_request(self, data):
|
||||
self.data = frappe._dict(data)
|
||||
self.data = {str(key): str(value) for (key, value) in data.items()}
|
||||
|
||||
try:
|
||||
self.integration_request = create_request_log(self.data, "Host", "GoCardless")
|
||||
@ -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())
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user