PHP code example of aliziodev / payid

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

    

aliziodev / payid example snippets


use Aliziodev\PayId\DTO\ChargeRequest;
use Aliziodev\PayId\Enums\PaymentChannel;
use Illuminate\Support\Facades\PayId;

$response = PayId::charge(ChargeRequest::make([
    'merchant_order_id' => 'ORDER-001',
    'amount'            => 150000,
    'currency'          => 'IDR',
    'channel'           => PaymentChannel::Qris,
    'customer'          => [
        'name'  => 'Alizio',
        'email' => '[email protected]',
    ],
]));

return redirect($response->paymentUrl);

$status = PayId::status('ORDER-001');

if ($status->status->isSuccessful()) {
    // Tandai order sebagai dibayar
}

$response = PayId::driver('xendit')->charge($request);

use Aliziodev\PayId\Events\WebhookReceived;
use Aliziodev\PayId\Enums\PaymentStatus;

Event::listen(WebhookReceived::class, function (WebhookReceived $event) {
    $webhook = $event->webhook;

    if ($webhook->status === PaymentStatus::Paid) {
        Order::markAsPaid($webhook->merchantOrderId);
    }
});

$fake = PayId::fake();

$fake->fakeCharge(ChargeResponse::make([
    'provider_name'           => 'midtrans',
    'provider_transaction_id' => 'TRX-001',
    'merchant_order_id'       => 'ORDER-001',
    'status'                  => PaymentStatus::Pending,
    'payment_url'             => 'https://example.com/pay',
    'raw_response'            => [],
]));

// Jalankan kode yang memanggil PayId::charge(...)

$fake->assertCharged();
bash
php artisan vendor:publish --tag=payid-config
bash
php artisan payid:install