#daveinto

1 messages · Page 1 of 1 (latest)

late tundraBOT
pastel sparrow
#

Hey Toby

fallen gyro
#

Hi 👋 what is your desired behavior when adding the new item? Do you want the customer to be immediately charged, but only for the new amount?

pastel sparrow
#

exactly

#

so they buy a subscription to the platform

#

and then maybe they want to upgrade some portions of that subscription

#

lets say storage.. from 100mb to 1TB

#

we need them to be charged the full amount for the upgrade.

#

ubscriptions->create(['customer'=>$customerID,'backdate_start_date'=>strtotime("midnight first day of this month"),'proration_behavior'=>'always_invoice','billing_cycle_anchor'=>strtotime("midnight first day of next month"),'metadata'=>['platformuserid'=>$callerUserID],'items'=>[['price'=>$subscription]],'automatic_tax' => ['enabled' => true]]);

#

thats the creation

#

subscriptions->update($subInfo['stripe_subscription_id'],['items'=>$items,'automatic_tax' => ['enabled' => true],'proration_behavior'=>'none','billing_cycle_anchor'=>"unchanged"]

#

and the update..which i know is wrong now..but i've tried many different variations.

#

without any succes

fallen gyro
#

That's tricky, because our system sees you providing someone with a product for only part of the billing period, so it doesn't think it's right to charge them the full amount unless the Subscription is being moved to its next billing period.

In order to accomplish this you'll need to process a separate payment for the amount you want to immediately charge the Customer, and then update the Subscription. For the update you'll want to set proration_behavior to none to avoid our proration logic being used.

pastel sparrow
#

so my subscription update...i need to change the start date until next month

#

and charge a 1 time purchase of this item before that?

fallen gyro
#

Do you want to change the Subscription's billing_cycle_anchor as part of this update? Or, referring back to your initial example, are you expecting the billing_cycle_anchor to remain anchored to the 15th of the month?

pastel sparrow
#

i want all the items to be billed on the first of each month

#

eg.. So one of the items is processing 10 files

#

they could do that all in one day

#

or they could take the full month for that to happen

#

so they are adding "Processing 10 files" package onto their monthly subscription

#

i could be on the basic package where i only can do 3 files..but on the 30th i realize i need the 10/month package and subscribe to that and do all 10 files on the 30th so prorating doens't make sense.

#

should i be looking at subscription schedules?

fallen gyro
#

Gotcha, so you'll need to completely circumvent our proration logic then. When you update the Subscription to include the new Prices in its items, you will want to set proration_behavior to none.

In order to charge the Customer immediately for the amount you'd like to, you will need to have another flow for charging them. If you're working with Subscriptions, and your customers are already accustomed to working with Invoices, then a good option for this is to create a one-off Invoice for the Customer for the amount that you want to charge them.

It'd probably also make sense to order those so that the Subscription isn't updated until the Invoice has been successfully paid.

#

Subscription Schedules are for scheduling future updates for Subscriptions, I'm not sure they'd be of help here yet.

pastel sparrow
#

so this is a net new feature... so we don't have to worry about clients behaviour at the moment.

#

so whatever is best/easiest way to go with this i'm more then happy to do.

#

if you look at my update command we are using none

#

update($subInfo['stripe_subscription_id'],['items'=>$items,'automatic_tax' => ['enabled' => true],'proration_behavior'=>'none','billing_cycle_anchor'=>"unchanged"]

fallen gyro
#

Yup, so that is the right approach to avoid using our proration calculations. Now you'll need another flow to charge the Customer for the amount you want them to pay today.

I think creating an Invoice for that would be a good approach:
https://stripe.com/docs/invoicing/integration

pastel sparrow
#

ok..

#

so let me see

#

Initial Subscription->Create..

#

then invoice->create, invoiceItems->create,charge the invoice

#

then subscroption->update (prorate=none) what about the start date of these items?

fallen gyro
pastel sparrow
#

ok super..just was wondering if i had to set the start date of the new items in the subscription to match the subscription start date.

#

or what do i have to do stop them from getting charged twice.

#

eg my subscription->update is charging them immediately

late tundraBOT
pastel sparrow
#

the wrong pro-rated amount for some reason... so after doing your invoice and charging that i dont want them to get charged by the subscription->update command.

fallen gyro
pastel sparrow
#

okk

#

in_1NQxFvEbjufZaAwgIKBmkeno

fallen gyro
pastel sparrow
#

weird. ok...i'll give i a go..hanks

#

ok..one question

#

charge_automatically gives me a nothing to invoice error since invoice->create doesn't have a place for me to add items.

fallen gyro
pastel sparrow
#

thats what i'm following

#

but the invoices->create so i can get an an invoice id

#

is giving me "Nothing to invoice the customer"

fallen gyro
pastel sparrow
#

that helps

#

thanks!

pastel sparrow
#

ok...i think the last question, dont see the option for automatic_tax

fallen gyro
pastel sparrow
#

ok..i lied another question

#

these items...

#

wrong paste

#

The price specified is set to type=recurring but this field only accepts prices with type=one_time.

#

so i assume that i have to change these items to be one_time

#

but since they become part of the subscription

#

they would be recurring?

fallen gyro
#

The Invoice is separate from the Subscription.

The Invoice is a one-time payment to collect the un-prorated amount, and will need to use one-time Prices.
The Subscription will need a recurring Price.
You will need two Price objects for this flow, one of each type.

pastel sparrow
#

ok got it..thanks!