#cgourmelon

1 messages · Page 1 of 1 (latest)

past turretBOT
drowsy comet
#

Hi! Let me help you with this.

spiral condor
#

Thx Vanya

#

Here's our ecommerce page :

#

Sorry it's in French

drowsy comet
#

Could you please give more context?

push some inputs to create an order on my webhook
What do you mean by this?

spiral condor
#

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 :

#

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

drowsy comet
#

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

spiral condor
#

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

drowsy comet
#

I understand.

spiral condor
#

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}}}

drowsy comet
spiral condor
#

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 ?

drowsy comet
#

It depends how is your app architected.

#

Ideally, you can create a successful order when you receive a payment_intent.succeeded webhook event.

spiral condor
#

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.

drowsy comet
#

Could you please share the PaymentIntent ID?

past turretBOT
spiral condor
#

{
"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"
}
}

full jetty
#

as the error message implies, you can't pass payment_method_types

spiral condor
#

Sorry, there it is : pi_3Mqw3OBCoEFG98lq1iNUxSww

full jetty
#

so have a look at your backend code that creates the PaymentIntent

spiral condor
#

How can I get rid of the giropay, EPS ect... then ?

#

I only need the card payment method

full jetty
#

you can turn them off in your Stripe dashboard in the Payment Method pages of the settings

spiral condor
#

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

full jetty
#

yep, if you want to POST additional data from your frontend to your backend you need to write the code for that.

spiral condor
#

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

full jetty
#

what have you tried so far?

full jetty
#

await fetch("/create.php", {
method: "POST", body: JSON.stringify({my_value: "foobar'})
});
and then in your backend you can read that POST body.

spiral condor
#

I've copied/past your code to test and it gives me an error message

#

Uncaught SyntaxError: Invalid or unexpected token

full jetty
#

I'm just giving you an example, you need to work on this as the developer

spiral condor
#

objectInBody = {
Id:"id",
Input: "input"
};

// Create the PaymentIntent and obtain clientSecret
const res = await fetch("/create.php", {
method: "POST",
body: JSON.stringify(objectInBody),
});

#

Ok it's working like this