#digital39999
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
when are you adding the discount?
would you mind sharing the subscription ID?
on checkout flow
i just canceled it, one sec
sub_1Nd8daJD5ALCvYmvEIerZtnq
does subscription go into active mode after coupon ends or
in that case no you wouldn't get a customer.subscription.updated event but rather just the customer.subscription.created one since upon checkout the subscription will be created with the coupon
instead of being applied after being created
yes but isnt subscription created as inactive? and then switches mode to active
if we create it manually
if you added a 100% discount, the first invoice will be paid, and the subscription will be active
ah
hmm, it was headache setting up webhooks, im using checkout.session.completed to check only for one time payments, and customer.subscription.updated for subs
so ig i would have to add a check into checkout.session.completed for "mode" field, and then fetch subscription?
for subscriptions, you should listen to invoice.paid
as explained here https://stripe.com/docs/billing/subscriptions/webhooks
and i should send some "warnings" on invoice.payment_failed and invoice.payment_action_required right?
one time payments wont trigger that event or?
unless you're using one-off invoices no they shouldn't
and in all cases even if you decide at one point to use one-off invoices, you can always look at 2 things in the invoice.paid event to sort which type of invoices this is
which
the first thing is invoice.subscription if you have an ID there, then it must be a invoice created by a subscription
and the second thing is the invoice.billing_reason
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
in the case of subscription_create then it's a subscription
subscription_cycle then it's a new cycle
so just last q, when i add invoice.paid, should i leave that first if statement too
or subscription_update this means that some updates have been made to the subscription
no need because you can use the billing_reason of the subscription to know which type of invoices this is
you can always retrieve the subscription and check its status but it's really up to you to decide which params are important to you for each event
so basically base events i need would be invoice.paid, customer.subscription.deleted and invoice.payment_failed
yes
good, thanks
when subscription is canceled, we get customer.subscription.deleted, now if cancel_at_period_end is true, will we get same event once subscription actually ends with that propertly being false
yes
can we somehow see from that invoice if 100% code was used, or do i just map items and compare to 0 lol
or amount_due
you can look at the https://stripe.com/docs/api/invoices/object#invoice_object-discounts field
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
or the https://stripe.com/docs/api/invoices/object#invoice_object-total field if you don't care why it's 0
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
nice
in what all cases customer.subscription.updated wont be sent, except 100% discount
I'm not sure I understand the question
when we apply 100% discount, customer.subscription.updated isnt sent, when all can that happen , because if we create normal subscription with session, that event gets fired and those properties change:
customer.subscription.updated event will only occur when you or your customer (via Customer billing portal for example) update the subscription
I think this only happens when there's a payment to be made
hm