#stiggz_subscription-oneoff

1 messages ¡ Page 1 of 1 (latest)

amber pantherBOT
#

👋 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/1290423116866125867

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

terse drift
#

@kindred pewter You have 2 options here

  1. Create a PaymentIntent for the amount, but we don't do any kind of "line item" tracking so no Product/Price references
  2. Use an Invoice instead to charge them for the extra fee
#

stiggz_subscription-oneoff

kindred pewter
#

Can you point me to an example of how to achieve this with an invoice? I was trying smoething similar to checkout, but it seemd line_items was not valid

terse drift
kindred pewter
#

Great, thanks! Does this look correct?

static async purchaseCredits(stripeCustomerId: string, bundle: IPricing.CreditBundle) {
    const invoice = await this.client.invoices.create({
      customer: stripeCustomerId,
      collection_method: 'charge_automatically',
    })

    await this.client.invoiceItems.create({
      customer: stripeCustomerId,
      price: this.bundlePrice(bundle),
      invoice: invoice.id,
    });

    await this.client.invoices.finalizeInvoice(invoice.id)

    return this.client.invoices.pay(invoice.id)
  }
#

The lifecycle is a little unclear, but it looks like charge_automatically + finalize + pay might do it?

terse drift
#

yes