Skip to content

monkybrain/klarna-checkout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Klarna Checkout for Node.js

Library for using Klarna Checkout with Node.js. Works for merchants in Sweden, Norway, Finland, Austria and Germany.

Uses promises for async operations.

If you find this useful or want to contribute, please send me a line.

Install

npm install klarna-checkout

Usage

Initialize

klarna = require('klarna-checkout')

klarna.init({
  eid: <STRING>
  secret: <STRING>
  live: <BOOLEAN>
})

Pass an object containing

  • eid (string)
    • Merchant ID supplied by Klarna
  • secret (string)
    • Shared secret supplied by Klarna
  • live (boolean)
    • true Live environment
    • false Test environment (default)

Configure

klarna.config({
  purchase_country: <STRING>			
  purchase_currency: <STRING>		
  locale: <STRING>											
  layout: <STRING>
  terms_uri: <STRING>
  cancellation_terms_uri: <STRING>
  checkout_uri: <STRING>
  confirmation_uri: <STRING>
  push_uri: <STRING>
})

Pass an object containing

  • purchase_country (string)
    • e.g. 'SE' for Sweden (default)
  • purchase_currency (string)
    • e.g. 'SEK' for Swedish Krona (default)
  • locale (string)
    • e.g. 'sv-se' for Swedish/Sweden (default)
  • layout (string)
    • 'desktop' (default)
    • 'mobile'
  • terms_uri (string)
  • cancellation_terms_uri (string)
  • checkout_uri (string)
  • confirmation_uri (string)
  • push_uri (string)

See API Docs: resource for more information

Place order

klarna.place(cart)

Parameters

Returns promise

Fetch order

klarna.fetch(id)

Parameters

  • id (string): Klarna order id

Returns promise

Confirm order

klarna.confirm(id, orderid1, orderid2)

Parameters

Returns promise

Update order

klarna.update(id, data)

Parameters

Returns promise

  • resolved: updated order (object)
  • rejected: error (string)

Error object

  • type (string):
    • 'HTTP' - HTTP request error (e.g. if network is down)
    • 'Klarna' - HTTP request ok but Klarna responded with an error
  • code (string)
  • message (sting)

Example

There is an example of a minimal Node.js Express server serving Klarna Checkout in example/


To be implemented

  • Recurring orders
  • Customization options (colors etc)

Any help is greatly appreciated!


API Documentation

Check out Klarna's API documentation here.

About

Klarna Checkout library for nodejs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published