GithubHelp home page GithubHelp logo

vantiv / litle-sdk-for-php Goto Github PK

View Code? Open in Web Editor NEW
18.0 51.0 36.0 2.41 MB

Vantiv eCommerce SDK for PHP

Home Page: https://developer.vantiv.com/community/ecommerce

License: MIT License

PHP 100.00%

litle-sdk-for-php's Introduction

Vantiv eCommerce PHP SDK

Important Support Note

Worldpay provides SDK updates for releases in the latest major version stream. We do not provide SDK updates to older releases, unless mandated by the card brands. All SDKs are open source, allowing you to update older versions as needed.

WARNING:

All major version changes require recertification to the new version. Once certified for the use of a new version, Vantiv modifies your Merchant Profile, allowing you to submit transaction to the Production Environment using the new version. Updating your code without recertification and modification of your Merchant Profile will result in transaction declines. Please consult you Implementation Analyst for additional information about this process.

About Vantiv eCommerce

Vantiv eCommerce powers the payment processing engines for leading companies that sell directly to consumers through internet retail, direct response marketing (TV, radio and telephone), and online services. Vantiv eCommerce is the leading authority in card-not-present (CNP) commerce, transaction processing and merchant services.

About this SDK

No major updates are planned for this repository. SDK Version 12 and above can be found here: cnp-sdk-for-php

The Vantiv eCommerce PHP SDK is a PHP implementation of the Vantiv eCommerce. XML API. This SDK was created to make it as easy as possible to connect process your payments with Vantiv eCommerce. This SDK utilizes the HTTPS protocol to securely connect to Vantiv eCommerce. Using the SDK requires coordination with the Vantiv eCommerce team in order to be provided with credentials for accessing our systems.

Each PHP SDK release supports all the functionality present in the associated Vantiv eCommerce XML version (e.g., SDK v9.3.2 supports Vantiv eCommerce XML v9.3). Please see the online copy of our XSD for Vantiv eCommerce XML to get more details on what the Vantiv eCommerce payments engine supports.

This SDK was implemented to support the PHP programming language and was created by Vantiv eCommerce. Its intended use is for online transaction processing utilizing your account on the Vantiv eCommerce payments engine.

See LICENSE file for details on using this software.

Source Code available from : https://github.com/LitleCo/litle-sdk-for-php

Please contact Vantiv eCommerce to receive valid merchant credentials in order to run tests successfully or if you require assistance in any way. We are reachable at [email protected]

SDK PHP Dependencies

Up to date list available at Packagist

Setup

Using with composer

If you are using a composer to manage your dependencies, you can do the following in your project directory:

  1. Install the composer using command:

curl -sS https://getcomposer.org/install | php

  1. Install dependencies using the command:

php composer.phar install

  1. Configure the SDK:

cd litle/sdk php Setup.php

  1. Run the attached sample:
<?php
require_once _DIR_.'/vendor/autoload.php';
#sale
$sale_info = array(
	     'id' => '456',
             'orderId' => '1',
             'amount'  => '10010',
             'orderSource' => 'ecommerce',
             'billToAddress' => array(
             'name' => 'John Smith' ,
             'addressLine1' => ' 1 Main St.',
             'city' => 'Burlington' ,
             'state' => 'MA' ,
             'zip' => '0183-3747',
             'country' => 'US'),
             'card' => array(
             'number' => '5112010000000003',
             'expDate' => '0112',
             'cardValidationNum' => '349',
             'type' => 'MC' )
            );
$initialize = new litle\sdk\LitleOnlineRequest();
$saleResponse =$initialize->saleRequest($sale_info);
#display results
echo ("Response: " . (litle\sdk\XmlParser::getNode($saleResponse,'response')) . "<br>");
echo ("Message: " . litle\sdk\XmlParser::getNode($saleResponse,'message') . "<br>");
echo ("Vantiv eCommerce Transaction ID: " . litle\sdk\XmlParser::getNode($saleResponse,'litleTxnId'));

php your_sample_name

Using without composer

If you're not, you have to add a require for each and every class that's going to be used.

  1. Configure the SDK

cd into litle/sdk php Setup.php

  1. Add the litle folder and require the path for your file

  2. run your file

php your_file

Clone Repo

  1. Install the LitleOnline PHP SDK from git.

git clone git://github.com/LitleCo/litle-sdk-for-php.git

php ~/composer.phar install

  1. Once the SDK is downloaded run our setup program to generate a configuration file.

