#cgourmelon
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
Thx Vanya
Here's our ecommerce page :
Service de livraison de Fleurs en cérémonie - Remise en mains propres au maître de cérémonie - Fleurs Frâiches et de saisons - POMPES FUNÈBRES DE FRANCE
Sorry it's in French
Could you please give more context?
push some inputs to create an order on my webhook
What do you mean by this?
If you add any flower to your basket you'll end up in the checkout page
This checkout page is already working and with our current bank solution.
But if you click on the following link, you'll end up in the checkout with Stripe installed in it :
Service de livraison de Fleurs en cérémonie - Remise en mains propres au maître de cérémonie - Fleurs Frâiches et de saisons - POMPES FUNÈBRES DE FRANCE
As you can see, there are lots of inputs that I need no pass to my webhook so I can create an order and send the email confirmation to the client once I receive a "payment_intent.succeeded" from Stripe
At first I was using the $paymentIntent = $event->data->object; to push some data but I can see now that it's not the right thing to do
Just to clarify, you don't need to call the webhook endpoint yourself, Stripe calls it. It's a way for Stripe to notify your applications when various events happen
In other words I don't know how to post my form correctely in order to create a proper order when the client presses the submit button
Yes of course, the webhook is called by Stripe
I've configured it in my Stripe Dashboard
Since the PaymentIntent is created when the client arrives at the checkout page I don't know where I can put my code that POST all my inputs of the form and creates teh order
At first I thought I could do it on the webhook.php file that I created but I can't call all the inputs of my checkout
FYI I'm using 3 files on my checkout : checkout.js, create.php and webhook.php
the PaymentIntent is created thx to the checkout.js and create.php
I understand.
the checkout.js calls the create.php that contains the following code to create a PaymentIntent with amount and currency
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $total_panier,
'currency' => 'eur',
'automatic_payment_methods' => [
'enabled' => false,
],
]);
At first, I was passing the basic info such as the name of the client in the handleSubmit function located in the checkout.js file like this :
confirmParams: {payment_method_data : {billing_details : {name : form.nom.value}}}
You can use this new flow where you create a PaymentIntent after the the customer submits their payment details: https://stripe.com/docs/payments/accept-a-payment-deferred
Where should I put all my POST and INSERT INTO mySQL code to create the order in that case ?
In the create-intent.php file ?
It depends how is your app architected.
Ideally, you can create a successful order when you receive a payment_intent.succeeded webhook event.
But you can pre-create an incomplete order in your backend as well. It depends on you.
But you can also collect customer address with Stripe Address Element: https://stripe.com/docs/elements/address-element/collect-addresses
Hello, me again
I've followed the PaymentIntent deferred tutorial and I have the following error message :
Payment details were collected through Stripe Elements using automatic payment methods and cannot be confirmed with a Payment Intent configured with payment_method_types.
Could you please share the PaymentIntent ID?
{
"expected_payment_method_type": "card",
"use_stripe_sdk": "true",
"key": "pk_test_pqFF1Y",
"client_secret": "***********************************",
"payment_method_data": {
"billing_details": {
"address": {
"country": "FR"
}
},
"type": "card",
"card": {
"number": " **** **** 4242",
"exp_month": "12",
"cvc": "",
"exp_year": "30"
},
"payment_user_agent": "stripe.js/ef908cc9a8; stripe-js-v3/ef908cc9a8; payment-element",
"muid": "3e6a0077-7aff-454f-9a79-e145f761891d503540",
"time_on_page": "14434",
"guid": "e73f2a37-63fd-4eb3-9fdb-6bdd24f490009d9104",
"sid": "7dd29381-da70-4c1d-a67e-9b1948e258e7faa6e5"
},
"return_url": "https://boutique.pompesfunebresdefrance.com/merci-2",
"client_context": {
"mode": "payment",
"currency": "eur"
}
}
Service de livraison de Fleurs en cérémonie - Remise en mains propres au maître de cérémonie - Fleurs Frâiches et de saisons - POMPES FUNÈBRES DE FRANCE
as the error message implies, you can't pass payment_method_types
Sorry, there it is : pi_3Mqw3OBCoEFG98lq1iNUxSww
so have a look at your backend code that creates the PaymentIntent
you need to pass automatic_payment_methods:{enabled:true} not false as you currently do. https://dashboard.stripe.com/test/logs/req_w8qfiKm5W3pE7j
How can I get rid of the giropay, EPS ect... then ?
I only need the card payment method
you can turn them off in your Stripe dashboard in the Payment Method pages of the settings
Oh ok perfect.
Ok so It's working now but I still dont know where to put my code to retreive all the inputs of my form and create an order on my mySQL database
I though it would be on the create.php file :
// Create the PaymentIntent and obtain clientSecret
const res = await fetch("/create.php", {
method: "POST",
});
But it's not
yep, if you want to POST additional data from your frontend to your backend you need to write the code for that.
I have the code
I just don't know where to put it
Since I don't have an action page on my form because of stripe, I don't know where to retrieve all my inputs data
This is where I'm confused
what have you tried so far?
you can add it to the fetch
await fetch("/create.php", {
method: "POST", body: JSON.stringify({my_value: "foobar'})
});
and then in your backend you can read that POST body.
I've copied/past your code to test and it gives me an error message
Uncaught SyntaxError: Invalid or unexpected token
I'm just giving you an example, you need to work on this as the developer