Reputation: 51
I am using the React components for Stripe.js to try and process a payment for a connected account, and collect a fee off of each payment. I am not sure if the flow between my client and server is properly picking up my cloned customer and payment method. When my test customer tries to pay, I get "No such payment_intent: 'pi_abc...zyx'". I have ensured I am using the correct private test keys on both client and server. My Connected accounts are express accounts. When I go to my Stripe dashboard to look at the 'Customers' tab under 'Connect', this is what I see:
It looks like a blank entry is being created each time I make a payment attempt.
Here are the steps I am currently taking to let the platform customer pay a Connected account:
React/Client Side - loadStripe with only the test key, not with a Stripe Connected account Id
const stripePromise = loadStripe('pk_test_abc...');
. I provide this to <Elements stripe={stripePromise}>
React/Client Side - User fills in payment form and presses submit. Create a paymentMethodReq from client/platform:
const paymentMethodReq = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
billing_details: billingDetails
});
Node/Server Side - Client then makes a request to my server to try and clone the platform payment method to a Connected account:
const serverPaymentMethod = await stripe.paymentMethods.create({
customer: data.customerStripeId, // Customer ID of the customer paying (platform customer)
payment_method: data.paymentMethodId, // Using the payment method Id generated from 'paymentMethodReq' on the client side
}, {
stripeAccount: connectedAccountStripeAccountId, // Using the Connected Account
});
Node/Server Side - Client then makes a request to my server to create/"clone" a new customer from the platform and link it to the Connected account
const customer = await stripe.customers.create({
payment_method: data.paymentMethodId, //Payment method id generated from 'serverPaymentMethod' above
}, {
stripeAccount: connectedAccountStripeAccountId, // Using the same Connected Account
});
Node/Server Side - Client then makes a request to my server to create a payment intent with the customer id that was linked to the Connected account along with the payment method that was generated from the server
const intent = await stripe.paymentIntents.create({
amount: data.price * 100,
currency: 'usd',
payment_method_types: ['card'],
payment_method: data.paymentMethodId, // Payment method id generated from 'serverPaymentMethod' above
customer: data.customerStripeId, // Customer Id generated from 'customer' above
description: data.desc,
capture_method: 'manual',
application_fee_amount: (data.price * 100) * 0.15,
}
React/Client Side - I try to confirm the card payment which results in the "No such payment_intent: 'pi_abc...zyx'" error
const confirmedCardPayment = await stripe.confirmCardPayment(paymentIntentResult?.data?.client_secret, {
payment_method: serverPaymentMethod?.data.id //Payment method id generated from 'serverPaymentMethod' above
});
I tried replacing stripe.confirmCardPayment
on the client with a call to my server that instead confirms the payment intent like so:
const confirmPaymentIntent = await stripe.paymentIntents.confirm(
data.paymentIntentId, // Payment intent id generated from 'intent' above
{
payment_method: data.paymentMethodId // Payment method id generated from 'serverPaymentMethod' above
});
and this also results in "No such payment_intent 'pi_3K...9Rx'"
If anyone could help me figure out where I am going wrong in this process, that would be greatly appreciated. Thank you
Upvotes: 0
Views: 328
Reputation: 1981
The error indicates that the PaymentIntent belongs to a different account with whose your current call is using a key of. It could be:
While I am seeing both PaymentIntent creation and confirmation calls doesn't use the stripeAccount parameter, I suspect that you missed the code somewhere and the PaymentIntent was actually created in your Connected Account, lead to #2 possibility above.
To debug this you can check which account the PaymentIntent belongs to, by searching its ID on Dashboard's search box, or simply write to Stripe Support with the ID and they can check it for you.
Upvotes: 0