D
Engineering

wallet_transactions

Skema koleksi wallet_transactions — type, status, bank_account embedded. Inkonsistensi literal vs konstanta.

Log transaksi wallet (deposit, withdraw, settlement). Tidak ada SoftDeletes.

Definisi model

app/Models/WalletTransaction.php

PropertiNilaiSumber
Collectionwallet_transactionsWalletTransaction.php:14
$guarded[]WalletTransaction.php:16
SoftDeletes
Primary keyUUID stringWalletTransaction.php:17-19

Konstanta

Type (WalletTransaction.php:21-23):

  • TYPE_DEPOSIT = 'deposit'
  • TYPE_WITHDRAWAL = 'withdrawal'
  • TYPE_SETTLEMENT = 'settlement'

Status (WalletTransaction.php:25-29):

  • STATUS_PENDING = 'pending'
  • STATUS_PROCESSING = 'processing'
  • STATUS_SUCCESS = 'success'
  • STATUS_FAILED = 'failed'
  • STATUS_CANCELLED = 'cancelled'

Field

FieldTipeDefaultCastSumber
idstring UUIDgeneratedWalletTransaction.php:61
wallet_idstringWalletService.php:353, WalletController.php:279
store_idstringWalletService.php:354, WalletController.php:280
user_idstringWalletService.php:355, WalletController.php:281
typestringWalletService.php:356,248, WalletController.php:282
amountintegerintegerWalletService.php:357,249, WalletController.php:283
feeinteger0integerWalletTransaction.php:52,40
feesobject/arrayWalletController.php:284
net_amountintegerauto-computeintegerWalletTransaction.php:64, WalletService.php:359
statusstring'pending'stringWalletTransaction.php:53,40
reference_idstringWalletService.php:361, WalletController.php:287
reference_typestringWalletService.php:362 ('order')
descriptionstring'Pembayaran order'WalletService.php:344,363,253
metadataarray/objectarrayWalletService.php:254-260
bank_accountobjectWalletController.php:291-297
doku_payout_invoicestringWalletController.php:289
rejection_reasonstring/nullnullWalletController.php:290
completed_atdatetimedatetimeWalletService.php:364,294, WalletTransaction.php:44
created_atdatetimeautodatetimeWalletTransaction.php:47
updated_atdatetimeautodatetimeWalletTransaction.php:48

metadata (deposit/withdrawal di WalletService)

Dari WalletService.php:254-260:

json
{
  "bank_code": "string",
  "account_number": "string",
  "account_name": "string",
  "invoice_number": "WD-<storeId>-<timestamp>",
  "initiated_by": "<userId>"
}

bank_account (embedded, dari WalletController)

Dari WalletController.php:291-297:

json
{
  "id": "uuid",
  "bank_code": "string",
  "bank_name": "string",
  "account_number": "string",
  "account_name": "string"
}

Relasi

NamaTipeFKSumber
walletbelongsToWallet.idwallet_idWalletTransaction.php:69-73
storebelongsToStore.idstore_id:74-76
userbelongsToUser.iduser_id:77-79
orderbelongsToOrder.idreference_id:81-87

Boot creating

WalletTransaction.php:59-66:

  • Set UUID id
  • Auto-compute net_amount = amount - fee jika belum di-set

Contoh dokumen

json
{
  "_id": ObjectId("..."),
  "id": "uuid-tx-1",
  "wallet_id": "<wallet.id>",
  "store_id": "<store.id>",
  "user_id": "<user.id>",
  "type": "withdraw",
  "amount": 100000,
  "fee": 0,
  "fees": { "total_fee": 5000 },
  "net_amount": 100000,
  "status": "PENDING",
  "reference_id": "WDR-20260105-...",
  "description": "Penarikan ke BCA - 1234567890",
  "doku_payout_invoice": "WD-20260105-...",
  "rejection_reason": null,
  "bank_account": {
    "id": "uuid-acc",
    "bank_code": "014",
    "bank_name": "BCA",
    "account_number": "1234567890",
    "account_name": "John Doe"
  },
  "created_at": ISODate("..."),
  "updated_at": ISODate("...")
}

Referensi

  • Alur Wallet — alur topup & withdraw
  • app/Models/WalletTransaction.php — model + konstanta
  • app/Services/WalletService.php — service (processDeposit, dead code requestWithdrawal)
  • app/Http/Controllers/WalletController.php — controller withdraw