algocashdev / algocash
v1.1.0
2023-06-20 16:25 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
这是一个 Algocash API
- API 版本: 1.0.0
需求
PHP 5.5 及以上
安装与使用
Composer
composer require algocashdev/algocash
手动安装
下载文件并包含 autoload.php
require_once('/path/to/Algocash/vendor/autoload.php');
测试
运行单元测试
composer install
./vendor/bin/phpunit
入门
请按照安装过程进行操作,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); $algo = Algocash::getInstance() ->setApiKey('merchant_key', 'merchant_secret') ->setAccessToken('api_access_token'); // ->enableProdMode(false); // default prod mode $apiInstance = new DepositApi($algo); $payer = new Payer("email", "phone"); $url = new Url("callback_url", "pending_url", "success_url", "error_url"); $body = new DepositRequest("invioceId", "amount", $payer, $url, "payment method"); try { $result = $apiInstance->createDeposit($body); print_r($result); } catch (\Algocash\ApiException $e) { echo 'Api Exception when calling DepositApi->createDeposit: ', json_encode($e->getError()), PHP_EOL; } catch (\Exception $e) { echo 'Exception when calling DepositApi->createDeposit: ', $e->getMessage(), PHP_EOL; } ?>
回调有效载荷
<?php $payload = @file_get_contents('php://input'); $sig_header = $_SERVER['Signature']; try { /** * @var CallbackPayload body */ $body = \Algocash\Callback::constructCallback($payload, $sig_header, 'accessToken'); http_response_code(200); } catch (\Algocash\SignatureVerificationException $e) { http_response_code(401); } catch (\Throwable $th) { http_response_code(500); } ?>
API 端点文档
所有 URI 都相对于 https://app.swaggerhub.com/apis-docs/gitdevstar/Algocash/1.0.0