#ilyoTheHorrid (Endstream)

1 messages · Page 1 of 1 (latest)

twilit monolithBOT
ruby sundial
#

(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)

round wigeon
#

I need to make the first charge of the subscription a different amount from the rest.

ruby sundial
#

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

round wigeon
#

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'
}
ruby sundial
round wigeon
#

OK, but how do I upgrade the API? is it the npm package version?

round wigeon
#

Thank you

ruby sundial
#

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

round wigeon
#

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?

edgy furnace
#

Hi again, can you share the ID of the request that returned this response?

round wigeon
edgy furnace
#

Apologies for the delay, pulling that up.

round wigeon
#

thank you

edgy furnace
#

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

Learn how to create and send an invoice with code.

round wigeon
#

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

vale wren
#

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?

round wigeon
#

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

vale wren
#

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?

round wigeon
#

not broken, just one invoice. It is for legal services.

vale wren
#

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

round wigeon
#

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 ?

vale wren
#

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

round wigeon
#

OK, great, what do I need to set end_behavior to, to terminate the subscription after X cycles?

vale wren
#

In that case you would set end_behavior to cancel

round wigeon
#

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?

mint gulch
#

Hi there, stepping in. Let me catch up here

round wigeon
#

Hi, thank you

mint gulch
#

Can you share the request id for the Subscription Schedule creation please?

round wigeon
#

sure

mint gulch
#

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?

round wigeon
#

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

mint gulch
round wigeon
#

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?

round wigeon
mint gulch
#

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?

round wigeon
round wigeon
round wigeon
#

The link that I sent you is for a new customer

mint gulch
#

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.