npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

checkout-api

v2.0.1

Published

A library for the Finnish Checkout online bank payment system integration

Readme

Checkout API

IMPORTANT NOTICE!

This library uses the legacy api. Documentation for the newer version is available here.

This is a simple library for online payments with the Finnish Checkout online bank payment system

Installing

npm install checkout-api --save

Usage

First you need to require the library and initialize an object with your credentials

var CheckoutApi = require('checkout-api');
// set the merchant authentication and return base url
var checkout = new CheckoutApi({
    merchantId:     '375917',
    merchantSecret: 'SAIPPUAKAUPPIAS',
    baseUrl:        'https://example.com'
  });

I strongly recommend using for example dotenv to load the merchant id and secret. It's a really bad idea to store them in version control.

You can then call the preparePayment(data, options) method to initiate a payment and get payment options

checkout.preparePayment({
  AMOUNT:     100,
  STAMP:      '123',
  REFERENCE:  '456'
}).then(printPaymentButtons);

When the payment has been made the user returns and you can validate the payment with the validateReturnMsg(message) method.

checkout.validateReturnMsg(req.query);

You can poll a payments status by calling pollPayment(data, options). The data parameter must include: STAMP, REFERENCE and AMOUNT and they must be the same as in the payment.

checkout.pollPayment(data, { responseType: 'xml' }).then(resp => { console.log(resp) });

preparePayment

preparePayment(data, options)

Returns: a promise

Data

You can use all options listed in the checkout.fi documentation. AMOUNT, STAMP and REFERENCE are required.

Options

Key | Allowed values | Default | Description --- | --- | --- | --- responseType | xml, html, json | json | What kind of data will the output be allowSmallPurchases | false, true | false | Allow less than 1€ payments

validateReturnMsg

validateReturnMsg(data)

Returns: true / false

data

A javascript object containing the query variables.

pollPayment

pollPayment(data, options)

Returns: a promise

Data

You can use all options listed in the checkout.fi documentation. AMOUNT, STAMP and REFERENCE are required. If you have overriden the defaults while making the preparePayment call, you must make the same overrides here for the checksums to match.

Options

Key | Allowed values | Default | Description --- | --- | --- | --- responseType | xml, html, json | json | What kind of data will the output be

CheckoutApi constructor

new CheckoutApi(options)

Key | Description --- | --- merchantId | Your merchant id merchantSecret | Your merchant secret baseUrl | The base url of your application sendRequest | You can use a different method for sending the request than the default Node.js request library. The given function must return a promise. This is usefull for example if you want to use a proxy for static outbound ip or write tests that don't actually send the request. defaults | You can define default values for the fields

var checkout = new CheckoutApi({
  merchantId:     process.env.MERCHANT_ID,
  merchantSecret: process.env.MERCHANT_SECRET,
  baseUrl:        process.env.BASE_URL,
  sendRequest:    (url, data) => new Promise(resolve => resolve('Mock response')),
  defaults:       { LANGUAGE: 'EN' }
});

Example

You can take a look at a minimal example in the example folder. It is meant only for displaying the basic functionalities of this library. A real app would not be structured like this.

You can run the example by typing (in the example folder):

npm install
node index.js

and opening http://localhost:3000 in your browser

Running tests

npm run test