I am using Stripe
as a payment gateway. Now there\'s a big problem bothers me.
I used code below to create a subscription:
This is exactly what Stripe's webhooks are for. After creating a customer with an initial subscription, you'll get six webhook notifications:
customer.created
, with the customer data (which you already have if you're saving what the API returns)charge.succeeded
(or charge.failed
), which contains the initial charge data you're looking forinvoice.created
, which is the associated invoiceinvoice.payment_succeeded
(or invoice.payment_failed
), also telling you the status of the chargecustomer.card.created
, with the details of the new cardcustomer.subscription.created
, with the details of the customer's subscription.Stripe's API, like many APIs and many payment solutions, is built to be used with webhooks. If you're not taking advantage of webhooks, you're going to be missing functionality, and you're probably working too hard for what can be done without webhooks.
Stripe works to deliver the data to you. If you're writing code to poll Stripe, you're working way, way too hard.