#jesus-estrada_subscriptions-usage-billing
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/1239668371667030077
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
tried :Stripe::Subscription.create({
customer: stripe_customer_id,
items: [{price: stripe_price_id}],
billing_cycle_anchor: (Time.now + 1.week).to_i,
proration_behavior: 'none'
}, stripe_request_config)
Hello, can you tell me more about what you mean by a daily subscription that is charged every seven days? Can you lay out how you would ideally like for that to be charged?
And do you have the ID of a subscription like this that has a trial when you don't expect it to?
for example, I created a daily price for 10USD. I don't want to charge the users once they purchase the subscription. I want to charge them after 7 days, in other words, I want to charge them for 70USD
every 7 days
I'm not creating trialing subscriptions for it
does it makes sense?
Gotcha. Unfortunately the cycles of our Prices cannot be broken up like that. If you define a daily price, that price can only be charged every day. So you will want to define this as a weekly price.
The only price configuration that we have that supports billing at the end of the cycle is usage-based billing. Everything else bills at the start of the month.
So, the way to get this behavior is to define a weekly usage-based billing price with a flat fee.
This doc lays out how to define that. You can define everything but the flat price as being $0 https://docs.stripe.com/billing/subscriptions/usage-based/pricing-models#fixed-fee-and-overage-model
I see. Thats a good call. Does this model support charging the user for x days if they cancel before the billing cycle is completed?
Unfortunately not, that was the caveat that I meant to bring up. Our metered billing flat fees do not support proration, so I think you'd need to calculate what that final charge should be and then charge your customer with an invoice for that amount.
I will add to our feature requests for billing at the end of a cycle and having a cycle length different than the price's cycle length. I definitely get how useful those features would be
Sounds good. This is very helpful. I'll reach out again in case I need more information after reading the docs and run some tests.
I created the subscription but the user was charges immediately
this is the request Stripe::Subscription.create({
customer: 'c_id',
items: [
{
price: 'p1_id',
quantity: 1,
},
{price: 'p2_id'},
],
}, stripe_request_config)
the params are the same mentioned in https://docs.stripe.com/billing/subscriptions/usage-based/pricing-models?dashboard-or-api=api#fixed-fee-and-overage-model
Can you send me the ID of that subscription adnt the prices that you pssed to it?
sub_1PG5WNCbKe5VvdH8C7gheTGT
Hi ๐
I'm stepping in as my colleague needs to go
Thanks for the ID, taking a look now
ty!
Okay so you provided a Customer and two prices. That means the Subscription defaults to automatically charging immediately if the Customer has a payment method.
What is the behavior you were looking for?
I'm looking for charging the user after 1 week, not immediately
Do you mean you want a free trial for 1 week? Or that you want to bill at the end of the billing cycle?
no, we don't want free trials, we only want to bill at the end of the billing cycle
Okay, the only way you can bill that way is to use usage-based billing prices
yes, that's what Pompey suggested, but when I create a subscription it is paid immediately
I followed these steps:
and this is the request I made
Stripe::Subscription.create({
customer: 'cus_Q2AtWBRwLqN8eZ',
items: [
{
price: 'price_1PC1qICbKe5VvdH8a0iO6hQL',
quantity: 1,
},
{price: 'price_1PG5TjCbKe5VvdH8OAo0wLSk'},
],
}, stripe_request_config)
both prices are weekly
The prices you provided are not. usage based so they bill immediately.
You did not create usage-based prices so you do not see that behavior
I created the steps in the URL I sent, using Stripe API. I created a new product and prices. The new subscription created was also paid immediatele sub_1PG6ASCbKe5VvdH8ge0oYYvE
The prices you created were not metered though
Stripe::Product.create({name: 'Alpaca AI tokens'}, stripe_request_config)
id created: price_1PG68HCbKe5VvdH8w09YfrJA
Stripe::Price.create({
product: 'prod_Q6Ijcyv0yhkYIV',
currency: 'usd',
unit_amount: 20000,
billing_scheme: 'per_unit',
recurring: {
usage_type: 'licensed',
interval: 'week',
},
}, stripe_request_config)
id created: price_1PG69PCbKe5VvdH8kfawvsqi
Stripe::Price.create({
product: 'prod_Q6Ijcyv0yhkYIV',
currency: 'usd',
billing_scheme: 'tiered',
recurring: {
usage_type: 'metered',
interval: 'week',
meter: 'mtr_test_61QNxJYWP4RG6rXc441CbKe5VvdH8DOa',
},
tiers_mode: 'volume',
tiers: [
{
up_to: 100000,
unit_amount_decimal: '0',
},
{
up_to: 'inf',
unit_amount_decimal: '0.1',
},
],
}, stripe_request_config)
Stripe::Subscription.create({
customer: 'cus_Q268Ir7AdKTM1w',
items: [
{
price: 'price_1PG68HCbKe5VvdH8w09YfrJA',
quantity: 1,
},
{price: 'price_1PG69PCbKe5VvdH8kfawvsqi'},
],
}, stripe_request_config)
I mean, I just did it again
If your prices are created for usage based billing, you also have to create usage records
This is different than a tiered price, those are not the same thing
You can not blend the two
I see
You would need to only create a Subscription for price_1PG69PCbKe5VvdH8kfawvsqi if you wanted to only bill at the end of the cycle
gotcha
And you would need to record usage of that price in order to determine the amount to bill: https://docs.stripe.com/billing/subscriptions/usage-based-legacy/pricing-models#metered
That makes sense. I'll run some other tests tomorrow because I need to hop off. Will reach out again in case I need something else. I appreciatte your help with it
Sure thing! It's why we're here.