UNPKG

klarna-checkout

Version:

Library for integrating Klarna Checkout in a nodejs environment

40 lines (32 loc) 834 B
# Webhooks fs = require 'fs' express = require 'express' app = express() bodyParser = require 'body-parser' app.use bodyParser.json() app.get '/', (req, res) -> console.log req.body res.send 'ok' app.listen 3000, -> console.log "Listening..." # Klarna klarna = require '../src/klarna' credentials = JSON.parse fs.readFileSync 'res/credentials.json', 'utf-8' klarna.init credentials klarna.config terms_uri: 'https://klarna-test.ngrok.io' confirmation_uri: 'https://klarna-test.ngrok.io' checkout_uri: 'https://klarna-test.ngrok.io' push_uri: 'https://klarna-test.ngrok.io' cart = items: [{ reference: 'abc123' name: 'fiskpinne', quantity: 1 unit_price: 1000 tax_rate: 2500 }] # FZHEOX7T34N4ALS9WRVIF89S0OV klarna.fetch 'FZHEOX7T34N4ALS9WRVIF89S0O' .then console.log .catch console.error