cryptoscan-one/cryptoscan-client-php

1.1.0 2023-07-10 13:27 UTC

This package is not auto-updated.

Last update: 2024-09-30 23:52:25 UTC


README

CryptoScan — 接收您个人账户上的USDT TRC20

  • 隐私
  • 功能API
  • 金钱受您控制

安装

建议使用composer安装

composer require cryptoscan-one/cryptoscan-client-php "~1.1.0"

使用

认证

https://cryptoscan.one/developer/index#auth

$publicKey = '...';
$privateKey = '...'

// Аутентификация по приватному ключу
$auth = AuthFactory::privateKey($publicKey, $privateKey);

// Аутентификация по подписи
$auth = AuthFactory::signature($publicKey, $privateKey);

创建发票

https://cryptoscan.one/developer/index#invoice-creating

$auth = AuthFactory::signature($publicKey, $privateKey);
$client = new CryptoScanClient($auth);

// Стандартный вызов
$command = new InvoiceCreate(10, '123');
$result = $client->invoiceCreate($command);

// Добавление дополнительных данных
$command = new InvoiceCreate(10, '123');
$command
    ->setMetadata('Example text')
    ->setCurrency("EUR");
$result = $client->invoiceCreate($command);

创建发票小部件

https://cryptoscan.one/developer/index#invoice-widget-creating

...
// Стандартный вызов
$command = new WidgetCreate(10, '123');
$result = $client->widgetCreate($command);

// Добавление дополнительных данных
$command
    ->setBackUrl('https://')
    ->setCancelUrl('https://')
    ->setWidgetDescription('Description')
    ->setLang('ru-RU');
    ->setCurrency("EUR");
$result = $client->widgetCreate($command);

查看发票

https://cryptoscan.one/developer/index#invoice-view

...
$invoiceId = 123456;
$result = $client->invoiceDetail($invoiceId);

搜索发票

https://cryptoscan.one/developer/index#invoice-find

...
$query = 123456;
$result = $client->invoiceSearch($query);

查看用户信息

https://cryptoscan.one/developer/index#user-info-view

...
$result = $client->userDetail();

支持的货币列表

https://cryptoscan.one/developer/index#supported-currency-rates

...
$result = $client->currencyRate();

检查货币可用性

https://cryptoscan.one/developer/index#check-currency

...
$result = $client->currencyRateStatus('EUR');

响应数据

错误处理

异常

HTTP客户端

使用自己的HTTP客户端

默认情况下,请求通过Guzzle发送。要连接自己的HTTP客户端

// Создание своего HTTP клиента
class MyHTTPClient impliments HttpClientInterface
{
    ...
}
$httpClient = new MyHTTPClient();
// Создание провайдера данных
$provider = ProviderFactory::http($httpClient);
$client = new CryptoScanClient($auth, $provider);

WebHook

处理来自服务器的支付响应

// Заголовок переданного запроса
$headers = [
    'public-key' => '...',
    'signature' => '...',
//    'private-key' => '...',
];

// Тело запроса
$data = [
    'event_type' => 'paid',
    'retry_count' => 3,
    ...
];

// Формирование WebHook запроса
$webHookData = new WebHookRequest($headers, $data);

$auth = AuthFactory::privateKey($publicKey, $privateKey);
$webHookHandler = new WebHookHandler($auth);
$message = $webHookHandler->handle($webHookData);

使用自己的数据获取方式

class MyWebHookData impliments WebHookDataInterface
{
    ...
}
$webHookData = new MyWebHookData($headers, $data);
....

可用的消息类型