#jain-kunal_error
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/1379848281927979009
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi can you share the request id where you're getting this error
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_AyRFb5dVwGzU88
req_uuPc3DEZmjMvFs
req_F6X49PSw4mwL4J
req_TrYRh9BTYMr34e
req_9aS7zOnl1HgLQz
Hey there, I'm taking over from my colleague. Let me take a look.
Looking at req_AyRFb5dVwGzU88 the customer cus_SPJpCtUfMyhDgI being used in the request is associated with another account. Not the account (acct_1RRuFjPG0QhJ8OcG) you're making the request on.
That's why the error is being returned.
I recommend double checking to make sure you're using the API keys associated with the account the customer was created on.
let customerId = "";
const existingCustomers = await stripe.customers.list({
email: contractor?.email,
limit: 1
}, {
stripeAccount: contractor?.accountId
});
customerId = existingCustomers?.data?.[0]?.id;
if(!existingCustomers || existingCustomers.data.length === 0 || !customerId) {
const customer = await stripe.customers.create({
email: contractor.email,
name: contractor?.fullName,
metadata: {
userId: contractor?.id,
accountId: contractor?.accountId
}
}, {
stripeAccount: contractor?.accountId // Create customer on the connected account
});
customerId = customer?.id;
}
// Create Stripe invoice
const invoice = await stripe.invoices.create({
customer: customerId,
currency: job?.currency || 'mxn',
metadata: {
jobId: job.id,
contractorId: job.contractorId,
transferGroup: job.id
},
description: `Payment for job completion - Job ID: ${job.id}`,
auto_advance: true, // Automatically finalize the invoice
});
// Add invoice item
await stripe.invoiceItems.create({
customer: accountId,
invoice: invoice.id,
amount: parseFloat(job?.totalAmount) * 100 || 0, // Convert to cents
currency: job?.currency || 'mxn',
description: job?.description || `Job completion payment`,
metadata: {
jobId: job.id,
contractorId: job.contractorId
}
});
// Finalize the invoice
const finalizedInvoice = await stripe.invoices.finalizeInvoice(invoice.id);
I am kind of using this part.
trying with same accoutn id and customer id.
can you please guide on what I am doign incorrect?
or can we connect on call?
Sorry, we won't be able to connect on a call.
I took a look at the customer creation request and I can see that the customer was created on an Express Connected Account via the Platform Account (acct_1RRuFjPG0QhJ8OcG). So in this case the customer cus_SPJpCtUfMyhDgI is on the connected account not the platform. So you're request to created the invoice should be on the connected account.
I recommend reading through or "Making API calls for connected accounts" doc [0]. That should help you here.
[0] https://docs.stripe.com/connect/authentication#stripe-account-header
my use case is create invoice bank transfer after their trnasfer is done.
can I do for this as well?
Can you clarify your question please.
I want to create an invoice after a client has completed a bank transfer (not before). Is it possible to generate the invoice after confirming the transfer is done?
My use case is to create an invoice for a bank transfer after the customer has completed the transfer. Can Stripe support this?
For example:
A client sends a bank transfer using Stripe.
After I confirm the payment is received in the bank, I want to generate an invoice in Stripe for accounting/record purposes.
I don't want to create a payment link or invoice before the bank transfer โ only after it's confirmed.
Is there a recommended way to handle this flow in Stripe?
That's not invoices work in the Stripe sense. You're referring to a receipt of payment.
You can manually send receipts via Stripe via the Dashboard [0]
[0] https://docs.stripe.com/receipts#manually-send-receipts-from-dashboard