stripe-archive / stripe-payments-demo

Sample store accepting universal payments on the web with Stripe Elements, Payment Request, Apple Pay, Google Pay, Microsoft Pay, and the PaymentIntents API. 💳🌍✨
https://stripe-payments-demo.appspot.com
MIT License
1.47k stars 547 forks source link

No API documentation for paymentIntents.confirm with Source Id #160

Closed Troy-Yang closed 3 years ago

Troy-Yang commented 3 years ago

Hi everyone,

I am looking into this demo and it works great!

However, I am confusing on why it works by connecting a paymentIntent with a source together in the demo?

This repo demo codes in client side at this line: // creating source with metadata ... metadata: { paymentIntent: paymentIntent.id, } ...

Then in webhook of server side at line: await stripe.paymentIntents.confirm(paymentIntent.id, {source: source.id});

I truly didn't find the confirm api includes the source parameter.

Can any one explain this part? I know it works, but i am looking for the evidence. Btw, I think the paymentIntent is very good and I do want to use it in Source when dealing with some payment methods.

Thanks in advanced!

willock-stripe commented 3 years ago

Hi @Troy-Yang –

You're correct that this is an undocumented (and niche) integration path, primarily designed for Stripe users who needed to upgrade to the PaymentIntents API (for example, to support Strong Customer Authentication), but still support local payment methods that weren't yet available on the PaymentIntents API. It's really just an alternative for calling POST /v1/charges, and shouldn't be necessary for most Stripe users, as you would typically just run the two APIs side-by-side, and especially now as most payment methods are now available directly on the PaymentIntents API.

Please note this is a different use-case to card_ and source_ compatibility on the PaymentIntents API.