#himel_code
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/1262728451488743560
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- himel_code, 21 hours ago, 17 messages
- himel_code, 22 hours ago, 11 messages
This might help
i did lot of but this is the recent here: in_1Pd9CZ4NtCd874Cxyylw3bOh
Hmm, that invoice is paid as reflected on the invoice.paid event: https://dashboard.stripe.com/test/events/evt_1Pd9DH4NtCd874Cx1JkHqPsZ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
here is the full code it might give you some context: ```const payInvoice = async (
invoice_id,
payment_method_id,
stripe_connect_account_id
) => {
try {
console.log("Starting payInvoice with invoice ID:", invoice_id);
// Pay the invoice with the specified payment method
const invoice = await stripe.invoices.pay(
invoice_id,
{
payment_method: payment_method_id,
},
{
stripeAccount: stripe_connect_account_id,
}
);
console.log("Invoice paid successfully:", invoice.id);
// Fetch payment method details
const paymentMethod = await stripe.paymentMethods.retrieve(
payment_method_id,
{
stripeAccount: stripe_connect_account_id,
}
);
// Prepare payment method details in a general format
const paymentMethodDetails = {
id: paymentMethod.id,
type: paymentMethod.type,
...(paymentMethod.card && {
brand: paymentMethod.card.brand,
last4: paymentMethod.card.last4,
exp_month: paymentMethod.card.exp_month,
exp_year: paymentMethod.card.exp_year,
}),
...(paymentMethod.us_bank_account && {
bank_name: paymentMethod.us_bank_account.bank_name,
last4: paymentMethod.us_bank_account.last4,
account_holder_name: paymentMethod.us_bank_account.account_holder_name,
account_holder_type: paymentMethod.us_bank_account.account_holder_type,
}),
};
await updateInvoiceWithStripeDetails(
invoice_id,
{
status: invoice.status,
status_transitions: invoice.status_transitions,
payment_intent: invoice.payment_intent,
payment_method: paymentMethodDetails,
},
"stripe_invoice_id"
);
console.log("payInvoice completed successfully:", invoice);
return invoice;
} catch (error) {
console.error("Error in payInvoice:", error);
throw error;
}
};```
I suspect your logs are from a different API call as the console.log() don't match. Maybe the /finalize call here, which will transition it to open: https://dashboard.stripe.com/test/logs/req_YiqahH7NIjkhpS
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I console logged like this and it's clearly showing that it coming from the invoice pay function : Starting payInvoice with invoice ID: in_1Pd9CZ4NtCd874Cxyylw3bOh 0|index | Invoice paid successfully: in_1Pd9CZ4NtCd874Cxyylw3bOh 0|index | Starting updateInvoiceWithStripeDetails for invoiceId: in_1Pd9CZ4NtCd874Cxyylw3bOh and identifier: stripe_invoice_id 0|index | Using column: stripe_invoice_id for update 0|index | Update successful for invoiceId: in_1Pd9CZ4NtCd874Cxyylw3bOh null 0|index | payInvoice completed successfully: { 0|index | id: 'in_1Pd9CZ4NtCd874Cxyylw3bOh', 0|index | object: 'invoice', 0|index | account_country: 'US', 0|index | account_name: 'April Hatfield', 0|index | account_tax_ids: null, 0|index | amount_due: 67900, 0|index | amount_paid: 0, 0|index | amount_remaining: 67900, 0|index | amount_shipping: 0, 0|index | application: 'ca_Nr7u0JseaJ
I again did some another test it still the same! after the paying of the invoice it showing as open! i can give a 30 sec quick screen record! for walkthorugh!
Ah, it's because you're attempting to pay it with an ACH Debit payment method. They're aysnc, so will take a few days to clear and in that time invocie remains 'open'
In test mode they clear ~a few seconds later which explaisn the marginal delay
As with all delayed/async payment methods, you should be using invoice.paid events to handle fulfulment
one question! if the user attempted to pay and it will take a few days! then meanwhile to prevent user to pay again i mean they might accidently again submit! how the user flow might looks like!
you are right when i paid with card it works as well!
Yeah, that's fair. You can check the attempted and/or attempt_count on the response from the /pay endpoint to see if we've attempted payment
If attempted: true and status: 'open' then prevent payment again I guess as it's processing. Alternatively you can 'expand' the payment_intent field in your /pay request and check the status field of that, which will be processing
That's helpful! Do you have any additional information or suggestions for improving the overall user experience?
UX regarding which part?
No i mean in term of webhook, like to make more consist update in database and displaying to user like you explained for proccession!
Well you'd listen for invoice.updated events (like this one: https://dashboard.stripe.com/test/events/evt_1Pd9D24NtCd874CxZyJzAK0e) which would send when you call /pay with a delayed/async payment method
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.