#Bernard Paulet

1 messages · Page 1 of 1 (latest)

eager falconBOT
boreal gyro
#

The ref of the request in error is the following : req_bT848vkPzuXim5

#

If you go to the customers of the connected account you see that cus_O7Zp5Jiou0U8dS does exist

rich nexus
#

You should use the Customer Id of the Platform. In this request req_bT848vkPzuXim5 you used cus_O7Zp5Jiou0U8dS which is the Connected Account customer

boreal gyro
#

That's the strange element... I tried with both but always receive the error referring to the connected account one...

rich nexus
#

Could you share the request id failed, but with your Platform Customer Id?

boreal gyro
#

It's the one I shared above

#

In the log, you see "on a fini de créer ou retrouver le client cus_NRNnvtzUxZp9Lp" that is the platform customer

#

"L ID du customer pour le compte connecté est cus_O7a84KbVqIS1yD" is the connected account customer

#

and it's that id that I give in the request

#

In fact, the id of the request is the id of another connected account customer...

#

with same email (key to retrieve customer)

#

customerId, the variable used in the request to give the customer id comes from the code :
` const customerList = await stripe.customers.list({
email: req.body.email,
limit: 1,
},
);
if(customerList.data != null && customerList.data.length != 0){
customerId = customerList.data[0].id;
//Retrouve la payment method du client
paymentMethod = await stripe.customers.listPaymentMethods(customerId);
paymentMethodId = paymentMethod.data[0].id;
} else {
const customer = await stripe.customers.create({
email: req.body.email,
},
);
customerId = customer.id;

        //Attache un payment method au client
        paymentMethod = await stripe.paymentMethods.create({
            type: "card",
        });

        paymentMethodId = await stripe.paymentMethods.attach(
            paymentMethod.id,
            {customer: customerId}
        );
    }`
rich nexus
#

Sure, can you find the request Id which used cus_NRNnvtzUxZp9Lp?

#

req_bT848vkPzuXim5 used cus_O7Zp5Jiou0U8dS instead

boreal gyro
#

In fact, cus_NRNnvtzUxZp9Lp and normally, it is the parameter that I pass to the request...

#

I will add a console.log to show the content of my variable, to be sure...

#

It takes a little time (it must deploy the function on firebase)

rich nexus
#

you have the Dashboard request log

boreal gyro
#

I made i run once again and now it's working...

rich nexus
#

That lucky bit comes when you talk to us 😉

boreal gyro
#

Yes but it crash now at the moment I create the ephemeral key with same message 'no such customer'.
I pass the id of the connected account customer, it that good?

#

And I have the same question for the creation of the payment intent, for the customer, is that the id of the platform customer of the connected account customer that I have to give?

rich nexus
#

Let's slow down a bit

#

Now you have successfully cloned the Payment Method, correct?

#

Next step is you need to clone the Customer, using the cloned PaymentMethod

boreal gyro
#

Ok, I missed that point !

rich nexus
#

pseudo code

  newCus = Stripe::Customer.create({
    payment_method: clone_payment_method,
  }, {
      stripe_account: 'acct_xxx', # Connected Account
  })
boreal gyro
#

Waouw, I was going to ask where I could find the doc...

#

Thanks !

#

But to be sure of the good syntax..
you wrote newCus = Stripe::Customer.create
it's not newCus = stripe****customers.create ?

#

And I dont have to pass the reference of the payment method?

eager falconBOT
rich nexus
#

That's pseudo code in Ruby, sorry

#

just for demo

boreal gyro
#

or the reference of my platform customer?

rich nexus
#

No, just the cloned payment method

boreal gyro
#

OK, I try ... 🙂

paper stratus
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

boreal gyro
#

OK, I am doing a quick test...

#

Just on question.
Here, I retrieve a platform customer and I attach a payment method to it.
Is that mandatory if the platform customer already has a payment method?

paper stratus
#

you can clone the Payment Method from the platform's customer

boreal gyro
#

To continue on the same conversation...
Now I have the error message "clone_payment_method is not defined" and my code is
const customerConnecte = await stripe.customers.create({ payment_method: clone_payment_method, }, { stripeAccount: req.body.destinationAccountId, } );

#

and just above (where I clone the payment method and attach it to the connected account) :
paymentMethodConnecte = await stripe.paymentMethods.create({ customer: customerId, payment_method: paymentMethodId, }, { stripeAccount: req.body.destinationAccountId, } );

paper stratus
#

"clone_payment_method is not defined" means that the clone_payment_method variable you're using here payment_method: clone_payment_method, is undefined

boreal gyro
#

Ok, I found the solution, I passed the payment_method id of the cloned payment method.
Now, I have successfully :

  • retrieved the platform customer
  • cloned the payment method of that customer to the connected account
  • cloned the customer to the connected account

I then try to create an ephemeral key with the id of the connected customer and I receive an error 'no such customer cus_[connectedId]'

#

Is that the correct process? (it is the one I used to receive platform payments : creation of ephemeral key and then creation of the paymentIntent)
And which id must I pass (platform customer of connected account one)?

paper stratus
#

when you created the ephemeral key did you use the stripeAccount header?

boreal gyro
#

no

#

I have to?

paper stratus
#

yes

#

whenever your accessing objects on your connected account

#

you need to pass the stripeAccount header

#

otherwise the request would be on your platform's account

boreal gyro
#

Thanks !

#

I have a more general question.
I have my customers on the platform and when they want to make a payment I clone the payment method and then the customer to the connected account.
Let suppose that at that moment the customer add a new card. Wil that new card be reflected on the customer account un the platform?

paper stratus
#

Let suppose that at that moment the customer add a new card. Wil that new card be reflected on the customer account un the platform?
it depends on your integration

boreal gyro
#

To go back to my app, it crashes... I suppose I don't have the good syntax :
const ephemeralKey = await stripe.ephemeralKeys.create( {customer: customerConnecte.id}, {stripeAccount: req.body.destinationAccountId}, {apiVersion: '2022-11-15'} );

paper stratus
#

const ephemeralKey = await stripe.ephemeralKeys.create(
{customer: customerConnecte.id},
{stripeAccount: req.body.destinationAccountId, apiVersion: '2022-11-15'}
);

boreal gyro
#

OK, thanks a lot !

paper stratus
#

let me know if you need any more help

boreal gyro
#

I will not hesitate ! 😉

paper stratus
#

be my guest 🙂

boreal gyro
#

And the good news, it seems to work ! 🙂

#

May I ask you to also thank orakaro for me?
I really appreciated your help and your patience !

paper stratus
#

glad to hear that

boreal gyro
#

I will probably come back to you for that point of the connected account customer who adds a new card and the reflection into the platform customer

paper stratus
#

it's going to be really hard to keep syncing between the platform's customer and the connected account's customer

#

one way you can do that, is to pass in the platform's customer ID in the metadata of the connected account's customer

#

it's really not that straightforward