zerosdev / paylabs-sdk-php
Unofficial Paylabs.co.id Integration Kit for PHP
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
Unofficial Paylabs.co.id Integration Kit for PHP
Requirements
- PHP v7.2+
- PHP JSON Extension
- PHP cURL Extension
Installation
- Run command
composer require zerosdev/paylabs-sdk-php
Usage
Notes
- The following payloads have been added automatically so you don't have to enter them manually
- requestId
- You can still enter your own requestId, otherwise we will generate random UUIDv4 for the requestId
- merchantId
- sign
- 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);
Please check the /examples
for the other examples