- PHP v7.2+
- PHP JSON Extension
- PHP cURL Extension
- Run command
composer require zerosdev/paylabs-sdk-php
- 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