#RGRTHAT

1 messages ยท Page 1 of 1 (latest)

wide anchorBOT
amber kestrel
elder sphinx
#

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?

amber kestrel
#

Yes, give me couple of minute while I check

elder sphinx
#

10 sec.

#

@amber kestrel req_1KHWfOX1g0aW3B

spice ravine
elder sphinx
#

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

elder sphinx
#

@spice ravine but Im not trying to clone payment method

spice ravine
#

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?

#
  1. Created on which Stripe account? The platform?
  2. 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

elder sphinx
#

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?

spice ravine
elder sphinx
#

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

spice ravine
#

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

elder sphinx
#

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?

spice ravine
#

Well the assumption in this flow is that you capture payment details before cloning

elder sphinx
#
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?

spice ravine
#

The resulting pm_xxx object and cus_xxx can then be cloned to the connected account(s), and used with a Payment Intent

elder sphinx
#

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

spice ravine
#

Well, yes. But you won't be able to clone the customer from the platform without a PM

elder sphinx
#

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
elder sphinx
#

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

spice ravine
elder sphinx
#

only issue is that the paymentIntent will not have the customer object attached...

spice ravine
elder sphinx
#

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

spice ravine
#

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

elder sphinx
#

yeh

elder sphinx
spice ravine
#

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

elder sphinx
#

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

spice ravine
#

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

elder sphinx
#

Yeh

weary rapids
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

elder sphinx
#

Thanks for help @spice ravine, I will try the integration @weary rapids I will let u know shortly if i stubble across problems

weary rapids
#

yes sure ๐Ÿ™‚

elder sphinx
#

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", ""],
weary rapids
#

generally you shouldn't rely on payment_method_types but rather on automatic_payment_methods

elder sphinx
#

yeh thats what i actually wanted

#

but this gave me error ```js
payment_method_types: {
automatic_payment_methods: true
}

weary rapids
elder sphinx
#

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?

weary rapids
#

why are you doing SetupIntents though?

elder sphinx
#

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

elder sphinx
weary rapids
#

on a Connected Account?

elder sphinx
#

yup

weary rapids
#

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

#

here is the list of potential values

elder sphinx
#

@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."

main radish
#

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?

elder sphinx
#

@main radish req_RNokauHPQcm6Ip

#

I suspect it is because when i create the customer initially I dont pass this prop ```js
source: 'tok_mastercard',

?
main radish
#

I believe so, it doesn't look like a Source was created for that Customer.

elder sphinx
#

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?

main radish
#

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.

elder sphinx
#

@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?

main radish
elder sphinx
#

@main radish

#

wierd it says its no such customer

main radish
#

There seem to be a couple functions there that have a customer variable, do you know which one raised that error?

elder sphinx
#

@main radish its the stripe.paymentMethods.create() that causes the error

main radish
#

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.

elder sphinx
#

true

#

but the initial customer is not a customer from the connected account

#

the initial customer is a platform customer

main radish
#

Correct

elder sphinx
#

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

main radish
#

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.

elder sphinx
#

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

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.

elder sphinx
#

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

main radish
#

What IDE are you using? VS Code presents me with autocompletion options when I'm working with our Node library.

elder sphinx
#

vscode & i use node.js

#

stripe is one of the few that dont give me intellisens

main radish
#

In that example, did you already declare and initialize stripe?

elder sphinx
#

exactly like ur above. I required and initialized it with key yes

#

u dont get intellisens aswell

dry tapir
#

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

elder sphinx
#

@dry tapir according to ur picture above, u dont get intellisens

#

no i simply just installed the library with ```js
npm i stripe

dry tapir
#

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?

elder sphinx
#

yes

#

I get no property suggestions at all

#

with intellisens i mean prop suggestions

#

like typescript suggestions

dry tapir
#

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

elder sphinx
#

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

dry tapir
elder sphinx
#

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

dry tapir
#

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