ibnuhalimm/laravel-tripay

Laravel Wrapper for Tripay Payment Gateway

v1.1.1 2022-06-22 03:50 UTC

This package is auto-updated.

Last update: 2024-11-22 09:07:52 UTC


README

Latest Version on Packagist Total Downloads

Laravel wrapper for Tripay payment gateway.

Contents

Installation

You can install the package via composer:

composer require ibnuhalimm/laravel-tripay

Optionally, you can publish the config file of this package with this command:

php artisan vendor:publish --tag="laravel-tripay-config"

Setting up

Put some environment variable to .env file:

TRIPAY_MERCHANT_CODE=
TRIPAY_API_KEY=
TRIPAY_PRIVATE_KEY=
TRIPAY_PRODUCTION_MODE=

** Valid value for TRIPAY_PRODUCTION_MODE is true or false

Usage

You can directly use the Tripay Facade (the alias or class itself):

Payment Channels

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

// Get all available payment channels
Tripay::paymentChannels();

// Or get single payment channels by specifying the code
Tripay::paymentChannels('BRIVA');

Get Fee of Payment Channel

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

$amount = 12000;
$paymentChannelCode = 'BRIVA';
Tripay::feeCalculator($amount, $paymentChannelCode);

Fetch the Transactions

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

Tripay::transactions();

Get Transaction Details

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

$reference = 'DEV-T11958501451EJYV'; // Get from create transaction response / Transaction list
Tripay::transactionDetails($reference);

Create a Transaction

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

// All required parameters
$params = [
    'method'            => 'MANDIRIVA',
    'merchant_ref'      => 'INV-123456',
    'amount'            => 25000,
    'customer_name'     => 'Your Customer Name',
    'customer_email'    => 'customer.email@domain.com',
    'customer_phone'    => '081234567890',
    'order_items'       => [
        [
            'name'        => 'Product Name 1',
            'price'       => 6000,
            'quantity'    => 2
        ],
        [
            'name'        => 'Product Name 2',
            'price'       => 13000,
            'quantity'    => 1
        ]
    ]
];

// You can override the callback URL
// By adding the `callback_url` parameter
$params = [
    ...
    'callback_url' => 'https://yourdomain.tld/callback',
    ...
];

// By default, expired time will be set for 24 hours
// You can change it by adding 'expired_time'
$params = [
    ...
    'expired_time' => 1582855837 // Should be in integer value as unix format
    ...
];

// Add more info of ordered items
$params = [
    ...
    'order_items'    => [
        [
            'sku'         => 'FB-01',
            'name'        => 'Product Name',
            'price'       => 20000,
            'quantity'    => 1,
            'product_url' => 'https://yourstore.com/product/product-01',
            'image_url'   => 'https://yourstore.com/product/product-01.jpg',
        ],
        [
            'sku'         => 'FB-07',
            'name'        => 'Product Name 2',
            'price'       => 5000,
            'quantity'    => 1,
            'product_url' => 'https://yourstore.com/product/product-02',
            'image_url'   => 'https://yourstore.com/product/product-02.jpg',
        ]
    ],
    ...
];


Tripay::createTransaction($params);

Override Default Config

use Ibnuhalimm\LaravelTripay\Facades\Tripay;

// Override the default config
Tripay::setConfig([
    'merchant_code' => 'NEW-CODE',
    'api_key' => 'ANOTHER-API-KEY',
    ...
])->paymentChannels();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ibnuhalim@pm.me instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.