Scanpay ruby client library
Branch: master
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
scanpay.gemspec

README.md

Scanpay ruby client

Ruby 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 Ruby version >= 2.0 with httpclient. The code is published at rubygems and you can install it with:

gem install scanpay

And include it in your project:

require 'scanpay'
client = Scanpay::Client.new('API key')

Manual installation

Download the latest release and include in into your project:

require_relative 'lib/scanpay'
scanpay = Scanpay::Client.new('API key')

Usage

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 = {
    'items' => [{ 'total' => '199.99 DKK' }]
];
puts "Payment url: #{scanpay.newURL(order, options)}"

seq(Integer, options)

Make a sequence request to get a hash with changes after a specified sequence number (docs | example).

localSeq = 921;
seqobj = scanpay.seq(localSeq, options)

handlePing(String, String)

Handle and validate synchronization pings. The method accepts two arguments, the body of the received ping and the X-Signature HTTP header. The method returns a hash (docs | example).

json = scanpay.handlePing(body, signature)

Options

All methods, except handlePing, accept an optional per-request options hash. 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)

License

Everything in this repository is licensed under the MIT license.