PHP code example of reefki / laravel-flip

1. Go to this page and download the library: Download reefki/laravel-flip 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/ */

    

reefki / laravel-flip example snippets


use Reefki\Flip\Facades\Flip;

// Always check the deposit balance first
$balance = Flip::balance()->get();              // ['balance' => 49656053]

// Find a recipient bank
$bca = Flip::banks()->find('bca');              // operational status, fee, queue

// Verify the account holder name (cached → sync; uncached → callback)
$inquiry = Flip::disbursement()->inquiry('5465327020', 'bca');

// Create a disbursement (idempotency key is 

Flip::balance()->get();          // ['balance' => int]

Flip::banks()->list();           // all banks
Flip::banks()->list('bca');      // filter by code
Flip::banks()->find('bca');      // single entry, or null

Flip::maintenance()->check();              // ['maintenance' => bool]
Flip::maintenance()->isUnderMaintenance(); // bool

$tx = Flip::disbursement()->create(
    payload: [
        'account_number'   => '1122333300',
        'bank_code'        => 'bni',
        'amount'           => 10000,
        'remark'           => 'Refund',
        'recipient_city'   => 391,
        'beneficiary_email'=> '[email protected]',
    ],
    idempotencyKey: 'refund-order-987',
    timestamp: now()->toIso8601String(), // optional X-TIMESTAMP
);

Flip::disbursement()->list(['pagination' => 50, 'page' => 2, 'status' => 'DONE']);
Flip::disbursement()->find('1234567890123456800');
Flip::disbursement()->findByIdempotencyKey('refund-order-987');

$inquiry = Flip::disbursement()->inquiry(
    accountNumber: '5465327020',
    bankCode: 'bca',
    inquiryKey: 'order-987',  // optional, for matching async callbacks
);

Flip::specialDisbursement()->create(
    payload: [
        'account_number' => '1122333300',
        'bank_code'      => 'bni',
        'amount'         => 10000,
        'sender_name'    => 'John Doe',
        'sender_address' => 'Jl. Example 123',
        'sender_country' => 100252,
        'sender_job'     => 'entrepreneur',
        'direction'      => 'DOMESTIC_SPECIAL_TRANSFER',
    ],
    idempotencyKey: 'special-1',
);

$bill = Flip::bill()->create([
    'title'        => 'Coffee Table',
    'type'         => 'SINGLE',
    'amount'       => 30000,
    'expired_date' => '2026-12-30 15:50',
    'step'         => 'checkout',          // checkout | checkout_seamless | direct_api
    'reference_id' => 'order-1234',
]);

Flip::bill()->list();
Flip::bill()->find($billId);
Flip::bill()->update($billId, ['status' => 'INACTIVE']);

Flip::payment()->forBill($billId, ['start_date' => '2026-01-01']);
Flip::payment()->list(['reference_id' => 'order-1234']);

$report = Flip::settlementReport()->generate('2026-01-01', '2026-01-09');
$status = Flip::settlementReport()->checkStatus($report['request_id']);

$rates = Flip::internationalDisbursement()->exchangeRates('C2C', 'USA');
$form  = Flip::internationalDisbursement()->formData('C2C', 'USA');

Flip::internationalDisbursement()->createConsumer($payload, 'idem-c2c-1');
Flip::internationalDisbursement()->createBusiness($payload, 'idem-b2b-1');

Flip::internationalDisbursement()->find($transactionId);
Flip::internationalDisbursement()->list(['pagination' => 25]);

Flip::reference()->cities();              // ['102' => 'Kab. Bekasi', ...]
Flip::reference()->countries();           // ['100000' => 'Afghanistan', ...]
Flip::reference()->citiesAndCountries();  // both, merged

// Force a v2 disbursement create even if FLIP_VERSION=v3
Flip::disbursement()->withVersion('v2')->create($payload, 'idem-1');

// Or for an entire facade chain
Flip::useVersion('v2')->disbursement()->list();

use Illuminate\Http\Request;
use Reefki\Flip\Facades\Flip;
use Reefki\Flip\Exceptions\InvalidWebhookSignatureException;

Route::post('/webhooks/flip/disbursement', function (Request $request) {
    try {
        $payload = Flip::webhook()->verify($request);
    } catch (InvalidWebhookSignatureException) {
        abort(403);
    }

    // $payload is the decoded `data` array
    // ['id' => '1234567890123456789', 'status' => 'DONE', 'amount' => '10000', ...]

    Disbursement::where('flip_id', $payload['id'])->update([
        'status'      => $payload['status'],
        'reason'      => $payload['reason'] ?? null,
        'time_served' => $payload['time_served'] ?? null,
    ]);

    return response()->noContent();   // Flip retries non-200s 5x at 2-min intervals
});

if (Flip::webhook()->isValid($request->input('token'))) {
    // ...
}

use Reefki\Flip\Exceptions\ValidationException;

try {
    Flip::disbursement()->create($payload, 'idem-1');
} catch (ValidationException $e) {
    foreach ($e->errors() as $err) {
        logger()->warning('flip.validation', $err); // ['attribute' => ..., 'code' => ..., 'message' => ...]
    }
    throw $e;
}

use Illuminate\Support\Facades\Http;
use Reefki\Flip\Facades\Flip;

Http::fake([
    'bigflip.id/big_sandbox_api/v3/disbursement' => Http::response([
        'id' => 1234567890123456800,
        'status' => 'PENDING',
    ], 200),
]);

$result = Flip::disbursement()->create($payload, 'idem-1');
bash
php artisan vendor:publish --tag=flip-config