PHPackages                             ilhamuket/tripay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. ilhamuket/tripay

ActiveLibrary[Payment Processing](/categories/payments)

ilhamuket/tripay
================

Tripay Payment Gateway SDK for Laravel 10, 11, 12 and PHP 8.2+

v1.0.9(3mo ago)011MITPHPPHP ^8.2

Since Feb 2Pushed 3mo agoCompare

[ Source](https://github.com/ilhamuket/tripay)[ Packagist](https://packagist.org/packages/ilhamuket/tripay)[ Docs](https://github.com/ilhamuket/tripay)[ RSS](/packages/ilhamuket-tripay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

Tripay SDK for Laravel
======================

[](#tripay-sdk-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0df84802fc98fdbd54be7940072ba040c0d4d50335968ada5161b41e8a66595f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f496c68616d756b65742f7472697061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Ilhamuket/tripay)[![Total Downloads](https://camo.githubusercontent.com/1ec1a9a08a4d65f348d47729ca20e9583e0004786cb90f02e2bc4196ca8987a2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f496c68616d756b65742f7472697061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Ilhamuket/tripay)[![License](https://camo.githubusercontent.com/a4d75924372d0ff187a9f428f9288eb1039f9620867de215b6cf1a13898a761d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f496c68616d756b65742f7472697061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Ilhamuket/tripay)

SDK PHP untuk mengintegrasikan [Tripay Payment Gateway](https://tripay.co.id) dengan Laravel 10, 11, dan 12.

✨ Features
----------

[](#-features)

- ✅ Support Laravel 10, 11, 12
- ✅ PHP 8.2+
- ✅ Closed Payment Transaction
- ✅ Payment Channels
- ✅ Fee Calculator
- ✅ Transaction List &amp; Detail
- ✅ Check Transaction Status
- ✅ Payment Instructions
- ✅ Callback Handling &amp; Validation
- ✅ Facade Support
- ✅ Type-safe Response Objects

📦 Installation
--------------

[](#-installation)

```
composer require Ilhamuket/tripay
```

### Publish Config

[](#publish-config)

```
php artisan vendor:publish --tag=tripay-config
```

### Environment Configuration

[](#environment-configuration)

Add to your `.env` file:

```
TRIPAY_MODE=sandbox
TRIPAY_MERCHANT_CODE=your-merchant-code
TRIPAY_API_KEY=your-api-key
TRIPAY_PRIVATE_KEY=your-private-key
```

🚀 Usage
-------

[](#-usage)

### Using Facade

[](#using-facade)

```
use Ilhamuket\Tripay\Facades\Tripay;
use Ilhamuket\Tripay\Data\TransactionData;
use Ilhamuket\Tripay\Data\OrderItem;
use Ilhamuket\Tripay\PaymentMethod;

// Get Payment Channels
$channels = Tripay::getPaymentChannels();
foreach ($channels->getChannels() as $channel) {
    echo $channel->getName() . ' - ' . $channel->getCode();
}

// Get only QRIS channel
$qris = Tripay::getPaymentChannels('QRIS');

// Calculate Fee
$fee = Tripay::calculateFee(100000, 'QRIS');

// Create Transaction
$transaction = new TransactionData();
$transaction
    ->setMethod(PaymentMethod::QRIS)
    ->setMerchantRef('INV-' . time())
    ->setAmount(100000)
    ->setCustomerName('John Doe')
    ->setCustomerEmail('john@example.com')
    ->setCustomerPhone('081234567890')
    ->addOrderItem([
        'name' => 'Product Name',
        'price' => 100000,
        'quantity' => 1,
    ])
    ->setReturnUrl('https://yoursite.com/return')
    ->setExpiryHours(24);

$response = Tripay::createTransaction($transaction);

if ($response->isSuccess()) {
    echo $response->getReference();      // Tripay reference
    echo $response->getCheckoutUrl();    // Checkout URL
    echo $response->getQrUrl();          // QR Code URL (for QRIS)
    echo $response->getPayCode();        // VA Number (for VA)
}

// Get Transaction Detail
$detail = Tripay::getTransactionDetail('T0001000000000000006');
if ($detail->isPaid()) {
    echo 'Transaction is paid!';
}

// Check Transaction Status
$status = Tripay::checkTransactionStatus('T0001000000000000006');

// Get Payment Instructions
$instructions = Tripay::getPaymentInstruction('BRIVA');
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Ilhamuket\Tripay\Tripay;

class PaymentController extends Controller
{
    public function __construct(
        protected Tripay $tripay
    ) {}

    public function createPayment()
    {
        $response = $this->tripay->createTransaction(...);
    }
}
```

### Direct Instantiation (Without Laravel)

[](#direct-instantiation-without-laravel)

```
use Ilhamuket\Tripay\Tripay;

$tripay = new Tripay(
    apiKey: 'your-api-key',
    privateKey: 'your-private-key',
    merchantCode: 'your-merchant-code',
    mode: 'sandbox' // or 'production'
);

// Switch mode on the fly
$tripay->production(); // Switch to production
$tripay->sandbox();    // Switch to sandbox
```

🔔 Handling Callback
-------------------

[](#-handling-callback)

Create a controller to handle Tripay callbacks:

```
