2017 © Pedro Peláez
 

library php_optimal_netbanx

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

image

alfallouji/php_optimal_netbanx

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  • Tuesday, July 14, 2015
  • by alfallouji
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3,895 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 3 % Grown

The README.md

Build Status, (*1)

PHP-Optimal-Netbanx

This is an OOP PHP Client for the Card payments Optimal Netbanx Restful service., (*2)

Authors & contact

Al-Fallouji Bashar - bashar@alfallouji.com, (*3)

Documentation and download

Latest version is available on github at : - http://github.com/alfallouji/PHP-Optimal-Netbanx, (*4)

License

This Code is released under the GNU LGPL, (*5)

Please do not change the header of the file(s)., (*6)

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version., (*7)

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE., (*8)

See the GNU Lesser General Public License for more details., (*9)

How to setup

You can use composer to use this library., (*10)

{
    "require": {
        "alfallouji/php_optimal_netbanx": "*"
    }
}

You can use composer to generate autoload map files., (*11)

composer dumpautoload, (*12)

How to start

This PHP client works with the Netbanx service (card payments)., (*13)

You will need an account with Optimal Payment in order to use this library., (*14)

You can create testing account here : https://developer.optimalpayments.com/en/, (*15)

Configuration

In order for you to use the NETBANX REST API, NETBANX must first set you up on their system and provide you with an API key. Your API key looks something like this:, (*16)

  • Key ID – MerchantXYZ
  • Key Password – B-tst1-0-51ed39e4-312d02345d3f123120881dff9bb4020a89e8ac44cdfdcecd702151182fdc952272661d290ab2e5849e31bb03deede7
  • Account ID - 12345678

They are available from : https://developer.optimalpayments.com/en/my-account/, (*17)

Please note that on the Optimal My Account page, the API key contains the Key ID and the Key Password. It has the following the format :, (*18)

API_KEY_ID:API_KEY_PASSWORD, (*19)

Sample

For an example, you can look at the tests/Functional folder., (*20)

``` /** * Helper function for test * * @param boolean $v Value to assert * * @return void */ function assertTest($v) { if ($v) { echo "\t[OK]" . PHP_EOL; } else { echo "\t[FAILED]" . PHP_EOL; exit(-1); } }, (*21)

$auth = new \Optimal\Netbanx\Model\Authorization(); $auth->merchantRefNum = 'refNum_' . uniqid(); $auth->amount = 10000 + rand(200, 3000); $auth->settleWithAuth = false; $card = new \Optimal\Netbanx\Model\Card(); $card->cardNum = '4530910000012345'; $card->type = 'VI'; $card->lastDigits = '2345'; $expiry = new \Optimal\Netbanx\Model\CardExpiry(); $expiry->month = 11; $expiry->year = 2019; $card->cardExpiry = $expiry; $auth->card = $card; $billingDetails = new \Optimal\Netbanx\Model\BillingDetails(); $billingDetails->street = '511 rue abelard'; $billingDetails->zip = 'H3E 1B6'; $billingDetails->city = 'Verdun'; $billingDetails->country = 'CA'; $auth->billingDetails = $billingDetails; $httpClient = new \Optimal\Netbanx\Client\Http($config['apiKey'], $config['apiPassword'], $config['accountId'], 'staging'); $service = new \Optimal\Netbanx\Service\Authorization($httpClient);, (*22)

// Test 1 - create auth echo PHP_EOL . 'Testing Authorization creation for ' . $auth->amount; $result = $service->create($auth); $id = isset($result['result']['id']) ? $result['result']['id'] : null; assertTest($id);, (*23)

// Test 2 - get auth echo PHP_EOL . 'Testing Authorization get for ' . $id; $result = $service->get($id); $getId = isset($result['result']['id']) ? $result['result']['id'] : null; assertTest($getId && $getId == $id);, (*24)

// Test 3 - partial reverse of auth $authReversal = new \Optimal\Netbanx\Model\AuthorizationReversal(); $authReversal->id = $getId; $authReversal->amount = rand(500, 1000); $authReversal->merchantRefNum = 'Reverse_for_' . $auth->merchantRefNum; echo PHP_EOL . 'Testing Authorization reverse for an amount of ' . $authReversal->amount; $result = $service->reverse($getId, $authReversal); assertTest(isset($result['result']['status']) && $result['result']['status'] == 'COMPLETED');, (*25)

// Test 4 - settle authorization echo PHP_EOL . 'Testing Authorization settlement'; $result = $service->settle($id, array('merchantRefNum' => $auth->merchantRefNum)); assertTest($result['code'] == 200 && isset($result['result']['id']));```, (*26)

The Versions

14/07 2015

dev-master

9999999-dev

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

LGPL-2.1

The Requires

  • php >=5.3.0

 

30/04 2015

0.0.8

0.0.8.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

LGPL-2.1

The Requires

  • php >=5.3.0

 

21/03 2015

0.0.7

0.0.7.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

LGPL-2.1

The Requires

  • php >=5.3.0

 

21/03 2015

0.0.6

0.0.6.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

LGPL-2.1

The Requires

  • php >=5.3.0

 

28/02 2015

0.0.5

0.0.5.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

LGPL-2.1

The Requires

  • php >=5.3.0

 

27/02 2015

0.0.4

0.0.4.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

The Requires

  • php >=5.3.0

 

27/02 2015

0.0.3

0.0.3.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

The Requires

  • php >=5.3.0

 

27/02 2015

0.0.2

0.0.2.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

The Requires

  • php >=5.3.0

 

27/02 2015

0.0.1

0.0.1.0

An OOP PHP Client for the Card payments Optimal Netbanx Restful service

  Sources   Download

The Requires

  • php >=5.3.0