cd litle-sdk-for-php/lib

php Setup.php

Running the above commands will create a configuration file in the lib directory.

  1. Create a symlink to the SDK

ln -s /path/to/sdk /var/www/html/nameOfLink

4.) Create a php file similar to:

<?php
require_once realpath(dirname(__FILE__)) . '/../lib/LitleOnline.php';  
    // Visa $10.00 sale
    $hash_in = array(
	      'amount'=>'106',
	      'orderId' => '123213',
	      'orderSource'=>'ecommerce',
	      'card'=>array(
	      'type'=>'VI',
	      'number' =>'4100000000000001',
	     'expDate' =>'1000')
	      );
//Perform the transaction on the Vantiv eCommerce Platform
$initialize = new LitleOnlineRequest();
$saleResponse = $initialize->saleRequest($hash_in);

// Display Result 
echo ("Message: " . XMLParser::getNode($saleResponse,'message') . "<br>");
echo ("Vantiv eCommerce Transaction ID: " . XMLParser::getNode($saleResponse,'litleTxnId'));

As of 8.13.1, you may also use a tree-oriented style to get the response values:

<?php
require_once realpath(dirname(__FILE__)) . '/../lib/LitleOnline.php';  
    // Visa $10.00 sale
    $hash_in = array(
	      'amount'=>'106',
	      'orderId' => '123213',
	      'orderSource'=>'ecommerce',
	      'card'=>array(
	      'type'=>'VI',
	      'number' =>'4100000000000001',
	     'expDate' =>'1000')
	      );
//Perform the transaction on the Vantiv eCommerce Platform
$initialize = new LitleOnlineRequest($treeResponse=true);
$saleResponse = $initialize->saleRequest($hash_in);

// Display Result 
echo ("Message: " . $saleResponse->saleResponse->message . "<br>");
echo ("Vantiv eCommerce Transaction ID: " . $saleResponse->saleResponse->litleTxnId);

NOTE: you may have to change the path to match that of your filesystems.

If you get an error like:

PHP Fatal error:  require_once(): Failed opening required '/home/gdake/git/litle-sdk-for-php/../lib/LitleONline.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/gdake/git/litle-sdk-for-php/foo.php on line 2

You need to change the second line of your script to load the real location of LitleOnline.php

If you get an error like:

PHP Fatal error:  require(): Failed opening required '/home/gdake/litle-sdk-for-php/lib/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/gdake/litle-sdk-for-php/lib/LitleOnline.php on line 42

You probably had a problem with composer. You can safely remove line 42 if you are not using batch processing, or you can edit it to point at our dependencies that you've downloaded in another way.

  1. Next run this file using php on the command line or inside a browser. You should see the following result provided you have connectivity to the Litle certification environment. You will see an HTTP error if you don't have access to the Litle URL

    Message: Valid Format Vantiv eCommerce Transaction ID:

More examples can be found here [php Gists])(https://gist.github.com/litleSDK)

Please contact Litle & Co. with any further questions. You can reach us at [email protected]

litle-sdk-for-php's People

Contributors

aaronhammond avatar abishekrsrikaanth avatar amitvig22 avatar arch85 avatar avedpath avatar azhurv avatar brianarnold789 avatar chahatsharma avatar chrisallenlane avatar danguerin avatar devenlabo123 avatar domtancredi avatar harshitvora avatar houzl avatar itoto avatar jfitzpatrick-directdigital avatar johnholden avatar juncai avatar kook005 avatar leonli0326 avatar michaelm111 avatar pshah91 avatar smithxxl avatar utoxin avatar vantivsdk avatar vivek42 avatar wting2013 avatar zappyzhao avatar zxc8027 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

litle-sdk-for-php's Issues

SDK on Composer

Could you make this library available through composer? It is easy to get updates.

Fix Setup.php to show error when opening file instead of misleading message

When an error occur opening the file to write the configuration it will show the following:

Warning: fclose() expects parameter 1 to be resource, boolean given in ..../Setup.php on line 85
The Litle configuration file has been generated, the file is located in the lib directory

The error prevented the file of being generated but still gave a positive message, hiding the real error that prevented the file of being accessed.
And also, the file is not being generated in the lib folder, it should print the real path to the file.

a version composer free

We are using version 8.19 in our company, we are trying to update to the newest version.. but the newest is under composer. When we try to use it without composer.. it has multiple calls to namespace litle\sdk and '/../../vendor/autoload.php'. I know we can modify this files to remove the namespace and manually include the libraries. But thats no the case.

Could you fix this? the explanation to use this sdk without composer does not work.

8.0 branch broken on php 7.2

In litle/sdk/LitleOnlineRequest.php the default values are null,

    private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)        $hash_config = LitleOnlineRequest::overrideConfig($hash_in);
        $hash = LitleOnlineRequest::getOptionalAttributes($hash_in, $hash_out);
        Checker::choice($choice1);
        Checker::choice($choice2);
        $request = Obj2xml::toXml($hash, $hash_config, $type);
        $litleOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml);
        return $litleOnlineResponse;
    }

