I am having nothing but trouble here. I have had several forms up and running but no matter what I do, I cannot get this form to finalize properly in sandbox.
I am able to place my order, make a payment, and information is properly displayed on the success page. The information is in the database but it won't finalize.
I have tested the ipn. Everything works perfectly if I change the VERIFIED to INVALID. Thus I have concluded that although the transaction is going through, paypal is sending an invalid response but I can't figure it out. I assume it has something to do with my config files???
Can anyone help me??? Also, I am a bit confused as what to include in these files. Can I delete any fields that I am not using on my form or are there certain ones I need to leave in?
global_config.inc.php
config.inc.php
I am able to place my order, make a payment, and information is properly displayed on the success page. The information is in the database but it won't finalize.
I have tested the ipn. Everything works perfectly if I change the VERIFIED to INVALID. Thus I have concluded that although the transaction is going through, paypal is sending an invalid response but I can't figure it out. I assume it has something to do with my config files???
Can anyone help me??? Also, I am a bit confused as what to include in these files. Can I delete any fields that I am not using on my form or are there certain ones I need to leave in?
global_config.inc.php
PHP Code:
//create variable names to perform additional order processing
function create_local_variables()
{
$info["business"] = @$_POST["business"];
$info["receiver_email"] = @$_POST["receiver_email"];
$info["receiver_id"] = @$_POST["receiver_id"];
$info["item_name"] = @$_POST["item_name"];
$info["amount"] = @$_POST["amount"];
$info["quantity"] = @$_POST["quantity"];
$info["total"] = @$_POST["total"];
$info["item_number"] = @$_POST["item_number"];
$info["invoice"] = @$_POST["invoice"];
$info["custom"] = @$_POST["custom"];
$info["memo"] = @$_POST["memo"];
$info["tax"] = @$_POST["tax"];
$info["option_name1"] = @$_POST["option_name1"];
$info["option_selection1"] = @$_POST["option_selection1"];
$info["option_name2"] = @$_POST["option_name2"];
$info["option_selection2"] = @$_POST["option_selection2"];
$info["num_cart_items"] = @$_POST["num_cart_items"];
$info["mc_gross"] = @$_POST["mc_gross"];
$info["mc_fee"] = @$_POST["mc_fee"];
$info["mc_currency"] = @$_POST["mc_currency"];
$info["settle_amount"] = @$_POST["settle_amount"];
$info["settle_currency"] = @$_POST["settle_currency"];
$info["exchange_rate"] = @$_POST["exchange_rate"];
$info["payment_gross"] = @$_POST["payment_gross"];
$info["payment_fee"] = @$_POST["payment_fee"];
$info["payment_status"] = @$_POST["payment_status"];
$info["pending_reason"] = @$_POST["pending_reason"];
$info["reason_code"] = @$_POST["reason_code"];
$info["payment_date"] = @$_POST["payment_date"];
$info["txn_id"] = @$_POST["txn_id"];
$info["txn_type"] = @$_POST["txn_type"];
$info["payment_type"] = @$_POST["payment_type"];
$info["for_auction"] = @$_POST["for_auction"];
$info["auction_buyer_id"] = @$_POST["auction_buyer_id"];
$info["auction_closing_date"] = @$_POST["auction_closing_date"];
$info["auction_multi_item"] = @$_POST["auction_multi_item"];
$info["child_fname"] = @$_POST["child_fname"];
$info["child_lname"] = @$_POST["child_lname"];
$info["child_grade"] = @$_POST["child_grade"];
$info["child_division"] = @$_POST["child_division"];
$info["parent_fname"] = @$_POST["parent_fname"];
$info["parent_lname"] = @$_POST["parent_lname"];
$info["parent_email"] = @$_POST["parent_email"];
$info["parent_phone"] = @$_POST["parent_phone"];
$info["item1_color"] = @$_POST["item1_color"];
$info["item1_inscription"] = @$_POST["item1_inscription"];
$info["item1_notes"] = @$_POST["item1_notes"];
$info["item1_quantity"] = @$_POST["item1_quantity"];
$info["item2_color"] = @$_POST["item2_color"];
$info["item2_inscription"] = @$_POST["item2_inscription"];
$info["item2_notes"] = @$_POST["item2_notes"];
$info["item2_quantity"] = @$_POST["item2_quantity"];
$info["item3_color"] = @$_POST["item3_color"];
$info["item3_inscription"] = @$_POST["item3_inscription"];
$info["item3_notes"] = @$_POST["item3_notes"];
$info["item3_quantity"] = @$_POST["item3_quantity"];
$info["item4_color"] = @$_POST["item4_color"];
$info["item4_inscription"] = @$_POST["item4_inscription"];
$info["item4_notes"] = @$_POST["item4_notes"];
$info["item4_quantity"] = @$_POST["item4_quantity"];
$info["item5_color"] = @$_POST["item5_color"];
$info["item5_inscription"] = @$_POST["item5_inscription"];
$info["item5_notes"] = @$_POST["item5_notes"];
$info["item5_quantity"] = @$_POST["item5_quantity"];
$info["item6_color"] = @$_POST["item6_color"];
$info["item6_inscription"] = @$_POST["item6_inscription"];
$info["item6_notes"] = @$_POST["item6_notes"];
$info["item6_quantity"] = @$_POST["item6_quantity"];
$info["item7_color"] = @$_POST["item7_color"];
$info["item7_inscription"] = @$_POST["item7_inscription"];
$info["item7_notes"] = @$_POST["item7_notes"];
$info["item7_quantity"] = @$_POST["item7_quantity"];
$info["item8_color"] = @$_POST["item8_color"];
$info["item8_inscription"] = @$_POST["item8_inscription"];
$info["item8_notes"] = @$_POST["item8_notes"];
$info["item8_quantity"] = @$_POST["item8_quantity"];
$info["first_name"] = @$_POST["first_name"];
$info["last_name"] = @$_POST["last_name"];
$info["payer_business_name"] = @$_POST["payer_business_name"];
$info["address_name"] = @$_POST["address_name"];
$info["address_street"] = @$_POST["address_street"];
$info["address_city"] = @$_POST["address_city"];
$info["address_state"] = @$_POST["address_state"];
$info["address_zip"] = @$_POST["address_zip"];
$info["address_country"] = @$_POST["address_country"];
$info["address_status"] = @$_POST["address_status"];
$info["payer_email"] = @$_POST["payer_email"];
$info["payer_id"] = @$_POST["payer_id"];
$info["payer_status"] = @$_POST["payer_status"];
$info["notify_version"] = @$_POST["notify_version"];
$info["verify_sign"] = @$_POST["verify_sign"];
return $info;
}
// post transaction data using curl
function curlPost($url, $data)
{
global $paypal;
// build post string
foreach ($data as $i=>$v)
{
$postdata.= $i . "=" . urlencode($v) . "&";
}
$postdata.="cmd=_notify-validate";
//execute curl on the command line
exec("$paypal[curl_location] -d \"$postdata\" $url", $info);
$info = implode(",",$info);
return $info;
}
// posts transaction data using libCurl
function libCurlPost($url,$data)
{
foreach($data as $i=>$v)
{
$postdata .= $i . "=" . urlencode($v) . "&";
}
$postdata .= "cmd=_notify-validate";
$ch = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata);
//Start ob to prevent curl_exec from displaying stuff.
ob_start();
curl_exec($ch);
//Get contents of output buffer
$info=ob_get_contents();
curl_close($ch);
//End ob and erase contents.
ob_end_clean();
return $info;
}
//posts transaction data using fsockopen.
function fsockPost($url, $data)
{
$web = parse_url($url);
// build post string
foreach ($data as $i=>$v) {
$postdata .= $i . "=" . urlencode($v) . "&";
}
$postdata .= "cmd=_notify-validate";
//Set the port number
if ($web["scheme"] == "https")
{
$web["port"]="443";
$ssl = "ssl://";
}
else
$web["port"] = "80";
// create paypal connection
$fp = @fsockopen($ssl . $web[host], $web[port], $errnum, $errstr, 30);
// error checking
if (!$fp)
{
echo "$errnum: $errstr";
}
else
{
fputs($fp, "POST $web[path] HTTP/1.1\r\n");
fputs($fp, "Host: $web[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($postdata)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata . "\r\n\r\n");
// loop through the response from the server
while (!feof($fp))
{
$info[] = @fgets($fp, 1024);
}
//close fp - we are done with it
fclose($fp);
//break up results into a string
$info=implode(",",$info);
}
return $info;
}
//Display Paypal Hidden Variables
function showVariables()
{
global $paypal;
?>
<!-- PayPal Configuration -->
<input type="hidden" name="business" value="<?php echo @$paypal['business']; ?>" />
<input type="hidden" name="cmd" value="<?php echo @$paypal[cmd]?>" />
<input type="hidden" name="image_url" value="<?php echo "{$paypal['site_url']}{$paypal['image_url']}"; ?>" />
<input type="hidden" name="return" value="<? echo "$paypal[site_url]$paypal[success_url]"; ?>" />
<input type="hidden" name="cancel_return" value="<? echo "$paypal[site_url]$paypal[cancel_url]"; ?>" />
<input type="hidden" name="notify_url" value="<? echo "$paypal[site_url]$paypal[notify_url]"; ?>" />
<input type="hidden" name="rm" value="<?php echo @$paypal[return_method]?>" />
<input type="hidden" name="currency_code" value="<?php echo @$paypal[currency_code]?>" />
<input type="hidden" name="lc" value="<?php echo @$paypal[lc]?>" />
<input type="hidden" name="bn" value="<?php echo @$paypal[bn]?>" />
<input type="hidden" name="cbt" value="<?php echo @$paypal[continue_button_text]?>" />
<!-- Payment Page Information -->
<input type="hidden" name="no_shipping" value="<?php echo @$paypal[display_shipping_address]?>" />
<input type="hidden" name="no_note" value="<?php echo @$paypal[display_comment]?>" />
<input type="hidden" name="cn" value="<?php echo @$paypal[comment_header]?>" />
<input type="hidden" name="cs" value="<?php echo @$paypal[background_color]?>" />
<!-- Product Information -->
<input type="hidden" name="item_name" value="<?php echo @$paypal[item_name]?>" />
<input type="hidden" name="amount" value="<?php echo @$paypal[amount]?>" />
<input type="hidden" name="quantity" value="<?php echo @$paypal[quantity]?>" />
<input type="hidden" name="total" value="<?php echo @$paypal[total]?>" />
<input type="hidden" name="item_number" value="<?php echo @$paypal[item_number]?>" />
<input type="hidden" name="undefined_quantity" value="<?php echo @$paypal[edit_quantity]?>" />
<input type="hidden" name="on0" value="<?php echo @$paypal[on0]?>" />
<input type="hidden" name="os0" value="<?php echo @$paypal[os0]?>" />
<input type="hidden" name="on1" value="<?php echo @$paypal[on1]?>" />
<input type="hidden" name="os1" value="<?php echo @$paypal[os1]?>" />
<!-- Shipping and Misc Information -->
<input type="hidden" name="shipping" value="<?php echo @$paypal[shipping_amount]?>" />
<input type="hidden" name="shipping2" value="<?php echo @$paypal[shipping_amount_per_item]?>" />
<input type="hidden" name="handling" value="<?php echo @$paypal[handling_amount]?>" />
<input type="hidden" name="tax" value="<?php echo @$paypal[tax]?>" />
<input type="hidden" name="custom" value="<?php echo @$paypal[custom]?>" />
<input type="hidden" name="invoice" value="<?php echo @$paypal[invoice]?>" />
<!-- Customer Information -->
<input type="hidden" name="child_fname" value="<?php echo @$paypal[child_fname]?>" />
<input type="hidden" name="child_lname" value="<?php echo @$paypal[child_lname]?>" />
<input type="hidden" name="child_grade" value="<?php echo @$paypal[child_grade]?>" />
<input type="hidden" name="child_division" value="<?php echo @$paypal[child_division]?>" />
<input type="hidden" name="parent_fname" value="<?php echo @$paypal[parent_fname]?>" />
<input type="hidden" name="parent_lname" value="<?php echo @$paypal[parent_lname]?>" />
<input type="hidden" name="parent_email" value="<?php echo @$paypal[parent_email]?>" />
<input type="hidden" name="parent_phone" value="<?php echo @$paypal[parent_phone]?>" />
<input type="hidden" name="item1_color" value="<?php echo @$paypal[item1_color]?>" />
<input type="hidden" name="item1_inscription" value="<?php echo @$paypal[item1_inscription]?>" />
<input type="hidden" name="item1_notes" value="<?php echo @$paypal[item1_notes]?>" />
<input type="hidden" name="item1_quantity" value="<?php echo @$paypal[item1_quantity]?>" />
<input type="hidden" name="item2_color" value="<?php echo @$paypal[item2_color]?>" />
<input type="hidden" name="item2_inscription" value="<?php echo @$paypal[item2_inscription]?>" />
<input type="hidden" name="item2_notes" value="<?php echo @$paypal[item2_notes]?>" />
<input type="hidden" name="item2_quantity" value="<?php echo @$paypal[item2_quantity]?>" />
<input type="hidden" name="item3_color" value="<?php echo @$paypal[item3_color]?>" />
<input type="hidden" name="item3_inscription" value="<?php echo @$paypal[item3_inscription]?>" />
<input type="hidden" name="item3_notes" value="<?php echo @$paypal[item3_notes]?>" />
<input type="hidden" name="item3_quantity" value="<?php echo @$paypal[item3_quantity]?>" />
<input type="hidden" name="item4_color" value="<?php echo @$paypal[item4_color]?>" />
<input type="hidden" name="item4_inscription" value="<?php echo @$paypal[item4_inscription]?>" />
<input type="hidden" name="item4_notes" value="<?php echo @$paypal[item4_notes]?>" />
<input type="hidden" name="item4_quantity" value="<?php echo @$paypal[item4_quantity]?>" />
<input type="hidden" name="item5_color" value="<?php echo @$paypal[item5_color]?>" />
<input type="hidden" name="item5_inscription" value="<?php echo @$paypal[item5_inscription]?>" />
<input type="hidden" name="item5_notes" value="<?php echo @$paypal[item5_notes]?>" />
<input type="hidden" name="item5_quantity" value="<?php echo @$paypal[item5_quantity]?>" />
<input type="hidden" name="item6_color" value="<?php echo @$paypal[item6_color]?>" />
<input type="hidden" name="item6_inscription" value="<?php echo @$paypal[item6_inscription]?>" />
<input type="hidden" name="item6_notes" value="<?php echo @$paypal[item6_notes]?>" />
<input type="hidden" name="item6_quantity" value="<?php echo @$paypal[item6_quantity]?>" />
<input type="hidden" name="item7_color" value="<?php echo @$paypal[item7_color]?>" />
<input type="hidden" name="item7_inscription" value="<?php echo @$paypal[item7_inscription]?>" />
<input type="hidden" name="item7_notes" value="<?php echo @$paypal[item7_notes]?>" />
<input type="hidden" name="item7_quantity" value="<?php echo @$paypal[item7_quantity]?>" />
<input type="hidden" name="item8_color" value="<?php echo @$paypal[item8_color]?>" />
<input type="hidden" name="item8_inscription" value="<?php echo @$paypal[item8_inscription]?>" />
<input type="hidden" name="item8_notes" value="<?php echo @$paypal[item8_notes]?>" />
<input type="hidden" name="item8_quantity" value="<?php echo @$paypal[item8_quantity]?>" />
<input type="hidden" name="first_name" value="<?php echo @$paypal[firstname]?>" />
<input type="hidden" name="last_name" value="<?php echo @$paypal[lastname]?>" />
<input type="hidden" name="address1" value="<?php echo @$paypal[address1]?>" />
<input type="hidden" name="address2" value="<?php echo @$paypal[address2]?>" />
<input type="hidden" name="city" value="<?php echo @$paypal[city]?>" />
<input type="hidden" name="state" value="<?php echo @$paypal[state]?>" />
<input type="hidden" name="zip" value="<?php echo @$paypal[zip]?>" />
<input type="hidden" name="email" value="<?php echo @$paypal[email]?>" />
<input type="hidden" name="night_phone_a" value="<?php echo @$paypal[phone_1]?>" />
<input type="hidden" name="night_phone_b" value="<?php echo @$paypal[phone_2]?>" />
<input type="hidden" name="night_phone_c" value="<?php echo @$paypal[phone_3]?>" />
<?php } ?>
config.inc.php
PHP Code:
if (!isset($paypal))
$paypal = array();
$paypal["return_method"] = 2; // 1=GET 2=POST
$paypal["lc"] = "US";
$paypal["bn"] = "toolkit-php";
$paypal["cmd"] = "_xclick";
// payment Page Settings
$paypal["display_comment"] ="0"; //0=yes 1=no
$paypal["comment_header"] = "Comments";
$paypal["continue_button_text"] = "Continue >>";
$paypal["background_color"] = ""; //""=white 1=black
$paypal["display_shipping_address"] = "1"; //""=yes 1=no
$paypal["display_comment"] = "1"; //""=yes 1=no
// product settings
$paypal["item_name"] = isset($_POST["item_name"]) ? $_POST["item_name"] : "";
$paypal["amount"] = isset($_POST["amount"]) ? $_POST["amount"] : "";
$paypal["quantity"] = isset($_POST["quantity"]) ? $_POST["quantity"] : "";
$paypal["total"] = isset($_POST["total"]) ? $_POST["total"] : "";
$paypal["item_number"] = "";
$paypal["payment"] = isset($_POST["payment"]) ? $_POST["payment"] : "";
$paypal["on0"] = isset($_POST["on0"]) ? $_POST["on0"] : "";
$paypal["os0"] = isset($_POST["os0"]) ? $_POST["os0"] : "";
$paypal["on1"] = isset($_POST["on1"]) ? $_POST["on1"] : "";
$paypal["os1"] = isset($_POST["os1"]) ? $_POST["os1"] : "";
$paypal["edit_quantity"] = ""; // 1=yes ""=no
$paypal["invoice"] = isset($_POST["invoice"]) ? $_POST["invoice"] : "";
$paypal["tax"] = isset($_POST["tax"]) ? $_POST["tax"] : "";
// shipping and Taxes
$paypal["shipping_amount"] = isset($_POST["shipping_amount"]) ? $_POST["shipping_amount"] : "";
$paypal["shipping_amount_per_item"] = "";
$paypal["handling_amount"] = "";
$paypal["custom"] = isset($_POST["custom"]) ? $_POST["custom"] : "";
// customer Settings
$paypal["child_fname"] = isset($_POST["child_fname"]) ? $_POST["child_fname"] : "";
$paypal["child_lname"] = isset($_POST["child_lname"]) ? $_POST["child_lname"] : "";
$paypal["child_grade"] = isset($_POST["child_grade"]) ? $_POST["child_grade"] : "";
$paypal["child_division"] = isset($_POST["child_division"]) ? $_POST["child_division"] : "";
$paypal["parent_fname"] = isset($_POST["parent_fname"]) ? $_POST["parent_fname"] : "";
$paypal["parent_lname"] = isset($_POST["parent_lname"]) ? $_POST["parent_lname"] : "";
$paypal["parent_email"] = isset($_POST["parent_email"]) ? $_POST["parent_email"] : "";
$paypal["parent_phone"] = isset($_POST["parent_phone"]) ? $_POST["parent_phone"] : "";
$paypal["item1_color"] = isset($_POST["item1_color"]) ? $_POST["item1_color"] : "";
$paypal["item1_inscription"] = isset($_POST["item1_inscription"]) ? $_POST["item1_inscription"] : "";
$paypal["item1_notes"] = isset($_POST["item1_notes"]) ? $_POST["item1_notes"] : "";
$paypal["item1_quantity"] = isset($_POST["item1_quantity"]) ? $_POST["item1_quantity"] : "";
$paypal["item2_color"] = isset($_POST["item2_color"]) ? $_POST["item2_color"] : "";
$paypal["item2_inscription"] = isset($_POST["item2_inscription"]) ? $_POST["item2_inscription"] : "";
$paypal["item2_notes"] = isset($_POST["item2_notes"]) ? $_POST["item2_notes"] : "";
$paypal["item2_quantity"] = isset($_POST["item2_quantity"]) ? $_POST["item2_quantity"] : "";
$paypal["item3_color"] = isset($_POST["item3_color"]) ? $_POST["item3_color"] : "";
$paypal["item3_inscription"] = isset($_POST["item3_inscription"]) ? $_POST["item3_inscription"] : "";
$paypal["item3_notes"] = isset($_POST["item3_notes"]) ? $_POST["item3_notes"] : "";
$paypal["item3_quantity"] = isset($_POST["item3_quantity"]) ? $_POST["item3_quantity"] : "";
$paypal["item4_color"] = isset($_POST["item4_color"]) ? $_POST["item4_color"] : "";
$paypal["item4_inscription"] = isset($_POST["item4_inscription"]) ? $_POST["item4_inscription"] : "";
$paypal["item4_notes"] = isset($_POST["item4_notes"]) ? $_POST["item4_notes"] : "";
$paypal["item4_quantity"] = isset($_POST["item4_quantity"]) ? $_POST["item4_quantity"] : "";
$paypal["item5_color"] = isset($_POST["item5_color"]) ? $_POST["item5_color"] : "";
$paypal["item5_inscription"] = isset($_POST["item5_inscription"]) ? $_POST["item5_inscription"] : "";
$paypal["item5_notes"] = isset($_POST["item5_notes"]) ? $_POST["item5_notes"] : "";
$paypal["item5_quantity"] = isset($_POST["item5_quantity"]) ? $_POST["item5_quantity"] : "";
$paypal["item6_color"] = isset($_POST["item6_color"]) ? $_POST["item6_color"] : "";
$paypal["item6_inscription"] = isset($_POST["item6_inscription"]) ? $_POST["item6_inscription"] : "";
$paypal["item6_notes"] = isset($_POST["item6_notes"]) ? $_POST["item6_notes"] : "";
$paypal["item6_quantity"] = isset($_POST["item6_quantity"]) ? $_POST["item6_quantity"] : "";
$paypal["item7_color"] = isset($_POST["item7_color"]) ? $_POST["item7_color"] : "";
$paypal["item7_inscription"] = isset($_POST["item7_inscription"]) ? $_POST["item7_inscription"] : "";
$paypal["item7_notes"] = isset($_POST["item7_notes"]) ? $_POST["item7_notes"] : "";
$paypal["item7_quantity"] = isset($_POST["item7_quantity"]) ? $_POST["item7_quantity"] : "";
$paypal["item8_color"] = isset($_POST["item8_color"]) ? $_POST["item8_color"] : "";
$paypal["item8_inscription"] = isset($_POST["item8_inscription"]) ? $_POST["item8_inscription"] : "";
$paypal["item8_notes"] = isset($_POST["item8_notes"]) ? $_POST["item8_notes"] : "";
$paypal["item8_quantity"] = isset($_POST["item8_quantity"]) ? $_POST["item8_quantity"] : "";
$paypal["firstname"] = isset($_POST["firstname"]) ? $_POST["firstname"] : "";
$paypal["lastname"] = isset($_POST["lastname"]) ? $_POST["lastname"] : "";
$paypal["address1"] = isset($_POST["address1"]) ? $_POST["address1"] : "";
$paypal["address2"] = isset($_POST["address2"]) ? $_POST["address2"] : "";
$paypal["city"] = isset($_POST["city"]) ? $_POST["city"] : "";
$paypal["state"] = isset($_POST["state"]) ? $_POST["state"] : "";
$paypal["zip"] = isset($_POST["zip"]) ? $_POST["zip"] : "";
$paypal["email"] = isset($_POST["email"]) ? $_POST["email"] : "";
$paypal["phone_1"] = isset($_POST["phone1"]) ? $_POST["phone1"] : "";
$paypal["phone_2"] = isset($_POST["phone2"]) ? $_POST["phone2"] : "";
$paypal["phone_3"] = isset($_POST["phone3"]) ? $_POST["phone3"] : "";