PHP code example of aliziodev / payid-transactions

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


$ledger = app(\Aliziodev\PayIdTransactions\Contracts\TransactionLedger::class);

$ledger->upsertStatus([
    'provider' => 'midtrans',
    'merchant_order_id' => 'ORDER-1001',
    'status' => 'paid',
    'amount' => 100000,
    'currency' => 'IDR',
    'subject_type' => 'subscription',
    'subject_id' => '01JABCDEF...',
]);

$ledger->recordChargeAttempt([
    'provider' => 'midtrans',
    'merchant_order_id' => 'ECOM-20260413-0001',
    'idempotency_key' => 'checkout-user-123-cart-888-v1',
    'status' => 'pending',
    'amount' => 350000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-01JXYZ123',
    'customer_reference' => '[email protected]',
    'metadata' => [
        'channel' => 'qris',
        'cart_id' => 'CART-888',
    ],
]);

$ledger->upsertStatus([
    'provider' => 'midtrans',
    'merchant_order_id' => 'ECOM-20260413-0001',
    'provider_transaction_id' => 'trx-9f3c1',
    'status' => 'paid',
    'amount' => 350000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-01JXYZ123',
]);

$ledger->recordChargeAttempt([
    'provider' => 'stripe',
    'merchant_order_id' => 'INV-2026-05-ACME-01',
    'idempotency_key' => 'stripe-sub-renew-sub_01ABC-2026-05',
    'status' => 'pending',
    'amount' => 199900,
    'currency' => 'USD',
    'subject_type' => 'subscription',
    'subject_id' => 'SUB-01ABC',
    'customer_reference' => 'cus_Nx12ABC',
    'metadata' => [
        'invoice_id' => 'in_1Px...',
        'billing_cycle' => '2026-05',
    ],
]);

$ledger->upsertStatus([
    'provider' => 'stripe',
    'merchant_order_id' => 'INV-2026-05-ACME-01',
    'provider_transaction_id' => 'pi_3Qx...',
    'status' => 'paid',
    'amount' => 199900,
    'currency' => 'USD',
    'subject_type' => 'subscription',
    'subject_id' => 'SUB-01ABC',
]);

$ledger->recordChargeAttempt([
    'provider' => 'paddle',
    'merchant_order_id' => 'LIC-2026-0042',
    'idempotency_key' => 'paddle-checkout-ctm_778-prod_42',
    'status' => 'pending',
    'amount' => 4900,
    'currency' => 'USD',
    'subject_type' => 'license_order',
    'subject_id' => 'LIC-ORD-42',
    'customer_reference' => 'ctm_778',
    'metadata' => [
        'product_id' => 'pro_plan',
        'license_type' => 'lifetime',
    ],
]);

$ledger->upsertStatus([
    'provider' => 'paddle',
    'merchant_order_id' => 'LIC-2026-0042',
    'provider_transaction_id' => 'txn_01hxyz...',
    'status' => 'paid',
    'amount' => 4900,
    'currency' => 'USD',
    'subject_type' => 'license_order',
    'subject_id' => 'LIC-ORD-42',
]);

$ledger->recordChargeAttempt([
    'provider' => 'doku',
    'merchant_order_id' => 'DOKU-ORDER-0099',
    'idempotency_key' => 'doku-va-order-99-v1',
    'status' => 'pending',
    'amount' => 275000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-0099',
    'customer_reference' => 'customer-0099',
    'metadata' => [
        'channel' => 'va_bni',
        'store' => 'jakarta-01',
    ],
]);

$ledger->upsertStatus([
    'provider' => 'doku',
    'merchant_order_id' => 'DOKU-ORDER-0099',
    'provider_transaction_id' => 'DOKU-TXN-7788',
    'status' => 'paid',
    'amount' => 275000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-0099',
]);

$ledger->recordChargeAttempt([
    'provider' => 'xendit',
    'merchant_order_id' => 'XND-INV-2026-01',
    'idempotency_key' => 'xendit-invoice-ext_123-v1',
    'status' => 'pending',
    'amount' => 850000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-7788',
    'customer_reference' => '[email protected]',
    'metadata' => [
        'invoice_id' => 'inv-123',
        'payment_method' => 'ewallet',
    ],
]);

$ledger->upsertStatus([
    'provider' => 'xendit',
    'merchant_order_id' => 'XND-INV-2026-01',
    'provider_transaction_id' => 'pay-abc-001',
    'status' => 'paid',
    'amount' => 850000,
    'currency' => 'IDR',
    'subject_type' => 'order',
    'subject_id' => 'ORD-7788',
]);

$event = $ledger->recordWebhookEvent([
    'provider' => 'stripe',
    'event_fingerprint' => hash('sha256', 'stripe|evt_123|pi_123'),
    'external_event_id' => 'evt_123',
    'merchant_order_id' => 'INV-2026-05-ACME-01',
    'provider_transaction_id' => 'pi_3Qx...',
    'signature_valid' => true,
    'payload' => ['type' => 'invoice.paid'],
    'received_at' => now(),
]);

$ledger->markWebhookProcessed($event, true);
bash
php artisan vendor:publish --tag=payid-transactions-config
php artisan vendor:publish --tag=payid-transactions-migrations
bash
php artisan payid-transactions:prune-webhooks --days=90