1. Go to this page and download the library: Download stevethomas/paypal-ipn library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stevethomas / paypal-ipn example snippets
$request = new PayPal\Ipn\Request\Curl();
$request->secure(true); //dont need to do this as its done by default, just demonstrating configuring the request component
$listener = new PayPal\Ipn\Listener($request);
$listener->setMode('sandbox');
try {
$status = $listener->verifyIpn();
}
catch (Exception $e) {
$error = $e->getMessage();
$status = false;
}
if ($status) {
// verified...
}
else {
// invalid...
$report = $listener->getReport();
}
namespace PayPal\Ipn\Request;
use PayPal\Ipn\Request as IpnRequest;
class CustomRequest extends IpnRequest
{
public function send()
{
//custom communication logic
}
}
namespace PayPal\Ipn\Response;
use PayPal\Ipn\Response as IpnResponse;
class CustomResponse extends IpnResponse
{
public function setBody($body)
{
$this->body = $body;
//do something else
}
public function setStatusCode($statusCode)
{
$this->statusCode = $statusCode;
//do something else
}
}
$request = new PayPal\Ipn\Request\CustomRequest();
$request->someCustomMethod();
$listener = new PayPal\Ipn\Listener($request);
...
$response = new PayPal\Ipn\Response\CustomResponse();
$response->someCustomMethod();
$request = new PayPal\Ipn\Request\CustomRequest(false, $response);
$listener = new PayPal\Ipn\Listener($request);
...
$data = array(
//...
);
$request = new PayPal\Ipn\Request\Curl($data);
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.