#robotuner
1 messages ยท Page 1 of 1 (latest)
Hello
hi
You get the webhook secret from your Dashboard when viewing the endpoint you created
At the top you will see a little field for Signing secret with a reveal button below it
In terms of the client_reference_id, this will show up in the checkout.session.completed Events object body: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-client_reference_id
found it. Thanks
๐
Thanks for the link. It raises a question about what I need to be looking for from the webhook. The pattern that I was thinking about implementing was to manage access to the my service by looking at payment Succeeded, Failed and Canceled events. I was thinking that with each month there would be another notification to the webhook that I could use to manage the state of access to the service. If the Client_reference_id is only returned on a checkout.session.completed event how do I use that to determine access to my service?
If you are providing a Subscription service then yeah you are going to want to handle it a bit differently.
So yeah you would only really use the checkout.session.completed Event for the initial starting of the Subscription. At that point, you likely want to copy down the client_reference_id to the Subscription or the Customer object as metadata.
Then for renewals you want to listen for customer.subscription.updated
And you check the status of the Subscription
That event will fire each time the Subscription renews.
It seems my design pattern is incorrect.
I notice that Checkout session object contains an expandable object for customer. the Doc also says the ID of the customer for this Session. Does that mean next month the same customer will generate another checkout session object but will have a different ID? Assuming that is not the case, is the correct pattern for the webhook to
- Wait for checkout session object.
- Look at it to determine if the mode is subscription, then inspect the status to ensure it is complete, then look if the payment_status to paid before allowing access to the service.
- Once I know this is a paying subscription, then I need to retrieve the customer based on the customer ID which I hope will be the same next month, and add the client_reference_id to the customers Metadata.
- Having completed that, can I expect that next month, when a new checkout session object is created, it will include the Client_reference_id that is extracted from the customer? Or will I need to look at the customer metadata for the client_reference_id if Client_reference_id is blank.
If this is the pattern, it seems the webhook is really only interested in one event to determine access to my service.
๐ hopping in here since bismarck had to head out
give me a minute to catch up
A checkout session object is only created when the subscription is first created - you would'nt get it again the next month when it comes time to renew
Is steps 1,2,and 3 correct? If I add the client_reference_id to the customers metadata. In a month when the customer is pays the monthly fee, will it then generate a payment intent Object? Does my webhook look for payment_intent.Succeeded, Failed or Canceled then extract the customers metadata to find the client_reference_id? Is this the basic pattern for subscriptions?
Yes when a subscription renews it'll generate a new payment intent (that's how they'd pay for the monthly fee). And yes, you can listen for the payment_intent.* events and retrieve the customer from there to get the client reference ID
There isn't really a "basic pattern" for subscrpitions - there's a lot of variation in what events you can listen to depending on what you need the event for
We have some general guidance at https://stripe.com/docs/billing/subscriptions/webhooks which I'd suggest reading if you haven't seen it yet