Enabling the Payment Gateway

The following attributes are required for arranging the payment acceptance through Relictum Pay:

  1. White node.

  2. Encryption keys.

  3. Payment contract registered in the White node.

  4. Relictum PHP SDK.

1. White Node

A White node is a node with a public IP address, which can be used to arrange any private home server for publishing on the Internet.

Installation guide on Medium.

2. Encryption Keys

Access keys must be generated for authorization on the node when performing invoicing requests and asset transfers.

Type the following commands in the console one by one:

openssl genrsa - out private .key 2048
openssl rsa - in private . key -pubout -out key .pub

Step-by-step instructions can be found below:

Step 1. First command.

Step 2. Result.

Step 3. Second command.

Step 4. Result.

The keys will be generated as a result. They will look as follows in the folder:

You need to rename the key.pub file to match your contract URI in order to issue invoices via RelictumPay. The file name must exclude "system://" and include the "-" character as a delimiter. Move it to the root directory of the node.

Example: your contract is system://payments/mycontract . In this case, the file (key) must be named payments-mycontract.pub .

Arranging payments from the node:

  • The key.pub file must be renamed into transfer.pub in order to send GTNs;

  • The key.pub file must be renamed into transfer2.pub in order to send any other tokens.

An example of a folder with a node with files is below:

When authorizing a request, the .key file corresponding to its .pub key pair must be sent along with the data.

This is another way to create an invoice for a customer via a php smart contract using our SDK:

$r = $request->doPaymentCreate( 'contract' , [ 'data' => [
        'payment' => $id,
        'addressfrom' => $relictum,
        'addressto' => $myaddress,
        'token' => 'usdr' ,
        'amount' => $sum
    ]]);

Result:

3. Relictum PHP SDK

If you use PHP in your project, the SDK will help you set up this process.

Installation. Enter the command in the console:

composer require relictumblockchain/rphpsdk

If you use versions from >=PHP8, you must add the disable version checking flag, otherwise the installation will fail:

--ignore-platform-req=php

You can also make requests in other languages or in other ways. The above sequence works for PHP.

Example of a node with an enabled payment contract and a detailed example of PHP scripts.

4. Registration of a Payment Contract in the White Node

  1. Go to Products -> Payment contract -> Add contract

  2. Fill in the following fields:

  • System name of the contract: any name in Latin in lower case, preferably in one word;

  • Supplier: select any name, preferably a short one, as it will be visible in the RelictumPay section as the object issuing the invoice. If the supplier name is long, it will cause line folding, so it is advisable to use a short one).

Result:

  1. You will be charged 50 USDR after you create and save a payment contract.

Example of sending a request via the console:

<?php

require ( _DIR__ . '/vendor/autoload.php' );

$privateKeyPath = _DIR__ . '/transfer.key';
$authorizationHelper = new
\Relictum\RPHPSDK\Helpers\AuthorizationHelper($privateKeyPath);

// Create configurator and set node uri
$configurator = new Relictum\RPHPSDK\RequestConfigurator([
    'config' => [ 'base_uri' => 'http://127.0.0.1/api/' ],
    'authorization' => $authorizationHelper
]);

// Create a new request
$request = new Relictum\RPHPSDK\Request($configurator);

try {
    // Create a new payment invoice
    
    $id = 10 ; // Payment id (any number, unique for this
    contract)
    $contract = 'mycontract' ; // Contract alias
    $relictum = 100 ; // The account of the user to whom the
    invoice is being issued
    $myaddress = 1 ; // The account to which the tokens will be
    transferred after payment
    
    $response = $request->doPaymentCreate($contract, [ 'data' => [
        'payment' => $id,
        'accountfrom' => $relictum, // or addressfrom for use
        relictum address instead of id
        'accountto' => $myaddress, // or addressto for use
        relictum address instead of id
        'token' => 'usdr' ,
        'amount' => 200
    ]]);
}
catch (Relictum\RPHPSDK\Exceptions\NodeRequestException $e) {
    // Catch exception and output error data
    var_dump($e);
}

// Output node response
var_dump($response);

Last updated