$value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; //$$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"; // assign posted variables to local variables $PAYPAL['receiver_email'] = $_POST['receiver_email']; $PAYPAL['txn_id'] = $_POST['txn_id']; $PAYPAL['payer_email'] = $_POST['payer_email']; $PAYPAL['payment_currency'] = $_POST['mc_currency']; $PAYPAL['payment_status'] = $_POST['payment_status']; $PAYPAL['reason_code'] = $_POST['reason_code']; if (!$connection) { if($debug_mode) mail($email_admin, "Paypal : pas de connection","$errno $errstr"); } else { if($debug_mode) mail($email_admin, "Paypal : connection",""); fputs ($connection, $header . $req); while (!feof($connection)) { $res = fgets ($connection, 1024); if (strcmp ($res, "VERIFIED") == 0) { if($debug_mode) mail($email_admin, "Paypal : verifie",""); // check that receiver_email is your Primary PayPal email if(in_array($PAYPAL['receiver_email'] , $application->paypal->business_list)) { // check that txn_id has not been previously processed if($debug_mode) mail($email_admin, "Paypal : business email ok : " . $PAYPAL['receiver_email'],""); // check that payment_amount/payment_currency are correct if(in_array($PAYPAL['payment_currency'], $application->paypal->currency_list) ) { if($debug_mode) mail($email_admin, "Paypal : currency ok " . $PAYPAL['payment_currency'],""); // process payment $message_status = traiter_status($PAYPAL['payment_status'],$PAYPAL['reason_code']); // creer la facture include "paypal-completion.php"; if(strcmp($PAYPAL['payment_status'] , "Completed") == 0) { if($debug_mode) mail($email_admin, "Paypal : status is completed",""); } else { if($debug_mode) mail($email_admin, "Paypal : status is not completed",""); } if($debug_mode) mail($email_admin, "Paypal : apres traitement " . $message_status,""); } else { if($debug_mode) mail($email_admin, "Paypal : currency invalid " . $PAYPAL['payment_currency'],""); } } else { if($debug_mode) mail($email_admin, "Paypal : business email invalid " . $PAYPAL['receiver_email'],""); } } else if (strcmp ($res, "INVALID") == 0) { if($debug_mode) mail($email_admin, "Paypal : invalid (is it an attack)",""); } } fclose ($connection); } /* $PAYPAL['first_name'] = $_POST["first_name"]; $PAYPAL['last_name'] = $_POST["last_name"]; $PAYPAL['address_name'] = $_POST["address_name"]; $PAYPAL['address_street'] = $_POST["address_street"]; $PAYPAL['address_city'] = $_POST["address_city"]; $PAYPAL['address_state'] = $_POST["address_state"]; $PAYPAL['address_country'] = $_POST["address_country"]; $PAYPAL['address_zip'] = $_POST["address_zip"]; $PAYPAL['contact_phone'] = $_POST["contact_phone"]; $PAYPAL['payment_amount'] = $_POST['mc_gross']; $PAYPAL['item_name'] = $_POST['item_name']; $PAYPAL['item_number'] = $_POST['item_number']; $PAYPAL['invoice'] = $_POST["invoice"]; $PAYPAL['custom'] = $_POST["custom"]; */ // pour les abonnements /*$PAYPAL['txn_type'] = $_POST["txn_type"]; $PAYPAL['subscr_date'] = $_POST["subscr_date"]; $PAYPAL['recurring'] = $_POST["recurring"]; $PAYPAL['period3'] = $_POST["period3"]; $PAYPAL['mc_amount3'] = $_POST["mc_amount3"]; $PAYPAL['mc_currency'] = $_POST["mc_currency"]; $PAYPAL['subscr_id'] = $_POST["subscr_id"]; */ ?>