简体   繁体   中英

SkipJack payment integration

I am using SkipJack as a payment gateway in my eCommerce application. I've downloaded SkipJack classes from the internet, and then I call the functions in my own script but there is an issue during the processing.

There is a method getErrors() . It is called when the payment is declined, in this function all the errors are written.

But when the payment proceeds then an empty array is printed with no error message. I am working to fix this issue for almost a week but I can't solve it. Please help me.

Thank you in advance

This is my code:

<?php
require_once 'skipjack.php';
$sj = new Skipjack();
//$sj->setDeveloper(true); // use the development server address, remove this line to use the live server 4445999922225

if (isset($_POST['submit'])) {

    $c_name = $_POST['c_name'];
    $c_email = $_POST['c_email'];
    $c_add = $_POST['c_add'];
    $c_city = $_POST['c_city'];
    $c_state = $_POST['c_state'];
    $c_zip = $_POST['c_zip'];
    $c_acc = $_POST['c_acc'];
    $c_cvv = $_POST['c_cvv'];
    $c_phone = $_POST['c_phone'];
    $c_month = $_POST['c_month'];
    $c_year = $_POST['c_year'];

    $sj->addFields(array(
        'OrderNumber' => '5',
        'ItemNumber' => 'i5',
        'ItemDescription' => 'Test Item',
        'ItemCost' => '5.50',
        'Quantity' => '1',
        'Taxable' => '0',
        'Streetaddress' => $c_add,
        'City' => $c_city,
        'State' => $c_state,
        'Zipcode' => $c_zip,
        'AccountNumber' => $c_acc,
        'cvv2' => $c_cvv,
        'SJName' => $c_name,
        'Email' => $c_email,
        'Month' => $c_month,
        'Year' => $c_year,
        'TransactionAmount' => '200.00'
    ));

    $sub = "Your payment Transaction";
    $msg = "<table width='50%'>
        <tr>
        <td>Order Number:</td><td>5</td>
        </tr>
        <tr>
        <td>Quantity:</td><td>1</td>
        </tr>
        <tr>
        <td>Name:</td><td>" . $c_name . "</td>
        </tr>
        <tr>
        <td>City:</td><td>" . $c_city . "</td>
        </tr>
        <tr>
        <td>Address:</td><td>" . $c_add . "</td>
        </tr>
        <tr>
        <td>Zip Code:</td><td>" . $c_zip . "</td>
        </tr>
        <tr>
        <td>Account Number:</td><td>" . $c_acc . "</td>
        </tr>
        <tr>
        <td>Message:</td><td>Your transaction has been declined, Pos_error_Blind_Credits_Failed</td>
        </tr>
        </table>";

    if ($sj->process() && $sj->isApproved()) {
        echo "Transaction approved!" . "<br> Email has sent to your email address";
        sendEmail($msg, $c_email, $sub);
    } else {
        echo "Transaction declined!\n";
        echo ($sj->getErrors()) . "<br> Email has sent to your email address";
        //echo $a;
    }
}
?>
<h3 align="center" style="width:100%;">Skip Jack</h3>

<form method="post" action="">
    <table width="1000" align="center" cellpadding="5" cellspacing="5">
        <tr>
            <td>Name:<br /></td>
            <td><input type="text" name="c_name" id="c_name" /></td>

            <td>Email:<br /></td>
            <td><input type="text" name="c_email" id="c_email" /></td>

            <td>Street Address:<br /></td>
            <td><input type="text" name="c_add" id="c_add" /></td>
        </tr>

        <tr>
            <td>City:<br /></td>
            <td><input type="text" name="c_city" id="c_city" /></td>

            <td>State:<br /></td>
            <td><input type="text" name="c_state" id="c_state" /></td>

            <td>Zip Code:<br /></td>
            <td><input type="text" name="c_zip" id="c_zip" /></td>
        </tr>

        <tr>
            <td>Credit Card Number:<br /></td>
            <td><input type="text" name="c_acc" id="c_acc" /></td>

            <td>Security code:<br /></td>
            <td><input type="text" name="c_cvv" id="c_cvv" /></td>

            <td>Phone:<br /></td>
            <td><input type="text" name="c_phone" id="c_phone" /></td>
        </tr>

        <tr>
            <td>Month:<br /></td>
            <td>
                <select name="c_month">
                    <option value="01">January</option>
                    <option value="02">February</option>
                    <option value="03">March</option>
                    <option value="04">April</option>
                    <option value="05">May</option>
                    <option value="06">June</option>
                    <option value="07">July</option>
                    <option value="08">August</option>
                    <option value="09">September</option>
                    <option value="10">October</option>
                    <option value="11">November</option>
                    <option value="12">December</option>
                </select>
            </td>

            <td>Year:<br /></td>
            <td>
                <select name="c_year">
                    <option value="2014">2014</option>
                    <option value="2015">2015</option>
                    <option value="2016">2016</option>
                    <option value="2017">2017</option>
                    <option value="2018">2018</option>
                    <option value="2019">2019</option>
                    <option value="2020">2020</option>
                </select>
            </td>

            <td>&nbsp;</td>
        </tr>
        <tr>
            <td align="center" colspan="5"><input type="submit" name="submit" /></td>
        </tr>
    </table>
</form>
</body>
</html>
?>

According to a comment on this APIs page, this is a problem with this PHP library:

There's bugs with this API .. for one at line 255 it's using $errorCodes when it should be using $this->errorCodes .. spent a while wondering why I wasn't seeing any errors but was getting a transaction failed message..

The example code doesn't work out of the box..

From: https://code.google.com/p/skipjack-php/wiki/ClassDocumentation

I would recommend trying the Skipjack library on GitHub , since it's more recent and might fix this problem. (Caveat: I haven't used either one.)

(Although it looks like this one's busted too. On line 429 , it should be $this->errorCodes[...] and not $errorCodes[...] .)

I've made the repairs in a forked repository for now, if you'd like to try that: https://github.com/firstclown/Skipjack-PHP-Library/tree/patch-1

Add

if(!empty($sj->getErrors())) {
    echo "Transaction declined!\n";
    echo  ($sj->getErrors())."<br> Email has sent to your email address";
}

instead of

echo "Transaction declined!\n";
echo  ($sj->getErrors())."<br> Email has sent to your email address";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM