mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
44 lines
3.2 KiB
JavaScript
44 lines
3.2 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* File Name: payments.mdl.js
|
|
* Type of Program: Model
|
|
* Description: Payment records for tier plan purchases.
|
|
* provider_payload JSONB stores all provider-specific data:
|
|
* {
|
|
* order_id, ← PayPal order ID
|
|
* capture_id, ← PayPal capture ID
|
|
* payer_id, ← PayPal payer ID
|
|
* approval_url, ← PayPal approval URL (stored at order creation)
|
|
* checkout: { promo_code, subtotal, discount },
|
|
* capture: { ...full PayPal capture response },
|
|
* error: { ...PayPal error response if failed },
|
|
* cancelled_at, cancelled_by
|
|
* }
|
|
* Author: Kenneth Obsequio (@lash0000)
|
|
* Date Created: Jun. 9, 2026
|
|
***********************************************************************************************************************************************************************/
|
|
const { DataTypes } = require('sequelize');
|
|
const sequelize = require('../../config/db.config');
|
|
|
|
const mdl_Payments = sequelize.define('Payment', {
|
|
payment_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: 'Payment ID', hidden: true, order: 0, filterable: true },
|
|
user_id: { type: DataTypes.BIGINT, allowNull: false, label: 'User ID', hidden: true, order: 1, filterable: true },
|
|
plan_id: { type: DataTypes.BIGINT, allowNull: false, label: 'Plan ID', hidden: true, order: 2, filterable: true },
|
|
tier_id: { type: DataTypes.BIGINT, allowNull: true, label: 'Tier ID', hidden: true, order: 3, filterable: true },
|
|
status: { type: DataTypes.ENUM('pending', 'completed', 'failed', 'cancelled', 'expired', 'refunded'), allowNull: false, defaultValue: 'pending', label: 'Status', hidden: false, order: 4, filterable: true },
|
|
amount: { type: DataTypes.DECIMAL(10, 2), allowNull: false, label: 'Amount', hidden: false, order: 3, filterable: false },
|
|
currency: { type: DataTypes.STRING(10), allowNull: false, defaultValue: 'USD', label: 'Currency', hidden: false, order: 6, filterable: true },
|
|
promo_code: { type: DataTypes.STRING(50), allowNull: true, label: 'Promo Code', hidden: false, order: 7, filterable: true },
|
|
discount: { type: DataTypes.DECIMAL(10, 2), allowNull: false, defaultValue: 0.00, label: 'Discount', hidden: false, order: 8, filterable: false },
|
|
provider: { type: DataTypes.STRING(50), allowNull: false, defaultValue: 'paypal', label: 'Provider', hidden: false, order: 9, filterable: true },
|
|
provider_payload: { type: DataTypes.JSONB, allowNull: true, defaultValue: {}, label: 'Provider Payload', hidden: true, order: 10, filterable: false },
|
|
paid_at: { type: DataTypes.DATE, allowNull: true, label: 'Paid At', hidden: false, order: 5, filterable: false },
|
|
createdBy: { type: DataTypes.BIGINT, allowNull: true, label: 'Created By' },
|
|
updatedBy: { type: DataTypes.BIGINT, allowNull: true, label: 'Updated By' },
|
|
deletedBy: { type: DataTypes.BIGINT, allowNull: true, label: 'Deleted By' },
|
|
}, {
|
|
tableName: 'payments',
|
|
timestamps: true,
|
|
paranoid: true,
|
|
});
|
|
|
|
module.exports = mdl_Payments; |