Service provides an API to make payouts and accept payment in SKINs and ETHER
Switch branches/tags
Nothing to show
Clone or download
akravin
akravin Release v1.2
Latest commit cfd24be Nov 24, 2017

README.md

SkinCoin payment service

The main goal of SkinCoin payment service is to simplify an integration third party applications with Ethereum network. The service provides an API to make payouts and accept payments in SKINs and ETHER. All API requests are idempotent, i.e. the result of a successful performed request is independent of the number of times it is executed

Requirements

All you need to install SkinCoin service is docker and docker-compose tools (see 'Install docker and docker-compose' topic).

If you decided to build application from source code you also need to install:

Install docker and docker-compose

To install the latest version of the docker do the following:

# curl -fsSL https://get.docker.com/ | sh
# curl -fsSL https://get.docker.com/gpg | apt-key add -

To install docker-compose do the following:

# curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

Installation types

There are two types of the installation:

  1. From pre-build binaries. This is the most fast way to run up application. Pre-build binaries was packed as docker images. You may find them here
  2. From source code. This requires to install JDK8 and 'maven' to compile source code.

Configuration

The SkinCoin payment service ships with default configuration. You may find it in file config.sh in the root dir. To make you application more secure in production you should change the default configuration values. Let's describe the configurable parameters:

  1. MySql
    • MYSQL_ROOT_PASSWORD - MySql 'root' password. Default value is 'root'
    • MYSQL_USER - SkinCoin payment service database user name. Default value is 'dbuser'
    • MYSQL_PASSWORD - SkinCoin payment service database user password. Default value is 'dbpass'
    • MYSQL_DATABASE - SkinCoin payment service database name. Default value is 'payment_service'
    • MYSQL_DATA_DIR - MySql database files location. Default value '/mnt/skincoin/mysql'
  2. Geth
    • GETH_DATA_DIR - Geth data files location. Default '/mnt/skincoin/geth'
    • ETHEREUM_NETWORK - Ethereum network. Possible values are: "live"(MAIN_NET), "private"(PRIVATE_NET) and "test"(TEST_NET). Default value is 'live'
  3. Skincoin Payment Service
    • SERVICE_PORT - Service port. Default value is '8189'
    • SERVICE_LOG_DIR - Service log dir. Default value '/mnt/skincoin/logs'
    • SKINCOIN_ADDRESS - SkinCoin token deployed address. Default value is '0x2bdc0d42996017fce214b21607a515da41a9e0c5' (for production only).
  4. Admin UI
    • ADMIN_NAME - Admin name. Default value is 'admin'
    • ADMIN_PASSWORD - Admin password. Default value is 'admin'
    • JWT_SECRET_KEY - Any random string. Uses to signing JWT token. Defauls value is 'secretKey'

Install from Pre-build binaries (for production environment)

NOTE Skip this topic in case of installation for the testing environment. Make sure that you've done configuration in config.sh file.

To install from pre-build binaries do the following:

  1. Generate configuration files and build docker images:
$ ./1_generate_config.sh
$ ./2_build_images.sh
  1. Start SkinCoin payment service:
$ docker-compose up -d

Install from Pre-build binaries (for testing environment)

NOTE Skip this topic in case of installation for the production environment.

Installation for testing environment includes an additional step to deploy SkinCoin smart contract to Ethereum private network. So the steps will be as described below:

  1. Set 'ETHEREUM_NETWORK=private' in config.sh

  2. Generate configuration files and build docker images:

$ ./1_generate_config.sh
$ ./2_build_images.sh
  1. Start Geth service only:
$ docker-compose up -d geth
  1. Connect to the Geth docker container and deploy SkinCoin smart contract:
$ docker exec -it skincoinpaymentservice_geth_1 sh
# ./deploy.sh

where 'skincoinpaymentservice_geth_1' is a name automatically generated by docker-compose utility.

  1. Wait for deploy contract completion and exit from the Get docker container:
# exit

NOTE Be shure that you leave the Geth container

  1. In the Geth data directory (see 'GETH_DATA_DIR' in config.sh) on your local host will be created 2 files:

    • Payout.address - File contains a payout address. Use this address when you'll be register a new application (see "Register a new application"). Payout password is '123'
    • Skincoin.address - File contains a SkinCoin contract deployed address.
  2. Change the value of 'SKINCOIN_ADDRESS' variable in config.sh) on address from the 'Skincoin.address' file.

  3. Generate configuration files and build docker images (one more time to apply our changes):

$ ./1_generate_config.sh
$ ./2_build_images.sh
  1. Start SkinCoin payment service:
$ docker-compose up -d

Installation validation

Make sure there are no errors in log file. See SERVICE_LOG_DIR for log location

Register a new application

One instance of the service can serve several third party applications. For this purpose "applications" are implemented. Your should register your application in order to use the API. Every new application has the following properties:

  • App ID - An unique application ID
  • Name - Application name
  • API Key - Secure key to access to the API
  • Payout address - Payout address in Ethereum networt. All payouts will be made from this address. Make sure there is enought money on it
  • Payout password - Password from the payout address.
  • Auth secret - A secret token to secure the callback notifications
  • Callback URL - Callback REST interface to accept notification from the service
  • Enable callback - Enable or disable notifications via REST interface.

To register a new application do the following:

  1. Go to Admin UI http://localhost:<SERVICE_PORT>
  2. Enter credentials as was specified in configuration (see <ADMIN_NAME> and <ADMIN_PASSWORD> ). Press "Login"
  3. Press "New" button, fill the form.
  4. Press "Save" button. The new application will be appeared in table.

Now you can try to use API as described here: API