EchoFool Posted October 7, 2008 Share Posted October 7, 2008 I have a script which is suppose to auto run to allow the user recieve what they buy.. but its not doing anything when a user purchases i get the money via the banking system but the product and log is not given/created. I have the IPN set to www.domain.com/script.php as example... But yeah the script doesn't do anything .. =/ this is what i got: <?php include("connect.php"); $Date = date("Y-m-d H:i:s",time()); $insert = mysql_query("INSERT INTO gamelogs SET (Log,LogTime) VALUES('connect established','$Date')") Or die(mysql_error()); //------------------------------------------------ // Read post from PayPal system and create reply // starting with: 'cmd=_notify-validate'... // then repeating all values sent - VALIDATION. //------------------------------------------------ $postvars = array(); while (list ($key, $value) = each ($HTTP_POST_VARS)) { $postvars[] = $key; } $req = 'cmd=_notify-validate'; for ($var = 0; $var < count ($postvars); $var++) { $postvar_key = $postvars[$var]; $postvar_value = $postvars[$var]; $req .= "&" . $postvar_key . "=" . urlencode ($postvar_value); } //-------------------------------------------- // Create message to post back to PayPal... // Open a socket to the PayPal server... //-------------------------------------------- $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 ("www.paypal.com", 80, $errno, $errstr, 30); //--------------------------------------------- fwrite($log, "Vals: ". $invoice." ". $receiver_email." ". $item_name." ". $item_number." ". $quantity." ". $payment_status." ". $pending_reason." ".$payment_date." ". $payment_gross." ". $payment_fee." ". $txn_id." ". $txn_type." ". $first_name." ". $last_name." ". $address_street." ". $address_city." ". $address_state . " ".$address_zip." ". $address_country." ". $address_status." ". $payer_email. " ". $payer_status." ". $payment_type." ". $notify_version." ".$custom." ". $verify_sign. "\ n"); //---------------------------------------------------------------------- // Check HTTP connection made to PayPal OK, If not, print an error msg //---------------------------------------------------------------------- if (!$fp) { echo "$errstr ($errno)"; fwrite($log, "Failed to open HTTP connection!"); $res = "FAILED"; } //-------------------------------------------------------- // If connected OK, write the posted values back, then... //-------------------------------------------------------- else { fputs ($fp, $header . $req); //------------------------------------------- // ...read the results of the verification... // If VERIFIED = continue to process the TX... //------------------------------------------- while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { //---------------------------------------------------------------------- // If the payment_status=Completed... Get the password for the product // from the DB and email it to the customer. //---------------------------------------------------------------------- if (strcmp ($payment_status, "Completed") == 0) { $UPDATE = mysql_query("UPDATE userpacks SET Quantity=Quantity+$quantity WHERE UserID='$custom'"); } //---------------------------------------------------------------------- // If the payment_status is NOT Completed... You'll have to send the // password later, by hand, when the funds clear... //---------------------------------------------------------------------- else { $subject = "Thank You"; $headers = 'From: Donations'; $message = "Thankyou for your donation.\n\nThe donator status for the donation will be sent to you when the funds have cleared.\n\nThankyou \n\n"; mail($payer_email, $subject, $message, $headers); mail($receiver_email, "Incomplete PayPal Process", "An incomplete transaction requires your attention."); } //---------------------------------------------------------------- // ..If UNVerified - It's 'Suspicious' and needs investigating! // Send an email to yourself so you investigate it. //---------------------------------------------------------------- else { mail($payer_email, "An Error Occurred...", "Dear player,\n an error occurred while PayPal was processing your order. Please contact paypal for checking this issue!"); mail($receiver_email, "Invalid PayPal Transaction!", "An invalid transaction requires your attention. Invoice number: $invoice UserID: $custom"); } } //-------------------------------------- // Insert Transaction details into DB. //-------------------------------------- $qry = "INSERT into donatorlogs ( invoice, receiver_email, item_name, item_number, quantity, payment_status, pendi ng_reason, payment_date, payment_gross, payment_fee, txn_id, txn_type, first_nam e, last_name, address_street, address_city, address_state, address_zip, address_ country, address_status, payer_email, payer_status, payment_type, notify_version , verify_sign ) VALUES ( \"$invoice\", \"$receiver_email\", \"$item_name\", \"$item_number\", \"$quantity\", \"$payment_status\", \"$pending_reason\", \"$payment_date\", \"$payment_gross\", \"$payment_fee\", \"$txn_id\", \"$txn_type\", \"$first_name\", \"$last_name\", \"$address_street\", \"$address_city\", \"$address_state\", \"$address_zip \", \"$address_country\", \"$address_status\", \"$payer_email\", \"$payer_status \", \"$payment_type\", \"$notify_version\", \"$verify_sign\" ) "; $result = mysql_query($qry); } } //------------------------------------------- // Close PayPal Connection, Log File and DB. //------------------------------------------- fclose ($fp); fclose ($log); ?> Link to comment https://forums.phpfreaks.com/topic/127387-help-with-transaction-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.