React - 添加的查询参数在支付网关重定向后消失
React - Added Query Parameter getting disappeared after payment gateway redirection
初始参数:
https://test.website.com/Form?value=testing&key=
根据用户选择,我使用以下代码添加查询参数值 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
但在这之后我有支付网关集成,点击同一标签页中的按钮将被重定向到支付页面,成功消息后它将重定向回父页面,并添加一个与支付相关的查询参数。当时添加的key不见了
即
https://test.website.com/Form?value=testing&key=&paymentStatus=Success
支付网关最终控制您的用户在完成交易后将被重定向到的位置。听起来在您的情况下,网关正在施展魔法,将用户重定向回他们来自的 URL。
支付网关通常允许您(集成商)自定义 url 他们被发回的目的地。 Stripe accepts a successUrl
in their client side JavaScript client. Adyen accepts a returnUrl
在他们的支付流程中。你没有提到你正在使用的网关,但我怀疑它会有类似的功能。
如果他们不这样做,您将不得不依靠魔法。我建议确保 https://test.website.com/Form?value=testing&key=some_value url is making it all the way into the browser's history. 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.
初始参数: https://test.website.com/Form?value=testing&key=
根据用户选择,我使用以下代码添加查询参数值 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 但在这之后我有支付网关集成,点击同一标签页中的按钮将被重定向到支付页面,成功消息后它将重定向回父页面,并添加一个与支付相关的查询参数。当时添加的key不见了
即 https://test.website.com/Form?value=testing&key=&paymentStatus=Success
支付网关最终控制您的用户在完成交易后将被重定向到的位置。听起来在您的情况下,网关正在施展魔法,将用户重定向回他们来自的 URL。
支付网关通常允许您(集成商)自定义 url 他们被发回的目的地。 Stripe accepts a successUrl
in their client side JavaScript client. Adyen accepts a returnUrl
在他们的支付流程中。你没有提到你正在使用的网关,但我怀疑它会有类似的功能。
如果他们不这样做,您将不得不依靠魔法。我建议确保 https://test.website.com/Form?value=testing&key=some_value url is making it all the way into the browser's history. 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.