#Elian Braja
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
could you please elaborate more and share some ids so I could take a look?
I have an occurring subscription
Subscription recurring interval is monthly and lets consider that we are in the middle of the month and I want to add a new subscription item to it and the price amount is 200$
for that I create a new subscription item with proration_behavior: "create_prorations"
after that I create the invoice to be paid for that subscription that result in 100$ for the remaining time
and this invoice has to be paid immediately by the customer
the problem is that even if the customer does not pay, he will get that new subscription item on the upcoming invoice of the entire subscription
I don't this to happen if customer does not pay the invoice for the occurring month
So in simple works I want the subscription item to be added only if the customer has paid the first invoice for the prorations
I'm not sure if this is possible without having to introduce a schedule
let me think about this for a second
Hello ๐
Taking over as tarzan needs to step away soon
Do you want the prorated amount to be paid by the customer immediately?
Can you clarify what the expected amount you want your users to pay in the example you provided above for a sub with $200 price?
if we are in the middle of the month 100$
and only after user makes this payment I want to add the subscription item to that subscription
I don't want the subscription item to be added for the next billing cycle automatically if the user has not done his first payment for the first invoice for the prorations of the remaining time (the $100 I mentioned before)
and when exactly do you want to charge for the newly added subscription item?
I will charge immediately $100 for the remaining time
If the invoice will be paid for that remaining time, I will add the subscription item for the next billing cycle too that will be +$200
Am I clear?
Okay correct me if I'm wrong
October 1st: you start a monthly sub for $100
October 15th: you want to add a new sub item and prorate
1/ You'd charge $50 for the remaining time
2/ Add a new subscription item for $200
November 1st: customer is charges $200 for the new price?
correct
so just to clarify one thing
I want to charge $50 but create the subscription item for the next billing cycle only if that invoice is paid
so if customer does not pay $50 (invoice remains opened), he will continue to pay just $100 the next billing cycle
This isn't something that's supported out of the box, you'd need to DIY the integration a lot.
In order to charge the prorated amount immediately (before adding the subscription item), you'll need to modify the billing cycle anchor to "now" so that we generate a new invoice for the prorated amount.
Then you'd want to offer a trial of however many days that are left in the original billing cycle and track wether the user paid the prorated amount invoice or not.
If they do, you'd update the subscription and add a new item when the trial ends and reset the billing cycle
If they don't, you'd reset the billing cycle again to charge the old price
I'd recommend giving this a try in test mode to make sure it behaves according to what you need.
But how can I generate a new invoice for a subscription without adding a subscription item?
by resetting the billing cycle to 'now'
but that way I have to also pay the remaining amount for the subscription itself besides of the new item added?
correct?
so if I have a occurring subscription ($200 total cost) and in the middle of the billing cycle I add a new item ($100 total cost) I will pay $100 + $50 = $150
correct?
Instead I want to pay only $50 (for that month) and then pay $300 the next billing cycle
but you're not adding a new subscription item until the customer pays the previous (prorated) invoice though, right?
yes
but resetting billing cycle to now would be problematic
because would not result in just a 50$ charge
but will result in a charge for the total subscription amount
If you're prorating the amount then it should charge $50 no?
but are we changing the billing_cycle to now?
what does it mean?
to change the billing_cycle to now?
https://stripe.com/docs/billing/subscriptions/billing-cycle#changing
Reset the anchor to the current time using billing_cycle_anchor=now. Be aware that this results in the customer being invoiced immediately. You can do this through the API.
customer will be invoiced immediately
it will also charge for other items in the subscription
not just the newly created susbcription item invoice
I think there's some confusion
there isn't a subscription item created on the subscription itself yet right?
I have just one question, apart of that
how can I add an invoice to a subscription
but without specifying the items attribute
1/ October 1: You have a subscription with $100 price
2/ October 15: You update the billing cycle anchor (without adding a new subscription item) to now with prorations, which generates a new invoice for $50
3/ October 15: You introduce a trial of 15/16 days which pushes the anchor to November 1st
4/ Then
- If customer pays $50 invoice then you add a new subscription item with prorations disabled so that the customer is charged the new price on November 1st
- If customers don't pay $50 invoice then I believe the sub will charge the old price of the subscription anyway right?
is not the case
the new item has not the same price with the current subscription item
I want to pay the proration for my new item only
Oh...
you got me?
So you want to prorate the new price and not the old one
yes
just the new price
and then I pay in total the next billing cycle
that will be old one + total new one
but until the the proration of the new one is not paid I do not have to add it as a subscription item
so as long as the user does not pay the proration, he will continue to pay the same old amount at the start of next billing cycle
Have you tried using our pending updates functionality yet? I think that should work in your use-case though I don't know off the top of my head how well it works with create_prorations as a proration behavior https://stripe.com/docs/billing/subscriptions/pending-updates
interesting
I am using Stripe::SubscriptionItem.update for example and when I set payment_behavior: "pending_if_incomplete" and increment the quantity by 1 it gets updated
why?
by the documentation it should not
?
Can you send me the ID for the subscription that you did this with? (sub_123)
sub_1LpYtdEMyoEBRsWZshB4UdLR
and the subscription item that I am trying to update is "si_MYgJks2G9XQayt"
I am just changing the quantity from 1 to 2
Thank you. I'm recreating this in my own tests as well. I wonder if this is related to always_invoice + pending_if_incomplete. So it might be that we support this for billing automatically but not creating the items and adding them to an invoice later (which would mean no custom discounts so that might not be viable)
Thank you. That looks like what I am doing so good that we are on the same track at least
and I see the quantity incremented. Instead it should wait for the invoice to be paid successfully and then update the quantity, correct?
I believe so but I may have misunderstood how this works in this use case. Still working with this and will get back with what I find
Hey apologies it took me a while on this. Ran in to a few issues while testing
So it looks like you do need to use always_invoice and send out the invoice immediately to take advantage of pending updates here
Because you are using subscriptions that charge automatically though, there isn't a way to add discounts to these update invoices after they were created
but I want to also add dicounts to that invoice
You can still apply discounts, but you have to add them to the customer beforehand and then make the update. So using something like customer balance to give the discount may be needed.
Are you planning on using our discounts/promo codes API for these discounts? Or were you planning to manually create credits or negative amount invoice items? Might have to test further to figure out if Discounts work with this flow
can you please send me the request you made for the subscription item
because I continue to get the quantity updated even if the invoice is not paid
Even with always_invoice? Do you have an ID for that subscription as well?
Getting my code for you now. It is in Python but should be easy to translate
my invoice automatically gets paid
why?
I just checked my invoices
and they are automatically marked as paid
I am also trying using the updateSubscription
items=[
{
"price": gold_monthly_id
},
],
collection_method='charge_automatically',
off_session=True)
...
stripe.Customer.create_balance_transaction(
customer.id,
amount=-100,
currency='usd',
)
sub = stripe.Subscription.modify(sub.id, proration_behavior='always_invoice', payment_behavior='pending_if_incomplete',
items=[
{
'id': sub['items'].data[0],
'quantity': 2
}
])
can you plase check my test
that I sent you
why my invoices are marked as paid?
automatically
Because your customer has a valid payment method set as their default payment method. Your subscription has a collection behavior of charge_automatically and we are using always_invoice as a proration behavior, so it is expected that an invoice will be created immediately and attempt to charge the user immediately. Because that customer has a valid payment method for their default, that charge is successful
To see this fail in test mode, you might have to set a default payment method for the customer or for the subscription that will fail this payment. One sec while I find that card
but I dont want that to happen
you are telling me that
payment_behavior: "pending_if_incomplete",
proration_behavior: 'always_invoice'
there are a must to be provided
to take advantage of pending update
then how can I also mark the invoice to stay open?
I dont want to charge automatically
Unfortunately I'm finding that you can't have the invoice stay open and take advantage of out pending updates functionality. To use it you would need to charge automatically. What you want to do may still be possible within those constraints as long as you can know what discounts you want to apply beforehand.
Otherwise, you will have to implement this yourself somewhat. In that scenario you would make this update normally with create_prorations, create your new invoice and apply discounts, and then check back in on the invoice X days later to see if it was paid. If not, delete the invoice and roll back the updates.
But this way I risk that the customer gets charged for the new subscription items if the new billing cycle starts
because with create_prorations the subscription item will be there even if the customer does not pay the prorations for that occurring month
One alternative DIY approach that I can think of is that you can preview what the prorations would be for updating the subscription, create a one-off invoice for that amount, send it to the user, and make the change on the actual subscription with no prorations once the one-off invoice is paid https://stripe.com/docs/api/invoices/upcoming
but how can I create an invoice without specifying a subscription
๐ stepping in here as Pompey needs to step away
So, if I understood correctly you mean to create an invoice with just amount and currency that does not have any relation with the subscription
correct?
You can create one-off invoice's using our create invoice endpoint: https://stripe.com/docs/api/invoices/create
how can i specify the amount to be charged?
Yes that seems to be what Pompey was indicating
with which attribute?
You create invoice items for the amount
The flow for one-off invoices is to:
1/ create invoice item(s) for the amount you want to charge
2/ create an invoice
3/ finalize/pay the invoice which will sweep up the invoice items and create the charge
does the invoice item automatically create an invoice?
No
The invoice item will be associated with the Customer and be picked up with the next created invoice
https://stripe.com/docs/invoicing/integration walks you through the steps here