#Mickadelyon

1 messages · Page 1 of 1 (latest)

chrome tapirBOT
neat sundial
#

Hi there!

#

How can I help?

swift quiver
#

J'e suis en test avec webhooks et j'ai une erreur 400

neat sundial
swift quiver
#

I wrote earlier for help and I was sent to my host who now sends me back to you with the feeling of being on tennis

neat sundial
#

Sorry to hear that.

#

So what is the error you see on your end?

swift quiver
neat sundial
#

Got it. If you check in the Stripe dashboard you can see that your server returned a 400 error.

#

What is the exact error you see in your server logs?

swift quiver
#

Message from my host Hello,

On our side, there is no ongoing incident or error related to your services, I invite you to contact the stripe.com service mentioned in the error message.

I wish you a good day.
In order to confirm the resolution of your request, you can reply to this email by indicating "Accepted" in the first line of your reply, or close the exchange in the customer area.
To refuse the proposed solution, you can provide details in response to this email by indicating "Refused" in the first line, or by continuing the current exchange in the customer area.
Please note that if there are no comments within the next seven days, this request will be automatically closed.

#

logs is 54.187.205.235 cvdumonde.com - [23/Feb/2023:11:15:16 +0100] "POST /paiement/public/index.php HTTP/1.1" 400 - "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)"

#

Would you like my php code?

neat sundial
#

Then I suggest you to add a lot of logs to your backend code, then trigger an event, and they check your server logs to see what is displayed.

swift quiver
neat sundial
#

You can start by adding a echo("the script is starting") at the very beginning of your file. And then log $payload, $signature, and $webhookSecret.

#

Then check what you see in your server.

swift quiver
#

this is my log [Thu Feb 23 14:38:59 2023] [error] [client 217.74.111.244] [host www.cvdumonde.com] AH01264: script not found or unable to stat:

neat sundial
#

No idea what this is, but it's not related to Stripe. So you don't see "the script is starting" in your logs?

swift quiver
#

No recent webhook attempt

neat sundial
#

Sorry but it's hard to help. All I can say is Stripe sent your server the event, and your server responded with a 400. You need to investiguate on your end what is going on.

swift quiver
#

Signature_verification_failed
Message: No signatures found matching the expected signature for payload

neat sundial
#

Great, this is useful!

#

Getting a SignatureVerificationError is quite common. It usually comes from two potential errors:

  • You are using the wrong webhook secret. So please double check you are using the correct one. It should look like whsec_xxx and match the one displayed in your dashboard
  • The payload you pass in the constructEvent function is not the raw payload. So you need to ensure that you get the raw body of the HTTP request that Stripe sent you, without any interference by your code or framework in the middle.
    To debug this you'll need to add logging to log every value you pass to constructEvent (the payload, the secret, and the signature header) and then we can try to have a look at what part is wrong
swift quiver
neat sundial
#

This doesn't help. Like I said above:

To debug this you'll need to add logging to log every value you pass to constructEvent (the payload, the secret, and the signature header) and then we can try to have a look at what part is wrong

swift quiver
#

this is my code file_put_contents("constructEvent_logs.txt", "Payload: " . $payload . "\nSignature: " . $signature . "\nWebhook secret: " . $webhookSecret . "\n", FILE_APPEND);
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $signature, $webhookSecret
);
}

pulsar flicker
#

Yes, and you should log the contents of $payload, $signature, $webhookSecret to help you debug this

#

The most common causes of this error are mutated body/payload and the wrong secret

swift quiver
#

it's done and I returned the logs to you

#

and everything looks good to me

neat sundial
#

Looks like you are using the wrong webhook secret.

#

It should end with tqcO

#

But the on your are using ends with 146n. You can find the full ID in your dashboard.

swift quiver
#

I am lulled in shame, I reversed my key Signing secret key with id webhooks

swift quiver
#

is it possible to ask how to deal with the following $_POST["name"]=>object?

pulsar flicker
#

I'm not sure what you mean by that. Can you explain more?

swift quiver
#

how to treat the returned values ​​these values ​​are $_post?

pulsar flicker
#

Can you share an example? I still don't understand what you're trying to do exactly

swift quiver
#

//bdd
include '../../inc/connect.php';

  // Enregistrez les informations dans votre base de données
  $maj_abo = $bdd->prepare('INSERT INTO resho_abonnement 
          (ID_USER, ABONNEMENT, TARIF_HT, DATE_CREATION, ETAT_1_OK_2_IMPAYE_3_ANNULEE) 
          VALUES 
          (?, ?, ?, ?, ?)
          ON DUPLICATE KEY UPDATE 
          ABONNEMENT = VALUES(ABONNEMENT), 
          TARIF_HT = VALUES(TARIF_HT), 
          ETAT_1_OK_2_IMPAYE_3_ANNULEE = VALUES(ETAT_1_OK_2_IMPAYE_3_ANNULEE)');
  $maj_abo->execute(array($profil_OK["ID"], $paymentIntent->id, $paymentIntent->amount, $tomorrow, 1));
pulsar flicker
#

Ok, and what does this have to do with webhook event processing?