Scanpay PHP client library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
tests
.gitignore
LICENSE
README.md
composer.json

README.md

Scanpay PHP Client

PHP client library for the Scanpay API. You can always e-mail us at help@scanpay.dk or chat with us on irc.scanpay.dk:6697 or #scanpay at Freenode (webchat)

Installation

You need PHP version >= 5.6 with php-curl enabled. The package is published at Packagist. You can install the client via Composer:

composer require scanpay/scanpay

And initiate it in your project with:

$scanpay = new Scanpay\Scanpay(' API-key ');

Manual installation

If you do not wish to use Composer, you can download the latest release and include in into your project:

require('lib/Scanpay.php');
$scanpay = new Scanpay\Scanpay(' API-key ');

Methods

Please note that all methods accept an optional per-request options object. You can read more about this here.

newURL(Object, Object)

Create a payment link by passing the order details (spec) through newURL:

$order = [
    'items' => [
        [
            'name'     => 'Pink Floyd: The Dark Side Of The Moon',
            'total'    => '199.99 DKK'
        ]
    ]
];
print_r ($URL = $scanpay->newURL($order, $options)); // returns String

seq(Int, Object)

Get an array with a number of changes since the supplied sequence number:

$localSeq = 921;
$obj = $scanpay->seq($localSeq, $options);
print_r (obj.changes);
print_r ('New local seq after applying all changes: ' . obj.seq);

handlePing(Object)

Securely and efficiently validate pings. This method accepts an optional object with the following arguments:

  • signature, ie. a string with the X-Signature header (String)
  • body, ie. the HTTP message body (String).
  • debug default is false. (Boolean)
print_r ($json = $scanpay->handlePing());
print_r ($json.seq);

Options

All methods, except handlePing, accept an optional per-request options object. You can use this to:

  • Set the API key for this request (example)
  • Set HTTP headers, e.g. the highly recommended X-Cardholder-IP (example)
  • Change the hostname to use our test environment api.test.scanpay.dk (example)
  • Enable debugging mode (example)
  • Override cURL options with CURLOPT_* parameters (example).

Compatibility table

Feature Version
hash_equals 5.6
curl_strerror 5.5
Array, short syntax 5.4
Namespaces 5.3.0
json_decode 5.2.0
curl_setopt_array 5.1.3
hash_hmac 5.1.2
Exception class 5.1.0
Default function parameters 5.0.0

License

Everything in this repository is licensed under the MIT license.