zerosdev / paylabs-sdk-php
PHP 不官方的 Paylabs.co.id 集成工具包
v1.1.2
2023-04-06 06:38 UTC
Requires
- php: >=7.2.5
- ext-json: *
- guzzlehttp/guzzle: ^6.5|^7.0
- ramsey/uuid: ^4.0
Requires (Dev)
- phpunit/phpunit: ^6.0|^7.0|^8.0|^9.0|^10.0
README
PHP 不官方的 Paylabs.co.id 集成工具包
需求
- PHP v7.2+
- PHP JSON 扩展
- PHP cURL 扩展
安装
- 运行命令
composer require zerosdev/paylabs-sdk-php
使用方法
注意事项
- 以下有效载荷已自动添加,您无需手动输入
- requestId
- 您仍可以输入自己的 requestId,否则我们将生成随机 UUIDv4 作为 requestId
- merchantId
- 签名
- requestId
<?php require 'path/to/your/vendor/autoload.php'; use ZerosDev\Paylabs\Client as PaylabsClient; use ZerosDev\Paylabs\Support\Constant; use ZerosDev\Paylabs\VirtualAccount; $merchantId = '12345'; $apiKey = 'd1cfd***********888ed3'; $mode = Constant::MODE_DEVELOPMENT; $guzzleOptions = []; // Your additional Guzzle options (https://docs.guzzlephp.org/en/stable/request-options.html) $client = new PaylabsClient($merchantId, $apiKey, $mode, $guzzleOptions); $va = new VirtualAccount($client); $result = $va->create([ 'paymentType' => 'SinarmasVA', 'amount' => 10000, 'merchantTradeNo' => uniqid(), 'notifyUrl' => 'https://yourwebsite.com/payment/notify', 'payer' => 'Customer Name', 'goodsInfo' => 'Product Name' ]); echo $result->getBody()->getContents(); /** * For debugging purpose */ $debugs = $client->debugs(); echo json_encode($debugs, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
请查看 /examples
目录中的其他示例