#daveinto
1 messages · Page 1 of 1 (latest)
Hey Toby
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?
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
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.
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?
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?
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?
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.
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"]
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
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?
Can you elaborate? My understanding was you wanted to immediately grant the customer access to that, in which case you don't need to worry about start date.
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
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.
Can you share the ID of a request where this behavior was encountered? Setting proration_behavior to none in the request to update the Subscription should avoid the customer being invoiced immediately, unless there is something else being passed in that reqeust causing that behavior.
proration_behavior was set to always_invoice:
https://dashboard.stripe.com/test/logs/req_xkiKloJaMy9hBw
So it's expected that a new Invoice was created there.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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.
You have to create an Invoice Item to go on the Invoice, second chunk of sample code shown in this section of the provided guide shows how:
https://stripe.com/docs/invoicing/integration#create-invoice-code
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"
Ah, sorry, I think you may be on an older API version before we changed default behavior to make it easier to create an empty Invoice. Can you try passing pending_invoice_items_behavior as exclude in the request to create the Invoice?
https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
ok...i think the last question, dont see the option for automatic_tax
Should be the automatic_tax.enabled parameter:
https://stripe.com/docs/api/invoices/create#create_invoice-automatic_tax
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?
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.
ok got it..thanks!