Rubel Hosen
Rubel Hosen

Reputation: 309

How to redirect URL from 3rd party API to react component and receive post/response data?

I am working on an eCommerce project. For front-end I'm using react and for back-end I'm using .NET Core Web API. When a customer proceed to checkout(from front-end) he requires to make an online payment transaction. So, on checkout button click I go to my API, validate the order and then redirect to 3rd party payment gateway with two parameters, success URL and a fail URL (from front-end). Then the customer makes the payment and if everything is okay then the payment gateway redirects to the success URL with response data otherwise to the fail URL.

So now, my question is how should I be able to receive the response data from my front end?

I can write a success method in my WEB API and receive the data from Request.Form but as the API will be hosted on a cloud server and customer will be using his own device so obviously that won't work.

If you can suggest me any work around that would really help.

Upvotes: 0

Views: 1606

Answers (1)

wilsonson
wilsonson

Reputation: 73

The success and fail URL are designed for page to page web flow, and they should not be trusted as a secured feedback from the payment gateway, because anyone can fake this URL. You may consider the success and fail URL as indicators, to notify your web site the check the transaction status on the server side. Generally a payment gateway should an API for checking the transaction status.

For example, when a customer is being redirected from the payment gateway back to your web with success URL, your react web app should then call a web API on your server side, and this web API should call the API from payment gateway to check the transaction status. And if the transaction is success, then you can proceed your web flow, or otherwise, you should treat it as a failed transaction.

Upvotes: 2

Related Questions