PHP client for the Scanpay API

v1.4.0 2019-01-25 11:54 UTC


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


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

composer require scanpay/scanpay

You can then include 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:

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


The API documentation is available here. Most methods accept an optional per-request object with options, here referred to as $options.

newURL(Object, options)

Create a link to our hosted payment window (docs | example).

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

seq(Integer, options)

Make a sequence request to pull changes from the server (docs | example).

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


Handle and validate synchronization pings (docs | example).

print_r ($json = $scanpay->handlePing());
print_r ($json.seq);

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)

charge(Integer, Object, options)

Charge a subscriber (docs | example).

$subscriberid = 2;
$charge = [
    'orderid'    => 'charge-1023',
    'items'    => [
            'name'     => 'Pink Floyd: The Dark Side Of The Moon',
            'total'    => '199.99 DKK',
$scanpay->charge($subscriberid, $charge, $options);

renew(Integer, Object, options)

Create a link to renew the payment method for a subscriber. (docs | example).

print_r ($URL = $scanpay->renew($subscriberid, [], $options)); // returns String


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 (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


Everything in this repository is licensed under the MIT license.