paypal recupération données
bonjour
je galère depuis plusieurs jours, je n'arrive pas à comprendre pour récupérer les données.
html du bouton
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JX2V2J92">
<table>
<tr><td><input type="hidden" name="on0" value="Achat TutoCode">Achat TutoCode</td></tr><tr><td><select name="os0">
<option value="1 Code">1 Code 1.00 EUR</option>
<option value="5 Codes">5 Codes 5.00 EUR</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="EUR">
<input type="image" src="https://www.sandbox.paypal.com/fr_XC/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée !">
<img alt="" border="0" src="https://www.sandbox.paypal.com/fr_XC/i/scr/pixel.gif" width="1" height="1">
</form> |
après je prend l'option
Dirigez vos clients vers cette URL lorsqu’ils terminent leur paiement
le code de cette page (c'est un ancien code en 2010) mais ne fonctionne plus.
Leur doc comprend absolument rien avec leur api et je suis nul en anglais.
Quelqu'un peut m'aider pour récupérer tous les variable qui est sont en bas: item_name ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| // read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
//test sandbox
$auth_token = "AFcWxV21C7fd0v3bYC1AoAFPVzeEN1nQSdhqib.d4wim1kr";
$req .= "&tx=$tx_token&at=$auth_token";
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
//$header .= "Host: www.paypal.com:443\r\n";// pas utilisé
$header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); //test sandbox
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
echo $itemname = $keyarray['item_name'];
echo $payment_status = $keyarray['payment_status']; // statut refusé ou accepté
$payment_amount = $keyarray['mc_gross']; // montant de l'article
$payment_currency = $keyarray['mc_currency'];// en euros
$txn_id = $keyarray['txn_id'];// identifiant
$receiver_email = $keyarray['payer_email'];//mail paypal de paiement
$user_payment = $keyarray['custom']; |