klarna-on-demand
Version:
SDK for Klarna's on-demand purchase service.
84 lines (55 loc) • 3.5 kB
Markdown
# Klarna on Demand
[](https://travis-ci.org/klarna/klarna-on-demand-js)
[](https://www.npmjs.com/package/klarna-on-demand)
[](./LICENSE)
Klarna on-demand allows you to integrate Klarna's payment solution in applications that offer on demand services. It's a perfect fit for apps selling concert tickets, taxi rides, food pick-ups, etc.
This project contains Klarna's on-demand payment solution Javascript SDK, as well as a sample application utilizing the SDK. While the SDK is mostly aimed at hybrid phone apps, it can be utilized in any environment where Javascript is available.

While not necessary, the simplest way to get going with both the sample application and the SDK is to use [NPM](https://www.npmjs.com) and so all the following instructions will focus on that approach. For an alternative approach, see the [official documentation (coming soon)](http://developers.klarna.com).
## Using the SDK
Have a look at the [integration guide](doc/integration.md) for full details on how to use our SDK in your application.
## Running the sample application
### Prerequisites
The easiest way to run the application is to download the SDK's NPM module. To that end, simply install npm by following [this guide](https://docs.npmjs.com/getting-started/installing-node). Once installed, pick a directory where you would like to install the package and run:
```
npm install klarna-on-demand
```
### Running the application
In the directory where you've installed the package, simply run:
```
open node_modules/klarna-on-demand/example/index.html
```
or on Windows:
```
start node_modules/klarna-on-demand/example/index.html
```
**Note:** While this will get the application up and running, you will not be able to successfully perform purchases without a backend for the application to interact with. You should go [here](https://github.com/klarna/sample-ondemand-backend) and follow the instructions provided to get a sample backend running on your local machine.
## Contributing
You'd like to help us out? That's great! Here's what you need to do in order to contribute.
### Prerequisites
As per [running the application](#running_the_application).
### Setup
1. Fork the project and clone your repository
2. In the project folder, run `npm install`
3. Fire up your favorite editor and produce marvels!
### Building
The SDK's codebase is in coffeescript. To turn it into javascript so that you can try it out in a browser simply run the following in the project folder:
```
gulp build
```
This will place the compiled SDK in a newly created *./lib/* folder, with all intermediary javascript available under the *./build/* folder.
You can also simply run:
```
gulp
```
which will launch a browser hosting the test application and live-watch for any changes in the code.
### Tests
Pull requests must include tests for their proposed fixes/functionality. We use [Jasmine](http://jasmine.github.io/) to write our tests and you can find the tests themselves [here](./spec/).
#### Running the tests
From the project folder, simply run:
```
gulp watch-specs
```
to continuously run the tests as you code.
## License
Klarna on Demand is available under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for more info.