IPN listener paypel php
// example for laravel
public function listener(Request $request)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
$response = curl_exec($ch);
curl_close($ch);
if ($response == "VERIFIED") {
$this->payerEmail = $_POST['payer_email'];
$this->name = $_POST['first_name'] . " " . $_POST['last_name'];
$this->price = $_POST['mc_gross'];
$this->currency = $_POST['mc_currency'];
$this->paymentStatus = $_POST['payment_status'];
$this->amount = $_POST['quantity'];
$this->purchase_id = $_POST['txn_id'];
//$this->other
//$this->other1
if ($this->paymentStatus == "Completed") {
// code if
} else {
// code else
}
}
}
Zer0