Models¶
All models use UUIDv4 primary keys and include created_at/updated_at timestamps via the TimeStampedModel abstract base class.
Plan¶
Defines a subscription plan with pricing and billing schedule.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Plan display name |
|
|
URL-friendly identifier, used as lookup field |
|
|
Plan description |
|
|
Price per interval |
|
|
Currency code (default: |
|
|
Number of interval units (default: |
|
|
|
|
|
Trial duration in days (default: |
|
|
Max billing cycles, |
|
|
|
|
|
Dict of feature flags/limits |
|
|
Arbitrary metadata |
|
|
Display ordering |
Ordering: sort_order, price
Subscription¶
Represents a user’s subscription to a plan, synced with Midtrans.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Subscriber (CASCADE) |
|
|
Associated plan (PROTECT) |
|
|
See status choices below |
|
|
Payment method used |
|
|
Midtrans subscription ID for native recurring |
|
|
Saved card token or GoPay account ID |
|
|
Start of current billing period |
|
|
End of current billing period |
|
|
Trial period end date |
|
|
Number of completed billing cycles |
|
|
When next charge will be created |
|
|
Cancel when current period ends |
|
|
When cancellation was requested |
|
|
Reason for cancellation |
|
|
Customer first name for Midtrans |
|
|
Customer last name |
|
|
Customer email |
|
|
Customer phone |
|
|
Arbitrary metadata |
Subscription Status Choices¶
Status |
Description |
|---|---|
|
Created, awaiting first payment |
|
In free trial period |
|
Active and paid |
|
Payment failed, in grace period |
|
Temporarily paused by user/admin |
|
Permanently cancelled |
|
Expired (max cycles reached or grace period ended) |
Subscription Payment Types¶
credit_card, gopay, bank_transfer, echannel (Mandiri Bill), qris, shopeepay, wallet
Computed Properties¶
is_active→Trueif status isactiveortrialingis_in_grace_period→Trueifpast_dueand withinGRACE_PERIOD_DAYShas_access→Trueifis_activeoris_in_grace_period
Payment¶
Individual payment transaction tracked via Midtrans Core API.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Related subscription (nullable for standalone payments) |
|
|
Payer |
|
|
Unique Midtrans order ID (e.g., |
|
|
Midtrans transaction ID |
|
|
Payment method |
|
|
Transaction status from Midtrans |
|
|
Fraud detection result |
|
|
Total charge amount |
|
|
Currency code |
|
|
Amount refunded |
|
|
VA numbers, QR URLs, redirect URLs |
|
|
When Midtrans created the transaction |
|
|
When payment was settled |
|
|
When payment expires |
|
|
Full Midtrans API response |
|
|
Whether this is a retry charge |
|
|
Retry attempt number |
|
|
Arbitrary metadata |
Payment Status Choices¶
pending, capture, settlement, deny, cancel, expire, refund, partial_refund, authorize, failure
Computed Properties¶
is_successful→Trueifsettlementorcaptureis_paid→Trueifsettlementor (capture+fraud_status == "accept")
Invoice¶
Invoice generated for each billing cycle.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Unique number (e.g., |
|
|
Related subscription |
|
|
Related payment (nullable) |
|
|
Invoice recipient |
|
|
|
|
|
Pre-tax amount |
|
|
Tax amount |
|
|
Discount amount |
|
|
Final total |
|
|
Currency code |
|
|
Date invoice was issued |
|
|
Payment due date |
|
|
Date payment was received |
|
|
Billing period start |
|
|
Billing period end |
|
|
Invoice notes |
|
|
Reason for voiding |
InvoiceItem¶
Line item on an invoice.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Parent invoice |
|
|
Item description |
|
|
Quantity (default: |
|
|
Price per unit |
|
|
Auto-calculated: |
WebhookLog¶
Logs every incoming Midtrans webhook notification.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Order ID from notification |
|
|
Midtrans transaction ID |
|
|
Status from Midtrans |
|
|
Payment type |
|
|
Fraud detection result |
|
|
Amount (as string from Midtrans) |
|
|
SHA-512 signature from Midtrans |
|
|
Processing status: |
|
|
Full webhook payload |
|
|
Error details if processing failed |
|
|
Sender IP |
|
|
When processing completed |
NotificationLog¶
Logs outgoing notifications (email, in-app) sent to users.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Recipient user |
|
|
Related subscription (nullable) |
|
|
Related payment (nullable) |
|
|
Type (see choices below) |
|
|
|
|
|
|
|
|
Message subject |
|
|
Message body |
|
|
Recipient address |
|
|
Error details |
|
|
When notification was sent |
Notification Types¶
payment_success, payment_failed, payment_pending, subscription_created, subscription_activated, subscription_cancelled, subscription_expired, subscription_renewed, subscription_paused, subscription_resumed, invoice_issued, invoice_paid, invoice_overdue, expiry_reminder, payment_retry, refund_processed
Wallet¶
User wallet for holding balance used to pay subscriptions.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Wallet owner |
|
|
Current balance |
|
|
Currency code |
|
|
Whether wallet is active |
Computed Properties¶
has_sufficient_balance→Trueifbalance > 0can_afford(amount)→Trueifis_activeandbalance >= amount
WalletTransaction¶
Record of every wallet balance change.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Parent wallet |
|
|
|
|
|
Positive = credit, negative = debit |
|
|
Balance before transaction |
|
|
Balance after transaction |
|
|
Related object type ( |
|
|
UUID of related object |
|
|
Human-readable description |
TopUp¶
Top-up request linked to a Midtrans payment for crediting wallet.
Field |
Type |
Description |
|---|---|---|
|
|
Auto-generated UUID |
|
|
Target wallet |
|
|
Requester |
|
|
Top-up amount |
|
|
Payment method |
|
|
|
|
|
Unique Midtrans order ID (e.g., |
|
|
Midtrans transaction ID |
|
|
VA numbers, QR URLs |
|
|
Full Midtrans response |
Entity Relationship Diagram¶
See Architecture Diagrams for the full ER diagram of all models.