#Alfie-cloning-pms

1 messages · Page 1 of 1 (latest)

slate cargo
#

Hey, can you share an example Customer or Payment Intent ID?

frosty trellis
#

cus_LZaXW0GnWKDEXo This platform customer tried booking through this connected account. acct_1JuZuFKtQYabvPKI

#

Thanks 🙂

slate cargo
#

Can you share the cus_xxx from the connected account?

#

You wouldn't use that ID for a PI with direct charges

frosty trellis
#

So I believe the error came from trying to clone the customer to the connected account, because the customer hasn't appeared on the connected account in stripe dashboard

#
// first we need to tokenise the customer
        const token = await stripe.tokens.create({
            customer: stripe_customer_id,
        }, {
            stripeAccount: stripe_connect_id,
        });
        
        // and then use the token to clone the customer onto the connect account
        const customer = await stripe.customers.create({
            source: token.id,
        }, {
            stripeAccount: stripe_connect_id,
        });

        // then we can clone the existing payment method for the customer (from the card they created)
        const clonePaymentMethod = await stripe.paymentMethods.create({
            customer: stripe_customer_id,
            payment_method: stripe_paymentMethod_id,
        }, {
            stripeAccount: stripe_connect_id,
        });

        // now we can attach the cloned pm to the cloned customer
        const attachPaymentMethod = await stripe.paymentMethods.attach(
            clonePaymentMethod.id,
            { 
                customer: customer.id,
            },
            {
                stripeAccount: stripe_connect_id,
            },
        );
#

This is the flow

#

I'm assuming the error happened somewhere in here

#

Should I be adding the (platform) payment method in the stripe.customers.create({ function?

#

But then it's worked without issues for a number of people

#

Final step

                            payment_method_types: ['card'],
                            amount: amount_to_pay,
                            currency: 'gbp',
                            application_fee_amount: 0,
                            statement_descriptor_suffix: 'Booking ' + professional.get('first_name'),
                            customer: result.stripe_customer_id,
                            payment_method: result.payment_method_id,

                            // We can charge immediately but we need the payment method.
                            confirm: true,
                            off_session: true,
                        }, {
                            stripeAccount: professional.get('stripe_connect_id'),
                        });
slate cargo
frosty trellis
#

Ahh awesome I didn't know about these logs. req_XOYsl3CkfHlzon

#

So yeah it's the token call.

#

These are the other two

req_P4Cu0q6rbNI8IO
req_JHgimFLNGQUue4

slate cargo
#

Will take a look soon

frosty trellis
#

Thanks

frosty trellis
#

Oh I had one other q, we are interested in the Stripe Terminal Tap to Pay beta. We are obviously UK based, will it be possible for us to join the beta soon at all?

slate cargo
slate cargo
frosty trellis
#

Thanks yeah will register interest.

slate cargo
#

General steps for PM cloning:

  1. Collect payment details and create PM on platform account (recommended via a Setup Intent which will attach to customer, and carry out 3DS).
  2. Create a new PM using the platform API keys, passing the Stripe-Account header:
const paymentMethod = await stripe.paymentMethods.create({
  customer: '{{CUSTOMER_ID}}',
  payment_method: '{{PAYMENT_METHOD_ID}}',
}, {
  stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
});
  1. Use in PI and pass setup_future_usage parameter to save to connected account Customer for on/off-session payments.
frosty trellis
#

So I don't need to clone the customer itself to the connect account?

#

We are currently using the connected customer id when we create the paymentIntent, is that not necessary?

slate cargo
frosty trellis
#

Isn't that contradictory? Or am I missing something? I need the customer_id on the connect account for direct charges, so I will need to clone the customer onto the connected account first right?

slate cargo
#

You don't need to clone the customer, you'd just create a new one on the connected account

frosty trellis
#

ahh ok

#

So here, I can replace this with just creating the new customer

        const token = await stripe.tokens.create({
            customer: stripe_customer_id,
        }, {
            stripeAccount: stripe_connect_id,
        });
        
        // and then use the token to clone the customer onto the connect account
        const customer = await stripe.customers.create({
            source: token.id,
        }, {
            stripeAccount: stripe_connect_id,
        });
#

I don't need to tokenise the platform customer at all

slate cargo
#

Yep! That's the old way of doing things pre-Payment Methods API

frosty trellis
#

Right. Thanks I'll try implementing that this afternoon after lunch!