#kautuva-clone-source

1 messages · Page 1 of 1 (latest)

lone pier
#

Hi there, can you show me the code?

dusk apex
#

const tokenRequest = {
customer: stripeCustId,
card: chosenSource
}

const opts = { stripeAccount: stripe_account_id }

await stripe.tokens.create(tokenRequest,opts)

#

chosensource here is cloned source on connect account
stripeCustId is id of customer on connect account

stripe_acct_id is the account id of the connected account

#

req_id:
req_kbi1ex3VxOL3yE

lone pier
#

stripeCustId -> is this a platform customer or connect account customer?

dusk apex
#

connect

lone pier
#

The ID of the customer in your platform account -> the API is expecting the platform customer, not connect account customer

dusk apex
#

when I use the token to create the charge it'll charge which customer if I use platform customer id to create the token?

#

connect customer or platform customer?

#

also, I'm not cloning customer, only the source

#

creating two customers separatly

#

I want the token to create a charge on my connect customer

lone pier
#

Ok, so the purpose of this source cloning is to clone your platform customers' payment information across multiple connected accounts for reuse.

That's why the API is expect you to pass the platform customer ID when creating the token

Before you making charge to the customer on connect account, you have to create a new customer with source = token.id, and then charge on the newly created customer.

dusk apex
#

I already have my connect customer

#

I created it normally without any cloning

#

I just want to use my cloned source with that customer

#

Now, how do I do that?

#

This is the reason why I created the second customer without passing any source id

#

I attached the clone separately

#

Now I just want to charge that customer

#

So if the cloned source is attached to the customer on connect....can I just charge it?

lone pier
#

Yes, you can charge the customer on connect. But first you need to fix the source cloning problem.

dusk apex
#

I've already cloned my source and attached it to the customer I created on connect account

lone pier
#

So you have fixed the stripe.tokens.create problem that you mentioned earlier?

dusk apex
#

No, that is the problem. If I'm passing the platform_customer_acct_id and the cloned_source while creating the token how do I charge the connect_customer_account?

lone pier
dusk apex
lone pier
#

Can you send me the link?

dusk apex
lone pier
#

Got it, so you want to know how to make a direct charge, am I right?

dusk apex
#

yeah

#

I'm using the platform api key

lone pier
#

Cool, it's very similar to the way how you create customer on connect account

#

it's like creating a normal paymentIntent, just need to add in the stripeAccount header in the request.

#

You can specify the cloned customer ID, as well as the cloned payment method ID in the payment intent creation request

dusk apex
#

I can't create a charge? Why are we creating a payment Intent?

lone pier
#

Just to clarify, are you cloning a payment method or source?

#

If you want to make direct charge with Charge API, it's the same thing, just pass in the connect account ID in the stripeAccount header and you are good to go

dusk apex
lone pier
#

OK, btw Source and Charge are the old APIs. I'd recommend to use Payment Intent and Payment Method if possible

dusk apex
#

Yes, we'll be migrating to that too

#

But we already have a ton of existing customers with sources

#

while creating the charge which source id should I pass as parameter? the original source ( on platform ) or cloned source ( on connect ? )

#

I want the charge on connect

#

and the cloned source is attached to customer on connect

#

doesn't seem to work if I pass the cloned source id in the id parameter

#

it probably expects a token

#

req_blZPMpNC2YcZPR

#

it says I've not passed a source at all

lone pier
#

You didn't pass a source or customer, as the error says

#

you should pass the cloned source or customer.

dusk apex
#

I am passing the cloned source

#

const stripeResponse = await stripe.charges.create(
{
amount: adjustedAmount,
currency: plan_record.currency,
source: source.id,
description: Charge for customer id ${plan_record.fk_customer},
metadata: {
orderId: plan_record.fk_orders,
...plan_record.additional_info,
},
statement_descriptor: brandCharge
},
{
idempotencyKey: transaction_key,
stripeAccount: stripe_account_id
}
);

#

this should work?

lone pier
#

I don't see customer or source in iar_blZPMpNC2YcZPR

dusk apex
#

if source is the cloned source?

lone pier
#

Yup, it should work, can you try?

dusk apex
#

Yes. Trying that

#

Yes, that seems to have worked.

#

Thanks a lot Jack

lone pier
#

Cool! I'm so happy to hear that!

#

My shift is ending soon, do you need me to keep this thread open?

dusk apex
#

I think you can archive it if you please

#

Thanks for all the assistance

lone pier
#

OK, I will archive it then, feel free to come back if you have any questions