CPG-MP FSD Setting Service
FSD — Merchant Portal
A. Document controlA. Kiểm soát tài liệu
| Doc ID | CPG-FSD-CPG-MP_FSD_Setting_Service |
|---|---|
| VersionPhiên bản | 2.0 |
| StatusTrạng thái | Draft |
| Owner | CPG BA / Architecture |
| AudienceĐối tượng | Frontend, Backend, QA, Product |
| ClassificationPhân loại | Internal |
| Effective dateNgày hiệu lực | 01/12/2026 |
| Related docs | Merchant Portal Index · BR/NFR Catalog |
B. Version historyB. Lịch sử phiên bản
| Version | Date | Author | ChangesThay đổi |
|---|---|---|---|
| 1.0 | 17/01/2026 | Khoa Trinh | Version 1.0 |
| 2.0 | 18/06/2026 | Khoa Trinh | Release v2.0 (New fund flow, General Setting (split tabs), update QR Code, Checkout Link) |
C. Table of contentsC. Mục lục
- 1. Module Scope
- 2. User Roles
- 3. Functional Requirements
- 3.1 Common Service Management Layout
- F1. Service Management Page
- 3.2 Registered Services
- F2. Registered Services List
- 3.3 General Settings
- F3. Merchant Branding Settings
- F4. Webhook Configuration
- F5. Callback Configuration
- 3.4 QR Codes
- F6. QR Code List
- F7. Create New QR Code Page
- 3.5 Checkout Link
- F8. Checkout Link List
- F9. Create New Checkout Link Page
- F10. Customer-Facing Checkout Link Page
- 3.6 Supporting Modal: Create Invoice
- F11. Create Invoice Modal
- 3.7 Supporting Modal: Search Invoice ID
- F12. Search Invoice ID Modal
- 3.8 Supporting Modal: Create Virtual Account
- F13. Create Virtual Account Modal
- 3.9 Supporting Modal: Search Virtual Account
- F14. Search Virtual Account Modal
- 3.10 API Payment
- F15. API Key Management
- F16. 2FA Verification for Sensitive API Actions
- F17. IP Whitelist Management
- 4. Data Requirements
- 5. Enums
- 6. API Routes
- 7. Audit Log Requirements
- 8. Error Handling
- Use CasesUse Cases
D. ContentD. Nội dung
1. Module Scope
The Service Setting module allows merchants to configure and operate crypto payment services provided by the Crypto Payment Gateway.
The updated UI uses the page title Service Management and contains five main tabs:
| Tab | Purpose |
|---|---|
| Registered Services | View and enable/disable subscribed payment services |
| General Settings | Configure branding, webhook, callback, and general payment settings |
| QR Codes | Create and manage QR payment codes |
| Checkout Link | Create and manage checkout/payment links |
| API Payment | Configure API keys, webhook security, and IP whitelist |
In scope:
- View registered services
- Enable/disable available services
- Configure merchant branding
- Configure webhook and callback settings
- Manage QR Code payments
- Create new QR Code with Virtual Account and Invoice selection
- Preview generated QR payment page
- Manage Checkout Links
- Create new Checkout Link
- Create supporting Invoice from QR/Checkout flow
- Create supporting Virtual Account from QR/Checkout flow
- Search and select Invoice ID
- Search and select Virtual Account
- Manage API Payment settings
- Manage API keys with 2FA protection
- Manage IP whitelist
- Track QR scans and Checkout Link clicks
- Delete/disable QR Codes and Checkout Links
- Copy Checkout Link ID / public link
- Audit all sensitive actions
Out of scope:
- Customer-facing payment execution logic
- Blockchain settlement processing
- Transaction reconciliation logic
- Refund processing
- Fiat payment services for Phase 1
- On/off ramp configuration for Phase 1
2. User Roles
| Role | Permissions |
|---|---|
| Merchant Admin | Full access to all Service Setting functions |
| Merchant Operator | Manage QR Codes and Checkout Links, view general settings |
| Merchant Finance | View services, QR Codes, Checkout Links, and payment configuration |
| Merchant Developer | Manage API Payment, webhook, callback, and IP whitelist |
| Merchant Support | View-only access to service configuration |
| Merchant Viewer | Read-only access |
3. Functional Requirements
3.1 Common Service Management Layout
F1. Service Management Page
Description:
Displays service configuration modules in tab-based layout.
Page Header
| UI Element | Description |
|---|---|
| Page Title | Service Management |
| Main Tabs | Registered Services, General Settings, QR Codes, Checkout Link, API Payment |
| Primary CTA | Depends on selected tab |
Primary CTA by Tab
| Active Tab | CTA |
|---|---|
| Registered Services | None / Service action inside cards |
| General Settings | Save Changes |
| QR Codes | Create New QR Code |
| Checkout Link | Create New Checkout Link |
| API Payment | Generate API Key / Add IP request depending section |
Rules
- Default tab: Registered Services.
- Active tab is highlighted with underline.
- Inactive tabs are visible but muted.
- Merchant can only view services enabled for their merchant account or subscription tier.
- Each tab must preserve its filter state when user switches tabs.
- Delete actions must require confirmation.
- All destructive or security-sensitive actions must be audit logged.
3.2 Registered Services
F2. Registered Services List
Description:
Displays all payment services available to the merchant.
Supported Services
| Service | Description |
|---|---|
| QR Payment | Static or dynamic QR-based crypto payment |
| Checkout Link | Payment link shared with customer |
| API Payment | API-based dynamic payment generation |
Displayed Fields
| Field | Description |
|---|---|
| Service Name | Name of payment service |
| Service Type | Crypto / Fiat future extension |
| Status | Active / Inactive |
| Supported Networks | Tron, Ethereum, BSC, Polygon, etc. |
| Supported Assets | USDT, USDC, etc. |
| Pricing | Transaction fee, fixed fee, network fee policy |
| Tier / Limit | Usage limit, API rate limit, monthly volume limit |
| Last Updated | Last configuration change datetime |
Actions
| Action | Behavior |
|---|---|
| Enable Service | Activates service for merchant |
| Disable Service | Disables service for merchant |
| View Detail | Opens service configuration detail |
| Request Upgrade | Opens proposal/support flow if service is unavailable |
Rules
- Service availability must be enforced across QR Code, Checkout Link, and API Payment.
- If QR Payment is disabled, user cannot create new QR Code.
- If Checkout Link is disabled, user cannot create new Checkout Link.
- If API Payment is disabled, API key usage must be blocked.
- Disabling a service does not delete historical QR Codes, Checkout Links, or transactions.
- Disabling a service may disable new payment sessions.
- Re-enabling a service restores creation capability if merchant subscription and compliance status allow it.
3.3 General Settings
F3. Merchant Branding Settings
Description:
Allows merchant to configure payment page branding.
Fields
| Field | Type | Description |
|---|---|---|
| Brand Name | Text input | Displayed on QR and Checkout payment pages |
| Brand Logo | File upload | Merchant logo |
| Primary Color | Color picker | Primary action color |
| Secondary Color | Color picker | Secondary UI color |
| Background Color | Color picker | Payment page background |
| Group Background Color | Color picker | Card/panel background |
| Footer Brand Text | Text input | Optional footer text |
| Support Email | Email input | Optional customer support email |
Rules
- Logo supports PNG, JPG, JPEG, SVG if allowed.
- Logo max size should be configurable.
- Brand name is required if branding is enabled.
- Color values must be valid HEX values.
- Preview must update when branding changes.
- Saved branding applies to:
- QR Code payment page
- Checkout Link payment page
- Customer-facing invoice payment page
F4. Webhook Configuration
Description:
Allows merchant to configure server-to-server webhook delivery.
Fields
| Field | Type | Description |
|---|---|---|
| Webhook URL | URL input | Merchant endpoint |
| Webhook Secret | Generated / masked | Secret used to sign webhook payload |
| Enable Webhook | Toggle | Enables/disables delivery |
| Timeout | Number | Request timeout |
| Retry Attempts | Number | Number of retry attempts |
| Retry Delay | Number | Delay between retry attempts |
| Event Subscriptions | Checkbox | Events merchant wants to receive |
Supported Events
| Event | Description |
|---|---|
| payment.pending | Payment detected but not finalized |
| payment.success | Payment confirmed |
| payment.failed | Payment failed |
| refund.processed | Refund completed |
| refund.failed | Refund failed |
| checkout.expired | Checkout Link expired |
| qr.expired | QR Code expired |
Rules
- Webhook URL must be HTTPS in production.
- Webhook URL must be validated before save if validation is enabled.
- Webhook secret must be masked by default.
- Rotating webhook secret requires confirmation.
- Retry logic is handled by the core system.
- Webhook delivery logs must be preserved.
- Webhook configuration changes must be audit logged.
F5. Callback Configuration
Description:
Allows merchant to configure browser redirect/callback behavior after customer payment flow.
Fields
| Field | Type | Description |
|---|---|---|
| Success Callback URL | URL input | Redirect after successful payment |
| Failure Callback URL | URL input | Redirect after failed payment |
| Pending Callback URL | URL input | Redirect when payment is pending |
| Cancel Callback URL | URL input | Redirect when customer cancels |
| Callback Method | Dropdown | GET / POST, default POST |
| Include Transaction Details | Toggle | Include transaction fields in payload |
| Include Customer Information | Toggle | Include customer fields |
| Verify SSL | Toggle | Enforce SSL validation |
Rules
- Callback URL must be valid URL format.
- Production callback URL must use HTTPS.
- Callback does not replace webhook.
- Callback is customer/browser-facing.
- Webhook is server-to-server.
- Callback delivery attempts must be logged if POST callback is used.
3.4 QR Codes
F6. QR Code List
Description:
Displays all QR Codes created by the merchant.
Tab: QR Codes
Primary CTA
| Button | Behavior |
|---|---|
| Create New QR Code | Opens Create New QR Code page |
Filters
| Filter | Type | Placeholder / Value |
|---|---|---|
| Name | Text input | Enter name |
| Status | Dropdown | All Status |
| Asset | Dropdown | All Assets |
| Network | Dropdown | All Networks |
| Search | Button | Applies filters |
Table Columns
| Column | Description |
|---|---|
| # | Row number |
| Name | QR Code name |
| Amount | Fixed amount and asset, or Flexible |
| Network | Blockchain network badge |
| Created Datetime | QR creation datetime |
| Status | Active / Expired / Disabled |
| Scans | Number of QR scans |
| Actions | View, Download, Delete/Disable |
Actions
| Action | Icon | Behavior |
|---|---|---|
| View | Eye | Opens QR Code detail / preview |
| Download | Download | Downloads QR image |
| Delete / Disable | Trash | Disables or deletes QR Code after confirmation |
Rules
- Default sorting: Created Datetime DESC.
- QR Code with no fixed amount displays Flexible.
- Scan count increments when QR payment page is opened or QR is scanned.
- Expired QR Code cannot accept payment.
- Disabled QR Code cannot accept payment.
- Delete should preferably perform soft delete or disable for auditability.
- Download action downloads the latest generated QR image.
- QR Code status must update automatically when expiry datetime passes.
F7. Create New QR Code Page
Description:
Allows merchant to generate a QR Code for crypto payment collection.
Page Header
| UI Element | Description |
|---|---|
| Breadcrumb | Service Management / Create New QR Code |
| Page Title | Create New QR Code |
Form Fields
| Field | Required | Type | Description |
|---|---|---|---|
| QR Code Name | Yes | Text input | Display name for internal management |
| Virtual Account | Yes | Search/select input | Receiving virtual account |
| Invoice ID | No | Search/select input | Linked invoice |
| One Time Use | No | Checkbox | Disable QR after first successful payment |
| Expiry DateTime | No | Checkbox + datetime input | QR expiration datetime |
| Fix Amount | No | Checkbox | Determines whether amount is fixed |
| Amount | Conditional | Number input | Required if Fix Amount is enabled |
| Asset | Yes | Dropdown | USDT / USDC / supported token |
| Network | Yes | Dropdown | Tron / BSC / Ethereum / Polygon |
| Order ID | No | Text input | Merchant order reference |
| QR Code Preview | System generated | Preview panel | Branded customer-facing QR preview |
Supporting Buttons
| Button | Behavior |
|---|---|
| Search icon beside Virtual Account | Opens Search Virtual Account modal |
| Plus icon beside Virtual Account | Opens Create Virtual Account modal |
| Search icon beside Invoice ID | Opens Search Invoice ID modal |
| Plus icon beside Invoice ID | Opens Create Invoice modal |
| Cancel | Returns to QR Code list |
| Generate QR Code | Creates QR Code |
QR Code Preview
| Preview Field | Description |
|---|---|
| Merchant Brand | Merchant brand name/logo |
| QR Image | Encoded payment payload |
| Amount | Fixed amount or Flexible |
| Network | Selected network |
| Expires | Expiry datetime or Never |
| Footer | Platform brand and copyright |
Rules
- QR Code Name is required.
- Virtual Account is required.
- Asset and Network are required.
- Selected Virtual Account must support selected Network and Asset.
- If Invoice ID is selected:
- Asset should default from invoice asset.
- Amount may default from invoice total if Fix Amount is enabled.
- Order ID may default from invoice order ID.
- If Fix Amount is checked:
- Amount is required.
- Amount must be greater than 0.
- Amount precision must match asset decimals.
- If Fix Amount is unchecked:
- Amount displays Flexible.
- Customer may enter amount on payment page, if supported.
- If One Time Use is checked:
- QR is disabled after first successful payment.
- If Expiry DateTime is checked:
- Expiry datetime is required.
- Expiry datetime must be greater than current datetime.
- Generate QR Code is disabled until required validations pass.
- QR payload must include sufficient information to map payment to merchant, service, virtual account, asset, network, and optional invoice/order.
- Created QR Code must appear in QR Code list after success.
3.5 Checkout Link
F8. Checkout Link List
Description:
Displays all Checkout Links created by the merchant.
Tab: Checkout Link
Primary CTA
| Button | Behavior |
|---|---|
| Create New Checkout Link | Opens Create New Checkout Link page |
Filters
| Filter | Type | Placeholder / Value |
|---|---|---|
| Name | Text input | Enter name |
| Link ID | Text input | Enter link id |
| Status | Dropdown | All Status |
| Asset | Dropdown | All Assets |
| Network | Dropdown | All Networks |
| Search | Button | Applies filters |
Table Columns
| Column | Description |
|---|---|
| # | Row number |
| Name | Checkout Link name |
| Amount | Amount and asset |
| Link | Short Link ID / public link with copy icon |
| Network | Blockchain network badge |
| Created Datetime | Creation datetime |
| Status | Active / Expired / Disabled |
| Clicks | Number of link visits |
| Actions | View, Delete/Disable |
Actions
| Action | Icon | Behavior |
|---|---|---|
| View | Eye | Opens Checkout Link detail or customer-facing preview |
| Copy Link | Copy | Copies full checkout link URL |
| Delete / Disable | Trash | Disables Checkout Link after confirmation |
Rules
- Default sorting: Created Datetime DESC.
- Link ID must be unique.
- Copy action copies full public URL, not shortened Link ID.
- Click count increments when customer opens the Checkout Link.
- Expired Checkout Link cannot accept payment.
- Disabled Checkout Link cannot accept payment.
- Delete should preferably soft-disable for traceability.
- Checkout Link status auto-updates to Expired when expiry datetime passes.
F9. Create New Checkout Link Page
Description:
Allows merchant to generate a payment link for customer payment collection.
Page Header
| UI Element | Description |
|---|---|
| Breadcrumb | Service Management / Create New Checkout Link |
| Page Title | Create New Checkout Link |
Form Fields
| Field | Required | Type | Description |
|---|---|---|---|
| Link Name | Yes | Text input | Display name for merchant |
| Virtual Account | Yes | Search/select input | Receiving virtual account |
| Invoice ID | No | Search/select input | Linked invoice |
| One Time Use | No | Checkbox | Disable link after first successful payment |
| Expiry DateTime | No | Checkbox + datetime input | Link expiration datetime |
| Fix Amount | No | Checkbox | Determines if amount is fixed |
| Amount | Conditional | Number input | Required if Fix Amount is enabled |
| Asset | Yes | Dropdown | USDT / USDC / supported token |
| Network | Yes | Dropdown | Tron / BSC / Ethereum / Polygon |
Supporting Buttons
| Button | Behavior |
|---|---|
| Search icon beside Virtual Account | Opens Search Virtual Account modal |
| Plus icon beside Virtual Account | Opens Create Virtual Account modal |
| Search icon beside Invoice ID | Opens Search Invoice ID modal |
| Plus icon beside Invoice ID | Opens Create Invoice modal |
| Cancel | Returns to Checkout Link list |
| Generate Link | Creates Checkout Link |
Rules
- Link Name is required.
- Virtual Account is required.
- Network and Asset are required.
- Selected Virtual Account must support selected Network and Asset.
- If Invoice ID is selected:
- Customer email, order ID, product information, asset, and total may be inherited from invoice.
- Amount may be fixed to invoice total depending on configuration.
- If Fix Amount is checked:
- Amount is required.
- Amount must be greater than 0.
- If Fix Amount is unchecked:
- Link amount is Flexible.
- If One Time Use is checked:
- Checkout Link becomes disabled after first successful payment.
- If Expiry DateTime is checked:
- Expiry datetime is required.
- Expiry datetime must be greater than current datetime.
- Generate Link creates public payment URL.
- Generated link appears in Checkout Link list.
- Public checkout page must display merchant branding, amount, asset, network, invoice/product data, and payment instructions.
F10. Customer-Facing Checkout Link Page
Description:
The public payment page opened by the customer.
Displayed Information
| Section | Description |
|---|---|
| Merchant Branding | Logo, brand name, colors |
| Product / Invoice Info | Product name, description, quantity, total |
| Payment Amount | Amount and asset |
| Network | Selected blockchain network |
| QR Code | Wallet scan payment QR |
| Connect Wallet | Optional wallet payment flow |
| Expiry Countdown | Time remaining before expiry |
| Payment Status | Pending / Success / Failed / Expired |
Rules
- Public page must not expose internal merchant configuration.
- Public page must be accessible without merchant login.
- Payment intent must be validated server-side.
- Expired or disabled link must show expired/disabled state.
- One-time use link must show used/disabled state after successful payment.
- Customer payment status should update by polling, websocket, or callback from transaction service.
3.6 Supporting Modal: Create Invoice
F11. Create Invoice Modal
Description:
Allows merchants to create a new invoice from QR Code or Checkout Link creation flow.
Triggered By
| Trigger | Behavior |
|---|---|
| Plus icon beside Invoice ID | Opens Create Invoice modal |
Modal Fields
| Field | Required | Type | Description |
|---|---|---|---|
| Order ID | Yes | Text input | Merchant order reference |
| Customer ID | No | Text input | Merchant customer identifier |
| Customer Email | Yes | Email input | Customer email |
| Expiry Time | Yes | Datetime picker | Invoice expiry datetime |
| Asset | Yes | Dropdown | Invoice asset |
| Product ID | Yes | Text input | Product code |
| Product Name | Yes | Text input | Product name |
| Price | Yes | Number input | Product unit price |
| Quantity | Yes | Number input | Product quantity |
| Total | System calculated | Number / read-only | Price × Quantity |
| Notes | No | Textarea | Optional invoice notes |
| Invoice Total | System calculated | Read-only | Sum of product totals |
Actions
| Button | Behavior |
|---|---|
| Add Product | Adds product row |
| Delete Product | Removes product row |
| Cancel | Closes modal |
| Create Invoice | Creates invoice and returns selected invoice to parent form |
Rules
- Order ID is required.
- Customer Email must be valid email format.
- Expiry Time must be greater than current datetime.
- At least one product row is required.
- Product ID and Product Name are required.
- Price must be greater than or equal to 0.
- Quantity must be greater than 0.
- Total is calculated automatically.
- Invoice Total is calculated automatically.
- Invoice asset must match selected QR/Checkout asset if already selected.
- After successful creation:
- Modal closes.
- New Invoice ID is populated in parent QR/Checkout form.
- Amount may be populated from Invoice Total.
3.7 Supporting Modal: Search Invoice ID
F12. Search Invoice ID Modal
Description:
Allows merchant to search and select an existing invoice.
Triggered By
| Trigger | Behavior |
|---|---|
| Search icon beside Invoice ID | Opens Search Invoice ID modal |
Search Filters
| Filter | Type | Placeholder |
|---|---|---|
| Invoice ID | Text input | Enter invoice id |
| Order ID | Text input | Enter order id |
| Customer Email | Text input | Enter customer email |
| Product Code | Text input | Enter product code |
| Search | Button | Applies filters |
Result Item Fields
| Field | Example |
|---|---|
| Invoice ID | INV001 |
| Order ID | ORD123456789 |
| Product Code | PRD-LAPTOP-001 |
| Customer Email | customer@techstore.com |
| Amount | 1,250.00 USDT |
| Status | Paid / Pending / Expired / Cancelled |
Pagination
| Field | Description |
|---|---|
| Showing Count | Showing 1 to 3 of 5 entries |
| Page Indicator | Page 1 of 2 |
| Previous / Next | Navigates pages |
Rules
- User can search by any filter or combination of filters.
- Empty search returns latest invoices.
- Only invoices owned by current merchant are shown.
- Only eligible invoice statuses can be selected for new QR/Checkout payment:
- Draft
- Pending
- Unpaid
- Paid invoices may be shown but should be disabled for selection unless re-payment is allowed.
- Selecting an invoice populates Invoice ID in parent form.
- Parent form may inherit order ID, customer email, asset, and amount from invoice.
3.8 Supporting Modal: Create Virtual Account
F13. Create Virtual Account Modal
Description:
Allows merchant to create a new Virtual Account from QR Code or Checkout Link creation flow.
Triggered By
| Trigger | Behavior |
|---|---|
| Plus icon beside Virtual Account | Opens Create Virtual Account modal |
Modal Fields
| Field | Required | Type | Description |
|---|---|---|---|
| Customer ID | Yes | Text input | Merchant customer ID |
| Customer Name | No | Text input | Customer display name |
| Customer Email | No | Email input | Customer email |
| Hot Wallet | Yes | Dropdown | Parent Hot Wallet |
| Network | Yes | Multi-select / checkbox | Supported networks |
| Assets | Yes | Multi-select / checkbox | Supported assets |
Actions
| Button | Behavior |
|---|---|
| Cancel | Closes modal |
| Create Virtual Account | Creates account and returns selected VA to parent form |
Rules
- Customer ID is required.
- Hot Wallet is required.
- At least one network must be selected.
- At least one asset must be selected.
- Customer Email must be valid if provided.
- Selected Hot Wallet must support selected network and asset.
- Duplicate Customer ID + Network + Asset configuration should be blocked or warned.
- Created Virtual Account must be active before it can be used.
- After successful creation:
- Modal closes.
- New Virtual Account is populated in parent form.
- Network and Asset may be populated based on created account.
3.9 Supporting Modal: Search Virtual Account
F14. Search Virtual Account Modal
Description:
Allows merchant to search and select an existing Virtual Account.
Triggered By
| Trigger | Behavior |
|---|---|
| Search icon beside Virtual Account | Opens Search Virtual Account modal |
Search Filters
| Filter | Type | Placeholder / Value |
|---|---|---|
| Customer ID | Text input | Enter customer ID |
| Address | Text input | Enter address |
| Network | Dropdown | All Networks |
| Hot Wallet | Dropdown | All Hot Wallets |
| Search | Button | Applies filters |
Result Item Fields
| Field | Example |
|---|---|
| Customer ID | CUST001 |
| Network | BSC Mainnet |
| Hot Wallet | Test Wallet |
| Address | 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb |
Pagination
| Field | Description |
|---|---|
| Showing Count | Showing 1 to 3 of 12 entries |
| Page Indicator | Page 1 of 4 |
| Previous / Next | Navigates pages |
Rules
- User can search by customer ID, address, network, and Hot Wallet.
- Empty search returns latest active Virtual Accounts.
- Only Virtual Accounts owned by current merchant are shown.
- Only Active Virtual Accounts can be selected.
- Selected Virtual Account must support target service:
- QR Code
- Checkout Link
- API Payment if reused
- Selecting Virtual Account populates parent form.
- Parent form should validate asset/network compatibility.
3.10 API Payment
F15. API Key Management
Description:
Allows merchant developer/admin to manage API credentials.
Fields
| Field | Description |
|---|---|
| Key Name | Production Key / Test Key |
| Environment | Live / Test |
| Masked Key | Masked API key |
| Status | Active / Revoked |
| Last Used At | Last API usage datetime |
| Created At | Key creation datetime |
Actions
| Action | 2FA Required | Behavior |
|---|---|---|
| Generate Key | Optional | Creates API key |
| Reveal Key | Yes | Reveals full key temporarily |
| Copy Key | Yes / Optional by policy | Copies key |
| Regenerate Key | Yes | Invalidates old key and creates new key |
| Revoke Key | Yes | Revokes key |
Rules
- API keys are masked by default.
- Full API key must only be shown once after generation unless reveal is allowed.
- Reveal, regenerate, and revoke require 2FA.
- Revoked API keys cannot be used.
- Regenerated keys must invalidate old keys immediately or after configured grace period.
- API key actions must be audit logged.
- API key raw value must not be stored in plaintext.
F16. 2FA Verification for Sensitive API Actions
Description:
Protects sensitive API key actions.
Protected Actions
| Action | Reason |
|---|---|
| Reveal API Key | Prevent credential leakage |
| Regenerate API Key | Prevent integration disruption |
| Revoke API Key | Prevent unauthorized service shutdown |
Flow
| Step | Description |
|---|---|
| 1 | User clicks protected action |
| 2 | System opens 2FA modal |
| 3 | User enters 6-digit authenticator code |
| 4 | System validates 2FA |
| 5 | If valid, action is executed |
| 6 | If invalid, error is shown |
| 7 | Attempts are limited |
| 8 | Challenge expires after configured time |
Rules
- 2FA code is required.
- Challenge expires after configured duration.
- Too many failed attempts lock the challenge.
- 2FA challenge and result must be audit logged.
F17. IP Whitelist Management
Description:
Restricts API access by approved IP addresses.
Fields
| Field | Description |
|---|---|
| IP Address | IPv4 or IPv6 |
| Label | Optional label |
| Status | Active / Removed |
| Created By | Creator |
| Created At | Creation datetime |
Actions
| Action | Behavior |
|---|---|
| View IPs | Displays whitelisted IPs |
| Remove IP | Removes IP from whitelist |
| Add IP | Creates support ticket/manual approval flow |
Rules
- IP address must be valid IPv4 or IPv6.
- CIDR support depends on policy.
- Adding IP may require support approval.
- Removing IP must require confirmation.
- API requests from non-whitelisted IPs must be blocked if whitelist enforcement is enabled.
- IP changes must be audit logged.
4. Data Requirements
Merchant settings tables
merchant_configs
| Field | Type | Required | Description |
|---|---|---|---|
| merchant_id | UUID | No | Owning merchant identifier |
| tax_mode | String | Yes | Tax calculation mode |
| tax_jurisdiction | String | Yes | Tax jurisdiction |
| tax_type | String | Yes | Tax type |
| tax_code | String | Yes | Tax code |
| tax_rate | Decimal | Yes | Tax rate |
| created_by | String | Yes | Creator user id |
| updated_by | String | Yes | Last updater user id |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
merchant_documents
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| document_type | String | Yes | Document type key |
| file_name | String | Yes | Stored file name |
| file_url | String | Yes | Document/file URL |
| mime_type | String | Yes | MIME type |
| file_size | Integer | Yes | File size in bytes |
| notes | String | Yes | Free-text notes |
| uploaded_by | String | Yes | Uploader user id |
| uploaded_at | DateTime | Yes | Upload timestamp |
| is_deleted | Boolean | Yes | Soft-delete flag |
| deleted_at | DateTime | No | Soft-delete timestamp |
| file_id | UUID | No | File-service object id |
| sumsub_doc_type | String | No | Sumsub document type mapping |
merchant_kyc_decisions
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| source | String | Yes | KYC decision source (manual / sumsub) |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| reason | String | No | Decision / rejection reason |
| decided_by | String | Yes | Decision actor id |
| decided_at | DateTime | Yes | Decision timestamp |
| created_at | DateTime | Yes | Created timestamp (UTC) |
merchant_kyc_manual
| Field | Type | Required | Description |
|---|---|---|---|
| merchant_id | UUID | No | Owning merchant identifier |
| full_name | String | Yes | Full legal name |
| date_of_birth | DATE | No | Date of birth |
| nationality | String | Yes | Nationality |
| id_type | String | Yes | ID document type |
| id_number | String | Yes | ID document number |
| id_expiry_date | DATE | No | ID expiry date |
| business_registration_number | String | Yes | Business registration number |
| business_registration_date | DATE | No | Business registration date |
| business_license_number | String | Yes | Business license number |
| residential_address | String | Yes | Residential address |
| city | String | Yes | City |
| state | String | Yes | State / province |
| postal_code | String | Yes | Postal code |
| country | String | Yes | Country |
| identity_verified | Boolean | Yes | Identity verification flag |
| address_verified | Boolean | Yes | Address verification flag |
| business_verified | Boolean | Yes | Business verification flag |
| updated_by | String | Yes | Last updater user id |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
merchant_kyc_provider
| Field | Type | Required | Description |
|---|---|---|---|
| merchant_id | UUID | No | Owning merchant identifier |
| provider_name | String | Yes | Provider name |
| applicant_id | String | Yes | Applicant id |
| inspection_id | String | Yes | Inspection id |
| review_status | String | Yes | Review status |
| review_answer | String | No | Review answer |
| reject_type | String | No | Reject type |
| reject_labels | JSON | Yes | Reject labels |
| provider_status | String | Yes | Provider status |
| hosted_url | String | No | Hosted url |
| hosted_url_expires_at | DateTime | No | Hosted url expires at |
| raw_response | JSON | Yes | Raw response |
| last_synced_at | DateTime | No | Last synced at |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
merchant_payment_services
| Field | Type | Required | Description |
|---|---|---|---|
| merchant_id | UUID | Yes | Owning merchant identifier |
| payment_service_id | UUID | Yes | Payment service id |
| created_at | DateTime | Yes | Created timestamp (UTC) |
merchant_roles
| Field | Type | Required | Description |
|---|---|---|---|
| id | Integer | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| name | String | Yes | Display name |
| description | String | No | Text description |
| permission_matrix | JSON | Yes | Permission matrix |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
merchant_service_fee_configs
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| service_id | UUID | Yes | Payment / product service identifier |
| tx_fee_wallet | String | Yes | Tx fee wallet |
| settlement_fee_wallet | String | Yes | Settlement fee wallet |
| vat_wallet | String | Yes | Vat wallet |
| operator | String | Yes | Operator |
| settlement_manager | String | Yes | Settlement manager |
| signers | JSON | Yes | Signers |
| fee_tokens | JSON | Yes | Fee tokens |
| fee_schedules | JSON | Yes | Fee schedules |
| enabled | Boolean | Yes | Feature enabled flag |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
merchant_tiers
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| name | String | Yes | Display name |
| description | String | No | Text description |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| valid_from | DateTime | No | Valid from |
| max_accounts | Integer | Yes | Max accounts |
| fee_structure | JSON | Yes | Fee structure |
| rate_limiting | JSON | Yes | Rate limiting |
| approved_by | String | No | Approved by |
| approved_at | DateTime | No | Approved at |
| rejected_by | String | No | Rejected by |
| rejected_at | DateTime | No | Rejected at |
| rejection_reason | String | No | Rejection reason |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
| settlement_period | String | Yes | Settlement period |
merchant_users
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| merchant_role_id | Integer | Yes | Merchant role id |
| String | Yes | Email address | |
| password_hash | String | Yes | Password hash (never expose in API) |
| name | String | Yes | Display name |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
merchants
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| merchant_id | String | Yes | Owning merchant identifier |
| business_name | String | Yes | Business name |
| business_address | String | Yes | Business address |
| contact_email | String | Yes | Contact email |
| tax_id | String | Yes | Tax id |
| manager_id | String | Yes | Manager id |
| manager_name | String | Yes | Manager name |
| contact_person | String | Yes | Contact person |
| contact_phone | String | Yes | Contact phone |
| supporter_id | String | Yes | Supporter id |
| supporter_name | String | Yes | Supporter name |
| status | String | Yes | Merchant status (draft / pending / active / rejected / suspended) |
| kyc_status | String | Yes | Kyc status |
| created_by | String | Yes | Creator user id |
| updated_by | String | Yes | Last updater user id |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
| tier | UUID | No | Custody / merchant tier label |
| business_type | UUID | No | Business type |
| cobo_vault_id | String | No | Cobo vault identifier |
webhook_setting_audits
| Field | Type | Required | Description |
|---|---|---|---|
| id | Integer | No | Primary key |
| merchant_id | UUID | Yes | Owning merchant identifier |
| actor | String | Yes | Actor |
| url_hash | String | Yes | Url hash |
| subscriptions | String | Yes | Subscriptions |
| created_at | DateTime | Yes | Created timestamp (UTC) |
webhook_settings
| Field | Type | Required | Description |
|---|---|---|---|
| merchant_id | UUID | No | Owning merchant identifier |
| url | String | Yes | Url |
| enabled | Boolean | Yes | Feature enabled flag |
| timeout_seconds | Integer | Yes | Timeout seconds |
| retry_attempts | Integer | Yes | Retry attempts |
| retry_delay_seconds | Integer | Yes | Retry delay seconds |
| events | String | Yes | Subscribed webhook event types |
| secret_version | Integer | Yes | Secret version |
| previous_secret_version | Integer | No | Previous secret version |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
Common payment-service tables
entities
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| entity_type | String | Yes | Entity type |
| name | String | Yes | Display name |
| description | String | No | Text description |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
| sumsub_doc_type | String | No | Sumsub document type mapping |
payment_services
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| code | String | Yes | Verification / 2FA code |
| name | String | Yes | Display name |
| type | String | Yes | Record type discriminator |
| service_kind | String | Yes | Service kind |
| description | String | No | Text description |
| features | JSON | No | Features |
| tier | String | Yes | Custody / merchant tier label |
| status | String | Yes | Lifecycle status (active / inactive / domain-specific values) |
| status_change_mode | String | Yes | Status change mode |
| is_deployed | Boolean | Yes | Is deployed |
| approval_status | String | Yes | Approval status |
| rejection_reason | String | No | Rejection reason |
| transaction_fee_percent | Decimal | No | Transaction fee percent |
| fixed_fee_amount | Decimal | No | Fixed fee amount |
| tier_limits | JSON | No | Tier limits |
| version | Integer | Yes | Version |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
service_blockchain_fees
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| service_id | UUID | Yes | Payment / product service identifier |
| blockchain | String | Yes | Blockchain slug (e.g. bsc, ethereum, polygon, tron) |
| tx_fee_percent | Decimal | Yes | Tx fee percent |
| fixed_fee_amount | Decimal | Yes | Fixed fee amount |
| fixed_fee_currency | String | No | Fixed fee currency |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
service_status_proposals
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | No | Primary key |
| service_id | UUID | Yes | Payment / product service identifier |
| requested_status | String | Yes | Requested status |
| reason | String | Yes | Decision / rejection reason |
| deactivation_mode | String | No | Deactivation mode |
| state | String | Yes | State / province |
| rejected_reason | String | No | Rejected reason |
| created_by | String | No | Creator user id |
| reviewed_by | String | No | Reviewed by |
| reviewed_at | DateTime | No | Reviewed at |
| created_at | DateTime | Yes | Created timestamp (UTC) |
| updated_at | DateTime | Yes | Last updated timestamp (UTC) |
5. Enums
QRCodeStatus
| Value | Description |
|---|---|
| ACTIVE | QR Code can accept payment |
| EXPIRED | QR Code expired |
| DISABLED | QR Code disabled by user/system |
| DELETED | Soft-deleted, if supported |
CheckoutLinkStatus
| Value | Description |
|---|---|
| ACTIVE | Link can accept payment |
| EXPIRED | Link expired |
| DISABLED | Link disabled by user/system |
| DELETED | Soft-deleted, if supported |
SupportedNetwork
| Value | Description |
|---|---|
| TRON | Tron network |
| ETHEREUM | Ethereum network |
| BSC | Binance Smart Chain |
| POLYGON | Polygon network |
SupportedAsset
| Value | Description |
|---|---|
| USDT | Tether |
| USDC | USD Coin |
InvoiceStatus
| Value | Description |
|---|---|
| DRAFT | Created but not payment-ready |
| PENDING | Waiting for payment |
| PAID | Paid |
| EXPIRED | Expired |
| CANCELLED | Cancelled |
ServiceStatus
| Value | Description |
|---|---|
| ACTIVE | Service enabled |
| INACTIVE | Service disabled |
| SUSPENDED | Disabled by platform/compliance |
6. API Routes
SoT (implemented):
| Method | Route | Description | Request | Response |
|---|---|---|---|---|
| GET/POST/PUT | /api/v1/merchant/config |
Tax/general merchant config | {tax_mode, tax_jurisdiction, tax_type, tax_code, tax_rate} |
{id, merchant_id, tax, payment_services[]} |
| GET/PUT | /api/v1/merchant/settings/webhook |
Webhook URL/secret settings | {webhook_url, enabled, events[]} |
{webhook_url, enabled, events[], secret?} |
| POST | /api/v1/merchant/settings/webhook/test |
Send test webhook | {} |
{ok, status_code?, error?} |
| POST | /api/v1/merchant/settings/webhook/secret/rotate |
Rotate signing secret | {} |
settings |
| GET | /api/v1/merchant/{merchant_id}/services/{merchant_service_id} |
Merchant service fee config | {merchant_id, merchant_service_id} |
{merchant_id, service_id, tx_bps, settlement_bps, vat_bps, fixed_*, enabled} |
7. Audit Log Requirements
| Action | Audit Required | Captured Fields |
|---|---|---|
| Enable Service | Yes | user, merchant, service, old_status, new_status, timestamp |
| Disable Service | Yes | user, merchant, service, old_status, new_status, timestamp |
| Update Branding | Yes | user, changed_fields, timestamp |
| Update Webhook | Yes | user, webhook_url_hash, event_subscriptions, timestamp |
| Rotate Webhook Secret | Yes | user, timestamp |
| Update Callback | Yes | user, changed_fields, timestamp |
| Create QR Code | Yes | user, qr_id, network, asset, amount_type, timestamp |
| Download QR Code | Optional | user, qr_id, timestamp |
| Disable/Delete QR Code | Yes | user, qr_id, reason, timestamp |
| Create Checkout Link | Yes | user, checkout_link_id, network, asset, amount_type, timestamp |
| Copy Checkout Link | Optional | user, checkout_link_id, timestamp |
| Disable/Delete Checkout Link | Yes | user, checkout_link_id, reason, timestamp |
| Create Invoice from Service Flow | Yes | user, invoice_id, order_id, amount, timestamp |
| Search Invoice | Optional | user, filters, timestamp |
| Create Virtual Account from Service Flow | Yes | user, virtual_account_id, customer_id, network, asset, timestamp |
| Search Virtual Account | Optional | user, filters, timestamp |
| Generate API Key | Yes | user, api_key_id, environment, timestamp |
| Reveal API Key | Yes | user, api_key_id, challenge_id, timestamp |
| Rotate API Key | Yes | user, api_key_id, challenge_id, timestamp |
| Revoke API Key | Yes | user, api_key_id, challenge_id, timestamp |
| Remove IP Whitelist | Yes | user, ip_entry_id, timestamp |
8. Error Handling
| Scenario | Expected Behavior |
|---|---|
| Service list fails to load | Show error and retry |
| User lacks permission | Show access denied |
| QR Code list empty | Show empty state |
| Checkout Link list empty | Show empty state |
| Invalid amount | Show inline validation |
| Amount is required but missing | Disable Generate button |
| Selected Virtual Account does not support asset/network | Show compatibility error |
| Expiry datetime is in the past | Show validation error |
| Invoice not found | Show empty result |
| Invoice already paid | Disable selection or show warning |
| Virtual Account not found | Show empty result |
| Virtual Account inactive | Disable selection |
| QR Code generation fails | Show error and retry |
| Checkout Link generation fails | Show error and retry |
| QR download fails | Show download error |
| Delete/disable fails | Show error and keep current state |
| Webhook URL invalid | Show URL validation error |
| Webhook test fails | Show response code/message |
| API key reveal 2FA fails | Show invalid code error |
| 2FA challenge expired | Prompt user to retry |
| IP address invalid | Show IP format error |
Use CasesUse Cases
Detailed use-case catalog for this module is maintained under 08_UC:Catalog use case chi tiết của module này được quản lý tại 08_UC: