Skipjack Erros not showing
<p>I want to ask a question, i am using skipjack payment gateway for transaction. All is going well but when i completes the payment process it gives me the error that <strong>"Transaction declined"</strong> but does not show the error. I mean it does not show which error occurs. Please help me. This is my code:</p>

<pre><code>&lt;?php
/**
 * 2008-24-01 11:28:17est
 * 
 * Skipjack
 * 
 * &lt;usage&gt;
 *      $sj = new Skipjack();
 *      $sj-&gt;setDeveloper(true); // use the development server address
 * 
 *      $sj-&gt;addFields(array(
 *              'OrderNumber' =&gt; '5',
 *              'ItemNumber' =&gt; 'i5',
 *              'ItemDescription' =&gt; 'Test Item',
 *              'ItemCost' =&gt; '5.50',
 *              'Quantity' =&gt; '1',
 *              'Taxable' =&gt; '0',
 *              'AccountNumber' =&gt; '4445999922225',
 *              'Month' =&gt; '12',
 *              'Year' =&gt; '2010',
 *              'TransactionAmount' =&gt; '200.00'
 *      ));
 *  
 *      if($sj-&gt;process() &amp;&amp; $sj-&gt;isApproved()) {
 *              echo "Transaction approved!";
 *      } else {
 *              echo "Transaction declined!\n";
 *              echo $sj-&gt;getErrors();
 *      }
 * &lt;/usage&gt;
 * 
 * Used to connect to the Skipjack API and submit credit card orders that need
 * to be authorized.
 * 
 * @author      Steven Vondruska, Bret Kuhns
 * @link        http://imgserver.skipjack.com/imgServer/5293710/skipjack_integration_guide.pdf
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 * @access      public
 */
class Skipjack {
        var $fields = array();          // Fields to be posted to the API
        var $response = array();        // Reponse array returned after query
        var $errors = array();          // Any errors that might have populated

        // REPLACE THESE VALUES WITH YOUR OWN GIVEN BY SKIPJACK
        var $serialNumber    = '123456789012';
        var $devSerialNumber = '123456789012';

        var $DEVELOPER = false;

        // Required fields from pages 49-50 in API manual
        var $requiredFields = array(
                        'SerialNumber', 'DeveloperSerialNumber', 'OrderNumber', 'ItemNumber',
                        'ItemDescription', 'ItemCost', 'Quantity', 'Taxable', 'SJName',
                        'Email', 'StreetAddress', 'City', 'State', 'ZipCode', 
                        'ShipToPhone', 'OrderString', 'AccountNumber', 'Month', 'Year',
                        'TransactionAmount'
                );
        // recommended dummy values from page 50 in API manual
        var $dummyVals = array(
                        'SJName' =&gt; 'NA',
                        'Email'  =&gt; 'None',
                        'StreetAddress' =&gt; 'None',
                        'City' =&gt; 'None',
                        'State' =&gt; 'XX',
                        'ZipCode' =&gt; '00000',
                        'ShipToPhone' =&gt; '0000000000',
                        'OrderString' =&gt; '1~None~0.00~0~N~||'
                );
        var $authCodes = array(
                        0 =&gt; 'Source Unknown',
                        1 =&gt; 'STIP, Timeout Response',
                        2 =&gt; 'LCS Response',
                        3 =&gt; 'STIP, Issuer in Suppression',
                        4 =&gt; 'STIP Reponse, Issuer Unavailable',
                        5 =&gt; 'Issuer Aproval',
                        7 =&gt; 'Aquirer Approval, Base 1 Down',
                        8 =&gt; 'Aquirer Approval of Referral'
                );
        var $errorCodes = array(
                        "1"       =&gt; "Success (Valid Data)",
                        "-35" =&gt; "Invalid credit card number",
                        "-37" =&gt; "Error failed communication",
                        "-39" =&gt; "Error length serial number",
                        "-51" =&gt; "Invalid Billing Zip Code",
                        "-52" =&gt; "Invalid Shipto zip code",
                        "-53" =&gt; "Invalid expiration date",
                        "-54" =&gt; "Error length account number date",
                        "-55" =&gt; "Invalid Billing Street Address",
                        "-56" =&gt; "Invalid Shipto Street Address",
                        "-57" =&gt; "Error length transaction amount",
                        "-58" =&gt; "Invalid Name",
                        "-59" =&gt; "Error length location",
                        "-60" =&gt; "Invalid Billing State",
                        "-61" =&gt; "Invalid Shipto State",
                        "-62" =&gt; "Error length order string",
                        "-64" =&gt; "Invalid Phone Number",
                        "-65" =&gt; "Empty name",
                        "-66" =&gt; "Empty email",
                        "-67" =&gt; "Empty street address",
                        "-68" =&gt; "Empty city",
                        "-69" =&gt; "Empty state",
                        "-79" =&gt; "Error length customer name",
                        "-80" =&gt; "Error length shipto customer name",
                        "-81" =&gt; "Error length customer location",
                        "-82" =&gt; "Error length customer state",
                        "-83" =&gt; "Invalid Phone Number",
                        "-84" =&gt; "Pos error duplicate ordernumber",
                        "-91" =&gt; "Pos_error_CVV2",
                        "-92" =&gt; "Pos_error_Error_Approval_Code",
                        "-93" =&gt; "Pos_error_Blind_Credits_Not_Allowed",
                        "-94" =&gt; "Pos_error_Blind_Credits_Failed",
                        "-95" =&gt; "Pos_error_Voice_Authorizations_Not_Allowed"
                );


        /**
         * Constructor
         *
         * @param       String  $serial
         * @param       String  $developer
         * @return      Skipjack
         */
        function Skipjack($serial = null, $developer = null) {
                if($serial != null) {
                        $this-&gt;addField('SerialNumber', $serial);
                } else {
                        $this-&gt;addField('SerialNumber', $this-&gt;serialNumber);
                }

                if($developer != null) {
                        $this-&gt;addField('DeveloperSerialNumber', $developer);
                } else {
                        $this-&gt;addfield('DeveloperSerialNumber', $this-&gt;devSerialNumber);
                }
        }


        /**
         * Add field to request, required field are:
         *   SJName (Billing Name), Email, StreetAddress, City, State, ZipCode, 
         *   ShipToPhone, AccountNumber (CC#), Month, Year, TransactionAmount, 
         *   OrderNumber, OrderString
         *
         * @param       String  $key
         * @param       String  $value
         * @return      void
         */
        function addField($key, $value) {
                if($value !== "" &amp;&amp; $value !== "Submit") {
                        $this-&gt;fields[$key] = $value;
                }
        }


        /**
         * Allow array to be sent to object at once
         *
         * @param       Array(String =&gt; String) $array
         * @return      void
         */
        function addFields($array) {
                foreach($array as $key =&gt; $value) {
                        $this-&gt;addField($key, $value);
                }
        }


        /**
         * Determines if all required fields are in the fields array before
         * attempting to post to Skipjack. If a dummy value is found for a field,
         * then it used as a default and no error is thrown for that field. Returns
         * false if any errors are encountered.
         *
         * @access      private
         * @return      boolean
         */
        function __canPost() {
                $return = true;

                foreach($this-&gt;requiredFields as $field) {
                        if(!isset($this-&gt;fields[$field])) {
                                if(array_key_exists($field, $this-&gt;dummyVals)) {
                                        $this-&gt;addField($field, $this-&gt;dummyVals[$field]);
                                } else {
                                        $return = false;
                                        $this-&gt;errors[] = 'Required field not found: '.$field;
                                }
                        }
                }

                return $return;
        }


        /**
         * Process the order using information in Skipjack::fields. Returns false
         * when an error is encountered.
         *
         * @return      boolean
         */
        function process() {
                $post = '';
                $return = true;

                if($this-&gt;__canPost()) {
                        foreach($this-&gt;fields as $key=&gt;$value) {
                                $post .= "$key=" . urlencode($value) . "&amp;";
                        }

                        if($this-&gt;DEVELOPER) {
                                $url = "https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI";
                        } else {
                                $url = "https://www.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI";
                        }
                        $ch = curl_init($url);
                        curl_setopt($ch, CURLOPT_HEADER, 0);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($post, "&amp;"));
                        $response = curl_exec($ch);
                        if(curl_errno($ch) &gt; 0) {
                                $this-&gt;errors[] = "Encountered Curl error number: ".curl_errno($ch);
                                $return = false;
                        }
                        curl_close($ch);

                        $response = explode("\r", $response);
                        $header = explode('","', $response[0]);
                        $data = explode('","', $response[1]);

                        foreach($header as $i =&gt; $array) {
                                $this-&gt;response[str_replace(array("\r",'"'), "", $array)] = str_replace(array("\r",'"'), "", $data[$i]);
                        }
                } else {
                        $return = false;
                }

                return $return;
        }


        /**
         * Check the response for errors, returns false if errors found.
         *
         * @return      boolean
         */
        function checkForErrors() {
                $return = true;

                if(!$this-&gt;isApproved()) {
                        if($this-&gt;isCardDeclined()) {
                                $this-&gt;errors[] = $this-&gt;response['szAuthorizationDeclinedMessage'];
                                $return = false;
                        } else {
                                // this will run if there is an error with the information that you have provided to skipjack
                                $this-&gt;errors[] = $errorCodes[$this-&gt;response['szReturnCode']];
                                $return = false;
                        }
                }

                return $return;
        }


        /**
         * @return      boolean
         */
        function isApproved() {
                return ($this-&gt;response['szIsApproved'] == 1);
        }


        /**
         * @return      boolean
         */
        function isCardDeclined() {
                return !empty($this-&gt;response['szAuthorizationDeclinedMessage']);
        }


        /**
         * Returns the response auth code and associated string
         *
         * @return      Array(int =&gt; String)
         */
        function getAuthCode() {
                return array((int)$this-&gt;response['AUTHCODE'] =&gt; $this-&gt;authCodes[(int)$this-&gt;response['AUTHCODE']]);
        }


        /**
         * Set the developer variable. If set to true, development server is used.
         *
         * @param       boolean $val
         * @return      void
         */
        function setDeveloper($value) {
                $this-&gt;DEVELOPER = (bool)$value;
        }


        /**
         * @return      boolean
         */
        function errorsExist() {
                return (count($this-&gt;errors) &gt; 0);
        }


        /**
         * @return      Array(String)
         */
        function getErrors() {
                return $this-&gt;errors;
        }


        /**
         * Reset the object's properties so multiple instantiations aren't required
         * for batch processing.
         *
         * @return      void
         */
        function reset() {
                $this-&gt;fields = array();
                $this-&gt;response = array();
                $this-&gt;errors = array();
        }


}
?&gt;
</code></pre>
