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:
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:
If you use versions from >=PHP8, you must add the disable version checking flag, otherwise the installation will fail:
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
Go to Products -> Payment contract -> Add contract
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:
You will be charged 50 USDR after you create and save a payment contract.
<?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);