ILYAS415 Posted December 7, 2007 Share Posted December 7, 2007 Hi. Basically i have a paypal IPN script and the problem is its not working. What basically happens is... User goes through payment system | He pays and payment is succesful | On my ipn script its meant to email the user but it doesn't Script example: http://www.ragingmortals.com/donate.php You can log in with username: demo password: demo NOTE: Only use the above if you want to test the ipn script. Although you'll spend 1p it will be refunded. Just reply here to get a refund of 1p Here is the coding of the form which takes them to paypal to pay and notifies the ipn script:- <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="email hidden "> <input type="hidden" name="item_name" value="Raging Mortals - Package 1"> <input type="hidden" name="item_number" value="1"> <input type="hidden" name="amount" value="0.01"> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB"> <input type="hidden" name="bn" value="PP-BuyNowBF"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> <input type="hidden" name="notify_url" value="http://www.ragingmortals.com/ipn_res.php"> <input type="hidden" name="rm" value="2"> </form> At the end of the script the script is notifying the ipn script. Here is my second script:- <? // made by robin kohli ([email protected]) for 19.5 Degrees (http://www.19.5degs.com) // ----- edit these settings // database settings $host="localhost"; $ln=""; $pw=""; $db=""; // paypal email $paypal_email = "[email protected]"; // email address where script should send notifications $error_email = "[email protected]"; // email header $em_headers = "From: Raging Mortals <[email protected]>\n"; $em_headers .= "Reply-To: [email protected]\n"; $em_headers .= "Return-Path: [email protected]\n"; $em_headers .= "Organization: Raging Mortals\n"; $em_headers .= "X-Priority: 3\n"; // ----------------- require("ipn_cls.php"); $paypal_info = $HTTP_POST_VARS; $paypal_ipn = new paypal_ipn($paypal_info); foreach ($paypal_ipn->paypal_post_vars as $key=>$value) { if (getType($key)=="string") { eval("\$$key=\$value;"); } } $paypal_ipn->send_response(); $paypal_ipn->error_email = $error_email; if (!$paypal_ipn->is_verified()) { $paypal_ipn->error_out("Bad order (PayPal says it's invalid)" . $paypal_ipn->paypal_response , $em_headers); die(); } switch( $paypal_ipn->get_payment_status() ) { case 'Pending': $pending_reason=$paypal_ipn->paypal_post_vars['pending_reason']; if ($pending_reason!="intl") { $paypal_ipn->error_out("Pending Payment - $pending_reason", $em_headers); break; } case 'Completed': $qry= "SELECT i.mc_gross, i.mc_currency FROM item_table as i WHERE i.item_number='$item_number'"; mysql_connect("$host","$ln","$pw") or die("Unable to connect to database"); mysql_select_db("$db") or die("Unable to select database"); $res=mysql_query ($qry); $config=mysql_fetch_array($res); if ($paypal_ipn->paypal_post_vars['txn_type']=="reversal") { $reason_code=$paypal_ipn->paypal_post_vars['reason_code']; $paypal_ipn->error_out("PayPal reversed an earlier transaction.", $em_headers); // you should mark the payment as disputed now } else { if ( (strtolower(trim($paypal_ipn->paypal_post_vars['business'])) == $paypal_email) && (trim($mc_currency)==$config['mc_currency']) && (trim($mc_gross)-$tax == $quantity*$config['mc_gross']) ) { $qry="INSERT INTO paypal_table VALUES (0 , '$payer_id', '$payment_date', '$txn_id', '$first_name', '$last_name', '$payer_email', '$payer_status', '$payment_type', '$memo', '$item_name', '$item_number', $quantity, $mc_gross, '$mc_currency', '$address_name', '".nl2br($address_street)."', '$address_city', '$address_state', '$address_zip', '$address_country', '$address_status', '$payer_business_name', '$payment_status', '$pending_reason', '$reason_code', '$txn_type')"; if (mysql_query($qry)) { $paypal_ipn->error_out("This was a successful transaction", $em_headers); // you should add your code for sending out the download link to your customer at $payer_email here. $rand= rand("1111111111", "9999999999"); //CODE FOR CLAIMING THE POINTS $to = "$payer_email"; $subject = "You payment - RM"; $body = "Congratulations! You have purchased some points! Now please follow the below instructions...<br><font color=red><strong>YOUR CODE NUMBER FOR CLAIMING YOUR POINTS IS $rand</font><br> Please enter this at the Raging Mortals donation page. If you forget this code you must contact a member of staff by emailing [email protected]. We will look into your payment and give you the points manually."; mail($to, $subject, $body); echo "<br>Congratulations! You have purchased some points! Now please follow the below instructions...<br><font color=red><strong>YOUR CODE NUMBER FOR CLAIMING YOUR POINTS IS $rand</font><br> Please enter this at the Raging Mortals donation page. If you forget this code you must contact a member of staff by emailing [email protected]. We will look into your payment and give you the points manually."; } else { $paypal_ipn->error_out("This was a duplicate transaction", $em_headers); } } else { $paypal_ipn->error_out("Someone attempted a sale using a manipulated URL", $em_headers); } } break; case 'Failed': // this will only happen in case of echeck. $paypal_ipn->error_out("Failed Payment", $em_headers); break; case 'Denied': // denied payment by us $paypal_ipn->error_out("Denied Payment", $em_headers); break; case 'Refunded': // payment refunded by us $paypal_ipn->error_out("Refunded Payment", $em_headers); break; case 'Canceled': // reversal cancelled // mark the payment as dispute cancelled $paypal_ipn->error_out("Cancelled reversal", $em_headers); break; default: // order is not good $paypal_ipn->error_out("Unknown Payment Status - " . $paypal_ipn->get_payment_status(), $em_headers); break; } ?> Please help, thanks. Btw as u can see ipn script was not coded by me thats y im struggling :@ If theirs any info missing then just mention it plz. thnx Link to comment https://forums.phpfreaks.com/topic/80687-urgent-need-help-with-paypal-ipn-script/ Share on other sites More sharing options...
ILYAS415 Posted December 8, 2007 Author Share Posted December 8, 2007 Bump Link to comment https://forums.phpfreaks.com/topic/80687-urgent-need-help-with-paypal-ipn-script/#findComment-409661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.