#Jay Zhuang
1 messages · Page 1 of 1 (latest)
Which particular pi_xxx are you having issue retrieving? Can you share a failing request ID (req_xxx)?
pi that was completed by stripe reader, my backend fetched the pi but lists the errors (node:832) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'last4' of undefined
Ok, that error is thrown from a different piece of code to what you've shared
pi that was completed by stripe reader,
Which ID?
pi_3M03IwAnxaVNkV1L1zv0stc7
Can you share the code where you attempting to look up the last4 field?
app.get("/retrievePaymentResultiPad", async (req, res) => {
// console.log(req.query.name)
try {
const paymentIntent = await stripe.paymentIntents.retrieve(
// req.query.name
'pi_3LzimBAnxaVNkV1L06lPrgBB'
// "pi_3Lmf4RAnxaVNkV1L03w5e2FQ"
)
} catch (error) {
console.log(error.body)
console.log("there is a problem")
}
});
i didnt look up last4
As stated, the error you shared:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'last4' of undefined
Is thrown from elsewhere in your code. That error wouldn't be thrown just from that API request
this pi pi_3M02uoAnxaVNkV1L10Mm6ZH4 was paid through Apple Pay, i have not problem retrieving informaiton
pi_3M03IwAnxaVNkV1L1zv0stc7 was paid successfully too. That's unrelated. Somewhere in your code you're looking to read a last4 field which is undefined
I suspect you're looking at payment_method_details hash on the Payment Intent. What will differ between a Terminal payment and a non-Terminal payment is the subhash (card vs card_present)
I guess you're reading card[last4] somewhere, and it doesn't exist on pi_3M03IwAnxaVNkV1L1zv0stc7 because it was a Terminal payment (you'd read card_present[last4])
thank you
You'd need to account for that in your code somehow, maybe using optional chaining (card?.last4)
thank you for helping me, i now know the issue.