dimanche 15 février 2015

Paypal Webhook Response

I have been trying to get Paypal's Webhooks to work but all ive been running into is problems. I am trying to make a simple payment process where the user just pays for a product and then I want to setup webhooks to alert me when the payment is made, refunded, or reversed. I have the payment process setup and that is not a problem. I am also hosting the webhook url at a SSL enabled URL.


When I have a purchase go through it sends the webhook response to the link and I have it upload a basic "test" variable to the database just to show that it is indeed being contacted. I also try to insert all of the post data into the database but that doesn't seem to work. Here is the code that the webhook contacts:



<?php
header('HTTP/1.1 200 OK');

$servername = "xxxx";
$username = "xxxx";
$password = "xxxx";
$db = "xxxx";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $db);

if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO vars (var) VALUES ('test')";
$conn->query($sql);

foreach ($_POST as $param_name => $param_val) {
echo "Param: $param_name; Value: $param_val<br />\n";
$sql = "INSERT INTO vars (var) VALUES ('" . $param_name . "')";
$conn->query($sql);
}
?>


So like i said I see it insert the "test" into the database but when I try to go through the post variables (which from what i understand there should be some) it doesnt upload any variables.


But when I use the IPN simulator on the paypal developer sandbox and I send it to the link it inserts all of the post variables.


So why is it contacting the URL but not including any of the information? Am I receiving it incorrectly and not processing it right?


Thank you.





Aucun commentaire:

Enregistrer un commentaire