Skip to content

[react-centra-checkout]: support parameter actionHandler for submitPayment #104

@adamsoderstrom

Description

@adamsoderstrom

Currently there's no way to do a custom action handler when using the submitPayment hook.
Therefore, we need to do optimistic logic (either do actions on "order confirmation" page or before calling submitPayment).

We should be able to opt-out of the default action handler, so we can validate that the payment was successful, trigger other logic and then redirect (or other).

// handle redirecting here
switch (response.action) {
case 'redirect':
if (response.url) {
window.location.href = response.url
}
break
case 'success':
// according to Centra docs – if action === 'success', user should be forwarded directly to the receipt page
window.location.href = `${receiptPage}/${response.token}`
break
case 'javascript':
if (response.code) {
const script = document.createElement('script')
const text = document.createTextNode(response.code)
script.appendChild(text)
document.body.appendChild(script)
}
break
default:
return response
}
return response
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions