muhammadnan/tripay-payment-gateway
Composer 安装命令:
composer require muhammadnan/tripay-payment-gateway
包简介
PHP Payment Gateway Tripay Library
README 文档
README
This package is un-official, already compatible with Composer, for more details please visit Documentation.
This package is made to make it easier for php users
IMPORTANT: Make sure you read the documentation and understand what these methods are used for!
need PHP 8 and above to use this package
Instalation for PHP >8
composer require muhammadnan/tripay-payment-gateway
Instalation for PHP <8
composer require muhammadnan/tripay-payment-gateway:1.0.5.1
Configuration
before starting further, you must define or import a tripay for further configuration
use Tripay\Main;
then after that configure api-key, private-key, merchant-code
$main = new Main( 'your-api-key', 'your-private-key', 'your-merchant-code', 'sandbox' // fill for sandbox mode, leave blank if in production mode );
or you can create or add env variable in your project (such as laravel, codeigniter) like this
TRIPAY_API_KEY='your-api-key' TRIPAY_PRIVATE_KEY='your-private-key' TRIPAY_MERCHANT_CODE='your-merchant-code' TRIPAY_MODE='sandbox' // fill for sandbox mode, leave blank if in production mode
and after add env variable in your project declare main class like this
$main = new Main();
For mode by default it will be in production mode, to change it to sandbox mode, you can add a 'sandbox' after the merchant code
Contents available
content method available so far
| Method | Contents | Status |
|---|---|---|
initChannelPembayaran() |
Channel Pembayaran |
OK |
initInstruksiPembayaran(string $code) |
Instruksi Pembayaran |
OK |
initMerchantChannelPembayaran(string $code) |
Merchant Channel Pembayaran |
OK |
initKalkulatorBiaya(string $code, int $amount) |
Kalkulator Biaya |
OK |
initDaftarTransaksi(int $page, int $per_page, string $sort, string $reference, string $merchant_ref, string $method, string $status) |
Daftar Transaksi |
OK |
initTransaction(string $merchantRef) |
Transaksi Open/Close |
OK |
initCallback() |
Callback |
OK |
Request available
request can return the available content, the list of available methods is as follows
| Method | Description |
|---|---|
getRequest(string $url) |
return return guzzle http client |
getResponse() |
return response |
getJson() |
return json decode |
getStatusCode() |
return status code |
getSuccess() |
return boolean |
getData() |
return data response |
Channel Pembayaran
This API is used to get a list of all available payment channels along with complete information including transaction fees for each channel
$main->initChannelPembayaran()
the next method can be seen in the request method or can be seen in examples
Instruksi Pembayaran
This API is used to retrieve payment instructions from each channel
$code = 'BRIVA'; //more info code, https://tripay.co.id/developer $init = $main->initInstruksiPembayaran($code)
the next method can be seen in the request method or can be seen in examples
Merchant Channel Pembayaran
This API is used to obtain a list of payment channels available in your Merchant account along with complete information including transaction fees for each channel
$code = 'BRIVA'; //more info code, https://tripay.co.id/developer $init = $main->initMerchantChannelPembayaran($code);
the next method can be seen in the request method or can be seen in examples
Kalkulator Biaya
This API is used to obtain detailed transaction fee calculations for each channel based on a specified nominal
$code = 'BRIVA'; //more info code, https://tripay.co.id/developer $amount = 1000;//your amount $init = $main->initKalkulatorBiaya($code, $amount);
the next method can be seen in the request method or can be seen in examples
Daftar Transaksi
This API is used to get a list of merchant transactions
$page = 1; $per_page = 50; $sort = 'desc'; $reference = 'T0001000000455HFGRY'; $merchant_ref = 'INV57564'; $method = 'BRIVA'; $status = 'PAID'; $init = $main->initDaftarTransaksi( $page, $per_page, $sort, $reference, $merchant_ref, $method, $status );
the next method can be seen in the request method or can be seen in examples
Transaction
Before proceeding to the next step in transactions, please configure your reference merchant
$merchantRef = 'your-merchant-ref';//your merchant reference $init = $main->initTransaction($merchantRef);
Before making a signature, please set the amount for close transactions and for open transactions, please set the payment method
$init->setAmount(1000); // for close payment $init->setMethod('BRIVAOP'); // for open payment
Note: if you use an open payment do not define the amount and vice versa if you use a close payment do not define the amount
Create Signature
$signature = $init->createSignature();
Close Transaction
To define close transaction, use the closeTransaction () method
$transaction = $init->closeTransaction(); // define your transaction type, for close transaction use `closeTransaction()`
After you define a close transaction, please set the payload with the setPayload (array $ data) method
examples:
$transaction->setPayload([ 'method' => 'BRIVA', // IMPORTANT, dont fill by `getMethod()`!, for more code method you can check here https://tripay.co.id/developer 'merchant_ref' => $merchantRef, 'amount' => $init->getAmount(), 'customer_name' => 'Nama Pelanggan', 'customer_email' => 'emailpelanggan@domain.com', 'customer_phone' => '081234567890', 'order_items' => [ [ 'sku' => 'PRODUK1', 'name' => 'Nama Produk 1', 'price' => $init->getAmount(), 'quantity' => 1 ] ], 'callback_url' => 'https://domainanda.com/callback', 'return_url' => 'https://domainanda.com/redirect', 'expired_time' => (time()+(24*60*60)), // 24 jam 'signature' => $init->createSignature() ]); // set your payload, with more examples https://tripay.co.id/developer
for get the payload u can use getPayload() method,
after set transaction u can sent the request and get data directly with the getData () method or for more method u can seen in the request method or can be see in examples
Get Close Detail Transaction
To see further transaction data, you can see it in transaction details, for close transactions, see below where to get reference code? please go to the simulator menu and get it in the transaction menu, there is a reference code that can be matched here
$referenceCode = 'your-reference-code'; // fill by reference code $detail = $transaction->getDetail($referenceCode); // return get detail your transaction with your reference code
the next method can be seen in the request method or can be seen in examples
Open Transaction
To define close transaction, use the openTransaction () method
$transaction = $init->openTransaction(); // define your transaction type, for close transaction use `openTransaction()`
After you define a open transaction, please set the payload with the setPayload (array $ data) method
examples:
$transaction->setPayload([ 'method' => $init->getMethod(), 'merchant_ref' => $merchantRef, 'customer_name' => 'Nama Pelanggan', 'signature' => $init->createSignature() ]); // set your payload, with more examples https://tripay.co.id/developer
for get the payload u can use getPayload() method,
after set transaction u can sent the request and get data directly with the getData () method or for more method u can seen in the request method or can be see in examples
Get Open Detail Transaction
To see further transaction data, you can see it in transaction details, for close transactions, see below where can i get uuid? please open the transaction menu then select open payment then there is a uuid code there
$uuidCode = 'your-uuid-code'; // fill by reference code $detail = $transaction->getDetail($uuid); // return get detail your open transaction with your uuid code
the next method can be seen in the request method or can be seen in examples
Get Daftar Pembayaran Transaction
To see a list of payments made in open transactions you can use this method you can get the uuid in your account.
$referenceCode = 'your-reference-code'; // fill by reference code $detail = $transaction->getDetail($referenceCode); // return get detail your transaction with your reference code
the next method can be seen in the request method or can be seen in examples
Callback
Callback is a method of sending transaction notifications from the TriPay server to the user's server. When the payment from the customer is completed, the TriPay system will provide a notification containing transaction data which can then be further managed by the user's system.
please define the method below before starting
$init = $main->initCallback(); // return callback
Receive JSON
to get the json that was sent by tripay you can use the method below
$init->get(); // get all callback
Decode JSON
rather than wasting time on json_decode, this package provides that
$init->getJson(); // get json callback
Get The Signature
take signature from tripay using the method below
$init->signature(); // callback signature
Callback Signature
tripay also sends a callback signature to validate customer data
$init->callbackSignature(); // callback signature
Call Event
for re-validation, tripay sends an event in the form of payment_status this package also captures that
$init->callEvent(); // callback event, return `payment_status`
Validate Signature
To shorten the code, we prepared signature validation as well.
$init->validateSignature(); // return `true` is valid signature, `false` invalid signature
Validate Event
To shorten the code too, we also set up validate events to go a step further
$init->validateEvent(); // return `true` is PAID, `false` meaning UNPAID,REFUND,etc OR call event undefined
Testing
This package is tested using PHPunit, but mostly direct testing
Contribute
If you want to contribute this SDK, you can fork, edit and create pull request. And we will review your request and if we finish to review your request. We will merge your request to developemnt branch. Thanks
muhammadnan/tripay-payment-gateway 适用场景与选型建议
muhammadnan/tripay-payment-gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.25k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 muhammadnan/tripay-payment-gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 muhammadnan/tripay-payment-gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2021-01-26