PHPackages                             alxmsl/paymentninjaclient - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. alxmsl/paymentninjaclient

ActiveLibrary[HTTP &amp; Networking](/categories/http)

alxmsl/paymentninjaclient
=========================

Powerful client for Payment.Ninja REAST API

v1.0.6(10y ago)1501Apache-2.0PHP

Since Sep 10Pushed 10y ago1 watchersCompare

[ Source](https://github.com/alxmsl/PaymentNinjaClient)[ Packagist](https://packagist.org/packages/alxmsl/paymentninjaclient)[ RSS](/packages/alxmsl-paymentninjaclient/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

PaymentNinjaClient
==================

[](#paymentninjaclient)

[![License](https://camo.githubusercontent.com/6c48c5fb244db031ed694fdea476499318423088d76f9eb7f57de951c78d5ae7/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f7061796d656e746e696e6a61636c69656e742f6c6963656e7365)](https://packagist.org/packages/alxmsl/paymentninjaclient)[![Latest Stable Version](https://camo.githubusercontent.com/8731e9831f04b5c7f3be4005f5d12c9e930ad1c16f76195e808a84073bfcb8bb/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f7061796d656e746e696e6a61636c69656e742f76657273696f6e)](https://packagist.org/packages/alxmsl/paymentninjaclient)[![Total Downloads](https://camo.githubusercontent.com/e1fc9b700f94089669d094fac2a27571014431c23affbfc0506a469d5365b43e/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f7061796d656e746e696e6a61636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/alxmsl/paymentninjaclient)

[![Build Status](https://camo.githubusercontent.com/bc231066caa6b5c0eac7707731aef3cc1064303b7aeafaa186e2c784674511ec/68747470733a2f2f7472617669732d63692e6f72672f616c786d736c2f5061796d656e744e696e6a61436c69656e742e737667)](https://travis-ci.org/alxmsl/PaymentNinjaClient)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4808d532a77285af85602b132afa0cb30d2c5b8539e30dc1c078f72df8568af1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c786d736c2f5061796d656e744e696e6a61436c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alxmsl/PaymentNinjaClient/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/39d43a8566ff0adaad0c1edcc8b68343bb9f48efa8790df1e1f419110e93e6be/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c786d736c2f5061796d656e744e696e6a61436c69656e742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alxmsl/PaymentNinjaClient/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/db8ac111f92069e95d3d2d3868676f7e6befa80b380f2b64e5c086ead3be0f60/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535663265663862643464323034303031653030303132612f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/55f2ef8bd4d204001e00012a)

Powerful client for [Payment.Ninja REST API](https://payment.ninja/#about)

Usage flow
----------

[](#usage-flow)

1. User inputs and submits data
2. Merchant calls method [card/getToken](/bin/card/getToken.php) via JSONP or AJAX and receives a temporary token for 10 minutes
3. Merchant submits credit card token to a server with other payment data
4. Merchant calls method [card/process](/bin/card/process.php) with credit card token
5. If `success` is `true` and ACS object is returned
    1. Merchant POSTs ACS parameters `PaReq`, `MD`, `TermUrl` to aACS url in a browser
    2. User inputs and submits his 3DSecure password
    3. ACS POSTs parameters `PaRes`, `MD` back to merchant's ACS return url
    4. Merchant calls method [card/authenticate](/bin/card/authenticate.php) passing `PaRes` and `MD` parameters
    5. If `success` is `true` then merchant can provide a service to a user
6. If success is `true` and ACS object is not returned, then merchant can show a success page to user
7. If `remember` was passed, merchant will receive a `permanentToken` parameter with [card/process](/bin/card/process.php) or [card/authenticate](/bin/card/authenticate.php) method responses. You can use `permanentToken` without requiring a user to input the credit card data again
8. If `recurring` was 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](/bin/card/processRecurring.php)method
9. If `verify_card` was passed, then transaction price will be set to €1, that will be put on hold and then instantly returned
10. `verify_card` can be effectively used with `recurring`, `recurring_interval`, `recurring_trial` or `remember`parameters as it checks the validity of a card via money hold/return
11. Merchant receives asynchronous callback with transaction details and can provide a￼service to a user if status is completed

Installation
------------

[](#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
------

[](#usages)

Firstly, create client instance with public and private key, that was provided in your account

```
    use alxmsl\PaymentNinja\Client;
    $Client = new Client('', '');

```

Now you can create request for REST API methods

- `user/resolve` via `Client::userResolve()`
- `user/changeRecurring` via `Client::userChangeRecurring()`
- `user/cancelRecurring` via `Client::userCancelRecurring()`
- `card/getToken` via `Client::cardGetToken()`
- `card/process` via `Client::cardProcess()`
- `card/authenticate` via `Client::cardAuthenticate()`
- `card/processRecurring` via `Client::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
-------------

[](#console-usage)

Surely, you can use simple CLI utilities for calling REST API methods

- `user/resolve` via `./bin/user/resolve`
- `user/changeRecurring` via `./bin/user/changeRecurring`
- `user/cancelRecurring` via `./bin/user/cancelRecurring`
- `card/getToken` via `./bin/card/getToken`
- `card/process` via `./bin/card/process`
- `card/authenticate` via `./bin/card/authenticate`
- `card/processRecurring` via `./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
-----

[](#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
-------

[](#license)

Copyright 2015 Alexey Maslov

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.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~42 days

Total

6

Last Release

3732d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/950057?v=4)[Alexey Maslov](/maintainers/alxmsl)[@alxmsl](https://github.com/alxmsl)

---

Top Contributors

[![alxmsl](https://avatars.githubusercontent.com/u/950057?v=4)](https://github.com/alxmsl "alxmsl (38 commits)")[![chapsuk](https://avatars.githubusercontent.com/u/5525114?v=4)](https://github.com/chapsuk "chapsuk (2 commits)")

---

Tags

apirestpaymentninjapayment.ninja

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alxmsl-paymentninjaclient/health.svg)

```
[![Health](https://phpackages.com/badges/alxmsl-paymentninjaclient/health.svg)](https://phpackages.com/packages/alxmsl-paymentninjaclient)
```

###  Alternatives

[andrewnovikof/omnipay-sberbank

Omnipay driver for Sberbank

3214.9k1](/packages/andrewnovikof-omnipay-sberbank)[mediamonks/rest-api-bundle

MediaMonks Rest API Symfony Bundle

1656.2k1](/packages/mediamonks-rest-api-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
