Disable payment link after successful payment

300 views
Skip to first unread message

Efren Bravo

unread,
Mar 22, 2023, 6:10:47 PM3/22/23
to Stripe API Discussion
Hello,

I'm new to Stripe and have not been able to find an answer to this doubt.

Is it possible to disable payment links after successful payment?

Thanks in advance.

Remi J.

unread,
Mar 22, 2023, 6:17:48 PM3/22/23
to api-d...@lists.stripe.com
Hello,

A PaymentLink is usually used to collect payments for many different customers with just one link. For example you want to sell a book for $20 or a recurring subscription for $10/month, you configure your PaymentLink in the Dashboard or the API with various options and then you share that PaymentLink's URL with all your customers and they can each individually pay. Each time the URL is clicked, it creates a Checkout Session for that specific individual customer for them to pay.

For that reason, we don't really have a feature to make PaymentLinks "one time use" or limited to a specific customer. Usually, when you want to do something like this, you can write some code to create a Checkout Session for that specific customer and redirect them to the URL which is short lived (24 hours expiry by default).

Now, while we don't automate this, you can technically implement this with some code. The idea here would be to create a PaymentLink and share the URL with that specific Customer. When they click on it, a Checkout Session will be created for them to go through and pay. At some point, they will complete the payment and you will get a `checkout.session.completed` Event sent to your webhook endpoint for you to handle fulfillment [1]. At that point, you can check the Session's `payment_link` property [2] to see which PaymentLink it's associated with and you can then make that one inactive via the API [3]. This is not perfect though and it's possible someone else could have clicked the link between the two operations, but that should get you close enough.

Hope this helps!
Remi


--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Efren Bravo

unread,
Mar 23, 2023, 11:46:58 AM3/23/23
to Stripe API Discussion, re...@stripe.com
Thanks for such a detailed explanation. All clear to me.

Have a nice day!

Reply all
Reply to author
Forward
0 new messages