Hi again,
I have almost completely integrated WePay into my site, but the last
thing I need to do is set up a checkout IPN so that when the status
changes to "captured" I can update my database.
The checkout json that I am sending with curl sends me to the checkout
page, and when I return I have all the information I need, but the
problem is that when the checkout status changes, the uri I supplied
for callback doesn't get visited. I use the php mail function on the
page that is supposed to be visited on callback, but the mail never
sends and my database never gets updated when the status changes.
Here is the code I use to send the checkout/create/:
//this is the array that I will JSON encode and send with curl
$arr = array('account_id'=>172777, "short_description"=>"This payment
will add $$amount to your business account balance.",
"type"=>"SERVICE", "reference_id"=>"$referenceId",
"amount"=>"$amount", "redirect_uri"=>"
http://www.mysite.com/
process.php", "callback_uri"=>"
http://www.mysite.com/callback/
businessCallback.php", "auto_capture"=>"true");
$sendThis = json_encode($arr);
//create a new disbursement call
$ch = curl_init('
https://stage.wepayapi.com/v2/checkout/create'); //
the URL of the call
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Authorization: Bearer
myToken', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendThis);
// execute the api call
$result = curl_exec($ch);
// echo the json response
$decoded = json_decode($result, true);
$redirect = $decoded['checkout_uri'];
header("Location: $redirect");
========================================================================
Here is the code I use on the page that is supposed to be posted to
when the status changes:
//I use mail to see if the page is visited
mail("
m...@myemail.com","payment callback", "callback has happened");
// am i supposed to use GET or POST here?
$checkoutId = $_GET['checkout_id'];
$ch = curl_init('
https://stage.wepayapi.com/v2/checkout');
$arguments = array(
"checkout_id"=>$checkoutId
);
$sendThis = json_encode($arguments);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Authorization: Bearer
myToken', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendThis);
// execute the api call
$result = curl_exec($ch);
// echo the json response
$decoded = json_decode($result, true);
$state = $decoded['state'];
$referenceId = $decoded['reference_id'];
//I then update my database here
Does anyone have any idea why the callback never seems to happen?
Thanks so much,
Chase