#Mahesh K
1 messages · Page 1 of 1 (latest)
Hi there!
You mean this: https://stripe.com/docs/api/invoices/object#invoice_object-application_fee_amount? It's only useful when using Stripe Connect. Are you using Stripe Connect?
Go it. Then when creating an invoice on a connected account, the application_fee_amount is the amount you want the platform to recieve.
ok thank you.
then for collection method key which one should i choose
charge automatically or send_invoice
may i know the difference?
Have you read the API reference? https://stripe.com/docs/api/invoices/object#invoice_object-collection_method
Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
What if my customer doesn't have the default source attached?
You mean if you use charge_automatically and the customer has no default payment method? Then you'll need to ask the user to enter a payment method. The simplest way would be to send them a link to the hosted_invoice_url https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url.
Happy to help 🙂
async function createInvoice(obj, accountID, amountTotal) {
let modified_obj = {
customer: obj.p_stripe_id,
amount : amountTotal * 100,
collection_method: 'send_invoice',
currency: 'usd',
customer_email : obj.contact_email,
application_fee_amount : 500
}
let invoice = await stripe.invoices.create(modified_obj, { stripeAccount: accountID })
return invoice
}
will it works
??
Have you tried running this code?