We made a AngularJS app where user opens a URL (xyz.com/booking) fills the forms and then selects some items for purchase.
After that user clicks on BUY button and
ngRoute
can't handle URLs accessed via POST , if you have rewrite on index.html you are just posting to index.html not to you route, it does not work when you have configured /booking-success and you POST on that url via cURL you are actually posting to index.html. Routing in angular is just "virtual" not real. Systems like cURL or any other HTTP client cant see it and therefore they are posting to index.html.
Never handle callback URLs from payment/booking/any gateway inside angular. Angular is dangerous because you must be sure that callback process will be executed. Angular is not fault tolerant , if there will be any javascript error, any error inside your angular call you will lost all callback data and you are literally screwed.
Callbacks must be part of your REST API and must be implemented to return HTTP status code 200, otherwise in case on any other HTTP code, gateway should know that they must retry call. (For example, skrill.com is repeating a callback 10 times in case of no HTTP 200 code). Actually, AngularJS will respond every time with a 200 because your web server will serve the index.html, it doesn't care what happens inside javascript code.
redirect_url
, usually URL that user is redirected after successful payment/action on broker side. But in the meantime the callback URL is still called on a lower level of your application. The redirect URL is called via GET inside browser redirect so user will see it as normal.Every "normal" gateway has callback_url
(low level notification for your API that action is successful and redirect_url
, that is redirecting back to your site xyz.com/booking-success). But they should be separated. If your gateway does not have redirection, you don't have a choice but to open whole booking in new window. And somehow notify your front end after callback is called. That can be done via polling with intervals. For example, 10 seconds, which is retrieving actual status of your booking_id
(column is_processed (true|false)
which you will set inside callback code. When status changes from false to true you will notify your front end (redirect user or show popup) . Also you can implement socket.io library which you can handle polling and your notification will be instant when callback URL is called.