Strike Lighting Payment tutorial

in #bitcoin7 years ago

Introduction 

This guide aims to show you how to use the Strike product to allow your website to accept payments using the Lightning Network.

The server has been built in Node.js with swagger and express.  It is a very simple code base and should be understandable by a novice user

Prerequisites

1) Download the demo application from GitHub

2) Familiarise yourself with swagger 

3) set up an account on Strike 

4) Download and install Ngrok 

Configuration

Ngrok

This allows us to have secure URL to your localhost server once you have downloaded and installed this go to the directory you installed it in terminal and type  

./ngrok http 10010 

This gives us a root URL we can use to access the Node Js server and will look something like this 


Take the https url https://637df86a.ngrok.io and put it into your web browser and you will see a connection show in the terminal.

Strike

Go the the following page API KEY and copy you API key

Go to the following page  

Add the Webhook URL use the one ngrok provided you and add /callback to it

Example

https://637df86a.ngrok.io/callback

Demo Application 

Charge.js

Open the demo application in your IDE of choice (I use sublime) and browse to the file charge.js

controllers/charge.js 

You will see the on line 37

  curl.setOpt( 'USERNAME', 'sk_DbtMYVfvzdu1WACermKq2JVMq87CMK38znj9qNXCRj9k' );

Replace this key with your own or I will get all your monies.

Script.js

Now Browse to  www/js/script.js 

On  line 5 you will see  

 var url = "http://127.0.0.1:10010/charge?amount=100&currency=btc&description=thing2"

Change the currency and descriptions to anything you want.

Running Demo Application

Go to the directory where you downloaded the demo application and type

swagger project start

Note this is hardcoded in for demo purposes, ideally, there would be some sort of checkout and from this, we would get the amount but this is good enough for demo purposes.  The description will have to be url encoded if you use spaces.

run www/checkout.html in your web browser and this will call the demo server and create a charge on strike.  I use apache and create a virtual host to achieve but this but you can use MAMP or anything that gives you a local web server.

That's it you now have integrated with Strike and can happily accept Lighting payment.

What you will have to do

  1. Tie it into the shopping cart of your choice
  2. When you initiate a charge (in charge.js) store the return from strike in your database
  3. Once a client has made a payment calllback.js is invoked you will have to ties this into your stock control / email system.