Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

What should I do with this form card expiration date error?

Hello everyone,

I've been working on a donation form for one of my friends. I'm using an API for all the processes. There's a class for the API which I have included the code for below. The problem is that I get an error for my card expiration date. Can you help me solve this? This is important and urgent for me. Thanks.

Form URL: http://arashemadi.com/heyw

My Form Code is Below:

<?php 
include 'leeina.class.php';
$admin_user1 = 'eqemre20140';
$admin_pswd1 = 'Snoppy99';
$admin_user = 'demo';
$admin_pswd = 'password';
$gw = new gwapi;
    if ($_SERVER["REQUEST_METHOD"] == "POST") {

        $title = $_POST["title"];
        $firstName = trim($_POST["firstName"]);
        $lastName = trim($_POST["lastName"]);
        $addressOne = trim($_POST["address1"]);
        $addressTwo = trim($_POST["address2"]);
        $organization = trim($_POST["organization"]);
        $city = trim($_POST["city"]);
        $state = $_POST["state_select"];
        $zip = trim($_POST["zip"]);
        $telephone = trim($_POST["phone"]);
        $fax = trim($_POST["fax"]);
        $email = trim($_POST["email"]);
        $sFirstName = trim($_POST["billing_firstName"]);
        $sLastName = trim($_POST["billing_lastName"]);
        $sAddressOne = trim($_POST["billing_address_1"]);
        $sAddressTwo = trim($_POST["billing_address_2"]);
        $sCity = trim($_POST["billing_city"]);
        $sState = $_POST["billing_state_select"];
        $sZip = trim($_POST["billing_zip"]);
        $sCountry = trim($_POST["billing_country"]);
        $gw->setLogin($admin_user, $admin_pswd);
        $gw->setBilling($firstName,$lastName,$organization,$addressOne,$addressTwo, $city,
                $state,$zip,"US",$telephone,$fax,$email," ");
         if (isset($_POST["billing_same"])) {
        $gw->setShipping($firstName,$lastName,$organization,$addressOne,$addressTwo, $city,
                $state,$zip,"US",$telephone,$fax,$email," ");
        }else{
        $gw->setShipping($sFirstName,$sLastName,"na",$sAddressOne,$sAddressTwo,$sCity,
                $sState,$sZip,"US",$email);}

    $doAmount = $_POST["input_other_amount"];
    $cardNum = $_POST["card_number"];
    $iCardNum = (int) $cardNum;
    $cardSc = $_POST["csc"];
    $iCardSc = (int) $cardSc;
    $cardEx = $_POST["expiration_month"];
    $iCardEx = (int) $cardEx;
    $ipAddress = $_SERVER['REMOTE_ADDR'];
        $gw->setOrder(rand(),"None",0.00, 0.00, " ",$ipAddress);

        $r = $gw->doSale($doAmount, $iCardNum, $iCardEx, $iCardSc);
        $results = $gw->responses['responsetext'];
        if ($results == 'SUCCESS') {
            # code...
            echo '<p class="results">YAY :) </p>'. $results . '<br />';
        }else{
            echo '<p class="results">NO :( </p>'. $results. '<br />';
        }
        }
?>
<html>
<head>
<link href="layout.css" rel="stylesheet" type="text/css">
<link href="styles.php" rel="stylesheet" type="text/css">
<link href="flick.css" rel="stylesheet" type="text/css">
<meta name="robots" content="noindex,follow">
<title>BrookLink</title>
<style type="text/css">
select {height:19.5px;}
#qgiv_main img.errorboxShow {clear:left; vertical-align: top;padding:0; margin:0;}
#power div img { margin-bottom: 50px; }
</style>

</head>
<body>
    <?php echo $result; ?>
        <center>
    <table width="757" height="50" cellpadding="0" cellspacing="0" border="0">
    <tbody>
    <tr>
    <td style="text-align:left;">
    <img src="logo.jpg" tip="">
    </td>
    <td style="vertical-align:bottom;">
    <a href="http://brooklink.org/">
    <img src="button.jpg" align="right" border="0" tip="">
    </a>
    </td>
    </tr>
    </tbody>
    </table>
    <table width="757" cellpadding="0" cellspacing="0" border="0">
    <tbody>
    <tr><td><img src="header.jpg" width="756" tip=""></td></tr>
    <tr><td id="top" height="20"></td></tr>
    <tr><td id="mid" width="757"><div style="color:#ffffff; margin-left: 10%; margin-right: 10%;">
