PHP code example of fadhila36 / laravel-multipayment

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

    

fadhila36 / laravel-multipayment example snippets


use Fadhila36\Multipayment\Facades\Multipayment;

public function bayar()
{
    // Driver bisa diganti: 'midtrans', 'xendit', 'duitku', 'doku', 'ayoconnect'
    $payment = Multipayment::driver('midtrans')->createPayment([
        'order_id' => 'INV-' . time(),
        'amount' => 100000,
        'customer' => [
            'name' => 'Budi Santoso',
            'email' => '[email protected]',
            'phone' => '08123456789', // Wajib untuk notifikasi WA
        ],
    ]);

    // Redirect user ke halaman pembayaran
    return redirect($payment['payment_url']);
}

use Fadhila36\Multipayment\Events\PaymentPaid;

public function handle(PaymentPaid $event)
{
    // $event->status berisi data standar: orderId, amount, paymentType
    $idOrder = $event->status->orderId;
    
    // Cari di database dan update
    $pesanan = Pesanan::find($idOrder);
    $pesanan->update(['status' => 'lunas']);
}

protected $listen = [
    \Fadhila36\Multipayment\Events\PaymentPaid::class => [
        \App\Listeners\UpdateStatusPesanan::class,
    ],
];
bash
    php artisan vendor:publish --tag=multipayment-config