#r3v3rb
1 messages · Page 1 of 1 (latest)
Hi there. Taking over for bismarck as they have to step out soon. Are you referring to a stripe api response object that you want to mock?
Indeed, I was hoping to use the CLI so that the webhook would fire but I'm told it should be a mock object
\o/
Skimming the previous thread it's because you want to keep the same id
So yeah mock is the way to go
Basically just run through the flow once and copy and paste the response object (modifying other fields as you see fit)
Any document showing this for checkout.session.complete objects?
No it's a bit of an uncommon ask, so there's no support article
What part is still unclear? I can get more specific if need be
Okay, firstly where does the mock object get called/created because I'm hoping to fire off a webhook with the data
It would have to all be done through your end, not Stripe. Code on your end would generate the mock response object then hit your endpoint with it.
okay so create a new controller, create an object with the session id and then hit the webhook with that data?
Seems like it would be much easier if the API/CLI could handle being passed a session id/customer id etc and fire the trigger accordingly
stripe trigger checkout.session.completed --session-id=ca_&^^& for example
Yeah it's just currently not possible
You can write in to support to feature request it
But no guarantees if it would be implemented
🙂 always happy to be outside the box!
Reason being is the subscriptions we are offering are to clients who have accounts already on our solution - so this is an extra for them to use. So the whole process of Stripe creating customers/then us creating customers on our end to match via webhook is back to front
we already have a customer, but need to use the session_id to get the customer details in the checkout.session.completed by that ID to apply their subscription status
That all makes sense. Is the reason you need to generate an event with the same checkout session each time for automated testing purposes? Just curious why your testing flow needs the same id each time
yep, otherwise I'm in the browser checking out and waiting for the webhook to fire for each event
to ensure I'm getting the same customer(my side) that subscribed/checked out (your id)
Fair enough
Yeah mocking is what you'll need. For automated testing flows, that makes the most sense
only for this testing as there are at least five webhooks to process
I guess this needs to change too for testing: $event = Webhook::constructEvent( $payload, $sig_header, $endpoint_secret );
where payload is my mock data from a previous manual call stored locally
Correct yeah you wouldn't make that call in a test scenario with a mock
so I could just grab the $event data and have that as the mock object then?
Yep
It should mostly just be copy paste
I'm guessing you don't have a postman to handle this either then?
Take the existing event data and change any params you want
No postman collection unfortunately
:/ bah! What's going on even PayPal have that...
I shall leave this discord now for being rude
please accept my utmost apologies
I didn't think you were being rude
No apologies necessary
Wait just to clarify what do you want from postman? If it's just a collection with all our api endpoints we might have that
Like we have this: https://github.com/stripe/stripe-postman. Is that what you're looking fo?
or this one for https://www.postman.com/zarciti/workspace/payments-service/request/10263243-7f0c38fd-b266-41b7-86f5-a6a932c2b9b6
but yes Postman service