I am integrating Snap Midtrans into my application, using Laravel as the backend and React as the frontend. The application follows a single-page app (SPA) concept, meaning page transitions are handled by react-router/react-router-dom without reloading, refreshing, or redirecting the web page.
Currently, I am adding the Snap feature to the application, but I am facing difficulties because every time a user completes the payment method selection, Snap redirects the application to the URL specified in the Midtrans Dashboard. This redirection disrupts my application’s state. However, I have already used JS callbacks, specifically the onPending
option. As stated in the documentation:
If Merchant use snap.js JS callbacks (onPending, onSuccess, onError), those JS callbacks will be triggered instead of redirection.
I have tried removing the Finish URL from the dashboard and overriding the Finish URL through the backend, but Snap still redirects (this time to the application’s main frontend page). I have also checked the documentation, but there seems to be no option to disable the redirection to the Finish URL.
I would appreciate any guidance. Thank you.