Inicio › Documentación › Instalación · origen_billing
Ejecuta el siguiente SQL en tu base de datos antes de arrancar el recurso por primera vez.
CREATE TABLE IF NOT EXISTS `origen_billing_jobs` (
`id` INT NOT NULL AUTO_INCREMENT,
`job_name` VARCHAR(50) NOT NULL,
`label` VARCHAR(100) NOT NULL DEFAULT '',
`society_account` VARCHAR(100) NOT NULL DEFAULT '',
`can_invoice` TINYINT(1) NOT NULL DEFAULT 1,
`commission` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
`society_loss` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
`active` TINYINT(1) NOT NULL DEFAULT 1,
`autopay_enabled` TINYINT(1) NOT NULL DEFAULT 0,
`autopay_mode` ENUM('immediate','delayed') NOT NULL DEFAULT 'immediate',
`autopay_delay_hours` INT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_job_name` (`job_name`),
KEY `idx_job_active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `origen_billing_products` (
`id` INT NOT NULL AUTO_INCREMENT,
`job_name` VARCHAR(50) NOT NULL,
`name` VARCHAR(100) NOT NULL,
`description` VARCHAR(255) NOT NULL DEFAULT '',
`price` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`active` TINYINT(1) NOT NULL DEFAULT 1,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_product_job` (`job_name`),
KEY `idx_product_active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `origen_billing_invoice_items` (
`id` INT NOT NULL AUTO_INCREMENT,
`invoice_id` INT NOT NULL,
`product_id` INT DEFAULT NULL,
`name` VARCHAR(100) NOT NULL,
`price` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`quantity` INT NOT NULL DEFAULT 1,
`subtotal` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`id`),
KEY `idx_item_invoice` (`invoice_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `origen_billing_invoices` (
`id` INT NOT NULL AUTO_INCREMENT,
`target_identifier` VARCHAR(100) NOT NULL,
`target_name` VARCHAR(100) NOT NULL DEFAULT '',
`author_identifier` VARCHAR(100) NOT NULL,
`author_name` VARCHAR(100) NOT NULL DEFAULT '',
`job_name` VARCHAR(50) NOT NULL,
`company_label` VARCHAR(100) NOT NULL DEFAULT '',
`society_account` VARCHAR(100) NOT NULL,
`amount` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`description` VARCHAR(255) NOT NULL DEFAULT '',
`notes` TEXT DEFAULT NULL,
`status` ENUM('pending','paid','cancelled') NOT NULL DEFAULT 'pending',
`commission_percent` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
`society_loss_percent` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
`net_amount` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`commission_amount` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`society_amount` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
`commission_status` ENUM('none','pending','delivered') NOT NULL DEFAULT 'none',
`commission_paid_at` TIMESTAMP NULL DEFAULT NULL,
`paid_at` TIMESTAMP NULL DEFAULT NULL,
`cancelled_by` VARCHAR(100) NULL DEFAULT NULL,
`context_data` TEXT NULL DEFAULT NULL,
`autopay_enabled` TINYINT(1) NOT NULL DEFAULT 0,
`autopay_mode` ENUM('immediate','delayed') NOT NULL DEFAULT 'immediate',
`autopay_delay_hours` INT NOT NULL DEFAULT 0,
`autopay_state` ENUM('none','scheduled','retrying','retry_on_login','done') NOT NULL DEFAULT 'none',
`autopay_attempts` INT NOT NULL DEFAULT 0,
`autopay_next_try_at` TIMESTAMP NULL DEFAULT NULL,
`autopay_last_error` VARCHAR(64) NULL DEFAULT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_target` (`target_identifier`),
KEY `idx_author` (`author_identifier`),
KEY `idx_job` (`job_name`),
KEY `idx_status` (`status`),
KEY `idx_commission` (`commission_status`),
KEY `idx_autopay` (`autopay_state`, `autopay_next_try_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;Añade el recurso después de sus dependencias:
ensure ox_lib
ensure oxmysql
ensure origen_billingLos jobs listados en Config.AuthorizedJobs (dentro de config.lua) son solo datos iniciales. Se insertan en la base de datos la primera vez que arranca el recurso, si el job no existe ya.
Tras el primer arranque, toda la gestión de jobs se hace desde el panel de administración del juego (/billingadmin). Los cambios en Config.AuthorizedJobs no sobrescribirán los registros existentes en la base de datos.
Para restablecer un job a sus valores iniciales, elimina su fila de origen_billing_jobs y reinicia el recurso.
Abre svconfig.lua y pon enabled = true junto con las URL de tus webhooks:
return {
enabled = true,
webhooks = {
['invoice-created'] = 'https://discord.com/api/webhooks/...',
['invoice-paid'] = 'https://discord.com/api/webhooks/...',
['invoice-cancelled'] = 'https://discord.com/api/webhooks/...',
['commission-paid'] = 'https://discord.com/api/webhooks/...',
},
}