#kelley_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1225874240352551054
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
We document multiple possible charge funds flows for Connect here: https://docs.stripe.com/connect/charges
Can you clarify which one you are attemtping to use?
Have this first route to create my payment_intent working:
const { amount, currency } = req.body;
const paymentIntent = await stripe.paymentIntents.create({
amount,
currency,
automatic_payment_methods: {
enabled: true,
},
application_fee_amount: 123,
},
{
stripeAccount: 'acct_1',
}
);
console.log(paymentIntent);
})```
Then when I go to confirm the payment intent:
const { paymentIntent } = req.body;
const capturedPaymentIntent = await stripe.paymentIntents.capture(paymentIntent);
console.log(capturedPaymentIntent);
})```
I get this error: This PaymentIntent could not be captured because it has a status of requires_payment_method. Only a PaymentIntent with one of the following statuses may be captured: requires_capture.
To chartge the customer, do I want capture or confirm?
And how can I test this in postman?
You are missing a few steps
The payment intent after you create it doesn't have a payment method associated with it
You can either make a separate API call to confirm the intent: https://docs.stripe.com/api/payment_intents/confirm and pass one of our testing Payment Methods; https://docs.stripe.com/testing?testing-method=payment-methods#cards
Or, you can include the test Payment Method when you create the Intent and pass confirm: true
You should not need to capture the funds unless you specify capture_method: "manual" when creating the intent
So when I am doing this from the frontend, I would get the pamynt method from the elements form and then what do I need to pass in the request body to charge the card?
Just this info:
const capturedPaymentIntent = await stripe.paymentIntents.confirm(
paymentIntent,
{
payment_method: 'pm_card_visa', <--- method from stripe elements?
return_url: 'https://example.com',
}
);```
That will transition the PaymentIntent to a status of requires_confirmation. Then you just need to confirm it and you will see the application fee deducated
So I
- Create payment intent
- Confirm payment intent
- Capture payment intent?
But I recommend you walk through our basic payment integration, end to end, and just include the Stripe Account header and application_fee_amount to see the whole flow clearly
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements
Let me peek
And you will only need to capture the intent if you specify that you want to capture it manually by passing capture_method: "manual" when you create the intent. Otherwise, it will go through automatically when you confirm it.
Ok gonna try to go through this whole flow.
thx
An am I using the connect accounts secret key? Or the connected accounts?
You use the Platform's API keys and specify the Connect Account in the stripe_account parameter