alxmsl / paymentninjaclient
Powerful client for Payment.Ninja REAST API
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/alxmsl/paymentninjaclient
Requires
- alxmsl/cli: >=2.0.1
- alxmsl/network: >=1.1.0
Requires (Dev)
- phpunit/phpunit: ~4
This package is not auto-updated.
Last update: 2025-11-09 00:53:03 UTC
README
Powerful client for Payment.Ninja REST API
Usage flow
- User inputs and submits data
- Merchant calls method card/getToken via JSONP or AJAX and receives a temporary token for 10 minutes
- Merchant submits credit card token to a server with other payment data
- Merchant calls method card/process with credit card token
- If
successistrueand ACS object is returned- Merchant POSTs ACS parameters
PaReq,MD,TermUrlto aACS url in a browser - User inputs and submits his 3DSecure password
- ACS POSTs parameters
PaRes,MDback to merchant's ACS return url - Merchant calls method card/authenticate passing
PaResandMDparameters - If
successistruethen merchant can provide a service to a user
- Merchant POSTs ACS parameters
- If success is
trueand ACS object is not returned, then merchant can show a success page to user - If
rememberwas passed, merchant will receive apermanentTokenparameter with card/process or card/authenticate method responses. You can usepermanentTokenwithout requiring a user to input the credit card data again - If
recurringwas passed, merchant will receive a recurring object, containing recurring frequency and ending date. Merchant can create new payments for a user calling the card/processRecurring method - If
verify_cardwas passed, then transaction price will be set to €1, that will be put on hold and then instantly returned verify_cardcan be effectively used withrecurring,recurring_interval,recurring_trialorrememberparameters as it checks the validity of a card via money hold/return- Merchant receives asynchronous callback with transaction details and can provide aservice to a user if status is completed
Installation
For simplified usage all what you need is require packet via composer
$ composer require alxmsl/paymentninjaclient
In third-party projects, require packet in your composer.json
"alxmsl/paymentninjaclient": "*"
...and update composer: composer update
Usages
Firstly, create client instance with public and private key, that was provided in your account
use alxmsl\PaymentNinja\Client;
$Client = new Client('<public key>', '<private key>');
Now you can create request for REST API methods
user/resolveviaClient::userResolve()user/changeRecurringviaClient::userChangeRecurring()user/cancelRecurringviaClient::userCancelRecurring()card/getTokenviaClient::cardGetToken()card/processviaClient::cardProcess()card/authenticateviaClient::cardAuthenticate()card/processRecurringviaClient::cardProcessRecurring()
For request execution you should call Request::execute() method. For example below code
use alxmsl\PaymentNinja\Client;
$Client = new Client('pU811cKE4', 'Pr1v4tEKEy');
$R = $Client->userResolve('aaa@aaa.ru', 'aaa@aaa.ru', '127.0.0.1')->execute();
var_dump($R);
...going to follow output
class alxmsl\PaymentNinja\Response\UserResponse#8 (1) {
private $id =>
string(5) "46919"
}
Console usage
Surely, you can use simple CLI utilities for calling REST API methods
user/resolvevia./bin/user/resolveuser/changeRecurringvia./bin/user/changeRecurringuser/cancelRecurringvia./bin/user/cancelRecurringcard/getTokenvia./bin/card/getTokencard/processvia./bin/card/processcard/authenticatevia./bin/card/authenticatecard/processRecurringvia./bin/card/processRecurring
So, user resolving example must be present as
$ php ./bin/user/resolve.php -b='pU811cKE4' -r='Pr1v4tEKEy' -e='aaa@aaa.ru' -u='aaa@aaa.ru' -i='127.0.0.1'
user's data
id: 46919
Each utility supports their quick help page
$ php bin/card/getToken.php --help
Using: /usr/local/bin/php bin/card/getToken.php [-h|--help] [-c|--callback] -m|--month -n|--number -b|--public -s|--security -y|--year
-h, --help - show help
-c, --callback - callback JSONP function name
-m, --month - expiration month
-n, --number - card number
-b, --public - project public key
-s, --security - card security code
-y, --year - expiration year
Tests
For completely tests running just call phpunit command
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.
Runtime: PHP 5.5.23 with Xdebug 2.3.2
Configuration: /Users/alxmsl/sources/PaymentNinjaClient.github/phpunit.xml.dist
.................
Time: 233 ms, Memory: 6.50Mb
OK (17 tests, 90 assertions)
License
Copyright 2015 Alexey Maslov alexey.y.maslov@gmail.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.