如何使用 Stripe Checkout 成功访问 clientReferenceId
How to access clientReferenceId on success using Stripe Checkout
我是 Stripe 的新手,使用看起来非常简单的设置来使用 Stripe Checkout 接受付款。我正在传递一个我需要在成功页面上访问的 clientReferenceId。这可能吗?这是在“结帐”按钮上调用的代码:
const stripeCheckout = async () => {
setLoading(true)
const stripe = await stripePromise;
const { error } = await stripe.redirectToCheckout({
lineItems: [
{
price: 'price_xxxxx',
quantity:1,
}
],
mode:"payment",
cancelUrl: window.location.origin,
successUrl: `${window.location.origin}/payment-complete`,
clientReferenceId: 'abc',
});
if (error) {
console.log("Error @ Checkout: ",error)
setLoading(false)
}
}
感谢您的帮助。
您可以通过在成功页面上检索结帐会话来访问 client_reference_id
:https://stripe.com/docs/payments/checkout/custom-success-page
然而,一个更简单的解决方案是将您的变量直接编码为成功 URL:
successURL: `${window.location.origin}/payment-complete?id=abc`,
然后在您的成功页面上,您可以访问查询字符串变量。
我是 Stripe 的新手,使用看起来非常简单的设置来使用 Stripe Checkout 接受付款。我正在传递一个我需要在成功页面上访问的 clientReferenceId。这可能吗?这是在“结帐”按钮上调用的代码:
const stripeCheckout = async () => {
setLoading(true)
const stripe = await stripePromise;
const { error } = await stripe.redirectToCheckout({
lineItems: [
{
price: 'price_xxxxx',
quantity:1,
}
],
mode:"payment",
cancelUrl: window.location.origin,
successUrl: `${window.location.origin}/payment-complete`,
clientReferenceId: 'abc',
});
if (error) {
console.log("Error @ Checkout: ",error)
setLoading(false)
}
}
感谢您的帮助。
您可以通过在成功页面上检索结帐会话来访问 client_reference_id
:https://stripe.com/docs/payments/checkout/custom-success-page
然而,一个更简单的解决方案是将您的变量直接编码为成功 URL:
successURL: `${window.location.origin}/payment-complete?id=abc`,
然后在您的成功页面上,您可以访问查询字符串变量。