Brochure



    How to integrate your PHP site with USA ePay payment gateway?

    Home  »  ecommercePayment GatewayPHPWeb_Development   »   How to integrate your PHP site with USA ePay payment gateway?

    How to integrate your PHP site with USA ePay payment gateway?

    Contributors: Vidya Poulose and Shivendra Singh

    USA ePay  has been helping merchants process their credit card and check transactions with speed and security since 1998. Currently the USA ePay gateway supports all of the major platforms in the credit card industry and works with some of the leading check platforms. We had an opportunity to integrate it with several web sites ownded by one of customers. We would like to share our experience. If you have any questions or need help, feel free to contact us.

    REQUIREMENTS

    -PHP 4.3.x or higher (http://www.php.net)

    -HTTPs streams support in PHP

    or

    -Curl/ssl module installed (http://curl.haxx.se/)

     

    Step:1->Download  The USAePay PHP Library from http://wiki.usaepay.com/developer/phplibrary

    The USAePay PHP library is a class for running transactions on the USAePay gateway.

    Step:2-> Download Certificate Authority (CA) bundle file from  https://www.usaepay.com/topics/curl-ca-bundle.crt .

    This is a file (Certificate Authority (CA) ) that validates all the popular “root” certificate authorities, and this in turn is used to verify that you are in fact correctly communicating with the New Relic servers, and that there is little to no chance of there being a “man in the middle” attack on your data.

    Steps3-> Run “verify_install.php”

    A “verify_install.php” script has been included in library that will help you check that your server is properly configured to use the php library. To use this script you must first edit it, filling in the correct path to usaepay.php. If you upload both usaepay.php and verify_install.php to the same directory, you can usually set the include to: include ”./usaepay.php”;

    Note: If the SSL certificate path test failed, it’s possible that curl is not correctly configured to use this bundle. You can correct the problem by adding the following code to your script:

     $tran->cabundle='<?php echo $certpath?>’; (Path of Certificate Authority (CA) file)

    Steps 4-> If  the file: “verify_install.php” runs with no errors and shows an “OK” in each category, Now we can start with following input arguments.

    <?php

    include “./usaepay.php”;    (First Add usaepay class. Path of usaepay class should be correct)

    $tran=new umTransaction;           (Instantiate USAePay client object)

    $tran->key=”Your_source_key_here“;   (Source key must be generated within the console)

    $tran->ip=$REMOTE_ADDR; (This allows fraud blocking on the customer’s IP address)

    $tran->testmode=1;         (Change this to 0 for the transaction to process)

    $tran->card=”1234567890987654″;   (card number, no dashes, no spaces)

    $tran->exp=”1234″;                            (expiration date 4 digits no)

    $tran->amount=”23.00″;                     (charge amount in dollars)

    $tran->invoice=”1234″;                       (invoice number.  Must be unique)

    $tran->cardholder=”name”;   (name of card holder)

    $tran->street=”address”;        (street address)

    $tran->zip=”560068″;                          (zip code)

    $tran->description=”description”;      (description of charge)

    $tran->cvv2=”123″;                             (cvv2 code (Security Code))   

    echo “<h1>Please wait one moment while we process your card…<br>\n”;

    flush();

    if($tran->Process())

    {

                echo “<b>Card Approved</b><br>”;

                echo “<b>Authcode:</b> ” . $tran->authcode . “<br>”;

                echo “<b>AVS Result:</b> ” . $tran->avs . “<br>”;

                echo “<b>Cvv2 Result:</b> ” . $tran->cvv2 . “<br>”;

    } else {

                echo “<b>Card Declined</b> (” . $tran->result . “)<br>”;

                echo “<b>Reason:</b> ” . $tran->error . “<br>”;      

                if(@$tran->curlerror) echo “<b>Curl Error:</b> ” . $tran->curlerror . “<br>”;        }

     

    Note:

    If Specified source key available, Card Number, Expiry date and cvv2 (Security Code) are valid then (after process of the card) we will get message for Card Approveal. Otherwise we will get message for Card Decline.

    How generate Sources key?

    We can generate key at http://www.usaepay.com. When you  logon to your USAePay Merchant Console (https://sandbox.usaepay.com/login).

    Steps for generating Source Key.

    Setting->Sources Keys->Add Sources->Fill-up Source Info->Apply

    After clicking “apply” button, source key will be generated. Now we can use this source key for transaction.

    For More information please read  http://wiki.usaepay.com/developer/phplibrary.

    Please follow and like us: