简体   繁体   English

React - 支付网关重定向后添加的查询参数消失

[英]React - Added Query Parameter getting disappeared after payment gateway redirection

Initial Parameter: https://test.website.com/Form?value=testing&key=初始参数: https://test.website.com/Form?value=testing&key=

Based on the user selection I'm adding the query parameter value key = "some_value" using the below code根据用户选择,我使用以下代码添加查询参数 value key = "some_value"

      const value = new URLSearchParams(this.props.location.search).get("value");
      const key = new URLSearchParams(this.props.location.search).get("key");
      if (key === "") {
        this.props.history.push({
          pathname: "/Form",
          search: `?value=${value}&key=${key}`,
        });
      }

https://test.website.com/Form?value=testing&key=some_value But After this I've Payment Gateway Integration where on click of button in same tab page will be redirected to payment page and after success message it'll redirect back to the parent page with the one more addition of query param related to payment. https://test.website.com/Form?value=testing&key=some_value但在此之后我有支付网关集成,点击同一标签页中的按钮将被重定向到支付页面,成功消息后它会重定向回来到父页面,再添加一个与付款相关的查询参数。 At that time, the added key is missing那时,添加的密钥丢失

ie https://test.website.com/Form?value=testing&key=&paymentStatus=Successhttps://test.website.com/Form?value=testing&key=&paymentStatus=Success

The payment gateway ultimately controls where your user will be redirected to after they complete the transaction.支付网关最终控制您的用户在完成交易后将被重定向到的位置。 It sounds like in your case, the gateway is doing some magic to redirect the user back to the URL they came from.听起来在您的情况下,网关正在做一些魔术来将用户重定向回他们来自的 URL。

It's common for payment gateways to allow you, the integrator, to customize the url they get sent back to.支付网关通常允许您(集成商)自定义他们返回的 url。 Stripe accepts a successUrl in their client side JavaScript client. Stripe 在其客户端 JavaScript 客户端中successUrl successUrl。 Adyen accepts a returnUrl in their payment flow. returnUrl在其付款流程中接受 returnUrl。 You don't mention the gateway you're using, but I suspect it'll have a similar feature.你没有提到你正在使用的网关,但我怀疑它会有类似的功能。

If they don't - you'll have to lean into the magic.如果他们不这样做 - 你将不得不依靠魔法。 I'd suggest making sure the https://test.website.com/Form?value=testing&key=some_value url is making it all the way into the browser's history.我建议确保https://test.website.com/Form?value=testing&key=some_value url 一直在浏览器的历史中。 The code snippet you've displayed here pushes it into a history prop of a component but it's unclear if that history is the same as the browser's history .您在此处显示的代码片段将其推送到组件的历史记录中,但不清楚该历史记录是否与浏览器的历史记录相同。

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

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