0

I am trying to integrate Authorize.net DPM into my PHP/smarty based shopping cart. It is proving to be quite a challenge. I am now getting this parse error.
I get this error:
Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/wopl/public_html/yamada/classes/gateways/authnet.class.php on line 119 which indicates the area I highlighted below. Any ideas? Thanks..,

<?
//name of the class would be letters before first dot in file name
 class authnet { 
//name of payment gateway. would not be empty
  var $name="authnet";

  function _install() {
   global $options,$SQL;
   return $SQL->put("CREATE TABLE ".$SQL->tp."authnet (
                      id int(14) NOT NULL PRIMARY KEY auto_increment,
                      ordid int(14) NOT NULL,
                      cc_type varchar(20),
                    //  cc_number varchar(128),
                     // cc_expire varchar(128),
                      cc_cvv varchar(15),
                      cc_fname varchar(255),
                      cc_lname varchar(255),
                      cc_state varchar(128),
                      cc_city varchar(255),
                      cc_zip varchar(25),
                      cc_address varchar(255),
                      cc_country varchar(255)
                    )");
  }
  
  function authnet() { //constructor
  }

//return Smarty code of button to show on checkout page
  function button() {  
   global $options;
// ID of returning HTML form element would be exactly the same as class name
   return "<input type=button value='{".chr(36)."options.authnet_button|escape}' id=authnet>";
  }

//return Smarty code of form to show on billing page
  function form() { 
   global $options,$ITEM;

   if(empty($_SERVER['HTTPS']) && empty($_SERVER['https']))
    if($options["authnet_use_https"]) {
     header("Location: ".str_replace("http://","https://",$options["URL"]."billing.php"));
     die;
    }

   $res="
    <table>
<script language=javaScript src='".$options["URL"]."classes/gateways/cccheck.js' type='text/javascript'></script>
<script language=javaScript>
{literal}
 function check_frm() {
  if(!CheckCardNumber(document.forms['frm'])) {
   alert('Please enter correct Card Information');
   return false;
  }
  if(document.forms['frm'].elements['b[cc_fname]'].value=='') {
   alert('Please enter First Name');
   return false;
  }
  if(document.forms['frm'].elements['b[cc_lname]'].value=='') {
   alert('Please enter Last Name');
   return false;
  }\n";

   if($options["authnet_use_cvv"]==1)
    $res.="
  if(document.forms['frm'].elements['b[cc_cvv]'].value=='') {
   alert('Please enter CVV');
   return false;
  }\n";
   if($options["authnet_use_city"]==1)
    $res.="
  if(document.forms['frm'].elements['b[cc_city]'].value=='') {
   alert('Please enter City');
   return false;
  }\n";
   if($options["authnet_use_zip"]==1)
    $res.="
  if(document.forms['frm'].elements['b[cc_zip]'].value=='') {
   alert('Please enter Zip');
   return false;
  }\n";
   if($options["authnet_use_address"]==1)
    $res.="
  if(document.forms['frm'].elements['b[cc_address]'].value=='') {
   alert('Please enter Address');
   return false;
  }\n";
   $res.="
  return true;
 }
{/literal}
</script>
     <form name=frm action=billing.php method=post onsubmit=\"return check_frm();\">
      <input type=hidden name=b[ordid] value=".$_SESSION["ordid"].">
     <tr>
      <th colspan=2>Card Holder Information</th>
     </tr>
     <tr>
      <td>First Name</td>
      <td><input type=text name=b[cc_fname] value='{".chr(36)."smarty.cookies.cc_fname|escape}'></td>
     </tr>
     <tr>
      <td>Last Name</td>
      <td><input type=text name=b[cc_lname] value='{".chr(36)."smarty.cookies.cc_lname|escape}'></td>
     </tr>";
   if($options["authnet_use_country"]) {
    $res.="
     <tr>
      <td>Country</td>
      <td><select name=b[cc_country]>";
    $countries=$this->_countries();
    foreach($countries as $c)
     $res.="       <option value='".str_replace("'","&quot;",$c)."'".(($_COOKIE["cc_country"]==$c)?" SELECTED":"").">".$c."</option>\n";
    $res.="</select>
      </td>
     </tr>
   }
 if($options["authnet_use_state"]){
    $res.="
     <tr>
      <td>State</td>
      <td><select name=b[cc_state]> ";
    $states=$this->_states();
    foreach($states as $sa=>$s)	
     $res.="       <option value='".$sa."'".(($_COOKIE["cc_state"]==$sa)?" SELECTED":"").">".$s."</option>\n";
    $res.="</select>
      </td>
     </tr>";
   }
   if($options["authnet_use_city"]) {
    $res.="
     <tr>
      <td>City</td>
      <td><input type=text name=b[cc_city] value='{".chr(36)."smarty.cookies.cc_city|escape}'></td>
     </tr>";
   }
   if($options["authnet_use_zip"]) {
    $res.="
     <tr>
      <td>Zip</td>
      <td><input type=text name=b[cc_zip] value='{".chr(36)."smarty.cookies.cc_zip|escape}'></td>
     </tr>";
   }
   if($options["authnet_use_address"]) {
    $res.="
     <tr>
      <td>Address</td>
      <td><input type=text name=b[cc_address] value='{".chr(36)."smarty.cookies.cc_address|escape}'></td>
     </tr>";
   }
   $res.="
     <tr>
      <th colspan=2>Card Information</th>
     </tr>
           <tr>
            <td>Type</td>
            <td>
             <select name=CardType>\n"; 
   if($options["authnet_accept_mastercard"]) 
    $res.="              <option value='MasterCard'>MasterCard\n";
   if($options["authnet_accept_visa"]) 
    $res.="              <option value='VisaCard'>Visa\n";
   if($options["authnet_accept_amex"]) 
    $res.="              <option value='AmExCard'>American Express\n";
   if($options["authnet_accept_dinclu"]) 
    $res.="              <option value='DinersClubCard'>Diners Club\n";
   if($options["authnet_accept_discover"]) 
    $res.="              <option value='DiscoverCard'>Discover\n";
   if($options["authnet_accept_enroute"]) 
    $res.="              <option value='enRouteCard'>enRoute\n";
   if($options["authnet_accept_jcb"]) 
    $res.="              <option value='JCBCard'>JCB\n";
   $res.="             </select>
            </td>
           </tr>
           <tr>
            <td>Card Number</td>
            <td>                  
             <input type=text name=CardNumber>
            </td>
           </tr>
           <tr>
            <td>Valid Thru</td>
            <td>
             <select name=ExpMon>\n";
   for($kk=1;$kk<13;$kk++) {
    $aa=getdate(mktime(1,1,1,$kk,1,2009));
    $res.="              <option value=".$kk.">".sprintf("%02d - %s",$kk,$aa["month"])."</option>\n";
   } 

   $res.="             </select>
             <select name=ExpYear>\n";
   $cd=getdate();
   for($kk=$cd["year"];$kk<$cd["year"]+7;$kk++)
    $res.="              <option value=".$kk.">".$kk."</option>\n";
   $res.="             </select>
            </td>
           </tr> ";
   if($options["authnet_use_cvv"]) {
    $res.="
     <tr>
      <td>CVV</td>
      <td><input type=text name=b[cc_cvv]></td>
     </tr>";
   }
   $res.="
     <tr>
      <td colspan=2><input type=submit value='Submit'></td>
     </tr>
     </form>
    </table> ";
   return $res;
  }

  function action() { //manage data from form shown on billing page
   global $options,$ITEM;
   $cexp=mktime()+31622400;
   setcookie("cc_fname",$_POST["b"]["cc_fname"],$cexp);
   setcookie("cc_lname",$_POST["b"]["cc_lname"],$cexp);
   setcookie("cc_country",$_POST["b"]["cc_country"],$cexp);
   setcookie("cc_state",$_POST["b"]["cc_state"],$cexp);
   setcookie("cc_city",$_POST["b"]["cc_city"],$cexp);
   setcookie("cc_zip",$_POST["b"]["cc_zip"],$cexp);
   setcookie("cc_address",$_POST["b"]["cc_address"],$cexp);

   $_POST["b"]["cc_type"]=$_POST["CardType"];
   $_POST["b"]["cc_number"]=$_POST["CardNumber"];
   $_POST["b"]["cc_expire"]=$_POST["ExpMon"]." - ".$_POST["ExpYear"];
   $ITEM->add("authnet",$_POST["b"]);
  }

  function settings_form() { //part of Smarty form on settings page in admin area
   global $options,$SQL;

   if(!isset($options["authnet_button"])) 
    $options["authnet_button"]="Pay by Credit Card";
   $tbldesc=@$SQL->get_all("DESC ".$SQL->tp."authnet");
   if($tbldesc===false) {
    if($this->_install()===false) return "Unable to install module due to database errors: ".mysql_error();
   } else {
    $flg=0;
    foreach($tbldesc as $f) 
     foreach($f as $fv)
      switch($fv) {
       case "id":
        $flg+=1;
       break;
       case "ordid":
        $flg+=2;
       break;
       case "cc_type":
        $flg+=4;
       break;
      /* case "cc_number":
        $flg+=8;
       break;
       case "cc_expire":
        $flg+=16;
       break;
       case "cc_cvv":
        $flg+=32;
       break;*/
       case "cc_fname":
        $flg+=64;
       break;
       case "cc_lname":
        $flg+=128;
       break;
       case "cc_state":
        $flg+=256;
       break;
       case "cc_city":
        $flg+=512;
       break;
       case "cc_zip":
        $flg+=1024;
       break;
       case "cc_address":
        $flg+=2048;
       break;
       case "cc_country":
        $flg+=4096;
       break;
      }
    if($flg!=8191)
     return "Database structure problem. Module may work incorrect.";
   }
   return '
    <tr>
     <td>Button Text:</td>
     <td><input type=text name=o[authnet_button] size=50 value="{'.chr(36).'options.authnet_button|escape}"></td>
    </tr>
    <tr>
     <td>Use https:</td>
     <td>
      <select name=o[authnet_use_https]>
       <option value=0{if !$options.authnet_use_https} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_https} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <th colspan=2>Card types:</th>
    </tr>
    <tr>
     <td>MasterCard</td>
     <td>
      <select name=o[authnet_accept_mastercard]>
       <option value=0{if !$options.authnet_accept_mastercard} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_mastercard} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Visa</td>
     <td>
      <select name=o[authnet_accept_visa]>
       <option value=0{if !$options.authnet_accept_visa} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_visa} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>American Express</td>
     <td>
      <select name=o[authnet_accept_amex]>
       <option value=0{if !$options.authnet_accept_amex} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_amex} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Diners Club</td>
     <td>
      <select name=o[authnet_accept_dinclu]>
       <option value=0{if !$options.authnet_accept_dinclu} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_dinclu} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Discover</td>
     <td>
      <select name=o[authnet_accept_discover]>
       <option value=0{if !$options.authnet_accept_discover} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_discover} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>enRoute</td>
     <td>
      <select name=o[authnet_accept_enroute]>
       <option value=0{if !$options.authnet_accept_enroute} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_enroute} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>JCB</td>
     <td>
      <select name=o[authnet_accept_jcb]>
       <option value=0{if !$options.authnet_accept_jcb} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_accept_jcb} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td colspan=2 align=center><b>Additional required fields</b></td>
    </tr>
    <tr>
     <td>CVV</td>
     <td>
      <select name=o[authnet_use_cvv]>
       <option value=0{if !$options.authnet_use_cvv} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_cvv} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Country</td>
     <td>
      <select name=o[authnet_use_country]>
       <option value=0{if !$options.authnet_use_country} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_country} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>State</td>
     <td>
      <select name=o[authnet_use_state]>
       <option value=0{if !$options.authnet_use_state} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_state} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>City</td>
     <td>
      <select name=o[authnet_use_city]>
       <option value=0{if !$options.authnet_use_city} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_city} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Zip</td>
     <td>
      <select name=o[authnet_use_zip]>
       <option value=0{if !$options.authnet_use_zip} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_zip} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>
    <tr>
     <td>Address</td>
     <td>
      <select name=o[authnet_use_address]>
       <option value=0{if !$options.authnet_use_address} SELECTED{/if}>{$language.options_no}</option>
       <option value=1{if $options.authnet_use_address} SELECTED{/if}>{$language.options_yes}</option>
      </select>
     </td>
    </tr>';

  
  }


