简体   繁体   English

外部付款后使用 POST 重定向到前端 URL

[英]Redirect to frontend URL with POST after external payment

My VueJS application relies on a Java backend.我的 VueJS 应用程序依赖于 Java 后端。 This Java backend serves all REST endpoints for providing the data.此 Java 后端服务于所有 REST 端点以提供数据。

When a user performs a checkout the backend responds with a redirect url and redirects the user to that URL.当用户执行结帐时,后端会使用重定向 URL 进行响应并将用户重定向到该 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.一旦在外部页面上完成支付过程,支付提供商就会将用户重定向到return_url ,在这种情况下,它是我的 VueJS 前端。 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.但是,外部系统将POST请求中的return_url直接发送到前端,由于没有端点侦听,因此无法在前端进行处理。

What would be an approriate way handling this?处理这个问题的适当方法是什么? As far as I know, VueJS doesn't have any possibility accepting POST requests.据我所知,VueJS 不可能接受 POST 请求。

TLDR; 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).任何外部支付网关系统或 OAuth/OpenID 等类似系统都有责任通过简单的浏览器重定向(通过 HTTP 302 和 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.理论上,您永远不会遇到这个问题,因为 POST 通常是一个 Ajax 请求。 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.假设您在外部支付页面上,当支付成功时,外部 JS 进行 POST 调用,因此支付页面应该负责通过读取响应重定向到适当的页面。

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.现在,第二种可能性是支付页面通过POST方法类型使用传统的FORM 提交,并以 JSON 或等效正文形式返回响应。 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.在这种情况下,您应该有一个服务器端脚本(在您的 ui 服务器上),它会侦听此调用,然后加载使用 Vue 构建的前端应用程序。

If your UI is being served by Java back-end, then it should be simple job of having a Servelet or JSP .如果您的 UI 由 Java 后端提供服务,那么拥有ServeletJSP应该很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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