#digital39999

1 messages ยท Page 1 of 1 (latest)

sinful jettyBOT
fervent canopy
#

๐Ÿ‘‹ happy to help

#

when are you adding the discount?

#

would you mind sharing the subscription ID?

golden turret
#

on checkout flow

#

i just canceled it, one sec

#

sub_1Nd8daJD5ALCvYmvEIerZtnq

#

does subscription go into active mode after coupon ends or

fervent canopy
#

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

golden turret
#

yes but isnt subscription created as inactive? and then switches mode to active

fervent canopy
#

no it will be created as trialing

#

sorry nvm!

#

why should it start inactive?

golden turret
#

if we create it manually

fervent canopy
#

if you added a 100% discount, the first invoice will be paid, and the subscription will be active

golden turret
#

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?

fervent canopy
#

for subscriptions, you should listen to invoice.paid

golden turret
#

and i should send some "warnings" on invoice.payment_failed and invoice.payment_action_required right?

golden turret
fervent canopy
#

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

golden turret
#

which

fervent canopy
#

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

#

in the case of subscription_create then it's a subscription

#

subscription_cycle then it's a new cycle

golden turret
fervent canopy
#

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

golden turret
#

so basically base events i need would be invoice.paid, customer.subscription.deleted and invoice.payment_failed

fervent canopy
#

yes

golden turret
#

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

fervent canopy
#

yes

golden turret
# fervent canopy 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

fervent canopy
golden turret
#

nice

#

in what all cases customer.subscription.updated wont be sent, except 100% discount

fervent canopy
#

I'm not sure I understand the question

golden turret
#

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:

fervent canopy
#

customer.subscription.updated event will only occur when you or your customer (via Customer billing portal for example) update the subscription

golden turret
#

but it occurs on normal checkout session end..?

fervent canopy
#

I think this only happens when there's a payment to be made

golden turret
#

hm