#tymm

1 messages · Page 1 of 1 (latest)

dim crestBOT
timber pawn
#

hello! there're a couple of options :

  1. use collection_method: send_invoice All invoices created for subscriptions where collection_method: send_invoice will still have a one hour period after they have been created during which they can be updated .
  2. Create the subscription with trial_end set a couple of seconds into the future. The subscription will first generate a $0 invoice, and once the trial is over a non-zero invoice will be created with a one hour draft period. The initial status of this subscription will be trialing and will transition to either active or past_due depending on the payment outcome.
  3. Create the subscription through a subscription schedule. When the schedule starts, the subscription’s initial status will be active with an initial draft invoice that is scheduled to finalize in an hour. Depending on whether payment of the initial invoice is successful or not, the subscription will either stay active or transition to past_due.
mossy token
#

thanks

timber pawn
#

taking a look at the request id you shared in the main channel

mossy token
#

ok. also, "SUM20" is the id of a coupon i created in stripe portal

timber pawn
#

hmm, gimme a while to check

timber pawn
#

@mossy token did this start happening recently?

mossy token
#

i was trying to implement it

#

not something that ive done previously

timber pawn
#

can you print out the params to see if it has the Discount inside, and if the Discount has the Coupon inside too?

mossy token
#

hmmm it really is empty

#

{"discounts":[{}]}

#

im using fastjson to parse the InvoiceUpdateParams object

#

InvoiceUpdateParams.Discount.builder().setCoupon("SUM20").build() returns {}

timber pawn
#

hmmm

#

actually should it be getCoupon instead?

mossy token
#

not an option

#

i think i've found the problem, its the problem with my code, the coupon code passed into it was being overridden.... surprisingly stripe api didnt complain about the null value, haha

timber pawn
#

oh 🤦‍♂️

#

glad that you figured it out anyway!

mossy token
#

sorry about it and thanks 😅

#

req_HblmUv43M1p8xQ
this is the request that ive made and i can see that the coupon code is attached, but the total amount and total_discount_amount are not updated, what am i missing?

viscid axle
#

I believe because the only item on that invoice is for proration and you can't discount proration items

#

that's why it has discountable:false

mossy token
#

is there a workaround for this

viscid axle
#

apply the coupon to the subscription before you update it

#

or I think you can add a line item to the invoice for a negative amount to effectively discount it

mossy token
viscid axle
#

sure, or before updating it in the way that resulted in that invoice

mossy token
#

oh? i have tried to update the subscription before, hmmm, let me try again

#

i have updated the subscription with the coupon in this request: req_GqXxZGd6AmiO3G
what should i do now to get the updated invoice? i have tried subscription.getLatestInvoice() but the content does not have any discounts in it

viscid axle
#

because the latest invoice is probably still the one from whenever the subscription was last created/updated

#

when something happens that causes a new invoice(like the next billing cycle, or certain updates that change the plan and cause proration), the coupon now associated with the subscription will apply to that

mossy token
#

hmmmm, how do i forced that? i cant finalize it because user should be able to remove coupon/ change coupon etc

viscid axle
#

force what?

mossy token
#

to generate new invoice right after i have added coupon to the subscription

viscid axle
#

an invoice for what exactly? I don't understand the overall use case

#

let's say you have a subscription, created Jan 1st. On Jan 17th you make that API call to update a coupon. The next invoice on Feb 1st will have a discount now.
what would you want instead?

mossy token
#

what about new subscriptions?

#

i would want to charge customers immediately for new subscriptions, and they can apply coupon in their order

viscid axle
#

then figure out what coupon is needed and pass that when creating the Subscription

mossy token
#

is there something like the preview proration but for when creating subscriptions?

mossy token
viscid axle
#

if what you're trying to do is create the subscription and then update a coupon while it's in the incomplete status, that won't work, the initial invoice is already finalized and can't be changed. You need to have everything ready at the time you create the sub