#RGRTHAT
1 messages ยท Page 1 of 1 (latest)
๐ Hi there, Happy to help!
You need to clone the customer in your connect account, you check this link
https://stripe.com/docs/connect/cloning-customers-across-accounts
let me try. 10 sec
cuz I have no clue what "source" / payment method the customer will use?
@amber kestrel How do I know which source to input?
I cant specify ```js
source: 'tok_mastercard'
@amber kestrel you there?
Yes, give me couple of minute while I check
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
I wouldn't recommend using Tokens and/or Sources. You should be using Payment Method objects: https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods
This payment is the first payment, so the customer have no payment source attached. The customer object initially is just the required props like email
All i try to do is add the customer.id to the paymentintent of the connected account
let me take a look
@spice ravine but Im not trying to clone payment method
But that's how you should be approaching this: create and clone PMs, not the Customer objects
Otherwise you can't clone Customers the way you were trying without an attached Source/Token, but those are old/deprecated APIs
What is the exact flow you're trying to build with Connect?
- Created on which Stripe account? The platform?
- What kind of Connect payments are you creating? Is there an example I can check?
Yes, that sounds like you're creating a 'direct charge' by passing the Stripe-Account header. In which case yes, the objects need to exist on that connected account
But all customers on the platform shouldnt really be attached to any specific connected account, as there will be tons of connected accounts on the platform
yes this is a direct charge payment
How can I add the platform customer to the customer prop in the connected account paymentIntent?
Then they'll need to be cloned to the related connected account for each direct charge
You can't
So how should I approach this? Do I need to create a customer object for each new connected account the customer buy from?
I thought platform customers that were not attached to any connected account, could simply just be attached by adding them to the paymentIntent. That way the paymentIntent reference to which customer that payed
Yep, but the benefit is that they won't need to re-enter payment details (i.e. if you setup their card on the platform and then clone that to the connected accounts โ like I originally linked)
You don't need to use Customer objects, but that's the only way to clone payment data between accounts โ if they're attached to a customer
So you have to weigh up your customers having to re-submit payment information each time they checkout with a different connected account
I see, let me take a deeper look at the link u linked
@spice ravine If I have to create a customer for each new connected account the customer interact with, that means that in the first transaction, I cant attach customer object to the paymentIntent.
I have to create the payment_method after the paymentIntent, because i need to retrieve the payment_method from the paymentIntent?
Well the assumption in this flow is that you capture payment details before cloning
my flow is that
1. Request is called on mount. PaymentIntent is initialized & sends client_secret from server to client.
2. The user write down payment details & click pay. This with call the stripe.confirmPayment() function client-side.
@spice ravine Its not possible to capture payment_method details before the paymentIntent is initialized?
Sure it is. What I'd recommend is using a Setup Intent on the platform account to capture and save payment details to your platform Customer object: https://stripe.com/docs/payments/save-and-reuse
The resulting pm_xxx object and cus_xxx can then be cloned to the connected account(s), and used with a Payment Intent
Iยดm not sure If I want to ask for payment details before the user tries to do his first payment @spice ravine
Is it possible to collect payment_method when customer does his first transaction somehow?
Or do I need to make a seperate request after the first payment. Make a seperate request where i send payment_method to server, and then create payment_method and server. The only issue is the first paymentIntents wont have a customer attached to it
Well, yes. But you won't be able to clone the customer from the platform without a PM
But this wont work, because the paymentIntent is initialized before the customer inputs his payment details
@spice ravine Are all stripe payment flows made so u have to initially ask for payment details before any transaction take place, if u want to save customer to the connected account paymentIntent?
1. I dont want user having to input details all the time for each new connected account
I don't understand the ask
I confirm the paymentIntent clientSide. with stripe.confirmPayment()
maybe i should confirm it serverside?
and that way I can capture the payment_method and add a customer and payment_method
What you want to do just isn't possible unfortunately. You have 2 options:
- Manage customers and PMs on a per connected account basis: https://stripe.com/docs/payments/payment-methods/connect#confirming-payment-intent
- Create customers and attach/save PMs at platform level (without a payment), and then clone to the connected accounts.
only issue is that the paymentIntent will not have the customer object attached...
But then that object will be on the connected account and can't be cloned to other connected accounts
this confuse my eyes out lol. I want to add a simple customer object to the paymentintent, but i cant add the customer.id, because it requries a payment method
No, you can't clone the Customer because it requires a PM. That's the only reason for cloning Customers โ to clone PMs. There's no value in cloning a Customer object that just has arbitrary fields like email
Yes, as I've stated that's not the issue here
That's a perfectly normal way to integrate
The issue you have is you're trying to add a cus_xxx that exists on the platform, not the connected account. This won't work for direct charges
yeh
which of these 2 do u recommend
Well it depends on your business!
How many connected accounts do you envision having? Will it be difficult to juggle n customers per connected account?
You said you don't want to collect payment details without a payment, so that doesn't sound like an option
I think maybe the 2nd is best. Cuz with 2nd I can create a regular customer, initially get their payment details. Then save the customer_id to the database of user. Then when customer is going to pay, I just clone the customer that has a payment_method attached to it
Yup, exactly
That would be my preference. You can direct customers to setup payment details before processing the initial payment(s)
It's a small tradeoff for a better integration
Yeh
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
Thanks for help @spice ravine, I will try the integration @weary rapids I will let u know shortly if i stubble across problems
yes sure ๐
How do I know what strings to input here ```js
https://stripe.com/docs/payments/payment-methods/overview#cards
it just says the differnet methods. but i need to find the strings i can put inside the array. List of the "method codes" to put in the array
payment_method_types: ["card", "transfer", ""],
generally you shouldn't rely on payment_method_types but rather on automatic_payment_methods
yeh thats what i actually wanted
but this gave me error ```js
payment_method_types: {
automatic_payment_methods: true
}
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Im doing a setupIntent to collect payment details
@weary rapids doesnt seem the setupIntent have that prop?
maybe not specify payment_method_types at all?
why are you doing SetupIntents though?
yes
cuz i need to collect the payment details first
my payment flow is that i collect payment details from users first, before the initial payments
cuz i need to clone my customer and attach it to the paymentintents
When specifiying nothing, the only available thing is card
clone where?
on a Connected Account?
yup
i do the second one here
read this
ok sorry was catching up
so unfortunately SetupIntents don't support automatic_payment_methods
and you're right you have to pass the payment_method_types array yourself
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
here is the list of potential values
@weary rapids Im not able to create a token
Im trying to clone my customer & paymentMethods so I can use it for my connected account
it says ```js
"Error: The customer must have an active payment source attached."
Hi ๐ I'm jumping in as my teammate needed to step away.
Can you share the request ID (req_XXX) from the request where you encountered that error?
10 sec let me check dashboard
@main radish req_RNokauHPQcm6Ip
I suspect it is because when i create the customer initially I dont pass this prop ```js
source: 'tok_mastercard',
?
I believe so, it doesn't look like a Source was created for that Customer.
but is ```js
source: 'tok_mastercard',
i thought source was dynamic, and was actually meant to be the paymentMethod or something
mastercard seems very specific for the customer. What if the customer has visa card for example?
tok_mastercard is a test value. We provide test values that allow for the recreation of specific scenarios when working in test mode, you can find our complete list of available test cards here: https://stripe.com/docs/testing?numbers-or-method-or-token=tokens#cards
Source objects do represent a customer's payment method, but if you're working on a new integration then you should be looking at using our Payment Method objects instead, which are our newer implementation and replace Sources.
@main radish I thought that my "setupIntents" function earlier "appended" paymentMethod to the customer or something, and then all i had to do was to clone the customer object
@main radish as i create a paymentMethod instead of token, when i clone my customer to use it on a connected account paymentIntent, how should i do that?
Ah, it does look like you're creating Payment Methods, so you'll want to follow the approach that my teammate provided earlier, the main difference from what you're doing now is you'll also need to provide the ID of the Payment Method and create a Payment Method instead of a token:
https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods
There seem to be a couple functions there that have a customer variable, do you know which one raised that error?
@main radish its the stripe.paymentMethods.create() that causes the error
It looks like you're passing it the ID of the newly created Customer, not the Customer that you're trying to clone the Payment Method from.
true
but the initial customer is not a customer from the connected account
the initial customer is a platform customer
Correct
thats why i need to first clone that customer, and make it a "connected account" customer?
thats why i specify "stripeAccount" here, ```js
const customer = await stripe.customers.create({
stripeAccount: service.stripe_account_id,
});
oh i see
That's creating the new Customer on the Connected account, yes. The Payment Method creation request though is expecting the ID of the existing Customer and Payment Method object from the Platform account, the result of that request is that a Payment Method is created on the Connected account from that information.
I see
The error is gone
How can I prefill the card element with the payment method? is that possible?
when i do this, i dont really clone the customer. i create a new one. How can i clone the existing props from the old customer? without passing all the customer props again? like email, name, metadata
const customer = await stripe.customers.create({
stripeAccount: service.stripe_account_id,
});
@main radish
No, you can't prefill the Payment Element.
If you want to copy information from the Customer record on the Platform, then you would first retrieve the Customer object from your Platform account and use the information within it when creating the new Customer object on your Connected account.
I see. One last question that have annoyed me is. why doesnt stripe api have intellisens?
almost all other apis i use have intellisens
i get absolute no intellisens & props recommendations from stripe api
What IDE are you using? VS Code presents me with autocompletion options when I'm working with our Node library.
In that example, did you already declare and initialize stripe?
exactly like ur above. I required and initialized it with key yes
u dont get intellisens aswell
Hello, toby is stepping out but I can help out. Catching up here now...
Yeah huh just automatically working for me too. And how did you install the node-js library here? Is it installed to some custom directory maybe? I am not immediately sure why this would be broken but am looking in to it
@dry tapir according to ur picture above, u dont get intellisens
no i simply just installed the library with ```js
npm i stripe
Is code completion not part of Intellisense for VSCode? I thought it was for other versions of visual studio
Ah I see, that is based on the strings in my file, not intellisense
That second screenshot would be intellisense then correct?
yes
I get no property suggestions at all
with intellisens i mean prop suggestions
like typescript suggestions
So I found this GitHub issue for this https://github.com/stripe/stripe-node/issues/1039
Hello, I'm trying to follow the Stripe "Accept a Payment" integration tutorial here: https://stripe.com/docs/checkout/integration-builder but Intellisense in VS Code (http...
And adding "type": "module" to my package.json file does give me some intellisense stuff here but not specifically when typing things like stripe.customer
I see, i will try it out
Previously i created a customer connected to the connected account during paymentintent. If this same customer try to make another paymentIntent on the same connected account, with current code I will create a new customer everytime
i suppose i need to create a conditional, and only create connected account customer if the customer doesnt exist
i see the customer.retrieve function can only filter by customer id
i suppose i need to use the customers.search and specify a query
query based on metadata or something
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You can also use customers.list and filter by email if you are setting the email on these customer objects https://stripe.com/docs/api/customers/list#list_customers-email
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
u cant filter by something else
i cant just filter by email
cuz many customers can have same email, because it will be created customer for each new connected account
so i need to fetch all customers where connected account is something and also email
Gotcha, so yeah you will need to use search + metadata here
Also one quick thing to keep in mind is that changes to a customer object can take up to a minute to become searchable. Not sure how relevant that may be to you but I have seen some people run in to problems when they think it will be instant