Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rofiq02 committed Aug 14, 2021
0 parents commit b9884e2
Show file tree
Hide file tree
Showing 26 changed files with 1,086 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Zeros Developer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tripay Library

For usage examples. See `/examples` directory.
10 changes: 10 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

array_map(function ($class) {
return require_once $class;
}, array_merge(
glob(__DIR__.'/src/Constants/*.php'),
glob(__DIR__.'/src/Exceptions/*.php'),
glob(__DIR__.'/src/Drivers/*.php'),
glob(__DIR__.'/src/*.php')
));
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "trijayadigital/tripay-php",
"description": "TriPay Payment Library for PHP",
"type": "library",
"homepage": "https://tripay.co.id",
"license": "MIT",
"support": {
"issues": "https://github.com/trijayadigital/tripay-php/issues",
"source": "https://github.com/trijayadigital/tripay-php"
},
"authors": [
{
"name": "PT Trijaya Digital Grup",
"email": "[email protected]"
},
{
"name": "Suyadi",
"email": "[email protected]"
},
{
"name": "Zeros Technology",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"ext-json": "*",
"ext-curl": "*"
},
"autoload": {
"psr-4" : {
"Tripay\\": "src"
}
},
"require-dev": {
"phpunit/phpunit": "^7"
}
}
22 changes: 22 additions & 0 deletions examples/closed-payment/detail-transaksi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Transaction;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';
$reference = 'T00042MIWYR'; // Didapat setelah menjalankan request transaksi


$transaction = (new Transaction($environment))
->apiKey($apiKey)

->forClosedPayment();


$detail = $transaction->detail($reference);

print_r($detail);
49 changes: 49 additions & 0 deletions examples/closed-payment/request-transaksi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Transaction;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';
$privateKey = 'uyPNa-5VDDJ-jPoNo-YxnJE-2caD9';

$merchantCode = 'T0004';
$merchantRef = 'TRX-123456'; // Isi sembarang
$channelCode = 'BRIVA';

$minutes = 1440; // Waktu kedaluwarsa invoice (dalam menit, default 1440 = 24 jam);

$customerName = 'Asep Balon';
$customerEmail = '[email protected]';
$customerPhone = '0812345667890';




$transaction = (new Transaction($environment))
->apiKey($apiKey)
->privateKey($privateKey)
->merchantCode($merchantCode)
->merchantRef($merchantRef)
->channelCode($channelCode)

->expiresAfter($minutes)

->customerName($customerName)
->customerEmail($customerEmail)
->customerPhone($customerPhone)

// ->addItem('Nama Produk', 'Harga Satuan', 'Jumlah', 'Kode SKU')
->addItem('Nama Produk 1', 100000, 2, 'SKU-PRODUK-1')
->addItem('Nama Produk 2', 100000, 6, 'SKU-PRODUK-2')
->addItem('Nama Produk 3', 100000, 3, 'SKU-PRODUK-3')
->addItem('Nama Produk 4', 100000, 1, 'SKU-PRODUK-4')

->forClosedPayment();


$response = $transaction->process();

print_r($response);
19 changes: 19 additions & 0 deletions examples/merchant/channel-pembayaran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Merchant;

$environment = Environment::PRODUCTION;
$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';

$merchant = (new Merchant($environment))
->apiKey($apiKey);

// Jika panggil, hanya akan ditampilkan data sesuai channel code saja
// ->channelCode('BRIVA');

$channels = $merchant->channels();

print_r($channels);
20 changes: 20 additions & 0 deletions examples/merchant/daftar-transaksi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Merchant;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';

$page = 1;
$per_page = 25;

$merchant = (new Merchant($environment))
->apiKey($apiKey);

$transactions = $merchant->transactions($page, $per_page);

print_r($transactions);
22 changes: 22 additions & 0 deletions examples/merchant/kalkulator-biaya.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Merchant;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';

$channelCode = 'BRIVA';
$amount = 100000;

$merchant = (new Merchant($environment))
->apiKey($apiKey)
->channelCode($channelCode);


$calculate = $merchant->calculate($amount);

print_r($calculate);
22 changes: 22 additions & 0 deletions examples/open-payment/daftar-pembayaran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Transaction;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';
$uuid = 'T0001-OP1-7lXjI'; // Didapat setelah menjalankan request transaksi


$transaction = (new Transaction($environment))
->apiKey($apiKey)

->forOpenPayment();


$payments = $transaction->payments($uuid);

print_r($payments);
22 changes: 22 additions & 0 deletions examples/open-payment/detail-transaksi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Transaction;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';
$uuid = 'T0004-OP2-OK0JP5'; // Didapat setelah menjalankan request transaksi


$transaction = (new Transaction($environment))
->apiKey($apiKey)

->forOpenPayment();


$detail = $transaction->detail($uuid);

print_r($detail);
31 changes: 31 additions & 0 deletions examples/open-payment/request-transaksi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require '../../autoload.php';

use Tripay\Constants\Environment;
use Tripay\Transaction;

$environment = Environment::PRODUCTION;

$apiKey = 'CzAxUSKPk7e5vWxhxz7GpXjHVwlFT2VtslWlxuke';
$privateKey = 'uyPNa-5VDDJ-jPoNo-YxnJE-2caD9';

$merchantCode = 'T0004';
$merchantRef = 'TRX-123456'; // Isi sembarang
$channelCode = 'BRIVAOP';

$customerName = 'Asep Balon';

$transaction = (new Transaction($environment))
->apiKey($apiKey)
->privateKey($privateKey)
->merchantCode($merchantCode)
->channelCode($channelCode)
->merchantRef($merchantRef)
->customerName($customerName)

->forOpenPayment();

$response = $transaction->process();

print_r($response);
Loading

0 comments on commit b9884e2

Please sign in to comment.