#Miloszex
1 messages · Page 1 of 1 (latest)
What do you mean by 'next subscription is fired'?
I mean I have subscription model and the first period of payment is no longer valid so stripe must charge my card with next payment and then it fires to my webhook that the charge is successfull right?
what event type is it?
checkout.session.completed ?
Sure, you'd receive a customer.subscription.updated event to reflect the current_period_* fields changing, and then an invoice.paid event assuming the recurring payment succeeds
great! invoice paid is that what I was looking for. One more question.
In the payload the invoice id and subscription id is constant? So I can find my last database record with this id and create new one based on last?
The sub_xxx would be the same yes. However the in_xxx would be unique for each period
I mean constant in scope of one customer subsription
okay so I must base it on sub_xxxx
thank You so much. I will try it
Can I fire this event somehow from stripe cli and override sub_xxx to test it out?
I mean i know how to fire events from stripe cli but overriding data is not working for me I think I may doing something wrong
Which event?
What have you tried?
I need to fire this event invoice.paid with overrided subscription_id.
I tried something like
stripe trigger invoice.paid --override "subscription:id=myvalue"
because i need to test somehow next subscription payment in my webhook
2 moments
okay
stripe trigger invoice.paid --override=invoice:subscription="sub_xyz" --remove=invoice:pending_invoice_items_behavior
That should work
np
hmm
Trigger failed: Request failed, status=400, body={
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "Customer cus_O07bKByGpWeXN9 does not have a subscription with ID sub_1NE6GbBRN2bdQixcZBJUUQQT",
"param": "subscription",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_bdsI6dVz5HQ1jr?t=1685609999",
"type": "invalid_request_error"
}
}
i copied subscription id from my database
(its test env)
wrong customer id?
Yeah, what happens is the fixture (https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/invoice.paid.json) generates a new Customer object
So you may need to pass an --override for that too
so do I need to add --overrid=customer:id="cus_xxx" ?
meh customer already exists I just need this invoice paid for customer but I will try to handle it
somehow
Can't I just fire invoice paid? without previous calls?
you can but it will just create a new Customer object and Invoice and so on
stripe trigger invoice.paid
hmm. Okay one more thing Can I copy this payload and fire it from postman or something else with mocked data? instead of using stripe cli? will it work? Or this payload have whole different structure than this stripe fires to webhook?
it's easier to use stripe-cli
you can curl to yourself if you want but then if you check the webhook signature, that won't be present, so you'd have to either remove that check in your code, or manually generate a signature
Yeah It would be perfect to use stripe cli but I want to use invoice paid call for existing customer and existing subscription and when I overrinding subscription id and customer_id it throws error that customer already exists. Because like You said it trying to create customer when I trigger it
And all I need is to fire event that says "Hey we charged your account with next subscription period everything is fine here is Your notification" (for existing data in my database)
then maybe make your own fixture
trigger just runs the API calls specified by that JSON, you can copy the JSON and edit it and set up a fixture that does not create a new customer for example(there's only so much you can do with override, but you can just create a new fixture entirely)
https://stripe.com/docs/cli/fixtures