-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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).
accelerator/packages/react-centra-checkout/src/Context/index.tsx
Lines 414 to 437 in 995809e
| // 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
Labels
enhancementNew feature or requestNew feature or request