#mathieu-ducrot_api

1 messages ยท Page 1 of 1 (latest)

gritty sigilBOT
#

๐Ÿ‘‹ 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/1356264314964541602

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

sudden fractal
#

For info this is what my flow_data looks like :
$flowData = [
'type' => 'subscription_update_confirm',
'subscription_update_confirm' => [
'subscription' => $workspace->getSubscriptionId(),
'items' => [
[
'id' => 'si_S2knlk2oiRNQiP',
'quantity' => 1,
'price' => $this->getPriceId('power_monthly'),
],
[
'id' => null,
'quantity' => 2,
'price' => $this->getPriceId('professional_monthly'),
],
],
],
];

and so i'm getting the following error :
You passed an empty string for 'flow_data[subscription_update_confirm][items][1][id]'. We assume empty values are an attempt to unset a parameter; however 'flow_data[subscription_update_confirm][items][1][id]' cannot be unset. You should remove 'flow_data[subscription_update_confirm][items][1][id]' from your request or supply a non-empty value.

So i feel like my scenario doesn't seems to be possible with the subscription_update_confirm flow, but still asking to know if i'm missing something

west abyss
#

Hi, what does 'but it seems it doesn't work as close as the subscription update direct api as i cant pass an item without an id' mean exactly?

The request you shared above states that you're passing null on 'flow_data[subscription_update_confirm][items][1][id] but you can't do that.

sudden fractal
#

yeah it was a test but if i don't pass the id param is won't work either with the error "Missing required param"

my previous statement is about that when dealing directly with subscription using full API (and not using billing portal flow subscription_update_confirm like i'm trying here) i remember that this is how you are suppose to do for adding an item.

but here (billing portal flow subscription_update_confirm) i have a feeling this can't be achieve and you can only edit existing items (not remove or add items)
is that correct ?

west abyss
sudden fractal
#

can i instead init the subscription with the 3 product the customer can have but set there quantity to 0 if they don't take them ?
that way i could have all the items to be used with the flow mode
i find it is less weird for the customer to have a quantity with 0 than using coupon

gritty sigilBOT
west abyss
#

Hmm, you can try but I did not think you can change the quantity to 0.

sudden fractal
#

gonna try

Just letting you know that it would be really cool if the billing portal subscription_update feature could handle multiple product quantity/price update in addition to one product switching scenarios

#

arf indeed i cant pass a quantity to 0 when using the flow subscription_update_confirm
req_spaBpsKJpsaEtN https://dashboard.stripe.com/test/workbench/logs/req_spaBpsKJpsaEtN
"This value must be greater than or equal to 1."

so i guess that my use case is too advanced to update subscription with the billing portal when dealing with multiple items/product

west abyss
#

Yeap, I did not think it would work.

sudden fractal
#

as i understand from the documentation, the same goes for using checkout on such use case ?
i probably need to stick with subscription items direct API

west abyss
#

Checkout Session is used for creating the subscription and you use Customer Portal to manage it.

#

You can't pass a 0 qantity when you create it

#

With the API directly, you'll have more control yes

sudden fractal
#

is it possible then to use the api to update subscription items and to generate a payment link/invoice payment link or some sort based on the changes made by the API which we can redirect the customer for payment ?

raw radish
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away. Yes, if you perform the update in such a way that prorations are immediately calculated and an Invoice is generated to charge for them, then you can use the Hosted Invoice Page link returned in that Invoice object to direct your customers to a Stripe hosted page for paying that invoice. That link is stored in the hosted_invoice_url field:
https://docs.stripe.com/api/invoices/object#invoice_object-hosted_invoice_url

sudden fractal
#

ok sounds like what i need
and is there some best practices about managing those "opened" invoice that could potentially stay in that state if the user don't confirm (for like multiple back and forth situation) ?

raw radish
#

Is there something in particular you want to happen at some point during the situation you described?

sudden fractal
#

i don't know* if those unpaid invoice can be seens on the billing portal invoice history ?
maybe delete them after like 7 days if they didn't to anything on it ?
is that a problem in the first place or is it ok if we don't do anything on them ?

raw radish
#

I'd suggest using Test Clocks to step through these flows and determine what behavior you want to suit your business needs:
https://docs.stripe.com/billing/testing/test-clocks

If you want the update to be rolled back if the payment isn't paid in a given amount of time, I'd suggest exploring our Pending Updates behavior:
https://docs.stripe.com/billing/subscriptions/pending-updates

I believe unpaid Invoices are visible in the Billing Portal, but I'd need to test to be sure and the server is very busy at the moment, so it would be a while before I can test that. If you want to void the Invoice, you can use this endpoint:
https://docs.stripe.com/api/invoices/void

sudden fractal
#

thanks @raw radish for those docs, gonna look at it and do some testing

raw radish
#

Any time!

sudden fractal
#

still you guys did an awesome job on the billing portal
do you have any insight as if it will possible on the future to handle multiple items for multiple product on a subscription on it ?

raw radish
#

Sorry, I don't have that insight, but I can definitely file feedback with our teams indicating this is something you'd be interested in seeing offered in the future.

sudden fractal
#

completely, such thing will decrease the complexity of our integration and give more control for our customer on their subscription directly on stripe
you can count me in on that subject to test it as soon as you have a preview, and will give you feedback