#Miloszex

1 messages · Page 1 of 1 (latest)

red fossilBOT
fathom zealot
#

What do you mean by 'next subscription is fired'?

cold basin
#

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 ?

fathom zealot
#

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

cold basin
#

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?

fathom zealot
#

The sub_xxx would be the same yes. However the in_xxx would be unique for each period

cold basin
#

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

fathom zealot
#

What have you tried?

cold basin
#

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

fathom zealot
#

2 moments

cold basin
#

okay

fathom zealot
#

stripe trigger invoice.paid --override=invoice:subscription="sub_xyz" --remove=invoice:pending_invoice_items_behavior

#

That should work

cold basin
#

thanks I will test it out!

#

thank You again!

fathom zealot
#

np

cold basin
#

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"
}
}

Learn more about error codes and how to resolve them.

#

i copied subscription id from my database

#

(its test env)

#

wrong customer id?

fathom zealot
#

So you may need to pass an --override for that too

cold basin
#

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?

red fossilBOT
granite ledge
#

you can but it will just create a new Customer object and Invoice and so on

#

stripe trigger invoice.paid

cold basin
#

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?

granite ledge
#

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

cold basin
#

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)

granite ledge
#

then maybe make your own fixture

cold basin
#

Okay

#

thanks

granite ledge
#

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

cold basin
#

nice!

#

thanks!

#

it worked

#

thanks

#

again