# WalletMerchant

OTP application managing merchant onboarding, profiles, risk, compliance, QR codes, and POS transactions within the MercuryPay umbrella.

## Public Interface

```elixir
# Merchant registry
WalletMerchant.MerchantStore.store(merchant)
WalletMerchant.MerchantStore.get(merchant_id)
WalletMerchant.MerchantStore.update(merchant)
WalletMerchant.MerchantStore.list_by_status(status)
WalletMerchant.MerchantStore.list_by_type(type)
WalletMerchant.MerchantStore.list_by_country(country_code)
WalletMerchant.MerchantStore.search_by_name(query)

# Merchant profiles
WalletMerchant.MerchantProfileStore.store(profile)
WalletMerchant.MerchantProfileStore.get(merchant_id)
WalletMerchant.MerchantProfileStore.update(profile)

# Risk profiles
WalletMerchant.MerchantRiskProfileStore.store(risk_profile)
WalletMerchant.MerchantRiskProfileStore.get(merchant_id)
WalletMerchant.MerchantRiskProfileStore.update(risk_profile)

# Compliance checks
WalletMerchant.MerchantComplianceCheckStore.store(check)
WalletMerchant.MerchantComplianceCheckStore.get(check_id)
WalletMerchant.MerchantComplianceCheckStore.list_by_merchant(merchant_id)

# QR codes
WalletMerchant.MerchantQrCodeStore.store(qr_code)
WalletMerchant.MerchantQrCodeStore.get(qr_code_id)
WalletMerchant.MerchantQrCodeStore.list_by_merchant(merchant_id)

# POS transactions
WalletMerchant.PosTransactionStore.store(pos_txn)
WalletMerchant.PosTransactionStore.get(pos_txn_id)
WalletMerchant.PosTransactionStore.list_by_merchant(merchant_id)
```

## Responsibilities
- Merchant onboarding: registration, review submission, approval and rejection.
- Merchant profile enrichment (business details, settlement preferences).
- Risk profiling and compliance check tracking per merchant.
- QR code generation and lifecycle management.
- POS transaction recording.
- Merchant suspension and reinstatement.

## Forbidden Dependencies
- **wallet_ledger** — no direct ledger writes from this app.
- **wallet_auth** — no auth logic in this app.
- **wallet_accounts** — does not own account state.

## Dependencies
- `wallet_shared_kernel` — TypedId, Money, Correlation.
- `wallet_observability` — AuditEvent, Telemetry.
- `wallet_events` — DomainEvent behaviour.
- `wallet_database` — write-through persistence (MerchantPersistence, MerchantProfilePersistence, MerchantRiskProfilePersistence, MerchantComplianceCheckPersistence, MerchantQrCodePersistence, PosTransactionPersistence).

## TypedId Prefixes
- `mch_` — merchants.
- `mpr_` — merchant profiles.
- `mrsk_` — merchant risk profiles.
- `mcc_` — merchant compliance checks.
- `qrc_` — merchant QR codes.
- `pos_` — POS transactions.

## Events Emitted
- `WalletMerchant.Events.MerchantRegistered.v1`
- `WalletMerchant.Events.MerchantSubmittedForReview.v1`
- `WalletMerchant.Events.MerchantApproved.v1`
- `WalletMerchant.Events.MerchantRejected.v1`
- `WalletMerchant.Events.MerchantSuspended.v1`
- `WalletMerchant.Events.MerchantReinstated.v1`

## Stores
- `WalletMerchant.MerchantStore` — ETS-backed GenServer; MySQL write-through via `MerchantPersistence`.
- `WalletMerchant.MerchantProfileStore` — ETS-backed GenServer; MySQL write-through via `MerchantProfilePersistence`.
- `WalletMerchant.MerchantRiskProfileStore` — ETS-backed GenServer; MySQL write-through via `MerchantRiskProfilePersistence`.
- `WalletMerchant.MerchantComplianceCheckStore` — ETS-backed GenServer; MySQL write-through via `MerchantComplianceCheckPersistence`.
- `WalletMerchant.MerchantQrCodeStore` — ETS-backed GenServer; MySQL write-through via `MerchantQrCodePersistence`.
- `WalletMerchant.PosTransactionStore` — ETS-backed GenServer; MySQL write-through via `PosTransactionPersistence`.
