Community Forums 

Main Content

Re:Remot Call not working

    Jul 30 2013 01:05:58

    #1

    Lynn Greene

    Join date : 2011-07-25      Posts : 20

    anon said It is hard to tell what is wrong without seeing your remote call script code.

    Does the method (get/post) you set in the cart match what your test form is using (and what your script is looking for)?


    Here is my remote call script code:

    // this code is called after payment through Mal's Shopping Cart
    foreach ( $_POST AS $ky=>$vl ) {
    $variable[$ky] = $vl;
    }
    // $variable['date'] = "2 Aug 2011 - 19:26";
    // print_r ($variable);
    $offset=strpos($variable['date'], ' - ');
    $variable['date'] = substr($variable['date'],0,$offset);
    $mo['Jan']="01";
    $mo['Feb']="02";
    $mo['Mar']="03";
    $mo['Apr']="04";
    $mo['May']="05";
    $mo['Jun']="06";
    $mo['Jul']="07";
    $mo['Aug']="08";
    $mo['Sep']="09";
    $mo['Oct']="10";
    $mo['Nov']="11";
    $mo['Dec']="12";
    $offset = strpos($variable['date'], " ");
    $day = substr("0".substr($variable['date'],0,$offset),-2);
    $month=substr($variable['date'],$offset+1,3);
    $year=substr($variable['date'],-4);
    $variable['date']=$year."-".$mo[$month]."-".$day;
    $cart = "";
    $cart_left = $variable['cart'];
    while ($cart_left != "") {
    $offset = strpos($cart_left, ' : ');
    $description = substr($cart_left,0,$offset+1);
    // echo "cart=$cart!<BR>";
    $cart_left = substr($cart_left,$offset+3);
    $offset = strpos($cart_left," ");
    $quantity = substr($cart_left,0,$offset);
    if ($cart == "") {
    $cart = $quantity." each - ".$description."\n";
    } else {
    $cart.= $quantity." each - ".$description."\n";
    }
    $offset = strpos($cart_left, '~');
    if ($offset > 0) {
    $cart_left = substr($cart_left,$offset+1);
    } else {
    $cart_left = "";
    }
    }
    $variable['cart'] = $cart;
    $offset=strpos($variable['inv_name'], ' ');
    $variable['inv_first_name'] = substr($variable['inv_name'],0,$offset);
    $variable['inv_last_name'] = substr($variable['inv_name'],$offset+1);
    $thankyou_notification = "";
    $source = "clickandlearn.com";
    $order_date = "0000-00-00";
    $item = $variable['cart'];
    $ship_date ="0000-00-00";
    $shipped_notification ="";
    $processing_fee ="";
    $timestamp = date('Y-m-d H:i:s');
    if ($variable['inv_country'] == "US") {$variable['inv_country'] = "United States";}
    Include ('mysql_connect.inc');
    $next_key = 1;
    $start_break = false;
    $query = "SELECT * FROM `sales` order by `key`" ;
    // echo "query=$query<br>";
    $result = mysql_query( $query ) ;
    // echo "Results:<br>".$result."<br>";
    if ($result != "") {
    $num_results = mysql_num_rows ($result);
    // echo $num_results." items<br>";
    for ($i=0; $i <= $num_results; $i++)
    {
    $row = mysql_fetch_array($result) ;
    $key = $row['key'] ;
    if ($key >= $key_start && $start_break == false)
    {
    // echo "$key - Entry<br>";
    if ($key != $next_key)
    {
    $start_break = true;
    } else {
    // echo "Key=$key<br>";
    $next_key = $key + 1;
    }
    }
    }
    }
    // echo "<BR>";
    // echo "Method=".$variable['method']."<BR>";
    // echo "First Name=".$variable['inv_first_name']."<BR>";
    // echo "Last Name=".$variable['inv_last_name']."<BR>";
    // echo "Name=".$variable['inv_name']."<BR>";
    // echo "Company=".$variable['inv_company']."<BR>";
    // echo "Address1=".$variable['inv_addr1']."<BR>";
    // echo "Address2=".$variable['inv_addr2']."<BR>";
    // echo "State=".$variable['inv_state']."<BR>";
    // echo "Zip=".$variable['inv_zip']."<BR>";
    // echo "Country=".$variable['inv_country']."<BR>";
    // echo "Telephone=".$variable['tel']."<BR>";
    // echo "E-Mail=".$variable['email']."<BR>";
    // echo "IP Address=".$variable['ip']."<BR>";
    // echo "Cart=".$variable['cart']."<BR>";
    // echo "Total=".$variable['total']."<BR>";
    // echo "Tax=".$variable['tax']."<BR>";
    // echo "Fee=".$variable['mc_fee']."<BR>";
    // echo "Payment Date=".$variable['date']."<BR>";
    // echo "Thank you date=".$thankyou_notification."<BR>";
    // echo "Source=".$source."<BR>";
    // echo "Order Date=".$order_date."<BR>";
    // echo "Ship Date=".$ship_date."<BR>";
    // echo "Processing Fee=".$processing_fee."<BR>";
    // echo "Extra Data=".$variable['edata']."<BR>";
    // echo "Timestamp=".$timestamp."<BR>";
    // echo "Key=".$next_key."<BR>";
    $query = "INSERT INTO `sales` (`txn_type`,`first_name`,`last_name`,`address_name`,`address_company`,`address_street`,`address_city`,`address_state`,`address_zip`,`address_country`,`contact_phone`,
    `payer_email`,`ip`,`item_desc`,`mc_gross`,`tax`,`mc_fee`,`payment_date`,`thankyou_notification`,`source`,`order_date`,
    `ship_date`,`processing_fee`,`about`,`timestamp`,`key`) values
    ('".addslashes($variable['method'])."', '"
    .addslashes($variable['inv_first_name'])."', '"
    .addslashes($variable['inv_last_name'])."', '"
    .addslashes($variable['inv_name'])."', '"
    .addslashes($variable['inv_company'])."', '"
    .addslashes($variable['inv_addr1'])."', '"
    .addslashes($variable['inv_addr2'])."', '"
    .addslashes($variable['inv_state'])."', '"
    .addslashes($variable['inv_zip'])."', '"
    .addslashes($variable['inv_country'])."', '"
    .addslashes($variable['tel'])."', '"
    .addslashes($variable['email'])."', '"
    .addslashes($variable['ip'])."', '"
    .addslashes($variable['cart'])."', '"
    .addslashes($variable['total'])."', '"
    .addslashes($variable['tax'])."', '"
    .addslashes($variable['mc_fee'])."', '"
    .addslashes($variable['date'])."', '"
    .addslashes($thankyou_notification)."', '"
    .addslashes($source)."', '"
    .addslashes($order_date)."', '"
    .addslashes($ship_date)."', '"
    .addslashes($processing_fee)."', '"
    .addslashes($variable['edata'])."', '"
    .addslashes($timestamp)."', '"
    .addslashes($next_key)."')";
    $result = mysql_query( $query ) ;
    if ($result) {
    // echo mysql_affected_rows().' inserted into database.';
    } else {
    $emailtext.="Failed -".mysql_error()."!\n\n";
    }
    mysql_close($link);

    ?>

    Here is my cart HTML:

    <form action="http://ww7.aitsafe.com/cf/add.cfm"; method="post">
    <input type="hidden" name="userid" value="97404049">
    <input type="hidden" name="product[]" value="<?php echo $product; ?>">
    <input type="hidden" name="price" value="<?echo $price; ?>">
    <input type="hidden" name="units" value="0">
    <input type="hidden" name="qty" value="<?echo $qty; ?>">
    <input type="hidden" name="noqty" value="0">
    <input type="hidden" name="return" value='http://www.fiveneatthings.com/subscribe.php?submit=<?php echo $Subscribe; ?>'>
    <input type="submit" style="height: 30px; width: 450px; font-size:18px; font-family:arial" value="<?echo $Subscribe; ?>" name="submit">
    </form>

    The values are correct because they are correct in the e-mails that I received.

    Now, I'm wondering - the information in $product has a lot of new lines (\n). I'm wondering if that messes things up. I've seen somewhere how you can add additional information to the description in a different way. Maybe I have to parse $product for \n and enter the pieces in that manner. This should be easy to test.

    Any other ideas?

    Greene Ware, Etc.
    www.greeneware.com