简体   繁体   中英

Redirect to frontend URL with POST after external payment

My VueJS application relies on a Java backend. This Java backend serves all REST endpoints for providing the data.

When a user performs a checkout the backend responds with a redirect url and redirects the user to that URL. This is done simply like that:

window.location.href = redirectUrl;

As soon as the payment process is finished on the external page the payment provider redirects the user to a return_url which in this case is my VueJS front-end. However the external system sends the return_url in a POST request directly to the front-end which cannot be processed in the as there is no endpoint listening.

What would be an approriate way handling this? As far as I know, VueJS doesn't have any possibility accepting POST requests.

TLDR; It is the responsibility of any external payment gateway system or similar system like OAuth/OpenID to redirect to the calling app via simple browser redirects (via HTTP 302 and 303). So, you should ask/configure external payment provider to follow the standard workflow.

In theory, you should never encounter this problem as POST is typically an Ajax request. Imagine you are on external payment page and when the payment succeeds, external JS is making the POST call and hence the payment page should then take responsibility of redirecting to the appropriate page by reading the reponse.

Now, the second possibility is that payment page is using traditional FORM submission via POST method type and giving back response as JSON or equivalent body. In this case, you should have a server side script (on your ui-server) that would listen for this call and then load the front-end application built with Vue.

If your UI is being served by Java back-end, then it should be simple job of having a Servelet or JSP .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM