#kekko7072
1 messages · Page 1 of 1 (latest)
Can you elaborate a bit more? What's the issue?
Hy i have a backend code where i save for future usage the payment method. This is the code i use
stripe.checkout.sessions.create({
mode: "payment",
payment_method_types: ["card"],
customer: customerId,
// https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#save-payment-method-details
payment_intent_data: {setup_future_usage: "off_session"},
currency: "eur",
line_items: [
{
price_data: {
currency: "eur",
product_data: {
name: "Powerbank",
},
unit_amount: req.priceAmount,
},
quantity: 1,
},
],
success_url:
process.env.API_ENV === "dev" ?
${amperryGoDomainDev}/success :
${amperryGoDomainProd}/success,
cancel_url:
process.env.API_ENV === "dev" ?
${amperryGoDomainDev}/cancel :
${amperryGoDomainProd}/cancel,
metadata: {
uid: uid,
stationId: stationId,
orderId: orderId,
},
});
const paymentIntent = await stripe.paymentIntents.create({
amount: req.amount,
currency: req.currency,
customer: req.customer,
setup_future_usage: "off_session",
capture_method: hold ? "manual" : "automatic", // https://stripe.com/docs/payments/place-a-hold-on-a-payment-method
});
but now i'm facing often this issue you can find: req_WZHY5cvmXinFZp
Error message is:
message: "You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method."
Are you trying to use Checkout to accept payments?
yes i'm using that on web
but i configured that payment_method should be saved
but sometimes is not saved.
for example in this payment intent why it's not added for future usage?
So, you don't need to create Payment Intents if you're using Checkout.
pi_3MlnNxA94JJJ3znb0uAp3xMg
sorry my mistake i'm referring to payment intent
called from my app
this is the backend of this call
import * as functions from "firebase-functions";
import {error, stripe} from "../constants";
export const Payment = functions
.region("europe-west3")
.https.onCall(async (req, context) => {
try {
const ephemeralKey = await stripe.ephemeralKeys.create(
{customer: req.customer},
{apiVersion: "2020-08-27"}
);
const hold: boolean = req.use_hold ?? false;
// API DOC https://stripe.com/docs/api/payment_intents/create
const paymentIntent = await stripe.paymentIntents.create({
amount: req.amount,
currency: req.currency,
customer: req.customer,
setup_future_usage: "off_session",
capture_method: hold ? "manual" : "automatic", // https://stripe.com/docs/payments/place-a-hold-on-a-payment-method
});
return {
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: req.customer,
};
} catch (e) {
error(e);
return {
paymentIntent: "",
ephemeralKey: "",
customer: req.customer,
};
}
});
but the result is this: pi_3MlnNxA94JJJ3znb0uAp3xMg
It looks like the Customer ID you're passing doesn't have any attached Payment Methods. How are you creating Payment Methods right now? Is that what the Checkout Session code you posted above is for?
Yes
When they do the payment intent I save their payment info
But in this user seems it didn’t work
So I save the payment method on this way
Hmmm, can you describe a step-by-step explanation of what you want the payment flow to look like?
So I have two types of payment experience one in the web of the day is used to rent the service without the app and another one which is from the app
For the webapp i use the check out and user can pay directly and Then I save the metodo On their Stripe account, so when they are you, we’ll try next time the service they will have the payment ready. In the app are use payment intends to configure the payment with the Apple Pay and Google pay but also with the credit card so user can also configure the payment Samantha and then once it’s configured they can pay with The payment method already registered
That's really difficult to understand. I would recommend looking into Checkout in setup mode. This will allow you to save payment methods for future usage, which will give you the option of creating Payment Intents without bringing your customer back into the payment flow: https://stripe.com/docs/payments/save-and-reuse?platform=checkout
The problem is that it seems like the payment intent for the registration of the car. Sometimes it’s not working for some users. Please note the user I sent you before which paid, but didn’t have Ia card registered
Okay, but can I do Payment intent without check out ?
You can, but only if the Customer has a Payment Method attached: https://stripe.com/docs/api/payment_methods/attach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ok clear I will review the flow
Last thing
I’m getting an issue with payment setup confirm
“You can not confirm this payment intent because it’s already succeeded after being previously confirmed”
What does it mean on the specific ? The charge has already been done?
That just means the Payment Intent has been confirmed: https://stripe.com/docs/api/payment_intents/confirm
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 issue is due the fact that the checkout code it’s called automatically and j think it called before updating on the server the customer status from “need to pay” to “payed”
That means an authorization has been successful and the Payment Intent is ready to be paid
yeah, it will also error in that way if the Payment Intent is paid
Oak
Can you send me links of how to implement the flow correctly because I think I will need to redo the configuration and payment and so I want to read docs to do it the right way
Not sure if that's the flow you want. It's difficult to tell what you payment flow is supposed to look like. Right now it's a bit all over the place
Ok thank you