which calls

    public static function choice($choiceArray)
    {
        $i = 0;
        for ($y = 0; $y < count($choiceArray); $y++) {
            if (isset($choiceArray[$y])) {
                $i++;
            }
        }
        if ($i > 1) {
            throw new \InvalidArgumentException("Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!");
        }
    }

calling count(null) in php7.2 throws an error

handle re-auth transaction

Currently our sdk is unable to handle an auth transaction when it is given only a litleTxnId; in this scenario errors are thrown because required fields such as orderId are missing.

Fix test structure

fix the structure of the test folders so that all unit tests can be run with one command, check out what simpletest reccomends

Numerous unit-test errors

Hi

I just forked and cloned this repository, changed nothing, and ran phpunit. This was the output:

There were 26 failures:

1) litle\sdk\AuthReversalUnitTest::test_no_txnid
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


2) litle\sdk\Test\unit\AuthUnitTest::test_no_orderId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderId/'.


3) litle\sdk\Test\unit\AuthUnitTest::test_no_amount
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /amount/'.


4) litle\sdk\Test\unit\AuthUnitTest::test_no_orderSource
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderSource/'.


5) litle\sdk\Test\unit\AuthUnitTest::test_advancedFraudChecks_withoutThreatMetrixSessionId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /threatMetrixSessionId/'.


6) litle\sdk\Test\unit\CaptureGivenAuthUnitTest::test_no_amount
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /amount/'.


7) litle\sdk\Test\unit\CaptureUnitTest::test_no_txnid
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


8) litle\sdk\Test\unit\EcheckRedepositUnitTest::test_no_litleTxnId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


9) litle\sdk\Test\unit\EcheckRedepositUnitTest::test_no_routingNum_echeck
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /routingNum/'.


10) litle\sdk\Test\unit\EcheckRedepositUnitTest::test_no_routingNum_echeckToken
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /routingNum/'.


11) litle\sdk\Test\unit\EcheckVerificationUnitTest::test_no_amount
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /amount/'.


12) litle\sdk\Test\unit\EcheckVerificationUnitTest::test_no_orderId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderId/'.


13) litle\sdk\Test\unit\EcheckVerificationUnitTest::test_no_orderSounce
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderSource/'.


14) litle\sdk\Test\unit\ForceCaptureUnitTest::test_no_orderId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderId/'.


15) litle\sdk\Test\unit\ForceCaptureUnitTest::test_no_orderSource
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderSource/'.


16) litle\sdk\Test\unit\GiftCardCaptureUnitTest::test_no_txnid
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


17) litle\sdk\Test\unit\SaleUnitTest::test_no_orderId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderId/'.


18) litle\sdk\Test\unit\SaleUnitTest::test_no_amount
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /amount/'.


19) litle\sdk\Test\unit\SaleUnitTest::test_no_orderSource
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /orderSource/'.


20) litle\sdk\Test\unit\SaleUnitTest::test_advancedFraudChecks_withoutThreatMetrixSessionId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /threatMetrixSessionId/'.


21) litle\sdk\Test\unit\UpdateCardValidationNumOnTokenUnitTest::test_litleTokenIsRequired
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleToken/'.


22) litle\sdk\Test\unit\UpdateCardValidationNumOnTokenUnitTest::test_cardValidationNumIsRequired
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /cardValidationNum/'.


23) litle\sdk\Test\unit\VoidUnitTest::test_no_litleTxnId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


24) litle\sdk\Test\functional\AuthFunctionalTest::test_pos_missing_field
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /capability/'.


25) litle\sdk\Test\functional\EcheckRedepositFunctionalTest::test_echeckRedeposit_missing_litleTxnId
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /litleTxnId/'.


