Initial commit: API Wipay dengan fix CORS untuk GET request
This commit is contained in:
20
database/api_keys_hardening_migration.sql
Normal file
20
database/api_keys_hardening_migration.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- API Keys Hardening Migration
|
||||
-- Add security fields to api_keys table
|
||||
|
||||
ALTER TABLE api_keys
|
||||
ADD COLUMN IF NOT EXISTS rate_limit_per_minute INT DEFAULT 100 COMMENT 'Rate limit per minute (default: 100)',
|
||||
ADD COLUMN IF NOT EXISTS rate_limit_window INT DEFAULT 60 COMMENT 'Rate limit window in seconds (default: 60)',
|
||||
ADD COLUMN IF NOT EXISTS enable_ip_whitelist TINYINT(1) DEFAULT 0 COMMENT 'Enable IP whitelist (0=disabled, 1=enabled)',
|
||||
ADD COLUMN IF NOT EXISTS ip_whitelist TEXT NULL COMMENT 'IP whitelist (comma-separated or JSON array). Support CIDR notation.',
|
||||
ADD COLUMN IF NOT EXISTS expires_at DATETIME NULL COMMENT 'API key expiration date (NULL = never expires)',
|
||||
ADD COLUMN IF NOT EXISTS last_used_at DATETIME NULL COMMENT 'Last time API key was used',
|
||||
ADD COLUMN IF NOT EXISTS created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'API key creation date',
|
||||
ADD COLUMN IF NOT EXISTS updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last update date';
|
||||
|
||||
-- Index untuk performa
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at ON api_keys(expires_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_is_active ON api_keys(is_active);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_last_used_at ON api_keys(last_used_at);
|
||||
|
||||
-- Update last_used_at saat API key digunakan (akan di-handle di code)
|
||||
-- Trigger bisa ditambahkan jika diperlukan
|
||||
20
database/qris_migration.sql
Normal file
20
database/qris_migration.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- QRIS Payment Migration
|
||||
-- Add QRIS fields to pembayaran table
|
||||
|
||||
ALTER TABLE pembayaran
|
||||
ADD COLUMN IF NOT EXISTS qris_qr_code TEXT NULL COMMENT 'QRIS QR code content',
|
||||
ADD COLUMN IF NOT EXISTS qris_invoiceid VARCHAR(100) NULL COMMENT 'QRIS Invoice ID untuk check status',
|
||||
ADD COLUMN IF NOT EXISTS qris_nmid VARCHAR(100) NULL COMMENT 'QRIS NMID dari API',
|
||||
ADD COLUMN IF NOT EXISTS qris_request_date DATETIME NULL COMMENT 'Tanggal request QRIS invoice',
|
||||
ADD COLUMN IF NOT EXISTS qris_expired_at DATETIME NULL COMMENT 'QRIS expiration timestamp (30 menit dari request)',
|
||||
ADD COLUMN IF NOT EXISTS qris_check_count INT DEFAULT 0 COMMENT 'Jumlah check status (max 3 untuk user-triggered)',
|
||||
ADD COLUMN IF NOT EXISTS qris_last_check_at DATETIME NULL COMMENT 'Last check status timestamp',
|
||||
ADD COLUMN IF NOT EXISTS qris_status ENUM('unpaid', 'paid', 'expired') DEFAULT 'unpaid' COMMENT 'Status pembayaran QRIS',
|
||||
ADD COLUMN IF NOT EXISTS qris_payment_method VARCHAR(50) NULL COMMENT 'Metode pembayaran e-wallet (gopay, dana, ovo, dll)',
|
||||
ADD COLUMN IF NOT EXISTS qris_payment_customer_name VARCHAR(255) NULL COMMENT 'Nama customer dari e-wallet',
|
||||
ADD COLUMN IF NOT EXISTS qris_paid_at DATETIME NULL COMMENT 'Tanggal pembayaran QRIS';
|
||||
|
||||
-- Index untuk performa query
|
||||
CREATE INDEX IF NOT EXISTS idx_qris_invoiceid ON pembayaran(qris_invoiceid);
|
||||
CREATE INDEX IF NOT EXISTS idx_qris_status ON pembayaran(qris_status);
|
||||
CREATE INDEX IF NOT EXISTS idx_qris_expired_at ON pembayaran(qris_expired_at);
|
||||
Reference in New Issue
Block a user