Home > database >  Stripe differentiate between payment Intent and payment link
Stripe differentiate between payment Intent and payment link

Time:10-03

I'm trying to read the webhook response from both a payment intent (in which a user in the website press pay to pay for an item) and a payment link (where he receives a link which then he can pay through) I'm trying to find how can I differentiate between them but I can't find a difference. Is there a flag or something to distinguish which one was paid

CodePudding user response:

PaymentLinks[1] are a way to accept payment without building a storefront. It uses PaymentIntents[2] behind in order to accept payment.

Actually, when you create a PaymentLink, Stripe creates a Checkout Session[3] and a PaymentIntent for each payment attempt.

In order to track payments issued from PaymentLinks[4] using webhooks,you should listen to one of these events depending on your exact need:

  • checkout.session.completed [5] to track when customers completed a payment.

  • payment_intent.succeeded [6] to track when a Payment was done successfully.In order to distinguish between PaymentIntent that you’ve created by your own and from the ones are created by PaymentLinks, you can add metadata[7] when you create PaymentIntent from your website.

[1] https://stripe.com/docs/payments/payment-links

[2] https://stripe.com/docs/payments/payment-intents

[3] https://stripe.com/docs/payments/checkout

[4] https://stripe.com/docs/payments/payment-links/api#tracking-payments

[5] https://stripe.com/docs/api/events/types#event_types-checkout.session.completed

[6] https://stripe.com/docs/api/events/types#event_types-payment_intent.succeeded

[7] https://stripe.com/docs/api/payment_intents/create#create_payment_intent-metadata

  • Related