Skip to content

Nexteam-Indonesia/trivel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trivel

Unofficial Tripay wrapper for laravel

Maintained by CV Nexteam Teknologi Indonesia

Usage

  • Install it by using command : composer require nexteam/trivel

  • Add configuration in your .env file like this :

TRIVEL_BASE_URL="https://tripay.co.id/api-sandbox"
TRIVEL_API_KEY=...
TRIVEL_MERCHANT_CODE=...
TRIVEL_PRIVATE_KEY=...
  • Add TrivelServiceProvider to config/app.php :
'providers' => ServiceProvider::defaultProviders()->merge([
        // another service provider
        \Nexteam\Trivel\TrivelServiceProvider::class
    ])->toArray(),
  • Don't forget to publish the trivel-config by run command : php artisan vendor:publish trivel-config

Example

<?php

use Nexteam\Trivel\Dto\Transaction\ClosedTransactionRequest;
use Nexteam\Trivel\Exception\TrivelException;
use Nexteam\Trivel\Transaction\TrivelClosedTransaction;

// create close (one-time) transaction
// for the detail see official tripay documentation here : https://tripay.co.id/developer?tab=transaction-create

$payload = [
    'method' => 'BRIVA',
    'merchant_ref' => "INV0001",
    'amount' => 500000,
    'customer_name' => 'Nama Pelanggan',
    'customer_email' => 'emailpelanggan@domain.com',
    'customer_phone' => '081234567890',
    'order_items' => [
        [
            'sku' => 'FB-06',
            'name' => 'Nama Produk 1',
            'price' => 500000,
            '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)),
];

try {
    $data = TrivelClosedTransaction::make(new ClosedTransactionRequest($payload["merchant_ref"], $payload["amount"], $payload));
    $payCode = $data['pay_code'];
    $checkOutUrl = $data['checkout_url'];
    dd($data);
} catch (TrivelException $e) {
    // handling your exception here
}

About

Un-official Tripay wrapper for Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages