Skip to content

Commit baadc99

Browse files
committed
add example
1 parent 2705ac7 commit baadc99

10 files changed

+187
-0
lines changed

examples/callback-handling.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use Exception;
6+
use ZerosDev\TriPay\Client;
7+
use ZerosDev\TriPay\Callback;
8+
9+
$config = require __DIR__ . '/config.php';
10+
11+
$client = new Client($config);
12+
$callback = new Callback($client);
13+
14+
/**
15+
* Enable debugging
16+
*
17+
* !! WARNING !!
18+
* Only enable it while debugging.
19+
* Leaving it enabled can lead to security compromise
20+
*/
21+
$callback->enableDebug();
22+
23+
/**
24+
* Run validation
25+
* It will throws Exception when validation fail
26+
*/
27+
try {
28+
$callback->validate();
29+
} catch (Exception $e) {
30+
echo $e->getMessage();
31+
die;
32+
}
33+
34+
/**
35+
* Get callback data as object
36+
*/
37+
$data = $callback->data();
38+
39+
print_r($data);

examples/merchant-fee-calculator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Merchant;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$merchant = new Merchant($client);
12+
13+
$result = $merchant->feeCalculator(100000, 'BRIVA');
14+
echo $result->getBody()->getContents();

examples/merchant-payment-channel.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Merchant;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$merchant = new Merchant($client);
12+
13+
$result = $merchant->paymentChannels();
14+
echo $result->getBody()->getContents();

examples/merchant-transactions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Merchant;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$merchant = new Merchant($client);
12+
13+
$result = $merchant->transactions([]);
14+
echo $result->getBody()->getContents();

examples/open-payment-create.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\OpenPayment;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$openPayment = new OpenPayment($client);
12+
13+
$result = $openPayment->create([
14+
'method' => 'BSIVAOP',
15+
'merchant_ref' => 'USER-123',
16+
'customer_name' => 'Nama Pelanggan',
17+
]);
18+
echo $result->getBody()->getContents();

examples/open-payment-detail.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\OpenPayment;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$openPayment = new OpenPayment($client);
12+
13+
$result = $openPayment->detail('T1234OP234GDGT4');
14+
echo $result->getBody()->getContents();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\OpenPayment;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$openPayment = new OpenPayment($client);
12+
13+
$result = $openPayment->transactions('T1234OP234GDGT4');
14+
echo $result->getBody()->getContents();

examples/payment-instruction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Payment;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$payment = new Payment($client);
12+
13+
$result = $payment->instruction('BRIVA');
14+
echo $result->getBody()->getContents();

examples/transaction-create.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Support\Helper;
7+
use ZerosDev\TriPay\Transaction;
8+
9+
$config = require __DIR__ . '/config.php';
10+
11+
$client = new Client($config);
12+
$transaction = new Transaction($client);
13+
14+
/**
15+
* `amount` will be calculated automatically from order items
16+
* In this example, amount will be 43.000
17+
*/
18+
$result = $transaction
19+
->addOrderItem('Gula', 10000, 1)
20+
->addOrderItem('Kopi', 5000, 3)
21+
->addOrderItem('Teh', 3000, 1)
22+
->addOrderItem('Nasi', 15000, 1)
23+
->create([
24+
'method' => 'BRIVA',
25+
'merchant_ref' => 'INV123',
26+
'customer_name' => 'Nama Pelanggan',
27+
'customer_email' => 'email@konsumen.id',
28+
'customer_phone' => '081234567890',
29+
'return_url' => 'https://example.com/return',
30+
'expired_time' => Helper::makeTimestamp('1 DAY')
31+
]);
32+
echo $result->getBody()->getContents();

examples/transaction-detail.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
use ZerosDev\TriPay\Client;
6+
use ZerosDev\TriPay\Transaction;
7+
8+
$config = require __DIR__ . '/config.php';
9+
10+
$client = new Client($config);
11+
$transaction = new Transaction($client);
12+
13+
$result = $transaction->detail('T11111111111');
14+
echo $result->getBody()->getContents();

0 commit comments

Comments
 (0)