Nobody Publish Monsters

    scanpay

    1.3.0 • Public • Published

    Scanpay node.js client

    Node.js 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

    This package works with Node.js >= 6.6. Install the package with npm:

    npm install scanpay --save

    and include it in your project.

    const scanpay = require('scanpay')('API key');

    Manual installation

    Download the latest release and include in into your project:

    const scanpay = require('lib/scanpay.js')('API key');

    Methods

    All methods, except handlePing, will return a Promise. Note that some methods accept an optional per-request options object.

    newURL(Object, options) => String

    Create a payment link by passing the order details through newURL. Strictly speaking, only the following data is required, but we strongly encourage you to use the entire spec (example).

    const order = {
        items: [{ total: '6000 DKK' }]
    };
    scanpay.newURL(order, options)
        .then(url => console.log(url))
        .catch(err => { /* handle errors */ });

    handlePing(String, String)

    Securely and efficiently validate pings. This method accepts two arguments from the received ping request, the HTTP message body and the X-Signature HTTP header. The return value is a JSON object (example).

    try {
        const json = scanpay.handlePing(body, req.headers['x-signature']);
    } catch (e) { /* handle errors */ }

    seq(Int, options) => Object

    Make a sequence request to get an object with a number of changes since the supplied sequence number (example).

    const localSeq = 921;
    scanpay.seq(localSeq, options)
        .then(obj => console.log(obj.changes))
        .catch(err => { /* handle errors */ });

    Options

    All methods, except handlePing, accept an optional per-request options object. You can use it 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)

    Compatibility table

    Nodejs compatibility table for this library.

    Feature Version
    crypto.timingSafeEqual 6.6
    Arrow functions 6.0
    Default function parameters 6.0
    Array.isArray 6.0
    Buffer.from 5.10

    License

    Everything in this repository is licensed under the MIT license.

    Install

    npm i scanpay

    DownloadsWeekly Downloads

    3

    Version

    1.3.0

    License

    MIT

    Last publish

    Collaborators

    • cblach
    • ulrikmoe
    • scanpay-owner