#jnarowski
1 messages ยท Page 1 of 1 (latest)
Do you want to use an invoice?
It's one option, but not required
You can create a one time payment directly with payment intents, no invoice involved: https://stripe.com/docs/payments/accept-a-payment
I don't need invoice
can i create and charge if i have customer cc already?
can i associate price/product with payment intent
PaymentIntents don't interface with Prices and Products, you can informally use them together by referencing the price when setting the amount for the intent but they don't have parameters that reference each other or anything
You can directly create a PI to charge any CC that you have saved and set up for future use
A user is purchasing a one-off product. Which api do you recommend?
Seems like invoices might create a nice paper trial. Can I create invoice, add line items and charge it all at once?
Not opposed to PI
Either can work. Invoices do provide a more robust paper trail though PaymentIntents can send out receipts which are sufficient for some uses. https://stripe.com/docs/receipts
The Invoice API will require separate calls to create the invoice items and to create the invoice. Can't be done all at once but is still feasible to use for many flows
const invoice = await stripe.invoices.create({
customer: organization.stripe_customer_id,
collection_method: 'charge_automatically',
})
const invoiceItem = await stripe.invoiceItems.create({
customer: organization.stripe_customer_id,
invoice: invoice.id,
price: product.stripe_price,
})
will that do what I want, or do I need another call to actually process the invoice?
In that case you will also want to make a call to finalize the invoice https://stripe.com/docs/api/quotes/finalize
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Though you can also swap those steps and make sure to pass auto_advance: true when creating the invoice, that will tell the invoice to automatically finalize and charge the user in an hour
ok sounds good. THanks1
I think I will try it with payment intents first to keep things simple
another question, can we use stripe checkout but pass in an existing customer source if they already have one, or is the credit card always have to be typed in manually?
If you supply a customer ID we will prefill the payment info based on either the customer's most recently used card or the card they have set as their default depending on the mode. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hi ๐
You can if you have an already saved payment method that you pass along with confirm=True. https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method
If the Payment Method is attached to a Customer you will need to provide the Customer ID as well
got it. Thanks