#mukhiddin25_docs
1 messages · Page 1 of 1 (latest)
👋 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/1242549622598013009
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
I'm confused as here you said you want to send invoice
there are places where it is not suitable for us, so we want to check the time of the end of the tariff and send it to you to charge money. please through which api can i do this
and here you said you want to charge the payment method for an invoice
First of we charge first amount from customer using Payment Intent API and for secodary time I have already attepmt by using create invoice with flag immediately charge from card, I send customer ID and amount, unfortunately amount is not accept
I don't even know is it possible charge money using invoice that is why I have tried, but It did not work may be I misundersatand
You can. You need to create an invoice item first. You can't create an invoice with just the amount
So step 1 would be this where you save the payment method while charging the card:
https://docs.stripe.com/payments/save-during-payment?platform=web&ui=elements
step 2 would be to create an invoice item and then create an invoice
https://docs.stripe.com/api/invoiceitems/create
https://docs.stripe.com/api/invoices/create
when you create an invoice, pass the saved payment method as default_payment_method
https://docs.stripe.com/api/invoices/create#create_invoice-default_payment_method
Greate!
First payment I charge by using Payment Intent API and I have configured webhook event, it is working greate
Yes but make sure to set setup_future_usage parameter as that's required to save a payment method
Before first charge I am creating customer and then I create Intent by passing customer and setup_future_usage = off_session
Great
May I get payment method ID from success webhook event ? and with this payment method ID I will send create invoice by passing default_payment_method ?
Is there a connection between creating this item and creating an invoice?
Yes. You should see payment method ID on payment_intent.succeeded event.
Or you can list customer's associated payment methods by calling a different endpoint, see: https://docs.stripe.com/payments/save-during-payment?platform=web&ui=elements#charge-saved-payment-method
Is there a connection between creating this item and creating an invoice?
what do you mean by "this" item?
Is there a connection between create invoiceitem and create invoice? between those APIS
Yes, see: https://docs.stripe.com/api/invoiceitems
Invoice Items represent the component lines of an invoice. An invoice item is added to an invoice by creating or updating it with an invoice field, at which point it will be included as an invoice line item within invoice.lines.
Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined with a subscription. Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
As result
- create invoice
- create invoice item (send invoice ID when creating invoice item)
Am I correct understood ?
Which step money will charge from customer card ?
The order doesn't matter as the API supports both.
After the invoice is finalized, the payment method will be charged
which API should I call forn finalize invoice ?
Is it right https://docs.stripe.com/api/invoices/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.
Do any confirmation need by customer for finalize invoice?
if you set collection_method: charge_automatically then you won't need to call that API.
We'll automatically finalize the invoice.
https://docs.stripe.com/api/invoices
If your invoice is configured to be billed through automatic charges, Stripe automatically finalizes your invoice and attempts payment. Note that finalizing the invoice, when automatic, does not happen immediately as the invoice is created. Stripe waits until one hour after the last webhook was successfully sent (or the last webhook timed out after failing). If you (and the platforms you may have connected to) have no webhooks configured, Stripe waits one hour after creation to finalize the invoice.
If your invoice is configured to be billed by sending an email, then based on your email settings, Stripe will email the invoice to your customer and await payment. These emails can contain a link to a hosted page to pay the invoice.
After finalize API success responding does it meas money charged of customer card ? can I complete in our logic as payment success passed ?
or this complation logic should be after in webhook success event ?
I'd wait for invoice.paid event
does It settings in one place for intent and invoice webhook event ?
Not sure what you mean by that, can you elaborate?
I have configured webhook endpoint in stripe cabinet, event is coming when payment intent happened. Should I configure for invoice event another one ?
is one endoint enough both method ?
Yes, the same endpoint can listen to various events
Ok I will try If any other question will appear May I ask here ?