26) litle\sdk\Test\functional\TokenFunctionalTest::test_token_echeck_missing_required
Failed asserting that exception message 'Missing Field /user/' contains 'Missing Required Field: /accNum/'.

FAILURES!
Tests: 567, Assertions: 301, Failures: 26, Errors: 428.
Script phpunit handling the test event returned with an error

System information:

chris@fourside:~/src/revo/organization/litle-sdk-for-php$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:        16.10
Codename:       yakkety
chris@fourside:~/src/revo/organization/litle-sdk-for-php$ php --version
PHP 5.6.30-10+deb.sury.org~yakkety+2 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

I would like to use this SDK, but these errors make me relunctant to do so. Please advise. Thanks.

Optional Fields generate notices when not present

Stumbled across this while testing a sale transaction on our system. I don't pass litleTxnId, because obviously I don't have one yet, since it's a sale transaction, with no previous related transactions.

This generates a notice on line 74 of lib/LitleOnlineRequest.php, when it tries to access that element from the hash.

In other projects, I've solved this by having a blank template array that I plug the incoming values into, and then access that template, so that everything that I could use is already there. I can generate a patch for this if you want.

Path to litle_SDK_config.ini file (and its name too) file need to be configurable

If I am missing something, please point that out. My understanding that I need to configure litle_SDK_config.ini file in order to run/use the SDK (by the way it's really not clear from the limited docs how and where to configure SDK, documentation needs to be improved). It is unfortunate that there is no way to point the SDK to use a provided config file from a non-vendor/custom directory (e.g. /configs/vantiv-config.ini). It does not make too much sense to have this file modified inside the vendors folder (/vendors/litle/...) because of composer (should be able to recreate/reinstall litle SDK without overriding my config file).

I think this issue is critical and needs to be address. Thank you.

Invalid date format is not handled by the API

In certain cases, if you send an invalidate date format to the Litle API in a sale request, the returned response is not valid XML and appears to have some backend exception messaging within it.

Notice that the orderDate element in enhancedData is incorrectly formatted.

Request

<?xml version="1.0" encoding="utf-8"?>
<litleOnlineRequest merchantId="123456" merchantSdk="Magento;8.15.0" version="8.23" xmlns="http://www.litle.com/schema">
    <authentication>
        <user>USERNAME</user>
        <password>NEUTERED</password>
    </authentication>
    <sale customerId="[email protected]" reportGroup="123456">
        <orderId>110299471</orderId>
        <amount>1070</amount>
        <orderSource>ecommerce</orderSource>
        <billToAddress>
            <firstName>First</firstName>
            <lastName>Last</lastName>
            <addressLine1>123 Main St</addressLine1>
            <city>Boulder</city>
            <state>Colorado</state>
            <zip>80304</zip>
            <country>US</country>
            <phone>123-456-7890</phone>
        </billToAddress>
        <card>
            <type>VI</type>
            <number>XXXX1000</number>
            <expDate>0817</expDate>
            <cardValidationNum>NEUTERED</cardValidationNum>
        </card>
        <enhancedData>
            <salesTax>46</salesTax>
            <discountAmount>-239</discountAmount>
            <shippingAmount>468</shippingAmount>
            <destinationPostalCode>80304</destinationPostalCode>
            <destinationCountryCode>US</destinationCountryCode>
            <orderDate>202014-04-24</orderDate>
            <detailTax>
                <taxAmount>46</taxAmount>
            </detailTax>
            <lineItemData>
                <itemSequenceNumber>1</itemSequenceNumber>
                <itemDescription>Cuppow: Mason Jar Lid</itemDescription>
                <productCode>11642</productCode>
                <quantity>0</quantity>
                <lineItemTotal>0</lineItemTotal>
                <unitCost>795</unitCost>
            </lineItemData>
            <lineItemData>
                <itemSequenceNumber>2</itemSequenceNumber>
                <itemDescription>Cuppow: Regular</itemDescription>
                <productCode>9285</productCode>
                <quantity>0</quantity>
                <lineItemTotal>0</lineItemTotal>
                <unitCost>0</unitCost>
            </lineItemData>
        </enhancedData>
    </sale>
</litleOnlineRequest>

Response

<litleOnlineResponse version="1.0" xmlns="http://www.litle.com/schema/online" response="1" message="Unable to convert exception
invalid orderDate [202014-04-24] specified on enhancedData for payment [0]
Invalid xml date format: [202014-04-24]
For input string: &quot;>
</litleOnlineResponse>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.