i am using the following code for my paypal configuration here's the code
///Paypal Array///
$data=array(
//merchant email for live
//'merchant_email'=>'sumofish@yahoo.com',
//merchant email for test
'merchant_email'=>'uneebmir321-facilitator@yahoo.com',
'product_name'=>$bundleplan." Bundle Plan",
's_amount'=>$bundle_came_price, // Second` Amount
's_cycle'=>'M', //Second Period M=montrh,Y=year ,D=Days, W='week'
's_period'=>$period, // Second Cycle
//see small_price fucntionality again
'small_price'=>$bundle_came_price,
////see small_price fucntionality again
'currency_code'=>'USD',
'thanks_page'=>"https://".$_SERVER['HTTP_HOST'].'/puppy/puppy/thanks222.php',
'notify_url'=>"https://puppybundle.com/beta/ipn.php",
'cancel_url'=>"https://puppybundle.com/beta/index.php",
//true for sandbox false for live
'paypal_mode'=>true,
//true for sandbox false for live
'currency_symbole'=>'$'
);
///Paypal Array///
and here's the ipn class
<?php
session_start();
$unique_id=$_SESSION['unique_id'];
include("db.php");
file_put_contents("newfile.txt",var_export($_POST,true));
$status="not_completed";
$status2="paid";
$status3="remaining";
$zero=0;
$currency="CAD";
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// STEP 2: Post IPN data back to paypal to validate
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); // change to [...]sandbox.paypal[...] when using sandbox to test
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below.
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
// STEP 3: Inspect IPN validation result and act accordingly
if (strcmp (trim($res), "VERIFIED") == 0) {
// check whether the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
// assign posted variables to local variables
$price = $_POST['mc_gross'];
$currency = $_POST['mc_currency'];
$payer_email = $_POST['payer_email'];
$txn_id=$_POST['txn_id'];
$item_name = $_POST['item_name'];
if($item_name=="Small Bundle Plan"){
$item_name="small";
}
parse_str($_POST['custom'],$_MYVAR);
$custom =$_MYVAR['id'];
$unique_id =$_MYVAR['unique_id'];
trim($custom);
$txt =$custom;
$currency_code= $_POST['currency_code'];
$fulldate = gmdate('Y-m-d H:i:s');
if($txn_id){
$query="UPDATE `puppy_pending_transaction` SET `status`=? WHERE unique_id=?";
$stmt = $db->prepare($query);
if($stmt){
$stmt->bind_param("ss", $status2,$unique_id);
$stmt->execute();
$stmt->close();
}
$query="INSERT INTO `puppy_transaction_confirmed`(`transaction_id`,`unique_id`, `user_id`, `payer_email`, `transaction_time`, `package`, `amount`, `currency`,`status_delivery`) VALUES (?,?,?,?,?,?,?,?,?)";
$stmt = $db->prepare($query);
if($stmt)
{
$check=$stmt->bind_param("sssssssss",$txn_id,$unique_id,$custom,$payer_email,$fulldate,$item_name,$price,$currency,$status);
$stmt->execute();
$stmt->close();
}
$query="INSERT INTO `puppy_paid_transaction_record`(`unique_id`, `month_delivered`, `total`,`status`) VALUES (?,?,?,?)";
$stmt = $db->prepare($query);
if($stmt){
$stmt->bind_param("ssss", $unique_id,$zero,$item_name,$status3);
$stmt->execute();
$stmt->close();
}
}
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
?>
the problem is this code is working 100% fine for sandbox now what i did for live version is to change the merchant email to client email and paypal_mode to false for live testing and one other thing i changed the
`$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
in the ipn class to
`$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');`
for live mode i have used ipn simulator to validate my file and it is ok more over i am sure about the ipn path i set in paypal for merchant that is also ok am sure of it, i dont know whats wrong! can anybody point me on the right direction?