zerosdev/paylabs-sdk-php

PHP 不官方的 Paylabs.co.id 集成工具包

v1.1.2 2023-04-06 06:38 UTC

This package is auto-updated.

Last update: 2024-09-06 10:17:10 UTC


README

PHP 不官方的 Paylabs.co.id 集成工具包

release language license size downloads pulls

需求

  • PHP v7.2+
  • PHP JSON 扩展
  • PHP cURL 扩展

安装

  1. 运行命令
composer require zerosdev/paylabs-sdk-php

使用方法

注意事项

  • 以下有效载荷已自动添加,您无需手动输入
    • requestId
      • 您仍可以输入自己的 requestId,否则我们将生成随机 UUIDv4 作为 requestId
    • merchantId
    • 签名
<?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 目录中的其他示例