#ilyoTheHorrid (Endstream)
1 messages · Page 1 of 1 (latest)
(My goal is to update a specific charge in a subscription, and if there is a simpler way to do it, I would be happy to know)
Can you elaborate on this? You said "update a charge" and I wonder what you want to update and the reasoning (as it might be easier than upgrading the API, which could be a viable solution as well)
I need to make the first charge of the subscription a different amount from the rest.
Do you have a request ID for the request that didn't return any Invoice Items?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
It returned them, only it had no ii_
{
object: 'list',
data: [
{
id: 'sub_1MKjhcDvJEUYbQTxKb0OB9sG',
object: 'line_item',
amount: 112500,
amount_excluding_tax: 112500,
currency: 'usd',
description: null,
discount_amounts: [],
discountable: true,
discounts: [],
livemode: false,
metadata: {},
period: [Object],
plan: [Object],
price: [Object],
proration: false,
proration_details: [Object],
quantity: 1,
subscription: null,
subscription_item: 'si_N4tUvFzBxktTC0',
tax_amounts: [],
tax_rates: [],
type: 'subscription',
unique_id: 'il_1MKjhdDvJEUYbQTxkcfy5Nyx',
unique_line_item_id: 'sli_17b2aeDvJEUYbQTxe6bfdbc9',
unit_amount_excluding_tax: '112500'
}
],
has_more: false,
url: '/v1/invoices/in_1MKjhdDvJEUYbQTxKo4tvL9d/lines'
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Ahhh, okay. Yeah, so this is indeed because you're on an older API version that doesn't create Invoice Items. Do you want to upgrade the API version?
It looks like you'd need to at least upgrade to version 2011-12-06: https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#100---2011-12-06
If upgrading is not an option, can you elaborate on what you want to do? You could alternatively list the Subscription Items if you just need the info from them: https://stripe.com/docs/api/subscription_items/list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
OK, but how do I upgrade the API? is it the npm package version?
will this allow me to modify the amount of the first invoice?
Thank you
OK, but how do I upgrade the API? is it the npm package version?
You can do this via the Dashboard here: https://dashboard.stripe.com/developers
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
will this allow me to modify the amount of the first invoice?
Your integration would start creating Invoice Items and that would allow for you to update the amount of those Invoice items
Thank you, I upgraded the version, but still the same response:
{
object: 'list',
data: [
{
id: 'il_1MKosyDvJEUYbQTxANhe9USv',
object: 'line_item',
amount: 112500,
amount_excluding_tax: 112500,
currency: 'usd',
description: '1 × Test Subscription (at $1,125.00 / month)',
discount_amounts: [],
discountable: true,
discounts: [],
livemode: false,
metadata: {},
period: [Object],
plan: [Object],
price: [Object],
proration: false,
proration_details: [Object],
quantity: 1,
subscription: 'sub_1MKosyDvJEUYbQTxiE4HM4tB',
subscription_item: 'si_N4yqmmqbr725FU',
tax_amounts: [],
tax_rates: [],
type: 'subscription',
unit_amount_excluding_tax: '112500'
}
],
has_more: false,
url: '/v1/invoices/in_1MKosyDvJEUYbQTxJdnWdSzx/lines'
}
Do I need to change something else in the code to upgarde?
Hi again, can you share the ID of the request that returned this response?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Apologies for the delay, pulling that up.
thank you
I think you're not seeing the invoice_item field because the Invoice was created by a Subscription creation, and that creation does not appear to have included any Invoice Items.
Sorry that things are bit too busy for me to test at this myself at the moment, but can you try creating an Invoice from Invoice Items and see if that causes the invoice_item field to appear and be populated?
This integration builder example does this, and can be used as a reference:
https://stripe.com/docs/invoicing/integration/quickstart
Yes, I did create it from a subscription, so I think there is no point adding an invoice manually, since I need to amend the price of the existing invoices.
Maybe there is some simpler way to do it?
What I need is, for example: first payment of $990 and then each month for $100
Hey toby has to step out but I can help. Catching up now...
Is that $990, the $100 plus a bunch of different items, or is that just always how much you want the first payment to be before going to a normal monthly rate?
Not these specific amounts, but every customer will have an initial price and a price for the rest of the subscription, which are different
They need to be set programmatically through the API
No other payments/items
Gotcha, and do you want that first $990 to be broken out in to specific other fees/items, or should the invoices just say that this is the monthly fee throughout?
not broken, just one invoice. It is for legal services.
Gotcha. Subscription schedules may be useful here, you could define a price for the first month and another price for the subsequent ones, then create a schedule that uses the first price for a month and then switches https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#upgrading-subscriptions
The one kind of annoying caveat there is that you can't define the prices ad-hoc so you would need to create each price separately in the API and then create the schedule for them. That would be a pretty straightforward way to achieve the behavior that you want though
got it! sounds like the solution I'm looking for, thank you
By using iterations I can define how many months/cycles the subscription will run for?
So I don't need a cancel_at date?
Also, do I need to create a normal subscription first, or go straight to stripe.subscriptionSchedules.create ?
Correct. You can use iterations to say how many cycles the subscription should go for at each price
You can also have the last price go on indefinitely by specifying end_behavior=release
You can do it in either order. Creating a subscription schedule will create a subscription automatically unless you specify an existing subscription to create it off of
OK, great, what do I need to set end_behavior to, to terminate the subscription after X cycles?
In that case you would set end_behavior to cancel
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thank you!
const schedule = await stripe.subscriptionSchedules.create({
customer: customerId,
start_date: 'now',
end_behavior: 'cancel',
phases: [ {
items: [{ price: initialPrice.id }],
iterations: 1
}, {
items: [{ price: subscriptionPrice.id }],
iterations: stripePayments.numberOfPayments
}
]
})
It doesn't work at all as expected and I'm quite confused.
Why am I being charged for the second price but the first price appears as a draft?
What do I need to do so that initialPrice is charged immediately and then after a month subscriptionPrice kicks in?
Hi there, stepping in. Let me catch up here
Hi, thank you
Can you share the request id for the Subscription Schedule creation please?
sure
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Thank you. Also to summarize what you're trying to do, you'd like to add one time $990 fee to a monthly subscription. Is this correct? I.e. You'd like the fist invoice to have both the $990+$100 for the subscription?
Not exactly, I would like to have a first month price and then a subsequent subscription price. So the $990 are the first payment and the $100 is 2nd and on
They don't add up or consist of multiple products
price_1 for first month
price_2 for 2nd month and on
I see, thank you for clarifying. The flow that you have built with Subscription Schedules will work in this case. It is expected that the subscription invoice would be in draft status before it finalizes : https://stripe.com/docs/invoicing/overview and https://stripe.com/docs/billing/subscriptions/overview
You can finalize the invoice manually but making the Finalize Invoice call: https://stripe.com/docs/api/invoices/finalize
OK, Is there no way for it to charge as a normal invoice would?
Also, why was I charged the 2nd month price right at the beginning?
please take a look at the screenshot here
What do you mean by 'charge as a normal invoice would'? The way invoice works is outlined here were it stays in draft status initially.
From the request id you shared, it appears that the customer was deleted. Can you share a request id where the customer was not deleted?
I mean why is a normal subscription finalized automatically but this one needs manual finalization?
Here is a new one https://dashboard.stripe.com/test/logs/req_uy9dowIoBtfDst
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
It will automatically finalize within an hour: https://stripe.com/docs/billing/invoices/subscription#:~:text=Create an invoice&text=To create a one-off,finalized%2C you can edit it
This customer, https://dashboard.stripe.com/test/customers/cus_N50PcUvzZHLILE has been deleted.
The link that I sent you is for a new customer
When you click on that link, you can see the customer?
I tested this flow on my end and it's working as expected. My first phase's invoice is currently in draft status and I only see the first price billed on it.
default_settings: {
billing_cycle_anchor: "phase_start",
},
end_behavior: "cancel",
phases: {
0: {
proration_behavior: "none",
items: {
0: {
quantity: "1",
price: "price_1MKrYUGHtciddFoAYgKjDcUK",
},
},
iterations: "1",
},
1: {
proration_behavior: "none",
billing_cycle_anchor: "phase_start",
items: {
0: {
quantity: "1",
price: "price_1MKrYUGHtciddFoARHdeW0Xy",
},
},
iterations: "12",
},
},
start_date: "1672441308",
customer: "cus_MTc879WVkSBTLg",
});
From the code snipped and the screenshot provided, the draft invoice looks to be for price price_1MKqOJDvJEUYbQTxTCIIhWqs from phase 1.