#rpardela

1 messages ยท Page 1 of 1 (latest)

wild spearBOT
abstract talon
wild spearBOT
shy snow
#

And can I issue invoices for the account? Now I have such a problem that the customer has EUR currency set automatically and I want to expose him an invoice in USD currency (such payments I take from the card).

surreal python
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

shy snow
#

How to do it. I need an example in the source code. "The only way to change the default currency in which you charge a customer is to create a new Customer object representing that customer, attach a payment method, and then execute the requested task in the appropriate currency."

surreal python
#

you can create a one-time invoice with another currency then the default one

shy snow
#

I create the invoice this way. I get an error related to a different currency on the invoice and a different currency at the customer. What am I doing wrong?

#

My code: 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: 7, // 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);


    // Finalize the invoice
    //const finalizedInvoice = await stripe.invoices.finalizeInvoice(invoice.id);

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

}

surreal python
#

what's the error?

shy snow
#

Error: "The price specified supports currencies of usd which doesn't include the expected currency of eur."

#

Error occur in this step: / 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,
});

surreal python
shy snow
#

The only difference is that I shouldn't use "price: priceId" and insert the amount and currency manually?

surreal python
#

no you need to pass currency to both the invoice items and the invoice

#

so if you have priceIDs in your invoiceItems

#

you just need to specify the currency when creating the invoice

shy snow
#

It works! Many thanks ๐Ÿ™‚