Jintor
Jintor

Reputation: 657

stripe api curl subscription how to add to cart and get status each month

The question is about stripe API on how to add it in cart and getting the status of a subscription ID....

I'm following https://stripe.com/docs/billing/subscriptions/examples

Scenario example:

• Create product, Update price -d "recurring[interval]"=month -d unit_amount=3569

• Client pays in cart

• I want to do a cron job to check each month if the subscription ID (production / price IDs) have been successfully charged and processed to update it in my database.

Notes; I integrated a regular normal charge, I do <form action="stripe_charge.php" method="post"... <input type="hidden" name="stripe-currency" .... etc... but I can't find the documentation for subscription...

--1-- but how to add the plan / subscription in the cart form ?

--2-- How the curl would look like to get the status each month ?

Thanks

Upvotes: 0

Views: 326

Answers (1)

Justin Michael
Justin Michael

Reputation: 6495

For your first question I'm not sure what the answer is, as I can't see your entire form or backend code, but I think Stripe's guide for creating fixed-price Subscriptions using Elements might help.

Regarding your second question, instead of a cron job that polls every month, you can set up a webhook endpoint that will receive Subscription-related events from Stripe as they happen.

If you want to avoid webhooks and poll instead (not recommended as it will use more resources and be less timely) you can list Events using the API.

Upvotes: 1

Related Questions