def confirm_payment(redirect_flow_id, reference_doctype, reference_docname): client = gocardless_initialization(reference_docname) try: redirect_flow = client.redirect_flows.complete( redirect_flow_id, params={"session_token": frappe.session.user}) data = { "mandate": redirect_flow.links.mandate, "customer": redirect_flow.links.customer, "redirect_to": redirect_flow.confirmation_url, "redirect_message": "Mandate successfully created", "reference_doctype": reference_doctype, "reference_docname": reference_docname } try: create_mandate(data) except Exception as e: frappe.log_error(e, "GoCardless Mandate Registration Error") 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} except Exception as e: frappe.log_error(e, "GoCardless Payment Error") return {"redirect_to": '/integrations/payment-failed'}
def get_context(context): context.no_cache = 1 # all these keys exist in form_dict if not (set(expected_keys) - set(frappe.form_dict.keys())): for key in expected_keys: context[key] = frappe.form_dict[key] context['amount'] = flt(context['amount']) gateway_controller = get_gateway_controller(context.reference_docname) context['header_img'] = frappe.db.get_value("GoCardless Settings", gateway_controller, "header_img") else: frappe.redirect_to_message(_('Some information is missing'), _('Looks like someone sent you to an incomplete URL. Please ask them to look into it.')) frappe.local.flags.redirect_location = frappe.local.response.location raise frappe.Redirect
def get_context(context): context.no_cache = 1 # all these keys exist in form_dict if not (set(expected_keys) - set(frappe.form_dict.keys())): for key in expected_keys: context[key] = frappe.form_dict[key] context['amount'] = flt(context['amount']) gateway_controller = get_gateway_controller(context.reference_docname) context['header_img'] = frappe.db.get_value("GoCardless Settings", gateway_controller, "header_img") else: frappe.redirect_to_message(_('Some information is missing'), _('Looks like someone sent you to an incomplete URL. Please ask them to look into it.')) frappe.local.flags.redirect_location = frappe.local.response.location raise frappe.Redirect