#phillip_code

1 messages ยท Page 1 of 1 (latest)

frozen rockBOT
#

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

open jetty
#

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?

summer crown
#

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.

open jetty
#

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?

summer crown
#

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.

open jetty
#

No, but you can reuse the PaymentMethod object for the other Subscription.

summer crown
#

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?

open jetty
#

Yes.
Yes.

#

You will need to create a specifically configured Price for this and then record usage events.

summer crown
#

Okay thanks @open jetty . Just a couple last questions because I've never implemented usage billing.

  1. I would create a product (subscription) inside the Stripe dashboard and choose "Usage-based" for pricing model and select "Per unit" โ€“ correct?
  2. I'll set the amount to 0โ‚ฌ โ€“ correct?
  3. 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?
  4. Then, every day/week I'll update the usage via API depending on the ad budget that the user spent
open jetty
#
  1. 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.

summer crown
#

Thank you very much @open jetty ๐Ÿ™ I think I have all the information that I need for now. I appreciate your time