#feni-patel_api

1 messages ยท Page 1 of 1 (latest)

native ploverBOT
#

๐Ÿ‘‹ 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.

austere torrent
#

Hello

loud siren
#

Hi ๐Ÿ‘‹

can you be more specific about your question?

austere torrent
#

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

loud siren
austere torrent
#

req_tXfcSQdSdMjfdy

loud siren
#

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?

austere torrent
#

currently i am only creating the customers not any payment methods. does this required ?

loud siren
#

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.

austere torrent
#

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.

loud siren
#

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

austere torrent
loud siren
#

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.

austere torrent
#

Okay thanks but currently i am not doing anything like You collect the payment method data like you are doing now, on the Platform.

loud siren
#

Yes, you are.

Give me a sec to get all the related requests

austere torrent
#

Okay, waiting

#

pm_1R4kCjFhYfQgOdcBJJu3ziqu

#

this is the current method id i m using

loud siren
#
  • Payment Method pm_1R1o9IFhYfQgOdcB72OoEObk belongs to Platform Account acct_1QBBwSFhYfQgOdcB
  • It was created in this request
  • The request that failed was trying to use on Connected Account acct_1QWf5yFvwcOuFt19
#

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",

austere torrent
#

yes i got your point

loud siren
#

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.

austere torrent
#

I got your points

#

now i have one question,

loud siren
#

Okay sure

austere torrent
#

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 ?

loud siren
#

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.

austere torrent
#

Okay thanks

loud siren
#

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.

native ploverBOT
austere torrent
#

can we do something like await stripe.paymentMethods.attach(cardId, { customer: customerId }); ?

vagrant parcel
#

Hi there, stepping in for my colleague here

austere torrent
#

Hello

#

can i use the stripe.paymentMethods.attach method ?

vagrant parcel
#

At which stage are you referring to? When saving card details on the platform?

austere torrent
#

yes, when saving card details into playform as well as make a copy of that into connected account

vagrant parcel
#

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

austere torrent
#

i have setUpIntent api, front end team is calling that api and payment methods are always created into the front end side correct ?

vagrant parcel
#

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

austere torrent
#

i am only working into backend side.

#

so i need backend guide

vagrant parcel
#

Are you using Stripe Elements to collect payment method details on the frontend?

austere torrent
#

not aware about that

vagrant parcel
#

This isn't a purely backend process and the details about what is happening on the other end of the flow are important

#

Where does the pm_ come from? Do you have an (representative) example you can provide?