#drprofsgtmrj
1 messages · Page 1 of 1 (latest)
Hello! Nope, you can add a one-time payment. Do you want to add a one-time payment when you first create the Subscription, or do you want to add one to an existing Subscription?
Hm. Either one. I just was curious. I notice that it shows up as the invoice item.
I'll have to check to see if it comes back as an item in the subscription itself
It shows up as a separate line item on the Invoice the Subscription generates.
When creating a Subscription you can use the add_invoice_items property to add one-time items to the first Invoice for the Subscription you're creating: https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
To add extra items to a future Invoice see here: https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items
But if I wanted to modify the existing one would I be able to include a single time payment in it?
Yes.
For example, let's say you had a $10/month Subscription that's been going for three months.
You can add a one-time $20 charge to the next Invoice for that Subscription, which will be created when the next $10 payment is due, meaning $30 total will be due at that time.
That would be the fourth Invoice.
The fifth Invoice would not be impacted; it will be for $10 again.
But I'm saying using the subscription.modify endpoint
Plus, I just tested using the subscription.retrieve, and the single payment doesn't show up in the items (data)
That's not how it works.
You add an Invoice Item to the Customer, you don't modify the Subscription.
When the Subscription generates the next Invoice outstanding Invoice Items on the Customer will be swept up and included on that Invoice.
Thus you'll have a single Invoice with the normal Subscription charges plus the one-time item you added.
I think there is a misunderstanding
I'm not really asking HOW to do it. I'm asking, if we use the subscription.modify endpoint is it POSSIBLE to add a single time payment
If not, that's OK because then the assumption that all items have to have the same interval is fully correct.
Not using that endpoint, no. Why would you be limited to using that endpoint though?
Oh, wait!
I forgot the update endpoint has add_invoice_items as well, so I think that might work: https://stripe.com/docs/api/subscriptions/update#update_subscription-add_invoice_items
But it sounds like you're really asking if you can add something using the items parameter? I'm not sure why though?
Well. In our use case we plan on modifying the whole subscription to add or remove items.
They need go be all the same interval as the endpoint rejects things otherwise.
So I have a validation method that makes sure things are the same interval.
Okay, but why? What are you trying to do at a high level?
Take from our database and update stripe accordingly.
Basically, if we want to allow for single time payment items, we need to add extra logic to add them too
Rather than just assuming we can use the subscription modify
Sure, I guess? You would need new logic regardless of what endpoint you used?
I guess to clarify
I have a method that validates our abstracted items
Loops over each one and makes sure they are the same interval.
So if we COULD pass items into subscription modify that are both monthly and single time payment, then the validation needs to account for that.
However, in this case, the validation just needs to make sure that all items are monthly (or some other same interval)
Does that make sense?
If you're specifically talking about setting/modifying the items parameter when modifying a Subscription, yes, that makes sense.
Right. Additionally, when we retrieve the subscription back from the subscription retrieve, we can assume that the items will all have the same interval (and not having a single time payment)
And thus we need some other method to get them
Again, if you're talking about the items in the Subscription's items property, that is correct.
Sorry. I know that was confusing
No worries! We're here to help, and making sure you have the right info and understanding is part of that. 🙂
One last question
So I basically would need to get the invoice items if I want to capture the single time payment items as well
Yes.
You can list Invoice Items by Customer: https://stripe.com/docs/api/invoiceitems/list#list_invoiceitems-customer
Should I grab the next pending invoice?
You can also do that, sure: https://stripe.com/docs/api/invoices/upcoming
Ah that's good thanks