#kekko7072
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Are you with me?
Sorry give me 5 minutes
So hy i have a backend firebase function
that is called from an IOT device
and in this function i canfirm the payment method
try {
// API DOC https://stripe.com/docs/api/payment_intents/create
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: "eur",
customer: userData.billing.customerId,
confirm: true,
off_session: true,
payment_method: userData.billing.paymentMethodDefault,
payment_method_types: ["card"],
});
debug(paymentIntent.id);
debug(paymentIntent.payment_method);
const confirmPaymentIntent =
await stripe.paymentIntents.confirm(paymentIntent.id, {
payment_method: `${paymentIntent.payment_method}`,
});
log(confirmPaymentIntent.status);
} catch (e) {
payed = false;
error(e);
// Set user to not payed
await userCollection
.doc(uid)
.update({
"billing.paymentResume": true,
})
.catch((e) =>
error(
`Error in ending session,
ERROR: ${e}
| PID: ${req.body.powerBank}`
)
} else {
debug(
`✅ No transaction because user used it's wallet balance
\nUid: ${uid}
\nAmount: ${amount}
\nBalance: ${userData.billing.wallet.balance}
\nBalance_to_remove: ${balanceToRemove}`
);
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this is the request
req_rJ4WrgtSHZyZYg
it returns the error "You can not confirm this paymentIntent because it has already succeded afther being previously confirmed"
The request is successful, maybe you have another ID?
yes it's successful but on my try catch code
return this errore
My code is this:
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: "eur",
customer: userData.billing.customerId,
confirm: true,
off_session: true,
payment_method: userData.billing.paymentMethodDefault,
payment_method_types: ["card"],
});
debug(paymentIntent.id);
debug(paymentIntent.payment_method);
const confirmPaymentIntent =
await stripe.paymentIntents.confirm(paymentIntent.id, {
payment_method: ${paymentIntent.payment_method},
});
how should i change it to make sure i will not get this error
on the try catch block
this is the log
pi_3NDipuA94JJJ3znb14CplqUL
I see, this request has failed: req_fDGwlo1stL5M9R
becuase i have a webhook that says payment_intent.succeeded
You are creating a PaymentIntent with confirm: "true" and it succeeds immediately, you don't need to confirm it anymore.
ok so i can remove this code ? const confirmPaymentIntent =
await stripe.paymentIntents.confirm(paymentIntent.id, {
payment_method: ${paymentIntent.payment_method},
});
in the function that is called to make the user pay?
It depends what is the flow you are looking for. If you want to charge the saved Payment Method, yes you don't need to confirm the PaymentIntent separately
ok thankyou
can you suggest me flow if user hasnt payment method registred
what should i do?
ok thankyou
Happy to help. Please, let me know if you have any other questions.