#CasuallyCaffeinated
1 messages ยท Page 1 of 1 (latest)
For the sake of brevity, here's the code block that contains the function being called: ```js
const onConfirmPayment = async () => {
if (paymentMethod.__typename === CARD) {
const payload = { payment_method: paymentMethod.token };
setAwaitingResponse(true);
const response = await stripe.confirmCardPayment(clientSecret, payload);
setAwaitingResponse(false);
if (response.error) {
setScreen(ERROR_SCREEN);
} else {
setScreen(CONFIRMATION);
}
} else if (paymentMethod.__typename === BANK_ACCOUNT) { // This could be just an else statement, but I like to be precise.
const payload = { payment_method: paymentMethod.token };
setAwaitingResponse(true);
// const response = await stripe.confirmUsBankAccountPayment(clientSecret, payload);
const { error } = await stripe.confirmUsBankAccountPayment(clientSecret, payload);
setAwaitingResponse(false);
if (error) {
setScreen(ERROR_SCREEN);
} else {
setScreen(CONFIRMATION);
}
}
};```
The important portion is the code found in the else if block
Thanks for this ๐ And appreciate your patience
Thank you as well!
can you share the example PaymentIntent ID that you're working with here?
Where can I find the PaymentIntent? I know that payment_intent is returned from the function itself
{
"error": {
"code": "payment_intent_unexpected_state",
"doc_url": "https://stripe.com/docs/error-codes/payment-intent-unexpected-state",
"message": "This PaymentIntent's payment_method could not be updated because it has a status of processing. You may only update the payment_method of a PaymentIntent with one of the following statuses: requires_payment_method, requires_confirmation, requires_action.",
"payment_intent": {
"id": "pi_3M6boXAIEGRSPHp62TdLEqCK",
"object": "payment_intent",
"amount": 102800,
"amount_details": {
"tip": {}
},
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"client_secret": "pi_3M6boXAIEGRSPHp62TdLEqCK_secret_IfTPsB50RDD7b5WNpXMXXM7TQ",
"confirmation_method": "automatic",
"created": 1669044101,
"currency": "usd",
"description": "Monthly Rent",
"last_payment_error": null,
"livemode": false,
"next_action": null,
"payment_method": "pm_1M0PhzAIEGRSPHp6H8cW4tmg",
"payment_method_options": {
"us_bank_account": {
"verification_method": "automatic"
}
},
"payment_method_types": [
"card",
"us_bank_account"
],
"processing": null,
"receipt_email": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"status": "processing"
},
"request_log_url": "https://dashboard.stripe.com/test/logs/req_QGUNMitPxl3ndI?t=1669044105",
"type": "invalid_request_error"
}
}```
I can see that payment_intent is something stored in the object
pi_3M6boXAIEGRSPHp62TdLEqCK is the ID I was looking for ๐ taking a look
Awesome
Okay so when you create the PaymentIntent, you're also passing confirm: True
https://dashboard.stripe.com/test/logs/req_byaqHFdrGqe0Gq
So the API would try to confirm the PaymentIntent using the PaymentMethod that's provided with the request automatically. Hence, you don't really need to call confirmUsBankAccountPayment(...) here.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Oh, I see
Is there a different method I need to call then?
For ACH payments specifically?
You can try setting it to false
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-confirm
Would/Could that be done on the frontend, or would that need to be a backend feature?
You'd need to set confirm: false server-side when you create the PaymentIntent
Got it, I'll check out our backend code and see if I can do anything about this, or perhaps reach out to someone more specialized. Can you keep this thread open until I get back, in case I have more info to share? Or would it be simpler for me to just ask another question
Btw, where did you see that we're setting confirm: true ?
Got it, I'll check out our backend code and see if I can do anything about this, or perhaps reach out to someone more specialized. Can you keep this thread open until I get back, in case I have more info to share? Or would it be simpler for me to just ask another question
If you're back sooner, you can ask me or any other staff member to re-open the thread. If not, a new thread is fine too ๐
Btw, where did you see that we're setting confirm: true ?
https://dashboard.stripe.com/test/logs/req_byaqHFdrGqe0Gq
If you open the request in the dashboard, the request POST body should have it listed
Awesome, I saw it now, and I also see where in the backend we're setting it to true