2017 © Pedro Peláez
 

library innovate

A PHP client to perform payments with the Innovate payment gateway.

image

namshi/innovate

A PHP client to perform payments with the Innovate payment gateway.

  • Sunday, January 17, 2016
  • by odino
  • Repository
  • 18 Watchers
  • 7 Stars
  • 10,899 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 31 Versions
  • 0 % Grown

The README.md

NAMSHI | Innovate

Build Status, (*1)

SensioLabsInsight, (*2)

This library provides support for the Innovate payment gateway using Guzzle., (*3)

Version

From the 3.0.0 version, the client constructor has been changed. Now it accepts two more parameters:, (*4)

/* 2.x version */
$client = new Namshi\Innovate\Client('storeid', 'key');
/* 3.x version */
$client = new Namshi\Innovate\Client('storeid', 'merchantid', 'key', 'searchkey');

The added paramets are used when fetching the transactions related to a cart id (see below)., (*5)

Installation

You can install this library via composer: have a look at the package on packagist., (*6)

Then include it into your composer.json:, (*7)

"namshi/innovate": "1.0.*",

Pick major and minor version according to your needs., (*8)

Usage

To use the library you will need an instance of the Namshi\Innovate\Client class. This library will provide also helper classes that describe the data needed by the Innovate api., (*9)

``` php use Namshi\Innovate\Payment\Transaction; use Namshi\Innovate\Payment\BillingInformation; use Namshi\Innovate\Payment\Browser; use Namshi\Innovate\Payment\Billing\Customer; use Namshi\Innovate\Payment\Billing\Address; use Namshi\Innovate\Payment\Card; use Namshi\Innovate\Client;, (*10)

$client = new Client('storeid', 'merchantid', 'key', 'searchkey'); // get them from your innovate account, (*11)

$transaction = new Transaction('sale', 'ecom', true, 'ORDER_NUMBER', 'DESCRIPTION', 'USD', 40, 'AN OPTIONAL REFERENCE TO YOUR TRANSACTION'); $card = new Card('1234123412341234', '111', new \DateTime($cardExpiryDate)); $customer = new Customer('Mr', 'John', 'Doe'); $address = new Address('My address info 1', 'My address info 2', 'My address info 3', 'San Francisco', 'California', 'US', '00000'); $billing = new BillingInformation($customer, $address, "customers's-email@gmail.com", $customerIpAddress); $browser = new Browser($customerUserAgent, $requestAcceptHeader);, (*12)

$response = $client->performPayment($transaction, $card, $billing, $browser);, (*13)


If you want you can also inject your own Guzzle client instance (as long as it extendes `\Guzzle\Service\Client`) ```php $myGuzzleClient = MyGuzzleClient(...); $client = new Client('storeid', 'merchantid', 'key', 'searchkey', $myGuzzleClient);

How It Works

There are two types of transactions:, (*14)

We do not have a way to understand which is which beforehand. The way we can understand if we are dealing with a 3-D_Secure transaction is by checking the response from Innovate., (*15)

use Namshi\Innovate\Http\Response\Redirect;

$response = $client->performPayment($transaction, $card, $billing, $browser);

if ($response instanceOf Redirect) {
    // 3D secure transactions
} else {
    // Normal transactions
}

Authorization Statuses

Any payment will perform an authorization request first and then the payment request., (*16)

If the authorization is denied, you will receive a response with a failure message and the 400 Bad Request status code ., (*17)

Normal transaction

A normal transaction will follow only the authorization and payment steps already described. On your end you will only need to check that the status code of the response is a 200. The library will take care of the rest., (*18)

$response = $client->performPayment($transaction, $card, $billing, $browser);

if ($response->getStatusCode() === 200) {
    // payment done
} else {
    // transaction failed
}

3D secure transaction

A 3D secure transaction requires an additional step compared to the normal transaction., (*19)

When the library requests the authorization for a 3D secure transaction, Innovate will answer with a url where the customer should be redirect. The redirection should be done by your application (as described below)., (*20)

Once the customer is done with the 3D secure step, she'll be redirected back to the application and there you can use this library to perform the actual payment., (*21)

Note: The library will return an instance of 'Namshi\Innovate\Http\Response\Redirect' when the transaction is a 3D secure one., (*22)

The following example describes the code to perform a 3D secure payment:, (*23)

use Namshi\Innovate\Http\Response\Redirect;

$response = $client->performPayment($transaction, $card, $billing, $browser);

if ($response instanceof Redirect) {
    // build a form
}

The response object will contain the following values:, (*24)

  • targetUrl
  • session
  • paReq

You will need those as hidden fields to perform the redirect to Innovate:, (*25)

$targetUrl = $response->getTargetUrl();
$session   = $response->getSession();
$pareq     = $response->getPareq();

One simple way to redirect the customer with the right parameters is to build a form and add those values as hidden fields., (*26)

The must be sent to the targetUrl:, (*27)

<form name="acsform" action="[targetUrl from the response]" method="post">
    <input type="hidden" name="PaReq" value="[The pareq data from response]">
    <input type="hidden" name="MD" value="[Value that identifies the transaction on our end. It will be sent back unchanged in the the 3d secure response. (i.e.: you could use the session id to complete the transaction]">
    <input type="hidden" name="TermUrl" value="[return URL on your site]">
    <noscript><input type="Submit"></noscript>
</form>

Note: termUrl is the url where Innovate will redirect the customer after the 3D secure step., (*28)

An example of this form is here: ACS (Access Control Server) Form, (*29)

The easiest way to submit the form is with Javascript (without asking the customer to do it):, (*30)

<script>
    function autosub() {
        document.forms['acsform'].submit();
    }
    document.onload=autosub;
</script>

