#alexg_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/1286710305510129816
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const usageSubscriptions = await stripe.subscriptions.create({
customer: customerID,
items: [
{
price: usageTier.SEATS,
},
{
price: usageTier.DATABASE_ENTRIES,
},
{
price: usageTier.API_REQUESTS,
},
{
price: usageTier.BANDWIDTH,
},
{
price: usageTier.ASSET_STORAGE,
},
],
metadata: {
project_id: projectID,
project_slug: projectDetails.slug,
project_admin_link: `${config.ADMIN_URL}/admin/content/cloud_projects/${projectDetails.id}`,
project_hubspot_link: `https://app.hubspot.com/contacts/${config.HUBSPOT_DASHBOARD_ACCOUNT}/deal/${projectDetails.hubspot_deal_id}`,
},
...(subscription.trial_end && { trial_end: subscription.trial_end }),
});
here is where the usages subscription is created by the handler that fires on the checkout.session.completed webhook
Hi, if you've collected the payment method, Stripe would attach the payment method to the customer. However, it looks like you're talking about Stripe Checkout, https://docs.stripe.com/billing/quickstart with checkout.session.completed. However, the code you shared is using our direct API to create a subscription.
here is an example of a payment that failed as it has no payment method attached
Can you confirm which you're using?
so first the customer goes through a checkout -> base subscription is created
checkout.session.completed webhook fires
our api then catches the succesful webhook for the successful payment
We then create second subscription directly with the api that is attached to the same customer for which we record usage charges
ideally, what will then happen is that it attempts to use the customer's saved payment method to pay for that second subscription whenever they have accrued usages
So i have the customer's payment method on file
but i need to it be attached to this second subscription when it gets created
becuase what happens now is when they have a non-zero charge for usages the payment fails the first time and the customer has to go and manually enter their payment details again through the generated checkout in the stripe email
You can set the customer's invoice default payment method: https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method.