#tymm
1 messages · Page 1 of 1 (latest)
hello! there're a couple of options :
- use
collection_method: send_invoiceAll 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 . - 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.
- 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.
thanks
taking a look at the request id you shared in the main channel
ok. also, "SUM20" is the id of a coupon i created in stripe portal
hmm, gimme a while to check
@mossy token did this start happening recently?
can you print out the params to see if it has the Discount inside, and if the Discount has the Coupon inside too?
hmmm it really is empty
{"discounts":[{}]}
im using fastjson to parse the InvoiceUpdateParams object
InvoiceUpdateParams.Discount.builder().setCoupon("SUM20").build() returns {}
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
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?
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
https://stripe.com/docs/billing/subscriptions/coupons?dashboard-or-api=api#set-eligible-products
When you make changes to a subscription, any existing discounts are applied when proration is calculated. You can’t discount proration line items further on the invoice that’s generated.
is there a workaround for this
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
u mean before creating the subscription?
sure, or before updating it in the way that resulted in that invoice
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
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
hmmmm, how do i forced that? i cant finalize it because user should be able to remove coupon/ change coupon etc
force what?
to generate new invoice right after i have added coupon to the subscription
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?
what about new subscriptions?
i would want to charge customers immediately for new subscriptions, and they can apply coupon in their order
then figure out what coupon is needed and pass that when creating the Subscription
is there something like the preview proration but for when creating subscriptions?
im considering changing our payment ui/ flow too if its not natively supported in stripe
you can use https://stripe.com/docs/api/invoices/upcoming to preview anything yes, like what a Subscription which doesn't exist yet might look like, and can use things like https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-discounts to preview what effect a coupon would have on a preview subscription
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
ok will try it out, thanks