#phillip_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/1290976535238672406
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, let me help you with this.
Do you want to charge the customers periodically, right? For the same 90 EUR or the amount changes every month based on usage?
Hi Vanya, we want to always charge 90โฌ per month for the subscription, and we'd like to charge the ad budget weekly โ but separately from the subscription.
The reason is that even if the subscription is canceled, there might still be unpaid charges for the ad budget.
It seems like you need 2 Subscriptions per Customer, one monthly with fixed Price, and one weekly with usage-based amount. Does this sound right?
That could work, yes.
Is it possible to start both subscriptions at the same time? I'd like to avoid making the customer click multiple times or enter their information twice.
No, but you can reuse the PaymentMethod object for the other Subscription.
Or collect the PaymentMethod with SetupIntent first, and then create both Subscriptions simultaneously with it: https://stripe.com/docs/payments/save-and-reuse
I think I'm already creating a setup intent and saving the payment method.
const { error, setupIntent } = await stripe.value!.confirmSetup({
// @ts-ignore
elements: elements.value,
// @ts-ignore
redirect: 'if_required'
})
// @ts-ignore
const paymentMethod = setupIntent?.payment_method || null
Then I create a subscription like this.
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [
{
price,
},
],
trial_period_days: trialPeriodDays,
default_payment_method: paymentMethod,
coupon: couponId,
collection_method: "charge_automatically"
});
Question: Basically I would now create another subscription with the same payment method information. Correct?
What other parameters would I need to pass for the ad budget subscription?
Do I still need to pass collection_method: "charge_automatically" for the ad budget subscription?
Yes.
Yes.
For the ad budget you can use usage-based billing if you want to record the usage in Stripe: https://docs.stripe.com/billing/subscriptions/usage-based
You will need to create a specifically configured Price for this and then record usage events.
Okay thanks @open jetty . Just a couple last questions because I've never implemented usage billing.
- I would create a product (subscription) inside the Stripe dashboard and choose "Usage-based" for pricing model and select "Per unit" โ correct?
- I'll set the amount to 0โฌ โ correct?
- I'll set the billing method to weekly and create a new meter which I call "Ad Budget". I assign the meter "Ad Budget" to the subscription โ correct?
- Then, every day/week I'll update the usage via API depending on the ad budget that the user spent
You need to create a Product and Price objects, as well as a Meter. I recommend you to follow the guide carefully, as it contains all the answers: https://docs.stripe.com/billing/subscriptions/usage-based/implementation-guide?dashboard-or-api=dashboard
- The amount must be a price per unit, i.e. it can be 1 EUR per unit if your standard usage unit is 1 EUR. Then you set the number of units for this period based on the usage.
I.e. a unit of ad budget must be EUR, right?
Same as unit of cloud storage is a GB, for example. Then you would set the amount to the price of a GB.
Alternatively, you can assume that your unit is one cent, then it's amount is 0.01 EUR, if you want more precise values.
But otherwise, looks correct.
Thank you very much @open jetty ๐ I think I have all the information that I need for now. I appreciate your time