#yassinec_subscription-pendingupdate
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1286362049311408128
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
yassinec_subscription-pendingupdate
@fossil hazel that's expected. The Invoice will alwas be finalized immediately and attempted to be paid. And if the payment fails or requires 3DS for example it goes into "pending"
You can't just do this and then hope to change the Invoice after the fact, that won't work
Oh no ๐ฆ
Is there no way to apply a coupon on subscription update only?
Say I created a 200 USD / year subscription, and one month later customer makes an upgrade for the remainder of the year costing 50 USD
Why aren't you passing the Coupon during the update?
Because of this behavior (error message from the Stripe API)
When payment_behavior is set to pending_if_incomplete, you can only pass supported params. discounts is not supported. See https://stripe.com/docs/billing/subscriptions/pending-updates-reference#supported-attributes for more details.
ah my bad. Then yeah looks like you just can't do this. My advice is to not use the pending updates approach at all in that case (it's not a great feature if you ask me)
I use it so that if payment fails, the subscription updates are not applied
Would there be another way of charging the customer for an upgrade, and updating the subscription on payment success?
no that's the only way. Sadly it doesn't support your use-case I'm sorry
It's weird because I can do that on the dashboard
subscription update with immediate proration and ad-hoc coupon applied
yes but not with pending updates which you are explicitly trying to use
If you don't use pending updates then it works totally fine in the API too
ok I get it regarding pending updates
so what can I do in general to avoid updating the subscription if payment of an invoice with coupon fails?
as pending updates do not work
There's nothing you can do I'm sorry. We don't support such a flow. The only way is to update, and then get the customer to pay you and if they don't update again back to what it was before
that's exactly what the Dashboard UI does offer
that's tragic ๐
Do you know if I can from the UI attach a one-time coupon to an active subscription for the next automatic renewal?
I am trying to provide alternatives to my customers
yes you can do that easily both in code and the Dashboard. If you have questions about the Dashboard, I recommend contacting our support team at https://support.stripe.com/contact
OK
Thanks for the help man
One last thought
I guess I can create one-off invoices to upgrade a subscription, and apply a discount on them?
you can but it'll mess up your reporting, so I wouldn't do that
I have to run but my colleague is taking over if you have more questions!
Thank you ๐
๐ let me know if I can help any further
Hello bismarck
Can you clarify koopajah's point about one-off invoices messing up reporting?
Sure, let me catch up on the context
OK
I basically want to apply a coupon on a subscription update with pending update
But that's not supported by Stripe's API
pending updates = no coupons
Gotcha so you are considering creating a one-off Invoice and if they pay that successfully then updating the Subscription with a coupon?
Are these updates for Prices with the same interval?
Like both monthly?
What is the update that is occurring exactly?
More like updating the subscription, applying a discount but sending the invoice to the customer for payment
Could be a switch from monthly to yearly
Okay let's back up a second.
Can you give me an exact scenario of what you are trying to accomplish?
Like what is your ideal world? What problem or scenario are you trying to solve for here?
A customer has an active subscription, they want to:
- add an item to it
- or switch from monthly to yearly (pay the remaining 11 months)
- or both
They should be prorated immediately
And ideally they should be able to apply a coupon on the proration charge
And your concern here is that you only want to perform this update on successful payment?
Problem I solve for: customer upgrades subscription in app and want to use a promo code to pay less for that upgrade, and if the payment fails because of whatever the subscription is not updated
Gotcha, have you tried adding a negative Invoice Item to represent the discount instead of using a coupon?
I think this will work with Pending Updates
As that newly created Invoice should still pick up the Invoice Item
But I haven't tested this exact scenario myself
So you'll want to test it out
Interesting
I would lose on automatic discount computation though
If I use a percentage discount
no?
You would need to perform that calculation yourself, yes.
But that shouldn't be hard really
You can preview the upcoming Invoice to get the proration amount
So I could get the upcoming invoice, update its items, see the proration amount?
You can use https://docs.stripe.com/api/invoices/create_preview to simulate the upgrade and proration and get the exact amount
Then create an Invoice Item for that negative amount that corresponds with the discount
Yeah give it a test and see if it works -- like I said I'm not positive how this negative Invoice Item will interact with Pending Updates
I think it should work though
You may actually be able to do this all in one request by just doing add_invoice_items here in your update Sub request: https://docs.stripe.com/api/subscriptions/update#update_subscription-add_invoice_items
Ah wait no
That only allows for positive Invoice Items
So you do need to create it separately I believe
๐
there is no createPreview method, is it available in recent SDK versions only?
Hello! I'm taking over and catching up...
hello
Yeah, it's a more recent addition. What SDK are you using?
Java SDK 20.106.0
A really old one I think
I think I can upgrade if there are no breaking changes
Looks like it was added in 25.3.0: https://github.com/stripe/stripe-java/blob/master/CHANGELOG.md#2530---2024-04-18
There are breaking changes between that version and yours.