Include CloudCoin in an POS system

From CloudCoin Wiki
Revision as of 09:29, 20 December 2021 by Seanw (talk | contribs) (Step 3. Install Skywallet_Connect on your Web Server)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Step 1. Add Some DNS Records To Your DNS Zone

You will create DNS records so that people can figure out your Skywallet address and find your webhook. This allows them to send you payments and allows them to tell you in real-time that their payment was sent.

Example:

cloudcoin.mydomain.com. IN	A	1.63.140.196
cloudcoin.mydomain.com. IN     TXT  "https://host.mydomain.com/verify_payment.php"

1. Create an 'A' record on your DNS server.

  • The type will be 'A',
  • The Name will be 'cloudcoin'
  • The IPv4 Address will be the number on the back of your Skywallet debit card. This is the account that you want to receive CloudCoin into.
  • The TTL with be 'Auto'.*
  • Make sure you do not proxy this 'A' record but use DNS only (only applicable if your DNS supports proxy. Most do not).

2. Create a TXT record called on 'cloudcoin' your DNS server.

NOTE: Webhooks are how the client's application can communicate with your servers. This allows your customers to send real-time data from the Skyvault ATM application to your web server so that your servers know that you have been paid.


3. Test that the it is working by going to a command prompt (Windows) and typing:

nslookup cloudcoin.youdomain.com
where you replace "yourdomain.com" with the name of your domain. You should receive the IP address that is on the back of your Skyvault Debit card. Then do

nslookup set q=TXT cloudcoin.yourdomain.com

. You should see the url of your webhook page at the bottom of the results.


2. Providing a QR code for Cell Phones

Your software will need to generate a QR code so the customer can send your Skywallet account CloudCoins. The QR code will be a URL that any phone can use without installing any special software.

Sample URL that becomes a QR Code

The QR code and be done in two ways:

  1. Based on the current QR code
  2. Storing a record based on the transaction code on the server (recommended)

The QR code contains:

GET Code Current Data Elements in QR Example
to B4U Skyvault ID cloudcoin.b4uatm.com
cc Amount in CloudCoin 300
usd Amount in USD 300
b4u Transaction ID 7051ADBB378245A2A093C78A903046E3
m Merchant ID 129987
to Account to send CC cloudcoin.b4u.com
n Merchant Name Starbucks
t Terminal ID 34586

Sample URL based on current code:

Sample URL Resulting QR
https://skywallet.cc/b4u?cc=300&usd=3434&b4u=7051ADBB378245A2A093C78A903046E3&t=34333&m=88834&n=starbucks&to=cloudcoin.b4u.com Leaving Some Elements on Server

Sample URL based on recommended code:

Step 3. Install Skywallet_Connect on your Web Server

Skywallet_Connect is a CLI written in GO that will run on any operating system and can be called by any programming language. NOTE: For security reasons, you should store transactions somewhere (in a file or in a database) to validte against duplicated GUIDs.

1. Configure your web server as needed. CloudCoin has 30 World-Class System Administrators to help. You can see the most common setup by reading #Example Web Server Configuring For LAMP.

2. Download the Skywallet_connect binary from https://CloudCoinConsortium.com/zip/skywallet_connect.zip and put it in /usr/local/bin>

3. Change the permissions and make it executable:

chmod +x /usr/local/bin/skywallet_connect

4. create skywallet_connect HOME dir

sudo mkdir /var/www/skywallet_connect_home
sudo chown www-data:www-data /var/www/skywallet_connect_home

5. Create a file structure automatically by calling Skywallet_connect to check its balance. Become an Apache user. Expect an error when you enter the following commands to check the balance: Command:

su -fm www-data
$ /usr/bin/skywallet_connect balance

Response:

{"status":"fail", "code":11 "message":"Failed to find ID coin", "time":"158ns"}

6. After you execute the commands above, you should now have folders. Make sure /var/www/skywallet_connect_home is populated

ls -l /var/www/skywallet_connect_home/
total 24
drwx------ 2 www-data www-data 4096 Apr 11 12:58 Bank
drwx------ 2 www-data www-data 4096 Apr 11 12:58 Counterfeit
drwx------ 2 www-data www-data 4096 Apr 11 12:58 Fracked
drwx------ 2 www-data www-data 4096 Apr 11 13:00 ID
drwx------ 2 www-data www-data 4096 Apr 11 12:58 Sent
-rw-r--r-- 1 www-data www-data  626 Apr 11 13:00 main.log

7. Copy your Skywallet PNG debit card file in the ID folder and run the command again. Make sure the balance is working Command:

$ /usr/bin/skywallet_connect balance

Response:

{"total":0}

Your total may vary.

Web Hook Page

You will need to have a web page that receives notice that your customer has send you CloudCoins and is waiting at the ATM.

Sample URL that your Web Hook receives

https://b4uATM.com/CloudCoin?cc=3000&usd=300&m=11552&t=4447&b4u=7051ADBB378245A2A093C78A903046E3&n=starbucks&to=cloudcoin.b4u.com

Verifying Payment

You will need to verify that your Skywallet Account has received CloudCoins. You can do this by using the Skywallet Connect CLI. Skywallet Connect is a console application written in GoLang and runs on any platform. It can be called by any programming language.

Request:

$ ./skywallet_connect verify_payment 080A4CE89126F4F1B93E4745F89F6713 b4u.skywallet.cc

Response:

{"amount_verified":100,"status":"success","message":"CloudCoins verified"}


1. Sample Web Hook Page in PHP file (name it cloudcoin.php):

<?php

$skywallet_connect = "/usr/local/bin/skyvault_connect";
if (!file_exists($skywallet_connect))
        die("skyvault_connect not found");

if (!is_executable($skyvault_connect))
        die("skyvault_connect doesn't have exec permissions");

function verify_payment($guid, $amount, $skyvault,$meta) {
        global $skywallet_connect;

	$cmd =  "$skyvault_connect verify_payment $guid";
	echo $cmd;

        // Exec the binary
        $json = exec($cmd, $outarray, $error_code);
        if ($error_code != 0) {
            die("Invalid response from skyvault_connect: $error_code, Output $json");
        }

        $arr = json_decode($json, true);
        if (!$arr) {
		die("Failed to decode json: $json");
        }

        if (!isset($arr['amount_verified']) || !isset($arr['status'])) {
		die("Corrupted response: $json");
        }

        if ($arr['status'] != "success") {
		die("Invalid status in response: $json");
        }

        $amountVerified = $arr['amount_verified'];
        if ($amountVerified != $amount) {
               die("Invalid amount: $amountVerified, expected: $amount");
	}

	touch("./file.txt");	
}

isset($_GET['merchant_skyvault'])? $mywallet = $_GET['merchant_vault']: $mywallet = '';
isset($_GET['amount'])? $amount = $_GET['amount']: $amount = 0;
isset($_GET['guid'])? $guid = $_GET['guid']: $guid = '';
isset($_GET['meta'])? $meta = $_GET['meta']: $meta = '';

verify_payment($guid, $amount, $mywallet,$meta);
?>