#dvdmn-clone-card

1 messages ยท Page 1 of 1 (latest)

deep lotus
#

Sure but there's a lot more to it than just this sentence. for example why are cards on the platform if you do direct charges?

#

Ultimately, you haven't really given me an example of the error so it's hard to explain but you are likely passing the wrong params when you charge

#

Basically if you give me an example error, or an id, I can try and look it up to see what the error is and then explain what to change in your code, does that make sense?

stiff oasis
#

why are cards on the platform if you do direct charges?
because the platform charges the customer for a different product (like monthly subcr)

deep lotus
#

gotcha

stiff oasis
#

error: Customer cus_xxxx does not have a linked source with ID card_xxx.'

#

I guess I need to understand how stripe connect works 1st..

please correct me if I am wrong... platform account & the connected account are totally separate and nothing (customer or card) is shared between them. that is why I need token

deep lotus
#

correct

#

please provide me with a real example not the redacted error message. I can't help without an exact request id

stiff oasis
#

sorry about that
Customer cus_KwmsXP3Tu7N9YB does not have a linked source with ID card_1Jv2eRHTaLbc7iCqZXv9ToJI.'

deep lotus
#

perfect, let me look

stiff oasis
#

this is the code..

deep lotus
#

Okay so the Customer cus_KwmsXP3Tu7N9YB is the new one you created on the connected account. But the Card id card_1Jv2eRHTaLbc7iCqZXv9ToJI is incorrect because it's the id of the card you cloned, the one from the platform so that's the issue

stiff oasis
#

yes.. I could not find a way to add card to 'customer' I cloned for connect account

deep lotus
#

I don't understand what entry.cardID is in your code, but that's the overall problem you have. You can't do that. You saved a brand new card on the Customer when you create the new customer. You have to use that new card id instead for the charge

#

you already are, you are passing Source = token.Id

#

this is an old drawing I made

#

you see how the platform has cus_AAA card_111 and the connected account has cus_123 and card_ABC?

#

right now you are saying "please charge cus_123andcard_111`

stiff oasis
#

entry.cardID => card_1Jv2eRHTaLbc7iCqZXv9ToJI

deep lotus
#

yeah that's the wrong id

stiff oasis
#

the one saved on the platform account

deep lotus
#

that's the card id on the platform, which doesn't make sense

#

you explicitly went and cloned the card to have a brand new card on the connected account, so you need to reference that card

#

Really, let me simplify this for you entirely: remove the line Source = entry.cardId on the last bit. That way you do not say which card to charge, you let us charge the default card which is fine since it's a brand new customer with just one card

stiff oasis
#

my assumption was customer's cards are automatically shared over token since the default cardID appears on the cloned customer object.

#

you let us charge the default card which is fine since it's a brand new customer with just one card
that is the problem

#

we have a customer who manages two youth baseball teams and he want to use dedicated credit cards for each team

deep lotus
#

I'm sorry, please look at my exact drawing, that tells you all the relevant objects

stiff oasis
#

his default card belongs to team A, he wants to pick the 2nd card he has in the account for other team's transactions

stiff oasis
#

let me re-type the code and get the error message

deep lotus
#

I've explained the exact issue in your code above, did you see all my messages?

#

I clearly said what line of code is incorrect

stiff oasis
#

I understand the payment option part... I was talking about the token creation

#

I cannot use the card_1Jv2eRHTaLbc7iCqZXv9ToJI for the payment directly, I get it

deep lotus
#

I'm sorry, I don't follow you. I feel like I told you exactly what to hcange, and I don't get what's blocking you right now. I need you to be a bit more explicit about what is blocking you

stiff oasis
#

this is how I create the customer token

                  var token = new TokenService().Create(
                    new TokenCreateOptions {
                        Customer = stripeCustomer.customerID, // cus_KaD4yIMYQNfpz6
                        Card = entry.cardID // card_1Jv2hCHTaLbc7iCqjxWqSVpZ (2nd card)
                    },
                    new RequestOptions {
                        StripeAccount = directorAccount, // connected account
                    }
                );
#

is it the right way?

deep lotus
#

Ahhhhh

#

sorry I get it now

#

And yes Card = entry.cardID is how you tell us "I want to clone that specific card from the platform customer". If you don't pass it, we just clone the default one

#

duh, I should have seen that's what you meant, I thought you were already cloning the right one

stiff oasis
#

I just created this token tok_1KHCUFC9ocJF4bGwTsJ0CiRq

deep lotus
#

yeah that Token cloned the card card_1Jv2hCHTaLbc7iCqjxWqSVpZ from the platform

stiff oasis
#

can u check it on your end to make sure it has the right card, not the default one

#

cool

deep lotus
#

And so now you use that Token id tok_1KHCUFC9ocJF4bGwTsJ0CiRq to create a Customer with that new card and you will get a new Customer cus_AAAA with a new card id card_XXXXXX different from the platform one

stiff oasis
#

ok let me do that

#

like this?

var customer = new CustomerService().Create(
new CustomerCreateOptions {
Source = token.Id,
},
new RequestOptions {
StripeAccount = directorAccount,
}
);

#

it worked

deep lotus
#

Cool and now you need to charge that customer's card

stiff oasis
#

var paymentOptions = new ChargeCreateOptions {
Amount = amount * 100,
Currency = "usd",
Source = customer.DefaultSourceId,
Customer = customer.Id,
Description = $"Event Entry for {divisionData.eventName} | {divisionData.teamName}",
ReceiptEmail = stripeCustomer.email,
StatementDescriptor = siteName,
ApplicationFeeAmount = 100, // ### TINC FEE ###
};

#

is this the card with expiration 11/2023?

card_1KHCaUC9ocJF4bGwUDUeTLJa

#

it comes as defaultsourceID for the new customer I cloned

deep lotus
#

yeah that's because you are creating a brand new customer, with a brand new card/token. So that card becomes the default

#

Let's say, later, you want to add the other card to that customer. Instead of the Create Customer API you will use the Create Card API https://stripe.com/docs/api/cards/create and that will return a card_123456 as the new id to use in your charge

stiff oasis
#

cool

deep lotus
#

Are you unblocked?

stiff oasis
#

it is all good now, thank u so much for the help

deep lotus
#

yay!

#

congrats, sorry for all the back and forth. That flow is so easy once you get it, but it takes so long to "get it"

stiff oasis
#

12/2022 card was the default card for that customer.. payment shows the nov/23 expiration

deep lotus
#

woot!

stiff oasis
deep lotus
#

yeah it's hard to describe/explain unfortunately ๐Ÿ˜ฆ

stiff oasis
#

my assumption was 'customers are shared between platform & connected accounts"..

#

that would make things easy for me, but I can imagine the "pain" it would cause on stripe side of the system..

#

it is all good now, thanks again