PHP code example of muhammadnan / tripay-payment-gateway
1. Go to this page and download the library: Download muhammadnan/tripay-payment-gateway library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muhammadnan / tripay-payment-gateway example snippets
use Tripay\Main;
$main = new Main(
'your-api-key',
'your-private-key',
'your-merchant-code',
'sandbox' // fill for sandbox mode, leave blank if in production mode
);
$main = new Main();
$main->initChannelPembayaran()
$code = 'BRIVA'; //more info code, https://tripay.co.id/developer
$init = $main->initInstruksiPembayaran($code)
$code = 'BRIVA'; //more info code, https://tripay.co.id/developer
$init = $main->initMerchantChannelPembayaran($code);
$init->setAmount(1000); // for close payment
$init->setMethod('BRIVAOP'); // for open payment
$signature = $init->createSignature();
$transaction = $init->closeTransaction(); // define your transaction type, for close transaction use `closeTransaction()`
$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' => '[email protected]',
'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
$referenceCode = 'your-reference-code'; // fill by reference code
$detail = $transaction->getDetail($referenceCode); // return get detail your transaction with your reference code
$transaction = $init->openTransaction(); // define your transaction type, for close transaction use `openTransaction()`
$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
$uuidCode = 'your-uuid-code'; // fill by reference code
$detail = $transaction->getDetail($uuid); // return get detail your open transaction with your uuid code
$referenceCode = 'your-reference-code'; // fill by reference code
$detail = $transaction->getDetail($referenceCode); // return get detail your transaction with your reference code