#himel_code

1 messages ¡ Page 1 of 1 (latest)

worldly iglooBOT
#

👋 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.

winter masonBOT
#

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.

pastel silo
#

This might help

dense musk
#

What's the in_xxx ID?

#

Please paste it here, can't grab it easily from the screenshot

pastel silo
#

i did lot of but this is the recent here: in_1Pd9CZ4NtCd874Cxyylw3bOh

dense musk
pastel silo
#

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;
}
};```

dense musk
pastel silo
#

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!

dense musk
#

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

pastel silo
#

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!

dense musk
#

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

pastel silo
#

That's helpful! Do you have any additional information or suggestions for improving the overall user experience?

dense musk
#

UX regarding which part?

pastel silo
#

No i mean in term of webhook, like to make more consist update in database and displaying to user like you explained for proccession!

dense musk