payprocessing/atol-online

此软件包已被弃用且不再维护。作者建议使用 payprocessing/atol-sdk-api-v4 软件包。
此软件包的最新版本(v1.0.5)没有可用的许可证信息。

Atol.online SDK

v1.0.5 2019-02-22 13:35 UTC

This package is auto-updated.

Last update: 2019-05-29 12:05:36 UTC


README

安装

该项目建议使用 composer 进行安装

composer require payprocessing/atol-online

测试

为了运行测试,需要 PHPUnit,安装它需要执行以下命令:

composer require phpunit/phpunit

为了运行集成测试,需要将 tests/integration/MerchantSettingsSample.php 文件中的 Sample 名称删除,并插入商店设置。然后从项目根目录执行命令

vendor/bin/phpunit vendor/payprocessing/atol-online/tests/integration

使用示例

1. 请求令牌

$client = new Platron\Atol\clients\PostClient();

$tokenService = new Platron\Atol\services\GetTokenRequest('login', 'password');
$tokenResponse = new Platron\Atol\services\GetTokenResponse($client->sendRequest($tokenService));

2. 创建收据

$client = new Platron\Atol\clients\PostClient();
$receiptPosition = new Platron\Atol\data_objects\ReceiptPosition('Test product', 10.00, 2, Platron\Atol\data_objects\ReceiptPosition::TAX_VAT10);

$createDocumentService = (new Platron\Atol\services\CreateDocumentRequest('token'))
    ->addCustomerEmail('test@test.ru')
    ->addCustomerPhone('79268750000')
    ->addGroupCode('groupCode')
    ->addInn('inn')
    ->addMerchantAddress('paymentAddress')
    ->addOperationType(Platron\Atol\services\CreateDocumentRequest::OPERATION_TYPE_BUY)
    ->addPaymentType(Platron\Atol\services\CreateDocumentRequest::PAYMENT_TYPE_ELECTRON)
    ->addSno(Platron\Atol\services\CreateDocumentRequest::SNO_ESN)
    ->addExternalId('externalId')
    ->addReceiptPosition($receiptPosition);
$createDocumentResponse = new Platron\Atol\services\CreateDocumentResponse($client->sendRequest($createDocumentService));

3. 请求状态

$client = new Platron\Atol\clients\PostClient();
$getStatusService = new Platron\Atol\services\GetStatusRequest('groupCode', 'uuid', 'token');
$getStatusResponse = new Platron\Atol\services\GetStatusResponse($client->sendRequest($getStatusService));