Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Scanpay PHP client

The official PHP client library for the Scanpay API (docs). You can always e-mail us at, or chat with us on IRC at #scanpay


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)

capture(Integer, Object, options)

Capture an amount from a transaction.

$trnid = 2;
$data = [
    'total' => '1 DKK',
    'index' => 0,
$scanpay->capture($trnid, $data, $options);

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 HTTP headers, e.g. the highly recommended X-Cardholder-IP (example)
  • Override API key (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.