#arnaud
1 messages · Page 1 of 1 (latest)
👋 happy to help
would you mind sharing a request ID?
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
yes sure !
this is an example :
POST /v1/payment_intents
État
400 ERR
ID
req_1Kn2c2lrOmMkSJ
Date et heure
26/10/2023 11:37:28
Adresse IP
107.178.232.171
Version de l'API
2023-10-16
Source
Stripe/v1 NodeBindings/14.1.0
Idempotence
Clé — stripe-node-retry-d09c59db-e4d8-468a-af8c-3e03c63e0822
parameter_missing - amount
Missing required param: amount.
Ces informations vous ont-elles été utiles ?
Oui
Non
{
"payment_method": "pm_card_visa",
"description": "Commande de undefined",
"currency": "eur",
"setup_future_usage": "off_session",
"amount": <required>
}
Corps de la réponse
{
"error": {
"code": "parameter_missing",
"doc_url": "https://stripe.com/docs/error-codes/parameter-missing",
"message": "Missing required param: amount.",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_1Kn2c2lrOmMkSJ?t=1698313048",
"type": "invalid_request_error"
}
}
Corps de la requête POST
{
"payment_method": "pm_card_visa",
"description": "Commande de undefined",
"currency": "eur",
"setup_future_usage": "off_session"
}
ok so first things first
totalAmount is undefined
so it's not being passed down to the PaymentIntents create method
same with cardholderName
as for the customer, this needs to be the Stripe customerID
yes I know sorry, this one is an old one please forget it
so I'm not sure req.user is the right way to fetch that
please look this one is the last one I just did :
POST /v1/payment_intents
État
400 ERR
ID
req_1rANcQ3A51iiop
Date et heure
26/10/2023 12:07:58
Adresse IP
107.178.239.210
Version de l'API
2023-10-16
Source
Stripe/v1 NodeBindings/14.1.0
Idempotence
Clé — stripe-node-retry-3d618ca9-1e33-4e31-921b-280b0ec69b96
email_invalid - receipt_email
Invalid email address:
Ces informations vous ont-elles été utiles ?
Oui
Non
{
"currency": "eur",
"payment_method": "pm_card_visa",
"description": "Commande de titeuf",
"receipt_email": "",
"setup_future_usage": "off_session",
"amount": "4830"
}
Corps de la réponse
{
"error": {
"code": "email_invalid",
"doc_url": "https://stripe.com/docs/error-codes/email-invalid",
"message": "Invalid email address: ",
"param": "receipt_email",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_1rANcQ3A51iiop?t=1698314878",
"type": "invalid_request_error"
}
}
Corps de la requête POST
{
"currency": "eur",
"payment_method": "pm_card_visa",
"description": "Commande de titeuf",
"receipt_email": "",
"setup_future_usage": "off_session",
"amount": "4830"
}
It seems I just cant retrieve the email adress that is in my form in the frontend, which is weird
you just need to send me the req_xxx
instead of copy pasting the whole thing
req_1rANcQ3A51iiop
ok thanks for the tip 🙂
yes so this goes back to my point earlier
the customer property is the Stripe Customer ID cus_xxxx
I'm not sure customer: user, is the right way
I think user here is empty
this is just because you didn't send it
did you create a customer object for your customer?
no I didnt ! I red about it in the documentation but I didnt understand how and where I should implement it in my code
so how do I do that ?
I just need the cardholder name and his email, thats it ...
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
you can create a customer with just the email
or the name
I'm not sure which integration flow you're using
but I suggest using this https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
you shouldn't be passing the paymentMethod on the backend
but rather passing the client_secret to the frontend and loading PaymentElements to collect the payment details
Ok, so you suggest I put my function out of index.js and I put I directly in my payment component in frontend ??
This is my payment method :
exports.createPaymentIntent = functions.https.onRequest((req, res) => {
cors(req, res, async () => {
// Utilisez async ici
// Récupérez l'utilisateur authentifié (si nécessaire)
const user = req.user;
// Extrayez le nom du titulaire de la carte et l'adresse e-mail du corps de la demande
const { totalAmount, cardholderName, email } = req.body;
console.log("Total amount received from front-end:", totalAmount);
console.log("cardholderName received from front-end:", cardholderName);
console.log("email received from front-end:", email); // Vérifiez que la valeur est correcte ici
try {
// Créez un PaymentIntent avec Stripe
const paymentIntent = await stripe.paymentIntents.create({
amount: totalAmount, // Montant en cents (par exemple, 10,00 $)
currency: "eur",
payment_method: "pm_card_visa",
customer: user, // Vous pouvez associer le client ici
setup_future_usage: "off_session", // Pour les paiements futurs hors session
receipt_email: email, // Adresse e-mail du client
description: `Commande de ${cardholderName}`, // Description de la commande
// Autres informations de facturation si nécessaire
});
res.json({ clientSecret: paymentIntent.client_secret });
} catch (error) {
console.log("Error:", error); // Ajoutez ce log pour les erreurs
res.status(500).json({ error: error.message });
}
});
});
Ok, so you suggest I put my function out of index.js and I put I directly in my payment component in frontend ??
not at all
keep it where it is
remove the payment_method: "pm_card_visa",
ok that I can do
create the customer before creating the PaymentIntent
and you should be good to go
but I dont know how to create the customer objet should I do this :
const customer = await stripe.customers.create({
description: 'My First Test Customer ',
});
Im sorry but I dont know how I should do it ?
instead of description
you can pass in the email
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Im currently reading the documentation but I dont understand how I should do it
please could you help me 😢
const customer = await stripe.customers.create({
email: 'info@example.com ',
});
const paymentIntents = await stripe.paymentIntents.create({
customer: customer.id,
//...
});
thank you so much
So now this is what I got :
const customer = await stripe.customers.create({
email: "info@example.com ",
});
const paymentIntent = await stripe.paymentIntents.create({
customer: customer.id,
amount: totalAmount, // Montant en cents (par exemple, 10,00 $)
currency: "eur",
setup_future_usage: "off_session", // Pour les paiements futurs hors session
receipt_email: email, // Adresse e-mail du client
description: Commande de ${cardholderName}, // Description de la commande
});
Is that enought to receive the name and the email from the customer on my Payments Dashboard ?
now I have this log :
req_cksFOkvKNroUlR
still can't retrieve the email ...
In my front end JSX I have this form :
<div className="mb-4 ">
<label className="block text-black text-lg mb-2">
Informations de la carte{" "}
</label>
<div className="mb-4">
<input
className="px-2 py-2 rounded-lg"
type="text"
id="cardholder-name"
name="cardholder-name"
placeholder="Nom du titulaire de la carte"
required
/>
</div>
<div className="mb-4">
<input
className="px-2 py-2 rounded-lg"
type="email"
id="email"
name="email"
placeholder="Adresse e-mail"
required
/>
</div>
Then I do like this to take information :
// Obtenez les éléments du formulaire
const cardholderNameElement = document.getElementById("cardholder-name");
const emailElement = document.getElementById("email");
console.log("Email Element VERIFICATION :", emailElement);
But it doesnt work for my email and I dont fucking understand why 😢
Hey! Taking over for my colleague. Let me catch up.
Is that enought to receive the name and the email from the customer on my Payments Dashboard ?
What you mean exacty by Payments Dashboard ?
// Obtenez les éléments du formulaire
const cardholderNameElement = document.getElementById("cardholder-name");
const emailElement = document.getElementById("email");
console.log("Email Element VERIFICATION :", emailElement);
No you shouldn't get the email like the following
if you need to collect the customer's email, then create your own email field
What you mean exacty by Payments Dashboard ?
I mean when I test if my payment succeed I go the Payments dashboard on my account to see if its a success but I would like to collect email and name of cardholder thats it !
No you shouldn't get the email like the following
if you need to collect the customer's email, then create your own email field
How do I do that ? The actual input is not allready an email field ?
<div className="mb-4">
<input
className="px-2 py-2 rounded-lg"
type="email"
id="email"
name="email"
placeholder="Adresse e-mail"
required
/>
</div>
Im sorry Im a junior developer I might ask stupid questions 😢
This is not a Stripe related Issue.
you probably need to reach out to Stackoverflow or other community to understand why the binding isn't working in your frontend app
yes i know I will solutionate it myself thanxs
But I want to know if my method is ok or not :
const paymentIntent = await stripe.paymentIntents.create({
customer: customer.id,
amount: totalAmount, // Montant en cents (par exemple, 10,00 $)
currency: "eur",
description: Commande de ${cardholderName}, // Description de la commande
});
do I need to add any stuff to retrieve the email and name of the customer ?
I thinks its good now, here is my log :
req_y9gWFn9F4eXYUA
And I found all the informations I need in it (cardholder name and email)
You think Im ready to put my Stripe product in production ?
I can't tell, as I don't know your integration. I invite you to test your flows and if every thing is green you can go for production.
Only can judge when you can go to production
thanks 😉
So I mean everything looks fine, I have a 200 OK state of request, the ID is req_Do4VlaTmV0kw5e
The only red text I see are in the Body of request object, put it doesnt mean its bad right ?
I think Im ready to put my solution online do you agree ?