Data model & scopes
What CODGuard stores, and which Shopify permissions each capability needs.
Access scopes
read_customers · read_orders · read_themes · unauthenticated_read_product_listings · unauthenticated_write_checkouts · write_delivery_customizations · write_discounts · write_draft_orders · write_inventory · write_order_edits · write_orders · write_payment_customizations · write_products
Each maps to a capability you can point at. Draft orders and order edits exist for partial payments; discounts for prepaid incentives; payment and delivery customizations for rule enforcement at checkout.
Stored entities
All records are keyed by the shop's myshopify domain.
| Model | Purpose |
|---|---|
ShopConfig | One row per shop. OTP settings, payment modes, COD rules, RTO thresholds, plan, Function IDs. |
CodRule | Fine-grained COD rules evaluated in priority order. |
OtpVerification | Each OTP issued — hashed code, attempts, expiry, verified flag. |
VerifiedCustomer | Phone numbers that have cleared an OTP. Powers the returning-customer skip. |
WebhookReceipt | Idempotency lock, claimed before processing a webhook. |
PaymentModeSelection | The mode a shopper chose, linked to the resulting order. |
MessageTemplate | Editable message body per event and channel. |
MessageLog | Every message sent, with delivery status and the rate billed at send time. |
CodVerification | WhatsApp COD-confirmation links. |
AddressCorrectionRequest | Address-correction magic-link flow and its status. |
RtoRiskScore | Per-order score, band, signal breakdown and action taken. |
PaymentDiscount | Shopify discount and fee resources created per shop. |
AbandonedCheckout | Checkouts that started OTP but never converted. |
CustomerList | Per-shop blacklist and whitelist by phone or email. |
UsageRecord | Monthly usage counters per billing month. |
DailyAnalytics | Daily roll-up for the dashboard. |
AppEventLog | Immutable audit trail of every business event. |
ErrorLog | Structured log of every caught exception and API failure. |
ModalSettings | The storefront modal's styling and copy. |
PartialOrder | Deposit-paid orders and the real cart items to swap in. |
Phone numbers are stored in E.164, encrypted at rest, and masked throughout the admin UI.
