#spanila
1 messages · Page 1 of 1 (latest)
customer id is cus_OaVacWYqyN9tla
hi, yeah unfortunately the docs are really bad
you need to do what is described here : https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods , not what is described in step 2 of the guide you linked(which only works for customers using legacy payment instruments, but we still have not updated those docs).
i will try right away
but to clone paymentMethod, i first need to create customer on the connected account right?
and the token step was doing just that
no, you don't need a Customer on the connected account, but you do need one on the platform
in the snippet of code at that link, the CUSTOMER_ID is the ID of the customer on the platform whose card you are cloning(which I know is a confusing since it looks like you're making that request on behalf of the connected account so you'd usually expect the IDs to have to exist on the connected account; this request is the one exception to that rule).
oh, so this is shared customer of sorts. nice
well shared customers would be GREAT
nvm
paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: 'usd',
customer: clonedCustomer? clonedCustomer.id : null,
automatic_payment_methods: {enabled: true},
application_fee_amount: fee,
use_stripe_sdk: true,
capture_method: 'manual',
description: event.course.name + ' ' + U.formatDatetime(event.datetime, event.trainer?.user?.timezone),
metadata: {
eventID: event.id,
userID: self.user.id,
eventAttendanceType: U.getEventUserAttendanceTypeByCode(params.eventAttendanceType),
}
}, stripeOptions);
this is the way i was creating paymentintent. but now i have paymentmethod (single, would be great if multiple were possible) and no customer. how can i add the customer and multiple payment methods?
well after cloning you have a PaymentMethod that exists on the connected account, that's it
so to charge that you can create a PaymentIntent with like {amount:500, currency:usd, payment_method:"pm_clonedPaymentMethodID"},{stripeAccount:"acct_xxx"} , you don't explicitly need another Customer on the connected account
now if you do want to have a Customer on the connected account and add the cloned payment method to that, then you can, you'd create a new Customer (with the stripeAccount option) and use https://stripe.com/docs/api/payment_methods/attach , AFAIK
usually I suggest not storing the PaymentMethod on the connected account if you can avoid it, since it's generally easier if you use the platform customer as the source of truth and then clone on demand when you need a payment
i liked the idea of having platform customers with multiple payment methods and then when creating paymentintent, i would populate frontend component with customer and he can choose the right card.
the way you suggested - suppliying payment method really restricts the user to the default payment method. whats the point of adding cards then.
so i would like to keep customer in paymentmethod if possible and clone it, but the cloning part was token request that failed right?
const token = await stripe.tokens.create(
{
customer: '{{CUSTOMER_ID}}',
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);
so is there another way to clone customer?
there is no such thing as cloning a 'customer'
then i could clone the paymentMethods on connected accounts as you showed me and attach them. and they should be on the ui together with customer information for connected account user.
that is just a misnomer and part of the awful docs I referenced
😄
what is actually cloned is the customer's payment method, and that is all
cloning using tokens doesn't work becuse that's a legacy way, but https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods is the same thing
forget about tokens
the token code, and https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods, do the exact same thing, just one is for legacy objects and one is for current objects
but they do the same thing, which is copy a Customer's payment method from the platform to the connected account. And that's all they do, and that is all that the API provides, that is the building block, and using that the idea is you can build a concept of a "shared customer" in your integration (which is why it's called that in the docs)