#jayvir_api

1 messages ¡ Page 1 of 1 (latest)

minor sageBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1276462667195744257

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

harsh groveBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

ruby python
#

new

burnt cairn
#

Hi, what's exactly the challenge you're facing here?

ruby python
#

let paymentMethodDetails = await stripe.paymentIntents.retrieve(transaction_id, {
stripeAccount: config.connectedAccountId,
})

  const setupIntent = await stripe.setupIntents.create({
    payment_method: paymentMethodDetails?.payment_method,
    customer: customerId
  });

Error attaching PaymentMethod to Platform: StripeInvalidRequestError: No such PaymentMethod: 'pm_1PqUO5JRoJfA1S16xFRbeK8k'; It's possible this PaymentMethod exists on one of your connected accounts, in which case you should retry this request on that connected account. Learn more at https://stripe.com/docs/connect/authentication

#

i want to copy the payment_method in platform from one connected account
then use same payment_method to charge amount from another connected account

#

customerId is of platform account
paymentMethodDetails - 1st connected account

burnt cairn
ruby python
#

oh

#

then how should i proceed ?

#

platform account - A
one of connected account ie X - paymentIntent Method - created customer & payment method - payment happen here
one of connected account ie Y - use above method & card info charges once again
platform account - A - will get application fee from X - $3

Real example :

$106 - to be charged to user & by connected account ie X
$3 - taken by stripe
$3 - taken platform account - A as application fee
$100 - net received by connected account ie X

now again charges $5 from one of connected account ie Y

this should happen

i need to execute this

minor sageBOT
ruby python
#

Real example :

$106 - to be charged to user & by connected account ie X
$3 - taken by stripe
$3 - taken platform account - A as application fee
$100 - net received by connected account ie X

now again charges $5 from one of connected account ie Y

this should happen

i need to execute this

#

@candid chasm @burnt cairn guide me

burnt cairn
#

You should probably collect the PaymentMethod on the Platform account, and then copy it to the Connected accounts.

#

You can't copy PaymentMethods that were collected on the Connected accounts to any other account

candid chasm
#

yes I agree with @burnt cairn, if you want to share payment methods across different connected accounts you should save the payment method first on the platform and then you can clone it across all of your connected accounts when you want to

ruby python
#

bur how ?can u example me ?

candid chasm
#

you can read this guide for a start

#

and feel free to get back with any follow-ups

ruby python
#

const customer = await stripe.customers.create({
name: 'Jenny Rosen',
});

const setupIntent = await stripe.setupIntents.create({
customer: '{{CUSTOMER_ID}}',
});

