Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- header('Content-type: text/html; charset=utf-8');
- require_once('../config/baseDonnees.php');
- // read the post from PayPal system and add 'cmd'
- $req = 'cmd=_notify-validate';
- foreach ($_POST as $key => $value) {
- $value = urlencode(stripslashes($value));
- $req .= "&$key=$value";
- }
- // post back to PayPal system to validate
- $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', 80, $errno, $errstr, 30);
- // assign posted variables to local variables
- $item_name = $_POST['item_name'];
- $item_number = $_POST['item_number']; // id commande
- $payment_status = $_POST['payment_status']; // Completed,
- $payment_amount = $_POST['mc_gross']; //0.01
- $payment_currency = $_POST['mc_currency']; //CAD
- $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)
- {
- if ($payment_status == "Completed")
- {
- if($email_account == $receiver_email)
- {
- $pseudo="1";
- $item_name="1";
- $req = $bdd->prepare('INSERT INTO commande(id_user, montant) VALUES(:pseudo, :offre)');
- $req -> bindParam(':pseudo', $pseudo, PDO::PARAM_STR);
- $req -> bindParam(':offre', $item_name);
- $req -> execute();
- }
- }
- }
- else if (strcmp ($res, "INVALID") == 0)
- {
- }
- }
- fclose ($fp);
- }
- ?>
Add Comment
Please, Sign In to add comment