IPN Paypal

Par Yubo, il y a 10 ans


Bonjour,
j'ai suivis le tutoriel de grafikart pour utiliser l'ipn de paypal mais quand je test, il ne créer même pas les fichiers logs et quand j'update mes données comment je pourrais faire pour que ça incrémente le nombre de point? Par exemple si la personne à 5 points et achète 10 points, qu'il est 15 après le paiment.

Merci

<?php include 'inc/db.php'; $email_account = "gtt_buis@gmail.com"; $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; parse_str($_POST['custom'],$custom); if (!$fp) { } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // vérifier que payment_status a la valeur Completed if ( $payment_status == "Completed") { if ( $email_account == $receiver_email) { /** * C'EST LA QUE TOUT SE PASSE * PS : tjrs penser à vérifier la somme !! */ file_put_contents('log', print_r($_POST, true)); $req = $pdo->query("SELECT * FROM offers WHERE name='.$item_name.' LIMIT 1"); $d = $req->fetch(); if(!empty($d)){ $gtc = $custom['price']; $uid = $custom['user_id']; $data = serialize($_POST); //on met à jours le compte $pdo->query('UPDATE users SET gtc = '.$gtc.' WHERE id = '.$uid); //on save la commande $pdo->query("INSERT INTO shop_orders SET user_id = $uid, amount=$payment_amount, created=NOW(), datas=$data"); file_put_contents('log', 'paiement confirmé'); }else{ file_put_contents('log', 'Le paiment correspond à aucun offre'); } /** * FIN CODE */ } } else { // Statut de paiement: Echec } exit(); } else if (strcmp ($res, "INVALID") == 0) { // Transaction invalide } } fclose ($fp); }

3 réponses

Lanzelet, il y a 10 ans

// Set up the acknowledgement request headers
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// Open a socket for the acknowledgement request
$fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

// Send the HTTP POST request back to PayPal for validation
fputs($fp, $header . $req);

Il y a des changement à effectuer j'ai trouve ceci sur https://developer.paypal.com/docs/classic/ipn/gs_IPN/
mais pas plus de resultat de mon côte lol.

Xstoudi, il y a 10 ans

Y a pas une faille SQL ?

Xen0risDEV, il y a 10 ans

Je te conseillerais fortement d'utilisé cURL !