#Bernard Paulet
1 messages · Page 1 of 1 (latest)
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
You should use the Customer Id of the Platform. In this request req_bT848vkPzuXim5 you used cus_O7Zp5Jiou0U8dS which is the Connected Account customer
That's the strange element... I tried with both but always receive the error referring to the connected account one...
Could you share the request id failed, but with your Platform Customer Id?
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}
);
}`
Sure, can you find the request Id which used cus_NRNnvtzUxZp9Lp?
req_bT848vkPzuXim5 used cus_O7Zp5Jiou0U8dS instead
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)
https://dashboard.stripe.com/test/logs/req_bT848vkPzuXim5 here you can confirm
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
you have the Dashboard request log
I made i run once again and now it's working...
That lucky bit comes when you talk to us 😉
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?
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
Ok, I missed that point !
pseudo code
newCus = Stripe::Customer.create({
payment_method: clone_payment_method,
}, {
stripe_account: 'acct_xxx', # Connected Account
})
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?
or the reference of my platform customer?
No, just the cloned payment method
OK, I try ... 🙂
👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
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?
you can clone the Payment Method from the platform's customer
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, } );
"clone_payment_method is not defined" means that the clone_payment_method variable you're using here payment_method: clone_payment_method, is undefined
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)?
when you created the ephemeral key did you use the stripeAccount header?
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
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?
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
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'} );
const ephemeralKey = await stripe.ephemeralKeys.create(
{customer: customerConnecte.id},
{stripeAccount: req.body.destinationAccountId, apiVersion: '2022-11-15'}
);
OK, thanks a lot !
let me know if you need any more help
I will not hesitate ! 😉
be my guest 🙂
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 !
glad to hear that
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