#rpardela

1 messages · Page 1 of 1 (latest)

leaden vectorBOT
waxen ibex
#

const sendInvoice = async (customerId, priceId, quantity) => {
console.log('sendInvoice');
try {

    // Create a draft invoice with the invoice item and collection method set to 'send_invoice'
    const invoice = await stripe.invoices.create({
        customer: customerId,
        collection_method: 'send_invoice',
        days_until_due: 0, // Set the number of days until the invoice is due
        auto_advance: false, // Keep the invoice in draft mode
    });
    // Create a pending invoice item with the actual fee and a description
    const invoiceItem = await stripe.invoiceItems.create({
        customer: customerId,
        price: priceId,
        quantity,
        // description: 'Fees charged (Already Paid)',
        invoice: invoice.id,
    });

    // Mark the invoice as paid
    await stripe.invoices.pay(invoice.id, {
        paid_out_of_band: true,
    });

    // Finalize and send the invoice
    await stripe.invoices.sendInvoice(invoice.id);


    console.log(invoice, 'invoice');
    return ({ success: true, invoiceId: invoice.id });
} catch (error) {
    console.log(error.message, 'error');
    return ({ error: error.message });
}

}

eager junco
#

there is no future payment date on the invoice
Can you share what you're referring to here?
the invoice is sent to the customer's email address
This will happen automatically in live mode (assuming the setting is enabled). But we don't send emails in test mode