#waqas-ahmad_code
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/1288759263472390214
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- waqas-ahmad_api, 5 days ago, 18 messages
To Update a Subscription, you want to call Update Subscription API, not the Billing Portal API as the example code you provided
But my subscribtion amount is not fixed. It dpends how manay users are there in group. If usser increase or decrease memeber then subscription update according to member.
This is my configuration for porteal. const configuration =
await this.stripe.billingPortal.configurations.create({
business_profile: {
headline:
'Test partners with Stripe for simplified billing.',
},
features: {
invoice_history: {
enabled: true,
},
payment_method_update: { enabled: true },
subscription_update: {
proration_behavior: 'create_prorations',
enabled: true,
default_allowed_updates: ['price'],
products: [
{
prices: [data.priceId],
product: productId,
},
],
},
},
});
This is my session creation code:
const session = await this.stripe.billingPortal.sessions.create({
customer: customerId,
return_url: process.env[ENV_KEYS.STRIPE_SUCCESS_URL],
flow_data: {
type: 'subscription_update_confirm',
subscription_update_confirm: {
items: [
{
id: subscriptionItemId,
price: data.priceId,
quantity: numberOfDealers,
},
],
subscription: subscriptionId,
},
},
configuration: configuration.id,
});
You only use Billing Portal if you want to let your customer update their Subscription. Could you confirm that is what you are trying to do?
Yes
To create subscription I use checkout sessions.
Actually, when the user creates a subscription. I pass members of groupId in metadata. So it will return on webhook. I will update the status in my database using that ID. Now, the user updates the subscription, adding one more member to the group. I want to update the subscription metadata. How can I pass updated metadata to Stripe?
When customer updated your Subscription via Billing Portal, you will receive a customer.subscription.updated webhook event. You can then update the Metadata from there
But many users update subscription at a time. How system remember which user update subscription or not. Maybe user close portal link.
Each webhook event should have the corresponding Subscription Id and the Customer Id, wouldn't it be good enough for identify them?
I would just recommend the code from this repo:
https://github.com/fb-sean/stripe-ws/blob/ca0fa6c0e17127874ee89e421d0d79e8dbb543b9/src/STRIPE/helper.js#L67