#sylar_api

1 messages · Page 1 of 1 (latest)

timber novaBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1318301045369081866

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

cold cove
#

Here is the code example

    const params: Partial<Stripe.InvoiceCreatePreviewParams> = isRecurring
      ? {
          subscription_details: {
            items: priceArray.map((price) => ({ price })),
          },
        }
      : { invoice_items: priceArray.map((price) => ({ price })) };

    const preview = await this.stripe.invoices.createPreview({
      customer: dbuser.paymentSystemId,
      ...params,
      preview_mode: isRecurring ? 'recurring' : 'next',
    });
#

and example of the preview invoice lines:

{
  data: [
    {
      id: 'il_tmp_175897LT0n97qDN21653d625',
      object: 'line_item',
      amount: 3300,
      amount_excluding_tax: 3300,
      currency: 'pln',
      description: 'Cargo',
      discount_amounts: [],
      discountable: true,
      discounts: [],
      invoice: 'in_1QWk5zLT0n97qDN2KRhFfxH1',
      invoice_item: 'ii_1QWk5zLT0n97qDN26FC4fLHJ',
      livemode: false,
      ...
    },
    {
      id: 'il_tmp_1b099fLT0n97qDN2db1a2a72',
      object: 'line_item',
      amount: 2500,
      amount_excluding_tax: 2500,
      currency: 'pln',
      description: '1 × Standart bike (at 25.00 zł / week)',
      ...
    },
    {
      id: 'il_tmp_1b90c1LT0n97qDN25febabda',
      object: 'line_item',
      amount: 400,
      amount_excluding_tax: 400,
      currency: 'pln',
      description: '1 × Helmet (at 4.00 zł / week)',
      discount_amounts: [],
      discountable: true,
      discounts: [],
      invoice: 'in_1QWk5zLT0n97qDN2KRhFfxH1',
      livemode: false,
      metadata: {},
      period: [Object],
      ...
    }
  ]
}
fleet tendon
#

Thanks for the info, looking in to this

cold cove
#

So the question is "why does it populate the lines list with nonsense"?

fleet tendon
#

Can you send me the request ID of a time that you made this request and got this response? (req_123)

cold cove
#

the request id should be inside invoice preview response?

fleet tendon
cold cove
#

ok for example this one:
req_yWbvawsCNFh6il

#

it includes only one one-time price object, but resulting a weirdo list

fleet tendon
#

Ah it looks like that customer has a subscription with those prices on it already. Basically your call is saying to preview what happens if you added an invoice item to the customer and did nothing else. In this case, the invoice item would get appended to the subscription's next invoice when it cycles. So here we need to add params to tell the endpoint to create an invoice for just the items that you specified. Figuring out how to do that

#

Having trouble figuring this out, will ask my colleagues and get back to you

cold cove
#

Thanks

timber novaBOT
fleet tendon
#

Unfortunately we haven't been able to find a parameter for this for customers with subscription. I think the best workaround at the moment would be to provide customer details that match their billing address or whatever else is relevant here. That should preview an invoice for a theoretical new customer without anything else on them. I can put in a feature request to make this easier but I think that workaround is needed at the moment.
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-customer_details