<div id="qgiv_form">
    <script src="autoNumeric.jquery.js"></script>
    <script>var host = "https://secure.qgiv.com"</script>
    <form action="index.php" method="post">
          <input type="hidden" name="key" value="blink">
      <input type="hidden" name="referrer" value="">
      <input type="hidden" name="Additional[assocInfo]" id="Additional[assocInfo]" value="">
      <input type="hidden" name="currencyFormat[format]" id="currencyFormat[format]" value="0">
      <input type="hidden" name="currencyFormat[symbolLocation]" id="currencyFormat[symbolLocation]" value="0">
      <input type="hidden" name="currencyFormat[symbol]" id="currencyFormat[symbol]" value="$">

    <fieldset>
  <legend>Personal Information</legend>
    <ol class="field_listing">
    <li>
                    <p>
          <label for="title">
            Title          </label>
          <select id="title" name="Personal[salutation]">
            <option value=""></option>
                                            <option value="Mr.">Mr.</option>
                                            <option value="Ms.">Ms.</option>
                                            <option value="Mrs.">Mrs.</option>
                                            <option value="Mr. &amp; Mrs.">Mr. &amp; Mrs.</option>
                                            <option value="Dr.">Dr.</option>
                      </select>
        </p>
                    <p>
          <label for="firstName">First Name<span class="req"><abbr original-title="Enter your First Name">Required</abbr></span></label>
          <input name="Personal[firstName]" id="firstName" type="text" value="">
        </p>
        <p>
          <label for="lastName">Last Name <span class="req"><abbr original-title="Enter your Last Name">Required</abbr></span></label>
          <input name="Personal[lastName]" id="lastName" type="text" value="">
        </p>
      </li>
      <li class="address">
        <p>
          <label for="address1">Address <span class="req"><abbr original-title="Enter your Address">Required</abbr></span></label>
          <input name="Personal[address1]" id="address1" type="text" value="">
          <input name="Personal[address2]" id="address2" type="text" value="">
        </p>
          <p>
                  <label for="Organization">Organization</label>
                  <input name="Personal[Organization]" id="organization" type="text" style="width:125px" value="">
                </p>
      </li>
      <li class="address_citystate personal">
        <p>
          <label for="city">City <span class="req"><abbr original-title="Enter City">Required</abbr></span></label>
          <input name="Personal[city]" id="city" type="text" value="">
        </p>
        <p>
          <label for="state_select" class="domestic_fields">State <span class="req"><abbr original-title="Select your State">Required</abbr></span></label>
          <select name="Personal[state]" id="state_select" class="domestic_fields state_select">
              <option value=""></option>
            <option value="AL">Alabama</option>
            <option value="AK">Alaska</option>
            <option value="AZ">Arizona</option>
            <option value="AR">Arkansas</option>
            <option value="AA">Armed Forces (AA)</option>
            <option value="AE">Armed Forces (AE)</option>
            <option value="AP">Armed Forces (AP)</option>
            <option value="CA">California</option>
            <option value="CO">Colorado</option>
            <option value="CT">Connecticut</option>
            <option value="DE">Delaware</option>
            <option value="DC">DC</option>
            <option value="FL">Florida</option>
            <option value="GA">Georgia</option>
            <option value="HI">Hawaii</option>
            <option value="ID">Idaho</option>
            <option value="IL">Illinois</option>
            <option value="IN">Indiana</option>
            <option value="IA">Iowa</option>
            <option value="KS">Kansas</option>
            <option value="KY">Kentucky</option>
            <option value="LA">Louisiana</option>
            <option value="ME">Maine</option>
            <option value="MD">Maryland</option>
            <option value="MA">Massachusetts</option>
            <option value="MI">Michigan</option>
            <option value="MN">Minnesota</option>
            <option value="MS">Mississippi</option>
            <option value="MO">Missouri</option>
            <option value="MT">Montana</option>
            <option value="NE">Nebraska</option>
            <option value="NV">Nevada</option>
            <option value="NH">New Hampshire</option>
            <option value="NJ">New Jersey</option>
            <option value="NM">New Mexico</option>
            <option value="NY">New York</option>
            <option value="NC">North Carolina</option>
            <option value="ND">North Dakota</option>
            <option value="OH">Ohio</option>
            <option value="OK">Oklahoma</option>
            <option value="OR">Oregon</option>
            <option value="PA">Pennsylvania</option>
            <option value="RI">Rhode Island</option>
            <option value="SC">South Carolina</option>
            <option value="SD">South Dakota</option>
            <option value="TN">Tennessee</option>
            <option value="TX">Texas</option>
            <option value="UT">Utah</option>
            <option value="VT">Vermont</option>
            <option value="VA">Virginia</option>
            <option value="WA">Washington</option>
            <option value="WV">West Virginia</option>
            <option value="WI">Wisconsin</option>
            <option value="WY">Wyoming</option>
          </select>
        </p>
        <p>
          <label for="zip" class="country_fields  qhidden">Postal Code <span class="req"><abbr original-title="Enter your 5 digit Zip code">Required</abbr></span></label>
          <label for="zip" class="domestic_fields">Zip <span class="req"><abbr original-title="Enter your 5 digit Zip code">Required</abbr></span></label>
          <input name="Personal[zip]" id="zip" type="text" style="width:75px" value="">
        </p>
        <p class="country_fields outside-us qhidden">
          <label for="country">Country <span class="req"><abbr original-title="Enter your Country">Required</abbr></span></label>
          <select name="Personal[country]" id="country" class="outside-us countrySelect">
           <option value="" selected="">Select a Country</option>
          </select>
        </p>
        <p class="country_fields outside-us province qhidden">
          <label for="state_select_input" class="country_fields  qhidden">State/Province/Region</label>
          <select name="Personal[state]" class="country_fields state_select  qhidden province" id="state_select_input" rel="">
            <option value="" selected="">Please choose one (int'l state/province)</option>
          </select>
        </p>
              </li>

                <li class="email last">
            <p>
                <label for="email">Email<span class="req"><abbr original-title="Enter your email. Example: aaa@bb.com">Required</abbr></span></label>
                <input type="text" name="Personal[email]" id="email" style="width:200px" value="">
              </p>
                        <p>
                  <label for="phone">Phone number </label>
                  <input name="Personal[phone]" id="phone" type="text" style="width:125px" value="">
                </p>
                </li>
  </ol>
  </fieldset>
<fieldset>
    <legend>Billing Information <label for="billing_same"><input type="checkbox" name="billing_same" id="billing_same" class="toggle" checked="">Same as my personal information</label></legend>
    <ol class="field_listing toggle-content qhidden">
        <li>
                      <p>
              <label for="billing_firstName">First Name<span class="req"><abbr original-title="Enter your First Name">Required</abbr></span></label>
              <input name="Billing[firstName]" id="billing_firstName" type="text">
            </p>
            <p>
              <label for="billing_lastName">Last Name <span class="req"><abbr original-title="Enter your Last Name">Required</abbr></span></label>
              <input name="Billing[lastName]" id="billing_lastName" type="text" value="">
            </p>
        </li>
        <li class="address">
            <label for="Billing[address1]">Address <span class="req">Required</span></label>
            <input name="Billing[address1]" id="billing_address_1" type="text">
            <input name="Billing[address2]" id="billing_address_2" type="text">
        </li>
        <li class="last address_citystate billing">
            <p>
              <label for="billing_city">City <span class="req"><abbr original-title="Enter City name">Required</abbr></span></label>
              <input name="Billing[city]" id="billing_city" type="text">
            </p>
            <p>
              <label for="billing_state_select" class="domestic_fields">State <span class="req"><abbr original-title="Select your State">Required</abbr></span></label>
              <select name="Billing[state]" id="billing_state_select" class="domestic_fields state_select">
                <option value=""></option>
                <option value="AL">Alabama</option>
                <option value="AK">Alaska</option>
                <option value="AZ">Arizona</option>
                <option value="AR">Arkansas</option>
                <option value="AA">Armed Forces (AA)</option>
                <option value="AE">Armed Forces (AE)</option>
                <option value="AP">Armed Forces (AP)</option>
                <option value="CA">California</option>
                <option value="CO">Colorado</option>
                <option value="CT">Connecticut</option>
                <option value="DE">Delaware</option>
                <option value="DC">DC</option>
                <option value="FL">Florida</option>
                <option value="GA">Georgia</option>
                <option value="HI">Hawaii</option>
                <option value="ID">Idaho</option>
                <option value="IL">Illinois</option>
                <option value="IN">Indiana</option>
                <option value="IA">Iowa</option>
                <option value="KS">Kansas</option>
                <option value="KY">Kentucky</option>
                <option value="LA">Louisiana</option>
                <option value="ME">Maine</option>
                <option value="MD">Maryland</option>
                <option value="MA">Massachusetts</option>
                <option value="MI">Michigan</option>
                <option value="MN">Minnesota</option>
                <option value="MS">Mississippi</option>
                <option value="MO">Missouri</option>
                <option value="MT">Montana</option>
                <option value="NE">Nebraska</option>
                <option value="NV">Nevada</option>
                <option value="NH">New Hampshire</option>
                <option value="NJ">New Jersey</option>
                <option value="NM">New Mexico</option>
                <option value="NY">New York</option>
                <option value="NC">North Carolina</option>
                <option value="ND">North Dakota</option>
                <option value="OH">Ohio</option>
                <option value="OK">Oklahoma</option>
                <option value="OR">Oregon</option>
                <option value="PA">Pennsylvania</option>
                <option value="RI">Rhode Island</option>
                <option value="SC">South Carolina</option>
                <option value="SD">South Dakota</option>
                <option value="TN">Tennessee</option>
                <option value="TX">Texas</option>
                <option value="UT">Utah</option>
                <option value="VT">Vermont</option>
                <option value="VA">Virginia</option>
                <option value="WA">Washington</option>
                <option value="WV">West Virginia</option>
                <option value="WI">Wisconsin</option>
                <option value="WY">Wyoming</option>
              </select>
            </p>
            <p>
              <label for="billing_zip" class="country_fields  qhidden">Postal Code <span class="req"><abbr original-title="Enter your 5 digit Zip code">Required</abbr></span></label>
              <label for="billing_zip" class="domestic_fields  ">Zip <span class="req"><abbr original-title="Enter your 5 digit Zip code">Required</abbr></span></label>
              <input name="Billing[zip]" id="billing_zip" type="text" style="width:75px">
            </p>
            <p class="country_fields outside-us qhidden">
              <label for="billing_country">Country <span class="req"><abbr original-title="Enter your Country">Required</abbr></span></label>
              <select name="Billing[country]" id="billing_country" class="outside-us countrySelect">
                     <option value="" selected=""></option>
              </select>
            </p>
            <p class="country_fields outside-us province qhidden">
                <label for="state_select_input" class="country_fields  qhidden">State/Province/Region</label>
                <select name="Billing[state]" class="country_fields state_select  qhidden province" id="state_select_input" rel="Please choose one (int&#39;l state/province)"></select>
             </p>
                      </li>
    </ol>
</fieldset>
    <fieldset id="donation_fields_donation" class="donation_type_fieldset">
    <legend>Donation Amount</legend>
        <ol class="field_listing">
      <li class="donation_amount">
                            <p class="amount_item full">
                <label for="Donations[0][amount]" class="freehand">
                    $                   <input name="other_amount" id="input_other_amount" class="freehand currency_input" type="text" value="">
                     (Minimum: $50.00, Maximum: $25,000.00)                 </label>
            </p>
              </li> 
            </ol>
          </fieldset>
    <script type="text/javascript" src="./BrookLink_files/globalFunctions.js"></script>
    <fieldset class="" id="payment_information">
        <legend>Payment Information <span class="req">All Payment Fields are Required</span></legend>
                <ol class="field_listing">
              <li class="payment_types" id="payment_types">
                                <p class="payment_type_cc">
                  <label for="payment_type_cc">
                                            <strong id="visa">Visa</strong>
                                                                <strong id="mastercard">MasterCard</strong>
                                                                                    <strong id="discover">Discover</strong>
                                      </label>
                </p>
                          </li>
          <li class="payment_fields_cc" rel="card">
            <p>
              <label for="Payment[account]">Card Number</label>
              <input name="Payment[account]" id="card_number" type="text" autocomplete="off">
            </p>
            <p>
              <label for="Payment[csc]">CSC                 <abbr original-title="&lt;img src=&#39;https://secure.qgiv.com/common/images/icn-csc.png&#39; /&gt;">
                    <img src="icn-question.png" tip="">
                </abbr>
              </label>
              <input name="Payment[csc]" id="csc" style="width:75px;" type="text" autocomplete="off">
            </p>
            <p>
              <label for="Payment[expiry]">Expiration</label>
              <select name="Payment[expiry][month]" id="expiration_month" style="width:120px;">
                    <option value="0315">03/2015</option><option value="0415">04/2015</option><option value="0515">05/2015</option><option value="0615">06/2015</option><option value="0715">07/2015</option><option value="0815">08/2015</option><option value="0915">09/2015</option><option value="1015">10/2015</option><option value="1115">11/2015</option><option value="1215">12/2015</option><option value="0116">01/2016</option><option value="0216">02/2016</option><option value="0316">03/2016</option><option value="0416">04/2016</option><option value="0516">05/2016</option><option value="0616">06/2016</option><option value="0716">07/2016</option><option value="0816">08/2016</option><option value="0916">09/2016</option><option value="1016">10/2016</option><option value="1116">11/2016</option><option value="1216">12/2016</option><option value="0117">01/2017</option><option value="0217">02/2017</option><option value="0317">03/2017</option><option value="0417">04/2017</option><option value="0517">05/2017</option><option value="0617">06/2017</option><option value="0717">07/2017</option><option value="0817">08/2017</option><option value="0917">09/2017</option><option value="1017">10/2017</option><option value="1117">11/2017</option><option value="1217">12/2017</option><option value="0118">01/2018</option><option value="0218">02/2018</option><option value="0318">03/2018</option><option value="0418">04/2018</option><option value="0518">05/2018</option><option value="0618">06/2018</option><option value="0718">07/2018</option><option value="0818">08/2018</option><option value="0918">09/2018</option><option value="1018">10/2018</option><option value="1118">11/2018</option><option value="1218">12/2018</option><option value="0119">01/2019</option><option value="0219">02/2019</option><option value="0319">03/2019</option><option value="0419">04/2019</option><option value="0519">05/2019</option><option value="0619">06/2019</option><option value="0719">07/2019</option><option value="0819">08/2019</option><option value="0919">09/2019</option><option value="1019">10/2019</option><option value="1119">11/2019</option><option value="1219">12/2019</option><option value="0120">01/2020</option><option value="0220">02/2020</option><option value="0320">03/2020</option><option value="0420">04/2020</option><option value="0520">05/2020</option><option value="0620">06/2020</option><option value="0720">07/2020</option><option value="0820">08/2020</option><option value="0920">09/2020</option><option value="1020">10/2020</option><option value="1120">11/2020</option><option value="1220">12/2020</option><option value="0121">01/2021</option><option value="0221">02/2021</option><option value="0321">03/2021</option><option value="0421">04/2021</option><option value="0521">05/2021</option><option value="0621">06/2021</option><option value="0721">07/2021</option><option value="0821">08/2021</option><option value="0921">09/2021</option><option value="1021">10/2021</option><option value="1121">11/2021</option><option value="1221">12/2021</option><option value="0122">01/2022</option><option value="0222">02/2022</option><option value="0322">03/2022</option><option value="0422">04/2022</option><option value="0522">05/2022</option><option value="0622">06/2022</option><option value="0722">07/2022</option><option value="0822">08/2022</option><option value="0922">09/2022</option><option value="1022">10/2022</option><option value="1122">11/2022</option><option value="1222">12/2022</option><option value="0123">01/2023</option><option value="0223">02/2023</option><option value="0323">03/2023</option><option value="0423">04/2023</option><option value="0523">05/2023</option><option value="0623">06/2023</option><option value="0723">07/2023</option><option value="0823">08/2023</option><option value="0923">09/2023</option><option value="1023">10/2023</option><option value="1123">11/2023</option><option value="1223">12/2023</option><option value="0124">01/2024</option><option value="0224">02/2024</option><option value="0324">03/2024</option><option value="0424">04/2024</option><option value="0524">05/2024</option><option value="0624">06/2024</option><option value="0724">07/2024</option><option value="0824">08/2024</option><option value="0924">09/2024</option><option value="1024">10/2024</option><option value="1124">11/2024</option><option value="1224">12/2024</option><option value="0125">01/2025</option><option value="0225">02/2025</option><option value="0325">03/2025</option><option value="0425">04/2025</option><option value="0525">05/2025</option><option value="0625">06/2025</option><option value="0725">07/2025</option><option value="0825">08/2025</option><option value="0925">09/2025</option><option value="1025">10/2025</option><option value="1125">11/2025</option><option value="1225">12/2025</option><option value="0126">01/2026</option><option value="0226">02/2026</option><option value="0326">03/2026</option><option value="0426">04/2026</option><option value="0526">05/2026</option><option value="0626">06/2026</option><option value="0726">07/2026</option><option value="0826">08/2026</option><option value="0926">09/2026</option><option value="1026">10/2026</option><option value="1126">11/2026</option><option value="1226">12/2026</option><option value="0127">01/2027</option><option value="0227">02/2027</option><option value="0327">03/2027</option><option value="0427">04/2027</option><option value="0527">05/2027</option><option value="0627">06/2027</option><option value="0727">07/2027</option><option value="0827">08/2027</option><option value="0927">09/2027</option><option value="1027">10/2027</option><option value="1127">11/2027</option><option value="1227">12/2027</option><option value="0128">01/2028</option><option value="0228">02/2028</option><option value="0328">03/2028</option><option value="0428">04/2028</option><option value="0528">05/2028</option><option value="0628">06/2028</option><option value="0728">07/2028</option><option value="0828">08/2028</option><option value="0928">09/2028</option><option value="1028">10/2028</option><option value="1128">11/2028</option><option value="1228">12/2028</option><option value="0129">01/2029</option><option value="0229">02/2029</option><option value="0329">03/2029</option><option value="0429">04/2029</option><option value="0529">05/2029</option><option value="0629">06/2029</option><option value="0729">07/2029</option><option value="0829">08/2029</option><option value="0929">09/2029</option><option value="1029">10/2029</option><option value="1129">11/2029</option><option value="1229">12/2029</option><option value="0130">01/2030</option><option value="0230">02/2030</option><option value="0330">03/2030</option><option value="0430">04/2030</option><option value="0530">05/2030</option><option value="0630">06/2030</option><option value="0730">07/2030</option><option value="0830">08/2030</option><option value="0930">09/2030</option><option value="1030">10/2030</option><option value="1130">11/2030</option><option value="1230">12/2030</option></select>

            </p>
          </li>

        </ol>
              </fieldset>  <div class="actions">


<input type="submit" value="send">      
    <div class="productLogo">

                            <a href="javascript:void(o);" onclick="window.open('https://quickclick.com/cart/security.php', 'newwin','location=no,toolbar=no,scrollbars=no,resizable=no,directories=no,status=no,width=400,height=480');return false;"><img src="logooo.png" width="110px" height="46px" alt="" tip=""></a>

            </div>



  </div>

    <div class="qclear">&nbsp;</div>
    </form>
      </div>


</div>
</td></tr>
<tr><td id="bottom" align="right" height="24"></td>
</tr>
</tbody></table><table>
</table></center></div></body>
</body>
</html>

My API Class Code is Below:

<?php
define("APPROVED", 1);
define("DECLINED", 2);
define("ERROR", 3);

class gwapi {

// Initial Setting Functions

  function setLogin($username, $password) {
    $this->login['username'] = $username;
    $this->login['password'] = $password;
  }

  function setOrder($orderid,
        $orderdescription,
        $tax,
        $shipping,
        $ponumber,
        $ipaddress) {
    $this->order['orderid']          = $orderid;
    $this->order['orderdescription'] = $orderdescription;
    $this->order['tax']              = $tax;
    $this->order['shipping']         = $shipping;
    $this->order['ponumber']         = $ponumber;
    $this->order['ipaddress']        = $ipaddress;
  }

  function setBilling($firstname,
        $lastname,
        $company,
        $address1,
        $address2,
        $city,
        $state,
        $zip,
        $country,
        $phone,
        $fax,
        $email,
        $website) {
    $this->billing['firstname'] = $firstname;
    $this->billing['lastname']  = $lastname;
    $this->billing['company']   = $company;
    $this->billing['address1']  = $address1;
    $this->billing['address2']  = $address2;
    $this->billing['city']      = $city;
    $this->billing['state']     = $state;
    $this->billing['zip']       = $zip;
    $this->billing['country']   = $country;
    $this->billing['phone']     = $phone;
    $this->billing['fax']       = $fax;
    $this->billing['email']     = $email;
    $this->billing['website']   = $website;
  }

  function setShipping($firstname,
        $lastname,
        $company,
        $address1,
        $address2,
        $city,
        $state,
        $zip,
        $country,
        $email) {
    $this->shipping['firstname'] = $firstname;
    $this->shipping['lastname']  = $lastname;
    $this->shipping['company']   = $company;
    $this->shipping['address1']  = $address1;
    $this->shipping['address2']  = $address2;
    $this->shipping['city']      = $city;
    $this->shipping['state']     = $state;
    $this->shipping['zip']       = $zip;
    $this->shipping['country']   = $country;
    $this->shipping['email']     = $email;
  }

  // Transaction Functions

  function doSale($amount, $ccnumber, $ccexp, $cvv="") {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Sales Information
    $query .= "ccnumber=" . urlencode($ccnumber) . "&";
    $query .= "ccexp=" . urlencode($ccexp) . "&";
    $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    $query .= "cvv=" . urlencode($cvv) . "&";
    // Order Information
    $query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
    $query .= "orderid=" . urlencode($this->order['orderid']) . "&";
    $query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
    $query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
    $query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
    $query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
    // Billing Information
    $query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
    $query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
    $query .= "company=" . urlencode($this->billing['company']) . "&";
    $query .= "address1=" . urlencode($this->billing['address1']) . "&";
    $query .= "address2=" . urlencode($this->billing['address2']) . "&";
    $query .= "city=" . urlencode($this->billing['city']) . "&";
    $query .= "state=" . urlencode($this->billing['state']) . "&";
    $query .= "zip=" . urlencode($this->billing['zip']) . "&";
    $query .= "country=" . urlencode($this->billing['country']) . "&";
    $query .= "phone=" . urlencode($this->billing['phone']) . "&";
    $query .= "fax=" . urlencode($this->billing['fax']) . "&";
    $query .= "email=" . urlencode($this->billing['email']) . "&";
    $query .= "website=" . urlencode($this->billing['website']) . "&";
    // Shipping Information
    $query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
    $query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
    $query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
    $query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
    $query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
    $query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
    $query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
    $query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
    $query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
    $query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
    $query .= "type=sale";
    return $this->_doPost($query);
  }

  function doAuth($amount, $ccnumber, $ccexp, $cvv="") {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Sales Information
    $query .= "ccnumber=" . urlencode($ccnumber) . "&";
    $query .= "ccexp=" . urlencode($ccexp) . "&";
    $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    $query .= "cvv=" . urlencode($cvv) . "&";
    // Order Information
    $query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
    $query .= "orderid=" . urlencode($this->order['orderid']) . "&";
    $query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
    $query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
    $query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
    $query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
    // Billing Information
    $query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
    $query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
    $query .= "company=" . urlencode($this->billing['company']) . "&";
    $query .= "address1=" . urlencode($this->billing['address1']) . "&";
    $query .= "address2=" . urlencode($this->billing['address2']) . "&";
    $query .= "city=" . urlencode($this->billing['city']) . "&";
    $query .= "state=" . urlencode($this->billing['state']) . "&";
    $query .= "zip=" . urlencode($this->billing['zip']) . "&";
    $query .= "country=" . urlencode($this->billing['country']) . "&";
    $query .= "phone=" . urlencode($this->billing['phone']) . "&";
    $query .= "fax=" . urlencode($this->billing['fax']) . "&";
    $query .= "email=" . urlencode($this->billing['email']) . "&";
    $query .= "website=" . urlencode($this->billing['website']) . "&";
    // Shipping Information
    $query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
    $query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
    $query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
    $query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
    $query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
    $query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
    $query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
    $query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
    $query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
    $query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
    $query .= "type=auth";
    return $this->_doPost($query);
  }

  function doCredit($amount, $ccnumber, $ccexp) {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Sales Information
    $query .= "ccnumber=" . urlencode($ccnumber) . "&";
    $query .= "ccexp=" . urlencode($ccexp) . "&";
    $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    // Order Information
    $query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
    $query .= "orderid=" . urlencode($this->order['orderid']) . "&";
    $query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
    $query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
    $query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
    $query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
    // Billing Information
    $query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
    $query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
    $query .= "company=" . urlencode($this->billing['company']) . "&";
    $query .= "address1=" . urlencode($this->billing['address1']) . "&";
    $query .= "address2=" . urlencode($this->billing['address2']) . "&";
    $query .= "city=" . urlencode($this->billing['city']) . "&";
    $query .= "state=" . urlencode($this->billing['state']) . "&";
    $query .= "zip=" . urlencode($this->billing['zip']) . "&";
    $query .= "country=" . urlencode($this->billing['country']) . "&";
    $query .= "phone=" . urlencode($this->billing['phone']) . "&";
    $query .= "fax=" . urlencode($this->billing['fax']) . "&";
    $query .= "email=" . urlencode($this->billing['email']) . "&";
    $query .= "website=" . urlencode($this->billing['website']) . "&";
    $query .= "type=credit";
    return $this->_doPost($query);
  }

  function doOffline($authorizationcode, $amount, $ccnumber, $ccexp) {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Sales Information
    $query .= "ccnumber=" . urlencode($ccnumber) . "&";
    $query .= "ccexp=" . urlencode($ccexp) . "&";
    $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    $query .= "authorizationcode=" . urlencode($authorizationcode) . "&";
    // Order Information
    $query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
    $query .= "orderid=" . urlencode($this->order['orderid']) . "&";
    $query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
    $query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
    $query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
    $query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
    // Billing Information
    $query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
    $query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
    $query .= "company=" . urlencode($this->billing['company']) . "&";
    $query .= "address1=" . urlencode($this->billing['address1']) . "&";
    $query .= "address2=" . urlencode($this->billing['address2']) . "&";
    $query .= "city=" . urlencode($this->billing['city']) . "&";
    $query .= "state=" . urlencode($this->billing['state']) . "&";
    $query .= "zip=" . urlencode($this->billing['zip']) . "&";
    $query .= "country=" . urlencode($this->billing['country']) . "&";
    $query .= "phone=" . urlencode($this->billing['phone']) . "&";
    $query .= "fax=" . urlencode($this->billing['fax']) . "&";
    $query .= "email=" . urlencode($this->billing['email']) . "&";
    $query .= "website=" . urlencode($this->billing['website']) . "&";
    // Shipping Information
    $query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
    $query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
    $query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
    $query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
    $query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
    $query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
    $query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
    $query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
    $query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
    $query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
    $query .= "type=offline";
    return $this->_doPost($query);
  }

  function doCapture($transactionid, $amount =0) {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Transaction Information
    $query .= "transactionid=" . urlencode($transactionid) . "&";
    if ($amount>0) {
        $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    }
    $query .= "type=capture";
    return $this->_doPost($query);
  }

  function doVoid($transactionid) {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Transaction Information
    $query .= "transactionid=" . urlencode($transactionid) . "&";
    $query .= "type=void";
    return $this->_doPost($query);
  }

  function doRefund($transactionid, $amount = 0) {

    $query  = "";
    // Login Information
    $query .= "username=" . urlencode($this->login['username']) . "&";
    $query .= "password=" . urlencode($this->login['password']) . "&";
    // Transaction Information
    $query .= "transactionid=" . urlencode($transactionid) . "&";
    if ($amount>0) {
        $query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    }
    $query .= "type=refund";
    return $this->_doPost($query);
  }

  function _doPost($query) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://secure.tnbcigateway.com/api/transact.php");
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
    curl_setopt($ch, CURLOPT_POST, 1);

    if (!($data = curl_exec($ch))) {
        return ERROR;
    }
    curl_close($ch);
    unset($ch);
    print "\n$data\n";
    $data = explode("&",$data);
    for($i=0;$i<count($data);$i++) {
        $rdata = explode("=",$data[$i]);
        $this->responses[$rdata[0]] = $rdata[1];
    }
    return $this->responses['response'];
  }
}
?>

1 Answer

Jose Soto
Jose Soto
23,407 Points

I would recommend that you take down the admin username and password for your merchant gateway from your question and change the password immediately.

You probably want to seek some professional support if it is really important.