#itsoppong-direct-pi
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- its_oppong, 17 hours ago, 77 messages
- its_oppong, 2 days ago, 5 messages
👋 Can you clarify what you mean by "moving from transfering payments to direct charges"?
how i can add a customer to the payment intent object
You can pass thecustomerparam when creating the PaymentIntent: https://docs.stripe.com/api/payment_intents/create#create_payment_intent-customer
itsoppong-direct-pi
yea definitely,
so connected accounts for my app are standard, and I was advised for cross border payments, and future issues, its better to use direct charge instead of what i was using const paymentIntent = await stripe.paymentIntents.create({ amount: amount, currency: paymentObj.currency, payment_method_types: ['card', 'klarna'], receipt_email: paymentObj.email, customer: customer.id, application_fee_amount: totalFeeAmount, // Set the total fee amount transfer_data: { destination: stripeAccountId, }, description: paymentObj.description, metadata: { ...paymentObj, }, });
Okay, gotcha. In this case, you'd remove the transfer_data hash and use the Stripe-Account header instead in order for this to be a direct charge: https://docs.stripe.com/connect/direct-charges
customer can remain in your PI create call. However, this customer object needs to "live" on the connected account
ok so for the customer, i get this error The customer must have an active payment source attached.
let customer = await stripe.customers.list({ email: paymentObj.email });
console.log('custssomer1', customer);
if (customer.data.length === 0) {
customer = await stripe.customers.create({ email: paymentObj.email });
const token = await stripe.tokens.create(
{
customer: customer.id,
},
{
stripeAccount: stripeAccountId,
},
);
customer = await stripe.customers.create(
{
source: token.id,
},
{
stripeAccount: stripeAccountId,
},
);
console.log('custssomer2', customer);```
Can you share the request ID associated with the error you get?
req_gLyy5p4QT6nG5P
Which guide are you following at the moment?
Thanks!
I recommend following this guide instead: https://docs.stripe.com/payments/payment-methods/connect#cloning-payment-methods
but, hold on a second. Are you cloning payment methods from the platform to the connected account because you want to be able to charge the customer from either accounts?
I see, okay. I don't recommend cloning at all in that case. What you should do in your code above is create the customer on the connected account from the very beginning
customer = await stripe.customers.create({ email: paymentObj.email });
This should happen on the connected account; you should include the stripeAccount header here
customer = await stripe.customers.create({ email: paymentObj.email},stripeAccount:'{{CONNECTED_ACCOUNT_ID}}',}) so something like this?
yep!
i get a no such customer error No such customer: 'cus_PZLDx7widVV3yl'
I am assuming it is because the customer exists on my customers, but not on the connected accounts right?
Can you share the request ID for that error?
req_dlfToCOwE9XtNM
cus_PZLDx7widVV3yl was created on your platform, not the connected account
If your goal is to charge this customer from the connected account only, the customer should be created on the connected account
like this right let customer = await stripe.customers.list({ email: paymentObj.email }); if (customer.data.length === 0) { customer = await stripe.customers.create({ email: paymentObj.email }, { stripeAccount: '{{CONNECTED_ACCOUNT_ID}}' }); } else { customer = customer.data[0]; }
Yep, that looks right
hmm, I'm getting the same error
this is how my code looks let customer = await stripe.customers.list({ email: paymentObj.email }, { stripeAccount: stripeAccountId }); if (customer.data.length === 0) { customer = await stripe.customers.create({ email: paymentObj.email }, { stripeAccount: stripeAccountId }); } else { customer = customer.data[0]; }
Okay, that's only one part of your code, and this is creating a customer on the connected account. Where are you getting an error?
ahh thanks for that, my error was here const ephemeralKey = await stripe.ephemeralKeys.create( { customer: customer.id, }, { apiVersion: '2020-08-27', stripeAccount: stripeAccountId }, );
didnt know I had to pass stripeAccount here also
ah ok now an error with the payment sheet on the client side, would you know a typical reason why id get this error No such payment_intent
For direct charges, client side uses your platform's publishable key but you also need to pass the stripeAccount header: https://docs.stripe.com/connect/authentication#adding-the-connected-account-id-to-a-client-side-application
ah interesting, so instead of merchantIdentifier={STRIPE_MERCHANT}, i would use the stripeAccountId={{CONNECTED_ACCOUNT_ID}}
because Im using react native
You would do something like this: https://docs.stripe.com/connect/authentication?create-client=react-native