ktpay / ktwidget-api-php
ktwidget的PHP客户端
dev-master
2019-07-01 10:27 UTC
Requires
- ext-json: *
- ext-sodium: ^7.2
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/php-code-coverage: ^7.0
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: *
- symfony/var-dumper: ^4.2
This package is auto-updated.
Last update: 2024-09-29 05:02:41 UTC
README
安装
首先下载并安装 composer. 在我们的项目根目录下
composer require ktpay/ktwidget-api-php:dev-master
在生产环境上
composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader
如果你的项目之前没有使用过 composer
- 在我们的“main”文件中加载
require_once __DIR__ . './vendor/autoload.php';
启动器 - 然后使用它
基本用法
$appID = "xxx"; $appKey = "xxx"; $apiRequest = new \KTWidget\Merchant\Request($appID, $appKey); $response = $apiRequest->nameOfApiMethod(['data' => []]); if (!$response->success()) { var_dump($response->message()); die(); } var_dump($response->data())
创建支付
$response = $apiRequest->paymentCreate([ "order" => [ "amount" => 1000, "order_id" => "Order1", "description" => "Тестовая оплата за Order1", "callback_back_url" => "https://our.store.kz", "type" => "ecom", ], "user" => [ "merchant_user_id" => "user1", "phone" => "+77001234567", "email" => "test@example.com", ] ]);
测试
运行这个
[user@localhost xxx]$ KTPAYAPI_APP_KEY=xxx;KTPAYAPI_KEY=yyy phpunit
或者将环境添加到配置文件 phpunit.xml
<phpunit> ... <php> <env name="KTPAYAPI_APP_KEY" value="xxx"/> <env name="KTPAYAPI_KEY" value="yyy"/> </php> ... </phpunit>