#snackdex

1 messages ยท Page 1 of 1 (latest)

balmy spearBOT
#

Hello! We'll be with you shortly. 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.

shrewd narwhal
#

What do you mean

slow plover
#

i previously asked how to get the payment method and was told i could get it from the payment intent.

#

i generated an invoice for a user but didn't pay for it

#

i then used the payment intent to get the payment method to see what would happen

#

and i got the payment method back that is the customer's default payment method. is that intended behavior?

shrewd narwhal
#

Wait how does the invoice have a pm attached if you didn't pay it?

#

Can you share the invoice id so I can see what you're talking about?

slow plover
#

this is the invoice: in_1OKjwCELLwkYyxmwFGJQokCt

#

on that invoice i used the payment intent and fetch the payment method

#

this is in the developer not production

shrewd narwhal
#

Oh it's because you pass a customer with a default payment method set

#

That makes sense

slow plover
#

ah ok. i just wanted to make sure that was expected behavior

#

while i have you hear, can i ask a totally different stripe question ๐Ÿ‘€

shrewd narwhal
#

Yeah sure

slow plover
#

so i want to pass metadata to the line items. i can do that just fine, but not for a subscription line item. this is how i'm creating the invoice:

const subscriptionSchedule = await stripe.subscriptionSchedules.create({
      customer: stripeCustomerId,
      start_date: "now",
      end_behavior: "release",
      expand: ["subscription"],
      phases: [
        {
          collection_method: "charge_automatically",
          items: [
            {
              price: membershipPrice.stripePriceId
            }
          ],
          metadata: invoiceItemMetadata
        }
      ]
    });
    const subscription = subscriptionSchedule.subscription as Stripe.Subscription;
    const latestInvoiceId = subscription.latest_invoice as string;

shrewd narwhal
#

Is there a particular reason you need a subscription schedule?

slow plover
#

yes. i originally asked if it was possible to create an invoice with line items where i don't have a stripePrice/stripeProduct. in other words i just pass the currency for the line items.

i was told that wasn't possible, and to instead use a subscription schedule and that will allow me to do that

shrewd narwhal
#

Hm who told you to do that

#

Do you need a subscription?

#

This is doable with plain invoices...

slow plover
#

hmm let me see if i can find the message in discord, maybe i was wrong
the schedule makes it harder

#

and yes i do support subscriptions

shrewd narwhal
#

Ok just tell me what you're trying to do. Create one-off invoices or create a subscription?

#

Because the first example was a one-off invoice

slow plover
#

oh yes.
i also need to support a payment intent that has a mixture of a subscription and also different types of items

shrewd narwhal
#

That doesn't make sense

#

Payment Intents are a completely separate concept

slow plover
#

so for the payment sheet. i need to send a payment intent
whichever way i can get a user to purchase a subscription and other items in the same transaction. i was told that i could use invoices for that

shrewd narwhal
#

Oh

#

You could add invoice items for the one-off items and those would get pulled into the subscription's invoice

#

You shouldn't need a subscription schedule unless there's a valid reason

#

You can pass raw amounts to both invoice items and subscriptions

slow plover
#

ah ok! i found my notes:
so the original thing that i was trying to do was create an invoice with a subscription and some line items in one api call.

i did that by creating a subscription (not with a schedule) and then i got the invoice of that and tried to add line items to it.
when i did that i got an error this invoice is no longer editable

#

if there is a way to create an invoice with a subscription and line items can you please share. i would really appreciate the guidance

shrewd narwhal
#

Yeah you'd need to create the invoice items first (before the subscription) so they're pulled in when that first subscription invoice is created

slow plover
#

just to make sure i follow:

  • i create the invoice items first
  • i then create the subscription

and that automatically adds the line items to the subscription invoice?

shrewd narwhal
#

Yeah

#

If you pass the same customer id

slow plover
#

i'll do some testing! thank you for helping out