#mr_pablo
1 messages · Page 1 of 1 (latest)
Unfortunately there isn't a direct way to do that really. PaymentIntent's themselves don't use product/price information. Products and prices work with our Billling products (Subscriptions and Invoices)
So basically, you can use associate them with the intent if you want, but that would look something like putting their IDs in the PaymentIntent's metadata.
So we are looking to use Stripe Elements on our site, rather than the off-site checkout. The docs state we need to use the Payment Intent API for Elements. Does this mean Elements doesn't work with Products?
Correct, PaymentIntents work with things that use Products and Prices, but they don't directly interact with Products and Prices themselves.
Sorry but that makes no sense
The closest thing to that would be if you create one off Invoices. Those use Products and Prices and will automatically create/update a PaymentIntent with the proper amount.
right OK
So you can do that and when you want to see the products and prices you can look them up via the invoice property on the payment intent
And does Stripe Elements support Invoices?
Elements can use the PaymentIntent that an Invoice creates
So elements won't automatically show price and product info, but it will still let you confirm the payment for that invoice
OK, we'll take a look at the Invoices API
https://stripe.com/docs/api/invoices/create I can see mention of a Subscription, but not Product (we have one off prices as well as recurring)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And I cannot see any mention of Payment Intents when creating an invoice
Invoice items are created via separate API calls to the "Create Invoice Item" endpoint https://stripe.com/docs/api/invoiceitems/create
And the payment intent can be found as the invoice's payment_intent property https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
How do I say what Product the Invoice is for?
You pass in a Price ID if you have a predefined price or you pass in the Product's ID if you are creating an ad-hoc Price with the price_data argument[2].
[1] https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-price
[2] https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-price_data-product
The product IDs won't be directly on the Invoice, they will be on the invoice items' prices
right, so, I need the Invoice AND Invoice Item APIs?
Correct
How do I connect an Invoice to Invoice Item? Can't see anyway to do that
2 ways, you can either create the invoice and then the items or the items then the invoice.
- If you create the invoice then the items, pass in the invoice's ID to the
invoiceparameter when creating the items https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-invoice - If you want to create the items first, create the items without that parameter. When creating the invoice pass in a
pending_invoice_items_behaviorofinclude. That will make sure that all pending invoice items on the customer get added to the invoice. https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
Ok, got ya
This doc may also be helpful though it only shows the second method https://stripe.com/docs/invoicing/integration