gpt4 book ai didi

update stripe payment intent from wallet payment without creating a customer(在不创建客户的情况下从Wallet支付更新条带支付意向)

转载 作者:bug小助手 更新时间:2023-10-26 19:41:56 27 4
gpt4 key购买 nike



I am attempting to integrate wallets (Google/Apple Pay) into an existing Stripe elements page.

我正在尝试将钱包(Google/Apple Pay)集成到现有的条纹元素页面中。


const paymentRequest = stripe.paymentRequest({
country: 'GB',
currency: 'gbp',
total: {
label: 'Demo total',
amount: 1000,
},
});


paymentRequest.addEventListener('token', (event) =>
{
//const token = event.paymentMethod.token;
// Handle the token event here
if (event.token)
{
let token = event.token.id;
let payerName = event.payerName;
let payerEmail = event.payerEmail;
let payerPhone = event.payerPhone;

stripeWalletToken(token);
}

event.complete('success');
});

paymentRequest.addEventListener('source', (event) =>
{
if (event.source)
{
let payerName = event.payerName;
let payerEmail = event.payerEmail;
let payerPhone = event.payerPhone;

let source = event.source.id;
// Handle the source event here
stripeWalletSource(source);
}
// Handle the source event here
event.complete('success');
});


const prButton = elements.create('paymentRequestButton', {
paymentRequest: paymentRequest,
style: {
paymentRequestButton: {
type: 'default',
theme: 'dark',
height: '64px',
},
},
});

Once I receive the source id, I send it to my server and try to update the PaymentIntent as such:

收到源id后,我将其发送到服务器,并尝试按如下方式更新PaymentIntent:


    if (i != null)
{
var options = new PaymentIntentUpdateOptions
{
PaymentMethod = "pm_card_yournewsourceid", // Replace with your new PaymentMethod ID
};

var service = new PaymentIntentService();
PaymentIntent updatedPaymentIntent = service.Update(i.Id, options);

}

However I get the message "A source must be attached to a customer to be used as a payment_method". I do not want to create a customer on Stripe's platform. I simply want to update the existing payment intent with the payment that has been received from Google/Apple.

然而,我得到的消息是“必须将源附加到客户,才能用作付款方法”。我不想在斯利普的平台上创建客户。我只是想用从谷歌/苹果收到的付款更新现有的付款意图。


I have tried consulting Stripe's 'documentation' and there's nothing to cover it. Their support staff are unable to understand the issue, let alone provide a solution.

我试着查阅了斯利普的“文档”,但没有任何相关内容。他们的支持人员无法理解这个问题,更不用说提供解决方案了。


更多回答
优秀答案推荐

You're getting this error because you're using Tokens - which you shouldn't do.

您收到这个错误是因为您正在使用令牌--您不应该这样做。


I'd suggest following the up-to-date documentation on Stripe's Payment Request Element, which doesn't tokenize the card wallet using the Tokens API, but the Payment Methods API:

https://stripe.com/docs/stripe-js/elements/payment-request-button

我建议遵循关于Strike的支付请求元素的最新文档,该元素不使用令牌API来标记卡钱包,而是使用支付方法API:https://stripe.com/docs/stripe-js/elements/payment-request-button


Your integration differs from this documentation, notably on the paymentRequest.on('payment_method',{}) and stripe.confirmPayment({}):

https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html#html-js-complete-payment

您的集成与本文档不同,特别是在PaymentRequest.on(‘Payment_Method’,{})和stripe.confirmPayment({}):https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html#html-js-complete-payment


更多回答

yep. Unfortunately with no realistic support available from Stripe on the weekends I ended up asking ChatGPT for help and ended up down the token/source rabbit hole as that was the only event which appeared to be firing. Since removing that and resetting the paymentRequest..on(paymentmoethod) the paymentmethod now appears to be firing!

是啊。不幸的是,在周末,由于没有实际的支持,我最终向ChatGPT寻求帮助,结果陷入了令牌/源码兔洞,因为这似乎是唯一正在触发的事件。由于删除了它并重置了paymentRequest..on(Paymentmoethod),现在,pay方法似乎正在触发!

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com