Skip to content

zerosdev/linkqu-php

Repository files navigation

linkqu-php

Unofficial Integration Kit for LinkQu.id

Requirements

Installation

  1. Run command
composer require zerosdev/linkqu-php
  1. Run command
composer dump-autoload

The following steps only needed if you are using Laravel

  1. Then
php artisan vendor:publish --provider="ZerosDev\LinkQu\Laravel\ServiceProvider"
  1. Edit config/linkqu.php and put your API credentials

Basic Usage

Laravel Usage

<?php

namespace App\Http\Controllers;

use LinkQu;

class YourController extends Controller
{
    public function index()
    {
        $result = LinkQu::transaction()->createVa(function($va) {
            $va->setAmount(10000)
                ->setExpired(60)
                ->setCustomerId(uniqid())
                ->setPartnerRef(time())
                ->setCustomerName('Nama Pelanggan')
                ->setCustomerPhone('08123456789')
                ->setCustomerEmail('[email protected]')
                ->setBankCode('014');
        });

        if( LinkQu::hasError() ) {
            print_r(LinkQu::errors());
        } else {
            print_r($result);
        }
    }
}

Non-Laravel Usage

<?php

require 'path/to/your/vendor/autoload.php';

use ZerosDev\LinkQu\Client;
use ZerosDev\LinkQu\Constant;

$linkqu = new Client(function($client) {
    $client->setMode(Constant::DEVELOPMENT)
        ->setClientId('testing')
        ->setClientSecret('123')
        ->setServerKey('LinkQu@2020')
        ->setUsername('LI307GXIN')
        ->setPin('2K2NPCBBNNTovgB');
});

$result = $linkqu->transaction()->createVa(function($va) {
    $va->setAmount(10000)
    ->setExpired(60)
    ->setCustomerId(uniqid())
    ->setPartnerRef(time())
    ->setCustomerName('Nama Pelanggan')
    ->setCustomerPhone('08123456789')
    ->setCustomerEmail('[email protected]')
    ->setBankCode('014');
});

if( $linkqu->hasError() ) {
    print_r($linkqu->errors());
} else {
    print_r($result);
}