PHP code example of nekoding / tripay
1. Go to this page and download the library: Download nekoding/tripay 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/ */
nekoding / tripay example snippets
use Nekoding\Tripay\Networks\HttpClient;
use Nekoding\Tripay\Tripay;
use Nekoding\Tripay\Signature;
$data = [
'method' => 'BRIVA',
'merchant_ref' => 'KODE INVOICE',
'amount' => 50000,
'customer_name' => 'Nama Pelanggan',
'customer_email' => '[email protected] ',
'customer_phone' => '081234567890',
'order_items' => [
[
'sku' => 'FB-06',
'name' => 'Nama Produk 1',
'price' => 50000,
'quantity' => 1,
'product_url' => 'https://tokokamu.com/product/nama-produk-1',
'image_url' => 'https://tokokamu.com/product/nama-produk-1.jpg',
]
],
'return_url' => 'https://domainanda.com/redirect',
'expired_time' => (time() + (24 * 60 * 60)), // 24 jam
'signature' => Signature::generate('KODE INVOICE' . 50000)
];
// dengan facade
$res = Tripay::createTransaction($data)
$res = Tripay::createTransaction($data, Tripay::CLOSE_TRANSACTION);
// tanpa facade
$tripay = new Tripay(new HttpClient('api_key_anda'));
$res = $tripay->createTransaction($data);
$res = $tripay->createTransaction($data, Tripay::CLOSE_TRANSACTION);