PHP code example of paycryptoone / paycrypto-php-client

1. Go to this page and download the library: Download paycryptoone/paycrypto-php-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paycryptoone / paycrypto-php-client example snippets




use PayCrypto\Client\PayCryptoClient;

$client = new PayCryptoClient(
    publicKey: 'your_public_key',
    privateKey: 'your_private_key',
    baseUrl: 'https://api.paycrypto.one/api/v1/',
    authMode: 'signature'
);

use PayCrypto\Client\PayCryptoClientFactory;

$client = PayCryptoClientFactory::createFromEnv('signature');
$client = PayCryptoClientFactory::createFromEnv('private-key');

use PayCrypto\Client\PayCryptoClient;
use cryptoscan\command\InvoiceCreate;

$client = new PayCryptoClient($publicKey, $privateKey);
$cmd = new InvoiceCreate(10.5, 'order-' . time());
$cmd->setCurrency('USD')->setCryptocurrency('USDT')->setNetwork('TRC-20')->setMetadata('my-order');
$result = $client->invoiceCreate($cmd);
$invoiceId = $result->getId();
$wallet = $result->getWallet();
$finalAmount = $result->getFinalAmount();

use cryptoscan\command\WidgetCreate;

$widget = new WidgetCreate(7.5, 'widget-order-' . time());
$widget->setCurrency('USD')->setLang('ru-RU')->setWidgetDescription('Оплата заказа');
$result = $client->widgetCreate($widget);
$widgetUrl = $result->getWidgetUrl();
$invoiceId = $result->getId();

$detail = $client->invoiceDetail($invoiceId);
$detail->getId();
$detail->getClientReferenceId();
$detail->getStatus();
$detail->getFinalAmount();

$list = $client->invoiceList([
    'status' => 'paid_all',
    'client_reference_id' => 'order',
    'created_at_from' => 1700000000,
    'created_at_to' => 1700003600,
    'sort_by' => 'created_at',
    'sort_order' => 'desc',
    'limit' => 20,
    'offset' => 0,
]);
$items = $list->getItems();
$total = $list->getTotal();

$list = $client->invoiceSearch('order-123');
$items = $list->getItems();

use cryptoscan\command\InvoiceConfirm;

$confirm = new InvoiceConfirm($invoiceId, 'tx-hash-or-id-' . time());
$result = $client->invoiceConfirm($confirm);
$status = $result->getStatus();

$user = $client->userDetail();
$userId = $user->getId();

$rates = $client->currencyRate();
$items = $rates->getItems();

$status = $client->currencyRateStatus('USD');
$supported = $status->isSupported();
bash
composer