//manage data from form on settings page in admin
  function settings_manage() { 
  }

//Return payment details(evaluated by Smarty) for $order_id
  function details($order_id) {
   global $SQL;
   $res=$SQL->get_one("SELECT id,ordid,cc_type,cc_fname,cc_lname,cc_state,cc_city,cc_zip,cc_address,cc_country FROM ".$SQL->tp."authnet
 WHERE ordid=".(int)$order_id);
   if(count($res)>2) {
    $r=$this->name."<br><table>
     <tr>
      <td>First Name</td>
      <td>".$res["cc_fname"]."</td>
     </tr>
     <tr>
      <td>Last Name</td>
      <td>".$res["cc_lname"]."</td>
     </tr>\n";
    if(!empty($res["cc_country"]))
     $r.="     <tr>
      <td>Country</td>
      <td>".$res["cc_country"]."</td>
     </tr>\n";
    if(!empty($res["cc_state"]))
     $r.="     <tr>
      <td>State</td>
      <td>".$res["cc_state"]."</td>
     </tr>\n";
    if(!empty($res["cc_city"]))
     $r.="     <tr>
      <td>City</td>
      <td>".$res["cc_city"]."</td>
     </tr>\n";
    if(!empty($res["cc_zip"]))
     $r.="     <tr>
      <td>ZIP code</td>
      <td>".$res["cc_zip"]."</td>
     </tr>\n";
    if(!empty($res["cc_address"]))
     $r.="     <tr>
      <td>Address</td>
      <td>".$res["cc_address"]."</td>
     </tr>\n";
    $r.="     <tr>
     <td>Card type</td>
     <td>".$res["cc_type"]."</td>
    </tr>
    /*<tr>
     <td>Card Number</td>
     <td>".$res["cc_number"]."</td>
    </tr>
    <tr>
     <td>Card Expire</td>
     <td>".$res["cc_expire"]."</td>
    </tr>\n";
    if(!empty($res["cc_cvv"]))
     $r.="     <tr>
      <td>CVV</td>
      <td>".$res["cc_cvv"]."</td>
     </tr>\n"; */
    $r.="
    </table>";
    return $r;
   } else {
    return $this->name;
   }
  }
 
 function _countries() {
   return array("Afghanistan",
                "Albania",
                "Algeria",
                "Andorra",
                "Angola",
                "Antigua and Barbuda",
                "Argentina",
                "Armenia",
                "Australia",
                "Austria",
                "Azerbaijan",
                "Bahamas",
                "Bahrain",
                "Bangladesh",
                "Barbados",
                "Belarus",
                "Belgium",
                "Belize",
                "Benin",
                "Bhutan",
                "Bolivia",
                "Bosnia and Herzegovina",
                "Botswana",
                "Brazil",
                "Brunei",
                "Bulgaria",
                "Burkina Faso",
                "Burundi",
                "Cambodia",
                "Cameroon",
                "Canada",
                "Cape Verde",
                "Central African Republic",
                "Chad",
                "Chile",
                "China",
                "Colombi",
                "Comoros",
                "Congo (Brazzaville)",
                "Congo",
                "Costa Rica",
                "Cote d'Ivoire",
                "Croatia",
                "Cuba",
                "Cyprus",
                "Czech Republic",
                "Denmark",
                "Djibouti",
                "Dominica",
                "Dominican Republic",
                "East Timor (Timor Timur)",
                "Ecuador",
                "Egypt",
                "El Salvador",
                "Equatorial Guinea",
                "Eritrea",
                "Estonia",
                "Ethiopia",
                "Fiji",
                "Finland",
                "France",
                "Gabon",
                "Gambia, The",
                "Georgia",
                "Germany",
                "Ghana",
                "Greece",
                "Grenada",
                "Guatemala",
                "Guinea",
                "Guinea-Bissau",
                "Guyana",
                "Haiti",
                "Honduras",
                "Hungary",
                "Iceland",
                "India",
                "Indonesia",
                "Iran",
                "Iraq",
                "Ireland",
                "Israel",
                "Italy",
                "Jamaica",
                "Japan",
                "Jordan",
                "Kazakhstan",
                "Kenya",
                "Kiribati",
                "Korea, North",
                "Korea, South",
                "Kuwait",
                "Kyrgyzstan",
                "Laos",
                "Latvia",
                "Lebanon",
                "Lesotho",
                "Liberia",
                "Libya",
                "Liechtenstein",
                "Lithuania",
                "Luxembourg",
                "Macedonia",
                "Madagascar",
                "Malawi",
                "Malaysia",
                "Maldives",
                "Mali",
                "Malta",
                "Marshall Islands",
                "Mauritania",
                "Mauritius",
                "Mexico",
                "Micronesia",
                "Moldova",
                "Monaco",
                "Mongolia",
                "Morocco",
                "Mozambique",
                "Myanmar",
                "Namibia",
                "Nauru",
                "Nepal",
                "Netherlands",
                "New Zealand",
                "Nicaragua",
                "Niger",
                "Nigeria",
                "Norway",
                "Oman",
                "Pakistan",
                "Palau",
                "Panama",
                "Papua New Guinea",
                "Paraguay",
                "Peru",
                "Philippines",
                "Poland",
                "Portugal",
                "Qatar",
                "Romania",
                "Russia",
                "Rwanda",
                "Saint Kitts and Nevis",
                "Saint Lucia",
                "Saint Vincent",
                "Samoa",
                "San Marino",
                "Sao Tome and Principe",
                "Saudi Arabia",
                "Senegal",
                "Serbia and Montenegro",
                "Seychelles",
                "Sierra Leone",
                "Singapore",
                "Slovakia",
                "Slovenia",
                "Solomon Islands",
                "Somalia",
                "South Africa",
                "Spain",
                "Sri Lanka",
                "Sudan",
                "Suriname",
                "Swaziland",
                "Sweden",
                "Switzerland",
                "Syria",
                "Taiwan",
                "Tajikistan",
                "Tanzania",
                "Thailand",
                "Togo",
                "Tonga",
                "Trinidad and Tobago",
                "Tunisia",
                "Turkey",
                "Turkmenistan",
                "Tuvalu",
                "Uganda",
                "Ukraine",
                "United Arab Emirates",
                "United Kingdom",
                "United States",
                "Uruguay",
                "Uzbekistan",
                "Vanuatu",
                "Vatican City",
                "Venezuela",
                "Vietnam",
                "Yemen",
                "Zambia",
                "Zimbabwe");
  }
  
  function _states() {
    return array('AL'=>"Alabama",  
			'AK'=>"Alaska",  
			'AZ'=>"Arizona",  
			'AR'=>"Arkansas",  
			'CA'=>"California",  
			'CO'=>"Colorado",  
			'CT'=>"Connecticut",  
			'DE'=>"Delaware",  
			'DC'=>"District Of Columbia",  
			'FL'=>"Florida",  
			'GA'=>"Georgia",  
			'HI'=>"Hawaii",  
			'ID'=>"Idaho",  
			'IL'=>"Illinois",  
			'IN'=>"Indiana",  
			'IA'=>"Iowa",  
			'KS'=>"Kansas",  
			'KY'=>"Kentucky",  
			'LA'=>"Louisiana",  
			'ME'=>"Maine",  
			'MD'=>"Maryland",  
			'MA'=>"Massachusetts",  
			'MI'=>"Michigan",  
			'MN'=>"Minnesota",  
			'MS'=>"Mississippi",  
			'MO'=>"Missouri",  
			'MT'=>"Montana",
			'NE'=>"Nebraska",
			'NV'=>"Nevada",
			'NH'=>"New Hampshire",
			'NJ'=>"New Jersey",
			'NM'=>"New Mexico",
			'NY'=>"New York",
			'NC'=>"North Carolina",
			'ND'=>"North Dakota",
			'OH'=>"Ohio",  
			'OK'=>"Oklahoma",  
			'OR'=>"Oregon",  
			'PA'=>"Pennsylvania",  
			'RI'=>"Rhode Island",  
			'SC'=>"South Carolina",  
			'SD'=>"South Dakota",
			'TN'=>"Tennessee",  
			'TX'=>"Texas",  
			'UT'=>"Utah",  
			'VT'=>"Vermont",  
			'VA'=>"Virginia",  
			'WA'=>"Washington",  
			'WV'=>"West Virginia",  
			'WI'=>"Wisconsin",  
			'WY'=>"Wyoming");

  }
 }
 }
?>

Edited by ommannette: n/a

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by veedeoo
0

You need to close with a double quote (and a semi-colon) on line 118.

Edited by pritaeas: n/a

0

you may also fix your comment tag on line 480 /* and on line 492 */. The first is within html tags, while the second is within the php tags.

Another concern I have, what is the smarty version your script is currently using? The reason I am asking, because {literal} is no longer supported by the latest version of smarty ..

Edited by veedeoo: n/a

0

Another concern I have, what is the smarty version your script is currently using? The reason I am asking, because {literal} is no longer supported by the latest version of smarty ..

Not entirely true. It is still supported, but if you use spaces around your curly brackets, the literal tag is no longer needed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.