#irfanullah7513_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. Thank you for your patience!
⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
🔗 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/1214099798567690331
📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.
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.
- irfanullah_connect-customer-paymentmethods, 2 days ago, 23 messages
- irfan-ullah_code, 4 days ago, 14 messages
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
https://dashboard.stripe.com/test/logs/req_gbCLKVFL1Q5K1P OK I found the request ID.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
This request failed because you specified the stripe_account in the request param.
req_QtDvqhRvXaTvAf
You should specify a stripe_account in the request header instead.
You can refer to this doc to learn more about making API request for connected account (https://stripe.com/docs/connect/authentication)
Ah OK, you passed the connected account ID in the request header in the second request
I already specified the stripe_account
$result = $stripe->paymentMethods->attach(
'pm_1Oq8mXC3fRpXjzyoGStdmEme',
[
'customer' => 'cus_PNbkUIBmefytXN'
],
['stripe_account' => 'acct_1OSa5uC0wiqTfzk5']
);
Ok, but the payment method was created in the platform, and that's why it's not accessible in connected account yet.
Instead of attaching it to a customer directly, you need to clone it to the connected account https://docs.stripe.com/payments/payment-methods/connect#cloning-payment-methods
Okay, let me try with cloning
I using the following now I am getting error no customer even the customer exist under the connect account
$result = $stripe->paymentMethods->create([
'customer' => $stripe_customer_id,
'payment_method' => $payment_method_id,
], [
'stripe_account' => $this->connected_account_id
]);
req_Ui67j0kuLFiwaJ
You must provide the Customer ID in the request when cloning PaymentMethods that are attached to Customers for security purposes.
The customer ID here is the ID of the platform customer of which the payment method is attached to, not the ID of a connected account customer.
Where I can get the platform customer ID, because I have main account where I have created the connect account and under the connect account I created the customers.
You need to attach the payment method to a customer before you can clone it to a connected account.
If it's not, clone it without specify the customer in the request.
But I am specify the customer but the customer is under the connect account
As I said earlier, the customer should belongs to platform, not connected account. If the payment method wasn't attached to any customer, you can should just remove customer from the request.
It is possible to clone PaymentMethods to connected accounts without previously attaching them to Customers. However, note that the original PaymentMethod will be consumed, since PaymentMethods that aren’t attached to Customers can only be used once.
So for this I will create first the customer outside of the connect account and create the payment method for it and then I will clone this payment method for the customer under the connect account
" the customer outside of the connect account " -> I assume you mean the customer in platform?
Ok Have you tried?
I used the following code then got the following response, but I am confuse because the payemnt method is not attach to the customer under the connect account
$result = $stripe->paymentMethods->create([
'customer' => 'cus_Pb3unEeVnuSelp',
'payment_method' => $payment_method_id,
], [
'stripe_account' => $this->connected_account_id
]);
Stripe\PaymentMethod Object
(
[id] => pm_1OqW0sC0wiqTfzk5HZxKMD7F
[object] => payment_method
[billing_details] => Stripe\StripeObject Object
(
[address] => Stripe\StripeObject Object
(
[city] =>
[country] =>
[line1] =>
[line2] =>
[postal_code] =>
[state] =>
)
That's because you haven't attach it to any customer in the connected account yet.
in this code the customer id will be the connect account customer?
$result = $stripe->paymentMethods->create([
'customer' => 'cus_Pb3unEeVnuSelp',
'payment_method' => $payment_method_id,
], [
'stripe_account' => $this->connected_account_id
]);
No. Let me give you a summary so that we can be in the same page.
- Clone the payment method by using
$stripe->paymentMethods->create, thecustomerin the request param should belongs to platform - Attach the payment method to a customer in connected account by using
$stripe->paymentMethods->attach, thecustomerin the request param should belongs to the connected account.
Okay, but when I created the payment using the Stripe.js, is it not creating as a platform customer
stripe.createPaymentMethod({
type: 'card',
card: elements[0] // Assuming elements[0] represents your card Element
}
No, Stripe.js doesn't have an API to create a customer
You need to create a customer from your backend
If I create the token using the Stripe.js it also have the same flow?
If the question is about whether can can create a customer through tokens API from Stripe.js, No, Stripe.js doesn't have an API to create a customer