#atlastdb-metered-subs

1 messages · Page 1 of 1 (latest)

zenith folioBOT
worthy egret
#

Hello! Do you have a specific request ID that's failing that I can take a look at?

wooden vapor
#

Hi @worthy egret pleasure to get in touch with you

#

So The Specific scenario is im trying to upgrade a free Subscription to a pain one, with proration. Specifically im trying to retreive a future invoice, with the new subscription so i can calculate proration. But one of two things happens:

1 If it succeeds, I get back the new subscription, but its either giving me the full price, or ammount_due is 000.

#

Would it be recommended/safe to post the subscription ID of the subscription im trying to update? Its all in test mode anyway

worthy egret
#

Yup you can post the subscription ID here

wooden vapor
#

Okay here is the subscription ID: sub_1OUMRJKbZEfvkbKuGvnGekHf

#

Previously i had 4 different products set up (free, standard, business, and enterprise)

While trouble shooting last night, I ran into a quote in the docs that said in order to update subscription with proration I cannot change to a new Product with a different billing pattern. So I archived the 4 products and created one product "Z'Search Monlthy Usage based billing" which includes the 4 price tiers (free, standard, business, and enterprise). But eve after trying that out, retreiveInvoice still give me the error of "Cannot upgrade subscription to new price with different billing patterns

worthy egret
#

The Subscription you shared doesn't have an update request tied to it - was that intentional? I was hoping to see an example subscription that's showing the behavior you don't want

#

Also quick question - you mentioned you were doing usage-based billing

#

Do you want payment to be charged at the start of the month, or at the end of the month?

wooden vapor
#

Okay heres the actual payload im sending to retreiveInvoice and the error

Invoice Params: { customer: 'cus_PId4gXFiNa9OcM', subscription: 'sub_1OU1oiKbZEfvkbKuEKGtboKX', subscription_items: [ { id: 'si_PIyOVbyCZ48wl2', price: 'price_1OULapKbZEfvkbKu4ZQbCCiO', quantity: 1 } ], subscription_proration_date: 1704230312 }

Error Message: Cannot update plans with different usage types. The plan for the subscription item with the ID si_PIyOVbyCZ48wl2 is of usage type licensed, and you are trying to update to metered.

wooden vapor
#

I guess part of my question is If I'm even thinking on the same page as what stripe is asking for, If I'm completely off the course please let me know, and some guidance as to how to properly set up a Stipe Subscription pipeline would be great

worthy egret
#

Okay let's back up here - there are a couple of issues that I'm seeing:

  • You're creating your subscription with a $0 licensed price. This is creating issues when you update the Subscription because you can't update an exisitng subscription item from licensed - > metered. Instead, you should just create a $0 graduated price
  • When a Subscription is updated from a $0 price to a non-$0 price, we immediately reset the billing cycle anchor. There isn't any way around this
wooden vapor
#

Sounds good, Okay so maybe it was my confusion that I did not set up the Free Price as Metered - That can be fixed.

And on point two, so theoretically there is no way to have all my customers be billed on the first of each month? (Which is not a problem, if that means quicker integration times)

#

Ohhh I see, i set it up as graduated, but i never ticked of metered on the free price

worthy egret
zenith folioBOT
#

atlastdb-metered-subs

wooden vapor
#

Okay so to keep it simple, there are two thing I'm looking for 1) Billing Cycle to be billed on the 1st of each month and 2) Upgrade and Downgrade Pricing plans with Metered Usage

wooden vapor
#

Having the subs billed on the 1st of the month was a personal preference anyways and not business impacting

worthy egret
#

Yeah I think it's doable, just a bit finicky to get to work since you're going from a free -> to a non-free price mid-cycle

#

Definitely try our subscription schedules and see if that does the trick

zenith folioBOT
wooden vapor
#

So just to be Sure, can you create schedule from the dashboard? or is it done only through the Stripe API?

#

oh hello @autumn bluff, pleasure to speak with yuou

autumn bluff
#

Hi @wooden vapor I'm taking over this thread.

#

Are you asking if you can create a subscription schedule through Stripe Dashboard?

wooden vapor
#

Yes, that is correct

autumn bluff
#

Yes you can. When you create a subscription in Dashboard, you can choose a future date as the start day, and Dashboard will automatically create a schedule behind the scene.

wooden vapor
#

Okay, yeah that was my confusion, So would this statement be true: Schedules are created after or along with a new subscription?

#

I ask because right now, when a user is registered to my App we subscribe them to a free plan, with a billing anchor of the ffirst of next month

#

Is this the same as setting a schedule?

#

Okay well before we dive further on to that topic, I want to confirm If I create a product, with 4 prices (free - $0/m, standard - $20/m, business - $45/m, and enterprise - $150/m) all graduated with monitoring checked, I should be able to avoid the error i was receiving: Cannot update plans with different usage types. The plan for the subscription item with the ID si_PIyOVbyCZ48wl2 is of usage type licensed, and you are trying to update to metered.

autumn bluff
#

"when a user is registered to my App we subscribe them to a free plan," -> did you use subscription API or subscription schedule API? Is there a creation request ID that you can share with me?

wooden vapor
#

The Subscriptions API

#

I will paste the code bellow

#

Create Customer

    public set_customer(): Promise<any> {
        if (!this._ID) throw "No User data was found";
        if (!this.EMAIL) throw "No User data was found";
        return new Promise((resolve, reject) => {
            stripe.customers.create({ name: this.name, email: this.EMAIL, phone: this.phone_number })
                .then((response: any) => { this.customer_id = response.id; resolve(response); })
                .catch((error: any) => { console.log(error); reject(error) });

        })
    }
autumn bluff
#

Then it would just create a subscription, not schedule.

wooden vapor
#

Create Subscription

    public set_subscription(subscription: 'free' | 'standard' | 'business' | 'enterprise'): Promise<any> {
        if (!this._ID) throw "No User data was found";
        if (!this.EMAIL) throw "No User data was found";
        if (!this.customer_id) throw "No User data was found";
        return new Promise(async (resolve, reject) => {
            const { plans } = await this.zSubs.getOne(subscription);
            stripe.subscriptions.create({
                customer: this.customer_id,
                items: [{ price: plans.monthly.price_id },],
                billing_cycle_anchor: Math.floor(Date.now() / 1000) + (30 * 24 * 60 * 60),
                proration_behavior: 'create_prorations',
            })
                .then((response: any) => { this.subscription_id = response.id; resolve(response); })
                .catch((error: any) => { console.log(error); reject(error) });
        });
    }
wooden vapor
autumn bluff
#

You just need to create a schedule, and schedule will automatically create a subscription based on schedule's start_date.

wooden vapor
#

Okay wow this makes a lot more sense now

#

Okay looking at the api reference, I see how we can set it up monthly forever and to be set on the first of each month, this is great

wooden vapor
#

So I created a new product prod_PJIX3EV559W0d1

All four prices are Graduated and metered.