zerosdev/paylabs-sdk-php

Unofficial Paylabs.co.id Integration Kit for PHP

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

This package is auto-updated.

Last update: 2024-11-06 10:35:52 UTC


README

Unofficial Paylabs.co.id Integration Kit for PHP

release language license size downloads pulls

Requirements

  • PHP v7.2+
  • PHP JSON Extension
  • PHP cURL Extension

Installation

  1. 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
<?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