#Luiz Azevedo
1 messages · Page 1 of 1 (latest)
Have you tried the portal configuration here https://stripe.com/docs/api/customer_portal/configurations/create#create_portal_configuration-features-subscription_update-default_allowed_updates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Specify to only allow quantity
You can have 1 Portal configuration for 1 Portal session
Hello @unique cypress Orakaro,
I did this and created specific settings per session.
If the customer has a subscription with a monthly plan, when I use this configuration to create a new session with flow data, it works the way I want for cases where the customer can change the monthly plan to an annual one or the amount of the monthly plan.
{
"id": "bpc_1NTEz6Bb2P8uShrMtZfIKO2K",
"object": "billing_portal.configuration",
"active": true,
"application": null,
"business_profile": {
"headline": null,
"privacy_policy_url": "https://example.com/privacy",
"terms_of_service_url": "https://example.com/terms"
},
"created": 1689214224,
"default_return_url": null,
"features": {
"customer_update": {
"allowed_updates": [
"email",
"tax_id"
],
"enabled": true
},
"invoice_history": {
"enabled": true
},
"payment_method_update": {
"enabled": true
},
"subscription_cancel": {
"cancellation_reason": {
"enabled": false,
"options": [
"too_expensive",
"missing_features",
"switched_service",
"unused",
"other"
]
},
"enabled": false,
"mode": "at_period_end",
"proration_behavior": "none"
},
"subscription_pause": {
"enabled": false
},
"subscription_update": {
"default_allowed_updates": [
"quantity",
"price"
],
"enabled": true,
"products": [
{
"prices": [
"price_1NIH0oBb2P8uShrM2uAgCocP", //annual
"price_1NIH0oBb2P8uShrMserzYIMO". // monthly
],
"product": "prod_O4Pq1ZIXzR0blg"
}
],
"proration_behavior": "none"
}
},
.....
}
But if the customer has a subscription with the annual plan and I use the following configuration...I get an error...
{
"id": "bpc_1NTEs9Bb2P8uShrMbC5fqKqq",
"object": "billing_portal.configuration",
"active": true,
"application": null,
"business_profile": {
"headline": null,
"privacy_policy_url": "https://example.com/privacy",
"terms_of_service_url": "https://example.com/terms"
},
"created": 1689213793,
"default_return_url": null,
"features": {
"customer_update": {
"allowed_updates": [
"email",
"tax_id"
],
"enabled": true
},
"invoice_history": {
"enabled": true
},
"payment_method_update": {
"enabled": true
},
"subscription_cancel": {
"cancellation_reason": {
"enabled": false,
"options": [
"too_expensive",
"missing_features",
"switched_service",
"unused",
"other"
]
},
"enabled": false,
"mode": "at_period_end",
"proration_behavior": "none"
},
"subscription_pause": {
"enabled": false
},
"subscription_update": {
"default_allowed_updates": [
"quantity",
"price"
],
"enabled": true,
"products": [
{
"prices": [
"price_1NIH0oBb2P8uShrM2uAgCocP" // annual
],
"product": "prod_O4Pq1ZIXzR0blg"
}
],
"proration_behavior": "none"
}
},
.....
}
Error:
{
"error": {
"message": "This PortalSession cannot update subscription sub_1NT96FBb2P8uShrMdUKhgAtm because the configuration bpc_1NTEs9Bb2P8uShrMbC5fqKqq does not have any valid prices to switch to in its features[subscription_update][products]. This can be because there are no prices with a matching currency or tax behavior.",
"request_log_url": "xxxxx",
"type": "invalid_request_error"
}
}
and the most interesting thing is that if I create the session without the flow data with this configuration it works perfectly.
Wait, it errored on creating Portal Configuration, so what configuration you used to create the Session?
Re: error I think it doesn't let you to switch to the same price. It expects to switch from priceA to price B for example
That, and I understand. But the error only occurs when flow.data is used in the session.
But if we create the session without the flow.data, using only the configuration the error does not occur and it works.
In summary....
I believe that to solve my problem I will have to do the following:
Case one: Subscription with annual plan -
Create a session without flow.data with the configuration that only allows changing the amount of the current plan.
Case two: Subscription with monthly plan -
Create a session with flow.data with the configuration that allows changing both the amount of the current plan and switching to the annual plan.
The problem with this is that I will have different screens from the stripe.
One that will present the screen with the invoices and a button to update the plan.
One that will show the plan upgrade screen and then redirect.
I'll need a while to go through the issue, will get back to you in a bit
@fallen ocean - tks.
I speak here from Brazil, so right now I'm going to sleep. But tomorrow morning I will return to activities.
Thanks in advance for the support @unique cypress and @fallen ocean
sorry, I don't really quite understand what you mean by using flow.data . Like what orakaro mentioned, if your customer has an annual plan, it kinda makes sense that you can't update the subscription with that bpc - your bpc only has the same annual plan price to update the Subscription with.