klarna-checkout
Version:
Library for integrating Klarna Checkout in a nodejs environment
48 lines (34 loc) • 952 B
JavaScript
var app, bodyParser, cart, credentials, express, fs, klarna;
fs = require('fs');
express = require('express');
app = express();
bodyParser = require('body-parser');
app.use(bodyParser.json());
app.get('/', function(req, res) {
console.log(req.body);
return res.send('ok');
});
app.listen(3000, function() {
return console.log("Listening...");
});
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
}
]
};
klarna.fetch('FZHEOX7T34N4ALS9WRVIF89S0O').then(console.log)["catch"](console.error);