#feni-patel_api
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/1352317472925290567
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- feni-patel_api, 1 day ago, 10 messages
Hello
Hi ๐
can you be more specific about your question?
I am creating customer into main and connected account also used the setupIntent, and using the. but during the payment intente i am getting an error like below
slotDetails.catId 65c608806782899b0698f069
Error creating payment intent: StripeInvalidRequestError: No such PaymentMethod: 'pm_1R1o9IFhYfQgOdcB72OoEObk'; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account.
i am getting this type of error bcz during cutomer creation payment method is not created ?
const { email, name, catId, itemId} = req.body;
const paymentInfo = await stripeService.getPaymentInfo(catId, itemId);
const provider = paymentInfo[0]
const stripeData = provider.get('stripe');
const connectedAccountId = stripeData.fields.accountId;
const { customerId } = await stripeService.createCustomerIntoMainAndConnected(name, email ,connectedAccountId);
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ['card'],
customer: customerId,
above is my code
Can you share an API request ID for this error? It will start with req_
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_tXfcSQdSdMjfdy
Thanks
The payment method you are trying to use belongs to acct_1QBBwSFhYfQgOdcB. But you are trying to use it on a Payment Intent that is created on acct_1QWf5yFvwcOuFt19. This won't work
I think you are missing a step in your integration.
You are saving Payment Methods to your Platform Account, right? And then you want to use them on Connected accounts?
currently i am only creating the customers not any payment methods. does this required ?
Sorry but that is not correct, based on what I am looking at.
Let's take a pause
and can you describe first the steps you take on the Platform Account. Ignore everything about Connected Accounts right now.
For instance, based on the request you shared, this payment method pm_1R1o9IFhYfQgOdcB72OoEObk was created on that Platform account in this request. It only exists on the Platform Account.
let me explain you. i want to first i want to take the customer's card info and stored them so that using that card customer will pay in future.
take the customer's card info and stored them
On the platform, right?
You need to be explicit about exactly what accounts each action takes place on
want to do this for on platform account as well as connected account.
Okay so here is what you do.
- You collect the payment method data like you are doing now, on the Platform.
- Then, before you attempt to process a charge on the Connected Account, you make a one-time use copy of the Payment Method to the Connect Account
- Then you process the charge using the Payment Method ID for the Payment Method you just created on the Connected Account
We have a guide for this exact process here. I recommend you take some time to build exactly what we describe here and test it out. I think this will do what you want.
Okay thanks but currently i am not doing anything like You collect the payment method data like you are doing now, on the Platform.
Yes, you are.
Give me a sec to get all the related requests
Okay, waiting
pm_1R4kCjFhYfQgOdcBJJu3ziqu
this is the current method id i m using
pm_1R4kCjFhYfQgOdcBJJu3ziqu
this is the current method id i m using
No, it isn't
You shared req_tXfcSQdSdMjfdy. That request passed payment_method: "pm_1R1o9IFhYfQgOdcB72OoEObk",
yes i got your point
Great! So, if you follow the guide I provided earlier, you should be able to use your existing approach with one extra step and get the results you are looking for.
Okay sure
let existingCustomers = await stripe.customers.list({ email, limit: 1 });
let mainCustomer;
if (existingCustomers.data.length > 0) {
mainCustomer = existingCustomers.data[0];
console.log(`Customer already exists in main account: ${mainCustomer.id}`);
} else {
mainCustomer = await stripe.customers.create({
email,
name,
});
console.log(`Customer created in main account: ${mainCustomer.id}`);
}
let connectedCustomers = await stripe.customers.list(
{ email, limit: 1 },
{ stripeAccount: connectedAccountId }
);
let connectedCustomer;
if (connectedCustomers.data.length > 0) {
connectedCustomer = connectedCustomers.data[0];
console.log(`Customer already exists in connected account: ${connectedCustomer.id}`);
} else {
connectedCustomer = await stripe.customers.create(
{ email, name },
{ stripeAccount: connectedAccountId }
);
console.log(`Customer copied to connected account: ${connectedCustomer.id}`);
}
return {
mainCustomerId: mainCustomer.id,
connectedCustomerId: connectedCustomer.id
};
this is my function for creating the customer into main account and make the copy of tht customer into connected account , so for the payment methods i need to do same . correct ? but this payment method will sent from the front end then i can make the copy into connected account correct ?
You need to follow the guide I provided. I recommend building that as a separate test integration to be sure you understand how it behaves and how you can add it to your integration.
Okay thanks
But, essentially, you are correct. Once you have the Payment Method saved to your Platform Account, you can clone it to the Connected Account using the same approach as above.
I am stressing you review our documentation to make sure we dont' overlook a key detail in this process. Building an end-to-end simulation is really the best way to know for certain if this approach will work for you.
can we do something like await stripe.paymentMethods.attach(cardId, { customer: customerId }); ?
Hi there, stepping in for my colleague here
At which stage are you referring to? When saving card details on the platform?
yes, when saving card details into playform as well as make a copy of that into connected account
Why not follow the guide my colleague provided earlier and use a SetupIntent? That's this step: https://docs.stripe.com/connect/direct-charges-multiple-accounts#create-setup-intent
Using SetupIntents is the recommended approach, rather than manually attaching a payment method to a customer.
A SetupIntent 1) creates a pm_ Payment Method and 2) associates that Payment Method with a Customer
i have setUpIntent api, front end team is calling that api and payment methods are always created into the front end side correct ?
SetupIntents are an API resource; they are created on the backend and confirmed on the frontend. When a SetupIntent is confirmed with payment method details from Elements, it creates a Payment Method
which you get in the response to stripe.confirmSetup
Are you using Stripe Elements to collect payment method details on the frontend?
not aware about that