Hoi,

Ik probeer dus een systeem te maken, dat je na de betaling naar een pagina gaat en daar kun je dingen doen. Bijvoorbeeld een query opzetten etc. Maar als ik het script in sandbox test (PayPal developers website) werkt het wel. Dan geeft die gewoon valid terug, maar zodra in het live test geeft die invalid terug.

paypal_ipn:

<?php
class Paypal_IPN
{
/** @var string $_url paypal url voor paypal
private $_url;

/**
* @param string $mode live/sandbox keuze.
*/
public function __construct($mode = 'live')
{
if ($mode == 'live')
$this->_url = 'https://www.paypal.com/cgi-bin/webscr';;
//
else
$this->_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';;
}

public function run()
{
$postFields = 'cmd=_notify-validate';

foreach($_POST as $key => $value)
{
$postFields .= "&$key=".urlencode($value);
}

$ch = curl_init();

curl_setopt_array($ch, array(
CURLOPT_URL => $this->_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));

$result = curl_exec($ch);
curl_close($ch);

$fh = fopen('result.txt', 'w');
fwrite($fh, $result . ' -- ' . $postFields);
fclose($fh);

echo $result;
}
}
?>

pagina waar je naartoe gaat als de betaling klaar is:

<?php
require('paypal_ipn.php');

$paypal = new Paypal_IPN('live');
$paypal->run();
?>

Reageren