const paymentMethod = await stripe.paymentMethods.create(
{
customer: '{{PLATFORM_CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);

const paymentIntent = await stripe.paymentIntents.create(
{
payment_method: '{{PAYMENT_METHOD_ID}}',
currency: 'USD',
amount: 1099,
off_session: true,
confirm: true,
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);

#

const paymentMethod = await stripe.paymentMethods.create(
{
customer: '{{PLATFORM_CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);

how to get PAYMENT_METHOD_ID?

generally paymentIntents it get excuted first ?

const paymentIntent = await stripe.paymentIntents.create(
{
payment_method: '{{PAYMENT_METHOD_ID}}',
currency: 'USD',
amount: 1099,
off_session: true,
confirm: true,
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);

candid chasm
#

I'm not sure what this whole code is suppose to mean

ruby python
#

const paymentIntent = await stripe.paymentIntents.create(
{
amount: 1000,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
customer: customerId
application_fee_amount: 123,
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);

i am using this

#

so how i will get

You should probably collect the PaymentMethod on the Platform account, and then copy it to the Connected accounts.
You can't copy PaymentMethods that were collected on the Connected accounts to any other account ?

candid chasm
#

you create a SetupIntent on the platform

#
  customer: '{{CUSTOMER_ID}}',
});```
#

then you collect the Payment Method in the frontend

#

then you clone the Customer/PM into your connected account

ruby python
#

customerId should be platform or connected account ?

candid chasm
#

and then you create a Direct Charge in yout connected acccount

candid chasm
#

when you're not passing stripeAccount you're creating objects on your platform account

ruby python
#

then you collect the Payment Method in the frontend
how to collect & pass in backend ?

then you clone the Customer/PM into your connected account
how to clone ?

candid chasm
#

please read the docs I'm sending you

ruby python
#

so i need create session intead of paymentIntents ?

candid chasm
#

what session?

ruby python
#

stripe.checkout.sessions instead of stripe.paymentIntents.create. ?

candid chasm
#

you should create a SetupIntent

ruby python
#

u mean just SetupIntent

then charge money from backend ?

const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
automatic_payment_methods: {enabled: true},
customer: '{{CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
return_url: 'https://example.com/order/123/complete',
off_session: true,
confirm: true,
},
{
stripeAccount: '{{X}}',
});

const paymentIntent2 = await stripe.paymentIntents.create({
amount: 299,
currency: 'usd',
automatic_payment_methods: {enabled: true},
customer: '{{CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
return_url: 'https://example.com/order/123/complete',
off_session: true,
confirm: true,
},
{
stripeAccount: '{{Y}}',
});

right ?

candid chasm
#

let's step back for a second

#

what are you trying to achieve

#

let's forget about the implementation

#

would you mind telling me more about your use case?

ruby python
#

Real example :

$106 - to be charged to user & pass to connected account ie X
$3 - taken by stripe
$3 - taken platform account - A as application fee
$100 - net received by connected account ie X

now again user charges $5 from one of connected account ie Y

so user will get charged twice :
106
5

user will enter card info - once
this should happen

#

hope u got what i want to achieve @candid chasm ?

candid chasm
#

yes I just wanted to make sure that it's not a multi-party payout (e.g. paying the restaurant and the delivery person)

#

ok

#

so yes what we were doing is correct

candid chasm
#

so before you can create a PaymentIntent on the connected account you need to clone the Customer and their PaymentMethod to the Connected Account

#

all of this assuming that you are creating Standard Connect Accounts

ruby python
#

yes Standard Connect Accounts

#

setup SetupIntent - in frontend & backend - for getting just card information

clone CUSTOMER_ID1
clone PAYMENT_METHOD_ID1

const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
automatic_payment_methods: {enabled: true},
customer: '{{CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID1}}',
return_url: 'https://example.com/order/123/complete',
off_session: true,
confirm: true,
},
{
stripeAccount: '{{X}}',
});

clone CUSTOMER_ID2
clone PAYMENT_METHOD_ID2

const paymentIntent2 = await stripe.paymentIntents.create({
amount: 299,
currency: 'usd',
automatic_payment_methods: {enabled: true},
customer: '{{CUSTOMER_ID2}}',
payment_method: '{{PAYMENT_METHOD_ID2}}',
return_url: 'https://example.com/order/123/complete',
off_session: true,
confirm: true,
},
{
stripeAccount: '{{Y}}',
});

#

now flow is correct ?

candid chasm
#

yes

ruby python
#

it is bigger change
we were using paymentIntent
right ?

candid chasm
#

you're still using PaymentIntents

#

but you're adding some steps before that

ruby python
#

yes but card is loaded based on PaymentIntents Id right before ?
now it will based on setupIntents ?

candid chasm
#

yes but card is loaded based on PaymentIntents transaction_id
what do you mean by that?

ruby python
#

card view was loaded based on PaymentIntents Id right ?

candid chasm
#

you mean the PaymentElement?

#

you can use that with SetupIntents

ruby python
#

yes

ruby python
candid chasm
#

both need to change

#

in the front end instead of using confirmPayment you would use confirmSetup

ruby python
#

ya just saw that
was going to ask same

#

so in the way bigger change right @candid chasm
whole flow need to changed from front & back end ?

candid chasm
#

yes

ruby python
#

i got basic how the flow should be now atleast after this conversation
thanks @candid chasm

#

CC @real moat @dire flax

minor sageBOT