#snackdex
1 messages ยท Page 1 of 1 (latest)
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.
- snackdex, 3 hours ago, 11 messages
What do you mean
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?
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?
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
Oh it's because you pass a customer with a default payment method set
That makes sense
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 ๐
Yeah sure
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;
Is there a particular reason you need a subscription schedule?
In any case setting metada here updates the subscription item metadata: https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases-items-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
Hm who told you to do that
Do you need a subscription?
This is doable with plain invoices...
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
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
oh yes.
i also need to support a payment intent that has a mixture of a subscription and also different types of items
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
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
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
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
ie this call: https://stripe.com/docs/api/invoiceitems/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
i'll do some testing! thank you for helping out