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 🙏

© 2024 – Pkg Stats / Ryan Hefner

klarna-node

v0.1.2

Published

NodeJS wrapper for Klarna payment system

Downloads

43

Readme

Klarna Node.Js

klarna-node

Node JS wrapper for Klarna payments system (Checkout, Order Management)

Modules:

Module | API version ------------- | ------------- Checkout | V3 Order Management | V1

Installation

npm install klarna-node --save

Usage

const klarna = require('klarna-node').default;

klarna.init({
    uid: process.env.KLARNA_UID,
    password: process.env.KLARNA_PASSWORD,
    live: false,
});

Where KLARNA_UID and KLARNA_PASSWORD are credentials from Klarna Portal => Settings => API Credentials

Environments

Pass live: true to init() method to use live Klarna environment. Default live value is false

Mored details about Klarna environments here

klarna-checkout

Usage

const { klarnaCheckout } = require('klarna-node');

Configuration

klarnaCheckout.config({
    purchase_country: 'no',
    purchase_currency: 'nok',
    locale: 'en-GB',
    terms: 'http://mywebsite.com/terms',
    checkout: 'http://mywebsite.com/checkout.php?sid={checkout.order.id}',
    confirmation: 'http://mywebsite.com/success/?sid={checkout.order.id}',
    push: 'https://api.mywebsite.com/checkout/webhook?checkout_uri={checkout.order.id}',
});

Methods

createOrder(order)

Order object example:

{
  "order_amount": 503341,
  "order_tax_amount": 100668,
  "order_lines": [
    {
      "type": "physical",
      "reference": "19-402-SWE",
      "name": "Camera Travel Set",
      "quantity": 1,
      "quantity_unit": "pcs",
      "unit_price": 603341,
      "tax_rate": 2500,
      "total_amount": 503341,
      "total_discount_amount": 100000,
      "total_tax_amount": 100668,
      "image_url": "http://mywebsite.com/img/logo.png"
    }
  ],
  "shipping_options": [
    {
      "id": "free_shipping",
      "name": "Free Shipping",
      "description": "Delivers in 5-7 days",
      "price": 0,
      "tax_amount": 0,
      "tax_rate": 0,
      "preselected": true,
      "shipping_method": "Home"
    },
    {
      "id": "pick_up_store",
      "name": "Pick up at closest store",
      "price": 399,
      "tax_amount": 0,
      "tax_rate": 0,
      "preselected": false,
      "shipping_method": "PickUpStore"
    }
  ]
}

Refer Klarna Checkout documentation to check the order object details

getOrder(orderId)

The Order object

updateOrder()

In Progress

klarna-orderManagement

Usage

const { klarnaOrderManagement } = require('klarna-node');

Methods

acknowledgeOrder(orderId)

Description 1

captureOrder(orderId)

Description 2

Tests

TODO npm test

Contributing

Take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code. Create a PR to develop brunch of current repo.

TODO

  • Checkout
    • Update Order
  • Order Management
    • TODO 1
    • TODO 2
  • Tests
  • CI (Travis)