After the form is submitted the customer will be redirected to the 3D-Secure page which asks for extra credentials. From there she gets redirected to termUrl with two values ('PaRes', 'MD'):, (*31)

We can use this values to perfom the actual payment request:, (*32)

``` php $mpiData = array( 'PaRes' => $request->get('PaRes'), 'session' => $request->get('MD'), );, (*33)

$finalResponse = $client->perform3DSecurePayment($transaction, $card, $billingInformation, $browser, $mpiData);, (*34)


The final response lets us check if the payment is successful or denied: ```php if ($finalResponse->getStatusCode() === 200) { // payment done } else { // payment failed }

From 3.0.0 version there is a new method Namshi\Innovate\Client::searchTransactionsByCartId that let you fetch the transaction given the innovate cart id., (*35)

This method will return a \SimpleXMLElement object containing the answer from innovate or throw an exception (Namshi\Innovate\Exception\InnovateException)., (*36)

Tokenization of a credit card

With 4.0.0 version we add the ability to:, (*37)

  • request a token from a credit card
  • issue a normal transaction using a token instead of a credit card
  • issue a 3D Secure transaction using a token instead of a credit card

To request a token you should use the following method, (*38)


$client = new Client('storeid', 'merchantid', 'key', 'searchkey'); $card = new TokenizedCard('4000000000000002', new \DateTime('2025-5')); $billing = new TokenizedBillingInfo( new Customer('Forenames', 'Surname', 'Mr'), new Address('STREET_ADDRESS_LINE_1', 'STREET_ADDRESS_LINE_2', 'STREET_ADDRESS_LINE_3', 'CITY', 'REGION', 'COUNTRY', '12345'), 'test@namshi.com' ); $response = $client->tokenize($card, $billing); /* response body <remote> <result>1</result> <token> <ref>123400012340002</ref> <description>Visa Credit ending 0002</description> </token> </remote> */

To perform a normal transaction or a 3D Secure transaction with a token, the flow is the same described above, the only difference is:, (*39)

  • use an instrance of Namshi\Innovate\Tokenized\Token instead of Namshi\Innovate\Payment\Card
  • use an instrance of Namshi\Innovate\Tokenized\CustomerInformation instead of Namshi\Innovate\Payment\BillingInformation

Tests

You can run the test suite by first installing the dependencies and then running PHPUnit:, (*40)

php composer.phar install

./vendor/bin/phpunit -c .

There is an integration test that actually verify that the library works flawlessly., (*41)

To run it, you need to create a file called .innovate.config in your your project directory with 4 parameters, (*42)

``` php <?php, (*43)

$configs = array( 'storeId' => 'xxxxx', // your store Id in Innovate 'merchantId' => 'xxxxx', // your merchant Id in Innovate 'authenticationKey' => 'xxxxxxxxxxx', // your authentication key 'searchKey' => 'xxxxxxxxxxx', // your search key );, (*44)

// Card info $cardInfo = array( 'number' => '111111111111111', 'cvv' => 'XXX', );, (*45)

// The card which need redirection for 3d secured $redirectUrlCardInfo = array( 'number' => '111111111111111', 'cvv' => 'XXX',, (*46)

);, (*47)

// your ip and should be in Innovate white list $ip = 'xxx.xxx.xxx.xxx';, (*48)


and then run

phpunit tests/Namshi/Innovate/Test/Integration/ServiceTest.php ```, (*49)

The Versions

17/01 2016

dev-master

9999999-dev

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham
by filippo

17/01 2016

4.0.0

4.0.0.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham
by filippo

14/01 2016

dev-request-payment-with-token

dev-request-payment-with-token

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham
by filippo

29/12 2015

dev-add-credit-card-tokenization-request

dev-add-credit-card-tokenization-request

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham
by filippo

09/11 2015

dev-refundTest

dev-refundTest

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham

07/11 2015

dev-PHP7-support

dev-PHP7-support

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham

07/11 2015

dev-phpunit-5

dev-phpunit-5

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by Avatar cirpo
by ayham

09/08 2015

dev-refactor

dev-refactor

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

02/08 2015

dev-logger

dev-logger

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

01/08 2015

dev-enhance-test-coverage

dev-enhance-test-coverage

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

31/07 2015

dev-update-packages

dev-update-packages

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

31/07 2015

dev-fix-strtotime-in-test

dev-fix-strtotime-in-test

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

30/07 2015

dev-mpi-logs

dev-mpi-logs

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

28/04 2015

dev-p

dev-p

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

28/04 2015

dev-add-call-for-transaction-for-cart-id

dev-add-call-for-transaction-for-cart-id

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

28/04 2015

3.0.0

3.0.0.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar odino
by ayham

27/05 2014

dev-tests-on-hhvm

dev-tests-on-hhvm

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

27/05 2014

2.0.0

2.0.0.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

07/04 2014

dev-loos-dependencies

dev-loos-dependencies

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

09/03 2014

dev-expired-card-exception

dev-expired-card-exception

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

25/02 2014

dev-fix-expiry-date

dev-fix-expiry-date

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

25/02 2014

1.0.5

1.0.5.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

13/01 2014

dev-updated-docs

dev-updated-docs

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

11/12 2013

1.0.4

1.0.4.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

11/12 2013

dev-3d-secure-changes

dev-3d-secure-changes

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

09/12 2013

1.0.3

1.0.3.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

17/11 2013

1.0.2

1.0.2.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

17/11 2013

dev-error-response-changed

dev-error-response-changed

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

14/11 2013

1.0.1

1.0.1.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

12/11 2013

1.0.0

1.0.0.0

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham

16/07 2013

dev-innovate-readme

dev-innovate-readme

A PHP client to perform payments with the Innovate payment gateway.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ayham