@classytic/revenue 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as mongoose from 'mongoose';
2
- export { b as baseMetadataSchema, d as commissionSchema, c as currentPaymentSchema, g as gatewaySchema, h as holdSchema, a as paymentDetailsSchema, p as paymentSummarySchema, e as planSchema, r as referenceSchema, f as splitSchema, s as subscriptionInfoSchema, t as tenantSnapshotSchema } from '../split.schema-BPdFZMbU.js';
2
+ export { b as baseMetadataSchema, d as commissionSchema, c as currentPaymentSchema, g as gatewaySchema, h as holdSchema, a as paymentDetailsSchema, p as paymentSummarySchema, e as planSchema, r as referenceSchema, f as splitSchema, s as subscriptionInfoSchema, t as tenantSnapshotSchema } from '../split.schema-CETjPq10.js';
3
3
 
4
4
  declare const _default: {
5
5
  splitSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
@@ -368,19 +368,23 @@ declare const _default: {
368
368
  _id: false;
369
369
  }, {
370
370
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
371
+ refundedAmount: number;
371
372
  transactionId?: mongoose.Types.ObjectId | null | undefined;
372
373
  amount?: number | null | undefined;
373
374
  method?: string | null | undefined;
374
375
  verifiedAt?: NativeDate | null | undefined;
375
376
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
377
+ refundedAt?: NativeDate | null | undefined;
376
378
  reference?: string | null | undefined;
377
379
  }, mongoose.Document<unknown, {}, {
378
380
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
381
+ refundedAmount: number;
379
382
  transactionId?: mongoose.Types.ObjectId | null | undefined;
380
383
  amount?: number | null | undefined;
381
384
  method?: string | null | undefined;
382
385
  verifiedAt?: NativeDate | null | undefined;
383
386
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
387
+ refundedAt?: NativeDate | null | undefined;
384
388
  reference?: string | null | undefined;
385
389
  }, {
386
390
  id: string;
@@ -388,11 +392,13 @@ declare const _default: {
388
392
  _id: false;
389
393
  }>> & Omit<{
390
394
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
395
+ refundedAmount: number;
391
396
  transactionId?: mongoose.Types.ObjectId | null | undefined;
392
397
  amount?: number | null | undefined;
393
398
  method?: string | null | undefined;
394
399
  verifiedAt?: NativeDate | null | undefined;
395
400
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
401
+ refundedAt?: NativeDate | null | undefined;
396
402
  reference?: string | null | undefined;
397
403
  } & {
398
404
  _id: mongoose.Types.ObjectId;
@@ -405,11 +411,13 @@ declare const _default: {
405
411
  } | {
406
412
  [x: string]: mongoose.SchemaDefinitionProperty<any, any, mongoose.Document<unknown, {}, {
407
413
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
414
+ refundedAmount: number;
408
415
  transactionId?: mongoose.Types.ObjectId | null | undefined;
409
416
  amount?: number | null | undefined;
410
417
  method?: string | null | undefined;
411
418
  verifiedAt?: NativeDate | null | undefined;
412
419
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
420
+ refundedAt?: NativeDate | null | undefined;
413
421
  reference?: string | null | undefined;
414
422
  }, {
415
423
  id: string;
@@ -417,11 +425,13 @@ declare const _default: {
417
425
  _id: false;
418
426
  }>> & Omit<{
419
427
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
428
+ refundedAmount: number;
420
429
  transactionId?: mongoose.Types.ObjectId | null | undefined;
421
430
  amount?: number | null | undefined;
422
431
  method?: string | null | undefined;
423
432
  verifiedAt?: NativeDate | null | undefined;
424
433
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
434
+ refundedAt?: NativeDate | null | undefined;
425
435
  reference?: string | null | undefined;
426
436
  } & {
427
437
  _id: mongoose.Types.ObjectId;
@@ -432,11 +442,13 @@ declare const _default: {
432
442
  }> | undefined;
433
443
  }, {
434
444
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
445
+ refundedAmount: number;
435
446
  transactionId?: mongoose.Types.ObjectId | null | undefined;
436
447
  amount?: number | null | undefined;
437
448
  method?: string | null | undefined;
438
449
  verifiedAt?: NativeDate | null | undefined;
439
450
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
451
+ refundedAt?: NativeDate | null | undefined;
440
452
  reference?: string | null | undefined;
441
453
  } & {
442
454
  _id: mongoose.Types.ObjectId;
@@ -156,6 +156,15 @@ var currentPaymentSchema = new Schema(
156
156
  verifiedBy: {
157
157
  type: Schema.Types.ObjectId,
158
158
  ref: "User"
159
+ },
160
+ // Refund tracking fields
161
+ refundedAmount: {
162
+ type: Number,
163
+ default: 0,
164
+ min: 0
165
+ },
166
+ refundedAt: {
167
+ type: Date
159
168
  }
160
169
  },
161
170
  { _id: false }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schemas/transaction/common.schema.ts","../../src/schemas/transaction/gateway.schema.ts","../../src/enums/payment.enums.ts","../../src/enums/subscription.enums.ts","../../src/enums/escrow.enums.ts","../../src/enums/split.enums.ts","../../src/schemas/transaction/payment.schema.ts","../../src/schemas/transaction/commission.schema.ts","../../src/schemas/transaction/index.ts","../../src/schemas/subscription/plan.schema.ts","../../src/schemas/subscription/info.schema.ts","../../src/schemas/subscription/index.ts","../../src/schemas/escrow/hold.schema.ts","../../src/schemas/escrow/index.ts","../../src/schemas/split/split.schema.ts","../../src/schemas/split/index.ts","../../src/schemas/index.ts"],"names":["Schema"],"mappings":";;;;AAYO,IAAM,qBAAqB,IAAI,MAAA;AAAA,EACpC;AAAA;AAAA,GAEA;AAAA,EACA,EAAE,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,KAAA;AACxB;AAKO,IAAM,eAAA,GAAkB;AAAA,EAC7B,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,OAAO,KAAA,CAAM,QAAA;AAAA,IACnB,OAAA,EAAS,gBAAA;AAAA,IACT,KAAA,EAAO;AAAA,GACT;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,IA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,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACR;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,IAAA,EAAM;AAAA,KACR;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAMA,OAAO,KAAA,CAAM,KAAA;AAAA,MACnB,SAAS;AAAC;AACZ,GACF;AAAA,EACA,EAAE,KAAK,KAAA;AACT;AAEA,IAAO,oBAAA,GAAQ,WAAA;;;AChFf,IAAO,aAAA,GAAQ;AAAA,EACb,WAAA,EAAA;AACF,CAAA;;;ACUA,IAAO,eAAA,GAAQ;AAAA,EACb,GAAG,mBAAA;AAAA,EACH,GAAG,oBAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG;AACL","file":"index.js","sourcesContent":["/**\r\n * Common Transaction Schemas\r\n * @classytic/revenue\r\n *\r\n * Base schemas shared across transaction types\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Base metadata schema for transactions\r\n */\r\nexport const baseMetadataSchema = new Schema(\r\n {\r\n // Flexible key-value metadata\r\n },\r\n { _id: false, strict: false }\r\n);\r\n\r\n/**\r\n * Reference schema for polymorphic associations\r\n */\r\nexport const referenceSchema = {\r\n referenceId: {\r\n type: Schema.Types.ObjectId,\r\n refPath: 'referenceModel',\r\n index: true,\r\n },\r\n referenceModel: {\r\n type: String,\r\n enum: ['Subscription', 'Order', 'Membership', 'Booking', 'Invoice'],\r\n },\r\n};\r\n\r\nexport default {\r\n baseMetadataSchema,\r\n referenceSchema,\r\n};\r\n\r\n","/**\r\n * Gateway Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for payment gateway information\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Gateway Schema - Embedded in Transaction\r\n * Tracks payment gateway details\r\n */\r\nexport const gatewaySchema = new Schema(\r\n {\r\n type: {\r\n type: String,\r\n required: true,\r\n index: true,\r\n },\r\n sessionId: {\r\n type: String,\r\n sparse: true,\r\n index: true,\r\n },\r\n paymentIntentId: {\r\n type: String,\r\n sparse: true,\r\n index: true,\r\n },\r\n provider: {\r\n type: String,\r\n },\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n verificationData: {\r\n type: Schema.Types.Mixed,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default gatewaySchema;\r\n\r\n","/**\r\n * Payment Enums\r\n * @classytic/revenue\r\n *\r\n * Library-managed payment enums only.\r\n * Users define their own payment methods in their schema.\r\n */\r\n\r\n// ============ PAYMENT STATUS ============\r\n/**\r\n * Payment Status - Library-managed states\r\n */\r\nexport const PAYMENT_STATUS = {\r\n PENDING: 'pending',\r\n VERIFIED: 'verified',\r\n FAILED: 'failed',\r\n REFUNDED: 'refunded',\r\n CANCELLED: 'cancelled',\r\n} as const;\r\n\r\nexport type PaymentStatus = typeof PAYMENT_STATUS;\r\nexport type PaymentStatusValue = PaymentStatus[keyof PaymentStatus];\r\nexport const PAYMENT_STATUS_VALUES = Object.values(PAYMENT_STATUS);\r\n\r\n// ============ PAYMENT GATEWAY TYPES ============\r\n/**\r\n * Common gateway type constants for convenience\r\n *\r\n * ⚠️ IMPORTANT: These are NOT restrictions - just common reference values\r\n *\r\n * You can register ANY custom gateway provider by passing it to createRevenue():\r\n *\r\n * @example\r\n * ```typescript\r\n * const revenue = createRevenue({\r\n * providers: {\r\n * manual: new ManualProvider(),\r\n * bkash: new BkashProvider(), // ✅ Custom gateway\r\n * nagad: new NagadProvider(), // ✅ Custom gateway\r\n * stripe: new StripeProvider(), // ✅ Custom gateway\r\n * paypal: new PaypalProvider(), // ✅ Any gateway you want\r\n * }\r\n * });\r\n *\r\n * // Use by name\r\n * await revenue.monetization.create({ gateway: 'bkash', ... });\r\n * ```\r\n *\r\n * Reference values:\r\n * - MANUAL: Built-in manual provider (@classytic/revenue-manual)\r\n * - STRIPE: Stripe provider (build with @classytic/revenue-stripe)\r\n * - SSLCOMMERZ: SSLCommerz provider (build with @classytic/revenue-sslcommerz)\r\n *\r\n * Add your own: bkash, nagad, rocket, paypal, razorpay, flutterwave, etc.\r\n */\r\nexport const PAYMENT_GATEWAY_TYPE = {\r\n MANUAL: 'manual',\r\n STRIPE: 'stripe',\r\n SSLCOMMERZ: 'sslcommerz',\r\n} as const;\r\n\r\nexport type PaymentGatewayType = typeof PAYMENT_GATEWAY_TYPE;\r\nexport type PaymentGatewayTypeValue = PaymentGatewayType[keyof PaymentGatewayType];\r\nexport const PAYMENT_GATEWAY_TYPE_VALUES = Object.values(PAYMENT_GATEWAY_TYPE);\r\n\r\n// Backward compatibility alias\r\nexport const GATEWAY_TYPES = PAYMENT_GATEWAY_TYPE;\r\nexport const GATEWAY_TYPE_VALUES = PAYMENT_GATEWAY_TYPE_VALUES;\r\n\r\n","/**\r\n * Subscription Enums\r\n * @classytic/revenue\r\n *\r\n * All subscription-related enums and constants\r\n */\r\n\r\n// ============ SUBSCRIPTION STATUS ============\r\n/**\r\n * Subscription Status\r\n */\r\nexport const SUBSCRIPTION_STATUS = {\r\n ACTIVE: 'active',\r\n PAUSED: 'paused',\r\n CANCELLED: 'cancelled',\r\n EXPIRED: 'expired',\r\n PENDING: 'pending',\r\n INACTIVE: 'inactive',\r\n} as const;\r\n\r\nexport type SubscriptionStatus = typeof SUBSCRIPTION_STATUS;\r\nexport type SubscriptionStatusValue = SubscriptionStatus[keyof SubscriptionStatus];\r\nexport const SUBSCRIPTION_STATUS_VALUES = Object.values(SUBSCRIPTION_STATUS);\r\n\r\n// ============ PLAN KEYS ============\r\n/**\r\n * Supported plan intervals\r\n */\r\nexport const PLAN_KEYS = {\r\n MONTHLY: 'monthly',\r\n QUARTERLY: 'quarterly',\r\n YEARLY: 'yearly',\r\n} as const;\r\n\r\nexport type PlanKeys = typeof PLAN_KEYS;\r\nexport type PlanKeyValue = PlanKeys[keyof PlanKeys];\r\nexport const PLAN_KEY_VALUES = Object.values(PLAN_KEYS);\r\n\r\n","/**\r\n * Escrow/Hold Enums\r\n * @classytic/revenue\r\n *\r\n * Enums for platform-as-intermediary payment flow\r\n */\r\n\r\nexport const HOLD_STATUS = {\r\n PENDING: 'pending',\r\n HELD: 'held',\r\n RELEASED: 'released',\r\n CANCELLED: 'cancelled',\r\n EXPIRED: 'expired',\r\n PARTIALLY_RELEASED: 'partially_released',\r\n} as const;\r\n\r\nexport type HoldStatus = typeof HOLD_STATUS;\r\nexport type HoldStatusValue = HoldStatus[keyof HoldStatus];\r\nexport const HOLD_STATUS_VALUES = Object.values(HOLD_STATUS);\r\n\r\nexport const RELEASE_REASON = {\r\n PAYMENT_VERIFIED: 'payment_verified',\r\n MANUAL_RELEASE: 'manual_release',\r\n AUTO_RELEASE: 'auto_release',\r\n DISPUTE_RESOLVED: 'dispute_resolved',\r\n} as const;\r\n\r\nexport type ReleaseReason = typeof RELEASE_REASON;\r\nexport type ReleaseReasonValue = ReleaseReason[keyof ReleaseReason];\r\nexport const RELEASE_REASON_VALUES = Object.values(RELEASE_REASON);\r\n\r\nexport const HOLD_REASON = {\r\n PAYMENT_VERIFICATION: 'payment_verification',\r\n FRAUD_CHECK: 'fraud_check',\r\n MANUAL_REVIEW: 'manual_review',\r\n DISPUTE: 'dispute',\r\n COMPLIANCE: 'compliance',\r\n} as const;\r\n\r\nexport type HoldReason = typeof HOLD_REASON;\r\nexport type HoldReasonValue = HoldReason[keyof HoldReason];\r\nexport const HOLD_REASON_VALUES = Object.values(HOLD_REASON);\r\n\r\n","/**\r\n * Split Payment Enums\r\n * @classytic/revenue\r\n *\r\n * Enums for multi-party commission splits\r\n */\r\n\r\nexport const SPLIT_TYPE = {\r\n PLATFORM_COMMISSION: 'platform_commission',\r\n AFFILIATE_COMMISSION: 'affiliate_commission',\r\n REFERRAL_COMMISSION: 'referral_commission',\r\n PARTNER_COMMISSION: 'partner_commission',\r\n CUSTOM: 'custom',\r\n} as const;\r\n\r\nexport type SplitType = typeof SPLIT_TYPE;\r\nexport type SplitTypeValue = SplitType[keyof SplitType];\r\nexport const SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);\r\n\r\nexport const SPLIT_STATUS = {\r\n PENDING: 'pending',\r\n DUE: 'due',\r\n PAID: 'paid',\r\n WAIVED: 'waived',\r\n CANCELLED: 'cancelled',\r\n} as const;\r\n\r\nexport type SplitStatus = typeof SPLIT_STATUS;\r\nexport type SplitStatusValue = SplitStatus[keyof SplitStatus];\r\nexport const SPLIT_STATUS_VALUES = Object.values(SPLIT_STATUS);\r\n\r\nexport const PAYOUT_METHOD = {\r\n BANK_TRANSFER: 'bank_transfer',\r\n MOBILE_WALLET: 'mobile_wallet',\r\n PLATFORM_BALANCE: 'platform_balance',\r\n CRYPTO: 'crypto',\r\n CHECK: 'check',\r\n MANUAL: 'manual',\r\n} as const;\r\n\r\nexport type PayoutMethod = typeof PAYOUT_METHOD;\r\nexport type PayoutMethodValue = PayoutMethod[keyof PayoutMethod];\r\nexport const PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);\r\n\r\n","/**\r\n * Payment Schemas for Transaction Model\r\n * @classytic/revenue\r\n *\r\n * Schemas for payment tracking in transactions\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport {\r\n PAYMENT_STATUS_VALUES,\r\n} from '../../enums/index.js';\r\n\r\n/**\r\n * Current Payment Schema\r\n * Use this in your model: currentPayment: { type: currentPaymentSchema }\r\n *\r\n * Tracks the latest payment transaction for an entity\r\n */\r\nexport const currentPaymentSchema = new Schema(\r\n {\r\n transactionId: {\r\n type: Schema.Types.ObjectId,\r\n ref: 'Transaction',\r\n index: true,\r\n },\r\n amount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n status: {\r\n type: String,\r\n enum: PAYMENT_STATUS_VALUES,\r\n default: 'pending',\r\n index: true,\r\n },\r\n method: {\r\n type: String,\r\n // Users define payment methods in their transaction model\r\n },\r\n reference: {\r\n type: String,\r\n trim: true,\r\n },\r\n verifiedAt: {\r\n type: Date,\r\n },\r\n verifiedBy: {\r\n type: Schema.Types.ObjectId,\r\n ref: 'User',\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Payment Summary Schema\r\n * Use this in your model: paymentSummary: { type: paymentSummarySchema }\r\n *\r\n * Tracks payment history and totals\r\n */\r\nexport const paymentSummarySchema = new Schema(\r\n {\r\n totalPayments: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n totalAmountPaid: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n lastPaymentDate: {\r\n type: Date,\r\n },\r\n lastPaymentAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Payment Details Schema (for manual payments)\r\n * Embedded in Transaction model\r\n */\r\nexport const paymentDetailsSchema = new Schema(\r\n {\r\n provider: { type: String },\r\n walletNumber: { type: String },\r\n walletType: { type: String },\r\n trxId: { type: String },\r\n bankName: { type: String },\r\n accountNumber: { type: String },\r\n accountName: { type: String },\r\n proofUrl: { type: String },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Tenant Snapshot Schema\r\n * Captures organization payment details at transaction time (audit trail)\r\n */\r\nexport const tenantSnapshotSchema = new Schema(\r\n {\r\n paymentInstructions: { type: String },\r\n bkashNumber: { type: String },\r\n nagadNumber: { type: String },\r\n bankAccount: { type: String },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default {\r\n currentPaymentSchema,\r\n paymentSummarySchema,\r\n paymentDetailsSchema,\r\n tenantSnapshotSchema,\r\n};\r\n\r\n","/**\r\n * Commission Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for platform commission tracking\r\n * Embedded in Transaction model\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Commission Schema - Embedded in Transaction\r\n * Tracks platform commission with gateway fee deduction\r\n *\r\n * Usage: commission: commissionSchema\r\n */\r\nexport const commissionSchema = new Schema(\r\n {\r\n // Commission rate (e.g., 0.10 for 10%)\r\n rate: {\r\n type: Number,\r\n min: 0,\r\n max: 1,\r\n },\r\n // Gross commission amount (before gateway fees)\r\n grossAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Gateway fee rate (e.g., 0.029 for 2.9%)\r\n gatewayFeeRate: {\r\n type: Number,\r\n min: 0,\r\n max: 1,\r\n },\r\n // Gateway fee amount deducted from commission\r\n gatewayFeeAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Net commission (grossAmount - gatewayFeeAmount)\r\n netAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Commission status\r\n status: {\r\n type: String,\r\n enum: ['pending', 'paid', 'waived', 'reversed'],\r\n default: 'pending',\r\n },\r\n // For affiliate tracking\r\n affiliate: {\r\n recipientId: String,\r\n recipientType: {\r\n type: String,\r\n enum: ['user', 'organization', 'partner'],\r\n },\r\n rate: Number,\r\n grossAmount: Number,\r\n netAmount: Number,\r\n },\r\n // For multi-party splits\r\n splits: [\r\n {\r\n type: String,\r\n recipientId: String,\r\n rate: Number,\r\n grossAmount: Number,\r\n netAmount: Number,\r\n },\r\n ],\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default commissionSchema;\r\n\r\n","/**\r\n * Transaction Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport * from './common.schema.js';\r\nexport * from './gateway.schema.js';\r\nexport * from './payment.schema.js';\r\nexport * from './commission.schema.js';\r\n\r\nimport { baseMetadataSchema, referenceSchema } from './common.schema.js';\r\nimport gatewaySchema from './gateway.schema.js';\r\nimport paymentSchemas from './payment.schema.js';\r\nimport commissionSchema from './commission.schema.js';\r\n\r\nexport default {\r\n baseMetadataSchema,\r\n referenceSchema,\r\n gatewaySchema,\r\n commissionSchema,\r\n ...paymentSchemas,\r\n};\r\n\r\n","/**\r\n * Plan Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for subscription plans\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport { PLAN_KEY_VALUES } from '../../enums/subscription.enums.js';\r\n\r\n/**\r\n * Plan Schema - for defining subscription plans\r\n */\r\nexport const planSchema = new Schema(\r\n {\r\n key: {\r\n type: String,\r\n enum: PLAN_KEY_VALUES,\r\n required: true,\r\n },\r\n name: {\r\n type: String,\r\n required: true,\r\n },\r\n description: {\r\n type: String,\r\n },\r\n amount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n currency: {\r\n type: String,\r\n default: 'BDT',\r\n },\r\n interval: {\r\n type: String,\r\n enum: ['day', 'week', 'month', 'year'],\r\n default: 'month',\r\n },\r\n intervalCount: {\r\n type: Number,\r\n default: 1,\r\n min: 1,\r\n },\r\n features: [\r\n {\r\n type: String,\r\n },\r\n ],\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n isActive: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default planSchema;\r\n\r\n","/**\r\n * Subscription Info Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for subscription information embedded in entities\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport { SUBSCRIPTION_STATUS_VALUES, PLAN_KEY_VALUES } from '../../enums/subscription.enums.js';\r\n\r\n/**\r\n * Subscription Info Schema\r\n * Use this in your entity models that have subscriptions\r\n *\r\n * @example\r\n * const OrganizationSchema = new Schema({\r\n * name: String,\r\n * subscription: { type: subscriptionInfoSchema },\r\n * });\r\n */\r\nexport const subscriptionInfoSchema = new Schema(\r\n {\r\n planKey: {\r\n type: String,\r\n enum: PLAN_KEY_VALUES,\r\n required: true,\r\n },\r\n status: {\r\n type: String,\r\n enum: SUBSCRIPTION_STATUS_VALUES,\r\n default: 'pending',\r\n index: true,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n default: false,\r\n index: true,\r\n },\r\n startDate: {\r\n type: Date,\r\n },\r\n endDate: {\r\n type: Date,\r\n index: true,\r\n },\r\n canceledAt: {\r\n type: Date,\r\n },\r\n cancelAt: {\r\n type: Date,\r\n },\r\n pausedAt: {\r\n type: Date,\r\n },\r\n lastPaymentDate: {\r\n type: Date,\r\n },\r\n lastPaymentAmount: {\r\n type: Number,\r\n },\r\n renewalCount: {\r\n type: Number,\r\n default: 0,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default subscriptionInfoSchema;\r\n\r\n","/**\r\n * Subscription Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { planSchema } from './plan.schema.js';\r\nexport { subscriptionInfoSchema } from './info.schema.js';\r\n\r\nimport planSchema from './plan.schema.js';\r\nimport subscriptionInfoSchema from './info.schema.js';\r\n\r\nexport default {\r\n planSchema,\r\n subscriptionInfoSchema,\r\n};\r\n\r\n","/**\r\n * Hold/Escrow Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for platform-as-intermediary escrow flow\r\n * Spread into transaction schema when needed\r\n */\r\n\r\nimport { HOLD_STATUS, HOLD_STATUS_VALUES, HOLD_REASON_VALUES } from '../../enums/escrow.enums.js';\r\n\r\nexport const holdSchema = {\r\n status: {\r\n type: String,\r\n enum: HOLD_STATUS_VALUES,\r\n default: HOLD_STATUS.PENDING,\r\n index: true,\r\n },\r\n\r\n heldAmount: {\r\n type: Number,\r\n required: false,\r\n },\r\n\r\n releasedAmount: {\r\n type: Number,\r\n default: 0,\r\n },\r\n\r\n reason: {\r\n type: String,\r\n enum: HOLD_REASON_VALUES,\r\n required: false,\r\n },\r\n\r\n holdUntil: {\r\n type: Date,\r\n required: false,\r\n },\r\n\r\n heldAt: Date,\r\n releasedAt: Date,\r\n cancelledAt: Date,\r\n\r\n releases: [\r\n {\r\n amount: Number,\r\n recipientId: String,\r\n recipientType: String,\r\n releasedAt: Date,\r\n releasedBy: String,\r\n reason: String,\r\n metadata: Object,\r\n },\r\n ],\r\n\r\n metadata: {\r\n type: Object,\r\n default: {},\r\n },\r\n} as const;\r\n\r\nexport default holdSchema;\r\n\r\n","/**\r\n * Escrow Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { holdSchema } from './hold.schema.js';\r\n\r\nimport holdSchema from './hold.schema.js';\r\n\r\nexport default {\r\n holdSchema,\r\n};\r\n\r\n","/**\r\n * Split Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for multi-party commission splits\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport {\r\n SPLIT_TYPE_VALUES,\r\n SPLIT_STATUS,\r\n SPLIT_STATUS_VALUES,\r\n PAYOUT_METHOD_VALUES,\r\n} from '../../enums/split.enums.js';\r\n\r\n/**\r\n * Split Schema - Embedded in Transaction\r\n */\r\nexport const splitSchema = new Schema(\r\n {\r\n type: {\r\n type: String,\r\n enum: SPLIT_TYPE_VALUES,\r\n required: true,\r\n },\r\n recipientId: {\r\n type: String,\r\n required: true,\r\n index: true,\r\n },\r\n recipientType: {\r\n type: String,\r\n enum: ['platform', 'organization', 'user', 'affiliate', 'partner'],\r\n required: true,\r\n },\r\n rate: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n max: 1,\r\n },\r\n grossAmount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n gatewayFeeRate: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n max: 1,\r\n },\r\n gatewayFeeAmount: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n netAmount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n status: {\r\n type: String,\r\n enum: SPLIT_STATUS_VALUES,\r\n default: SPLIT_STATUS.PENDING,\r\n index: true,\r\n },\r\n dueDate: {\r\n type: Date,\r\n },\r\n paidDate: {\r\n type: Date,\r\n },\r\n payoutMethod: {\r\n type: String,\r\n enum: PAYOUT_METHOD_VALUES,\r\n },\r\n payoutTransactionId: {\r\n type: String,\r\n },\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default splitSchema;\r\n\r\n","/**\r\n * Split Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { splitSchema } from './split.schema.js';\r\n\r\nimport splitSchema from './split.schema.js';\r\n\r\nexport default {\r\n splitSchema,\r\n};\r\n\r\n","/**\r\n * Schema Index\r\n * @classytic/revenue\r\n *\r\n * Core schemas for injection into your models\r\n *\r\n * Note: Enums are separate. Import them from '@classytic/revenue/enums'\r\n */\r\n\r\n// Re-export core schemas only\r\nexport * from './transaction/index.js';\r\nexport * from './subscription/index.js';\r\nexport * from './escrow/index.js';\r\nexport * from './split/index.js';\r\n\r\n// Default export with core schemas\r\nimport transactionSchemas from './transaction/index.js';\r\nimport subscriptionSchemas from './subscription/index.js';\r\nimport escrowSchemas from './escrow/index.js';\r\nimport splitSchemas from './split/index.js';\r\n\r\nexport default {\r\n ...transactionSchemas,\r\n ...subscriptionSchemas,\r\n ...escrowSchemas,\r\n ...splitSchemas,\r\n};\r\n\r\n"]}
1
+ {"version":3,"sources":["../../src/schemas/transaction/common.schema.ts","../../src/schemas/transaction/gateway.schema.ts","../../src/enums/payment.enums.ts","../../src/enums/subscription.enums.ts","../../src/enums/escrow.enums.ts","../../src/enums/split.enums.ts","../../src/schemas/transaction/payment.schema.ts","../../src/schemas/transaction/commission.schema.ts","../../src/schemas/transaction/index.ts","../../src/schemas/subscription/plan.schema.ts","../../src/schemas/subscription/info.schema.ts","../../src/schemas/subscription/index.ts","../../src/schemas/escrow/hold.schema.ts","../../src/schemas/escrow/index.ts","../../src/schemas/split/split.schema.ts","../../src/schemas/split/index.ts","../../src/schemas/index.ts"],"names":["Schema"],"mappings":";;;;AAYO,IAAM,qBAAqB,IAAI,MAAA;AAAA,EACpC;AAAA;AAAA,GAEA;AAAA,EACA,EAAE,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,KAAA;AACxB;AAKO,IAAM,eAAA,GAAkB;AAAA,EAC7B,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,OAAO,KAAA,CAAM,QAAA;AAAA,IACnB,OAAA,EAAS,gBAAA;AAAA,IACT,KAAA,EAAO;AAAA,GACT;AAAA,EACA,cAAA,E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AAA,CAAa,OAAA;AAAA,MACtB,KAAA,EAAO;AAAA,KACT;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM;AAAA,KACR;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM;AAAA,KACR;AAAA,IACA,YAAA,EAAc;AAAA,MACZ,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACR;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,IAAA,EAAM;AAAA,KACR;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAMA,OAAO,KAAA,CAAM,KAAA;AAAA,MACnB,SAAS;AAAC;AACZ,GACF;AAAA,EACA,EAAE,KAAK,KAAA;AACT;AAEA,IAAO,oBAAA,GAAQ,WAAA;;;AChFf,IAAO,aAAA,GAAQ;AAAA,EACb,WAAA,EAAA;AACF,CAAA;;;ACUA,IAAO,eAAA,GAAQ;AAAA,EACb,GAAG,mBAAA;AAAA,EACH,GAAG,oBAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG;AACL","file":"index.js","sourcesContent":["/**\r\n * Common Transaction Schemas\r\n * @classytic/revenue\r\n *\r\n * Base schemas shared across transaction types\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Base metadata schema for transactions\r\n */\r\nexport const baseMetadataSchema = new Schema(\r\n {\r\n // Flexible key-value metadata\r\n },\r\n { _id: false, strict: false }\r\n);\r\n\r\n/**\r\n * Reference schema for polymorphic associations\r\n */\r\nexport const referenceSchema = {\r\n referenceId: {\r\n type: Schema.Types.ObjectId,\r\n refPath: 'referenceModel',\r\n index: true,\r\n },\r\n referenceModel: {\r\n type: String,\r\n enum: ['Subscription', 'Order', 'Membership', 'Booking', 'Invoice'],\r\n },\r\n};\r\n\r\nexport default {\r\n baseMetadataSchema,\r\n referenceSchema,\r\n};\r\n\r\n","/**\r\n * Gateway Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for payment gateway information\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Gateway Schema - Embedded in Transaction\r\n * Tracks payment gateway details\r\n */\r\nexport const gatewaySchema = new Schema(\r\n {\r\n type: {\r\n type: String,\r\n required: true,\r\n index: true,\r\n },\r\n sessionId: {\r\n type: String,\r\n sparse: true,\r\n index: true,\r\n },\r\n paymentIntentId: {\r\n type: String,\r\n sparse: true,\r\n index: true,\r\n },\r\n provider: {\r\n type: String,\r\n },\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n verificationData: {\r\n type: Schema.Types.Mixed,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default gatewaySchema;\r\n\r\n","/**\r\n * Payment Enums\r\n * @classytic/revenue\r\n *\r\n * Library-managed payment enums only.\r\n * Users define their own payment methods in their schema.\r\n */\r\n\r\n// ============ PAYMENT STATUS ============\r\n/**\r\n * Payment Status - Library-managed states\r\n */\r\nexport const PAYMENT_STATUS = {\r\n PENDING: 'pending',\r\n VERIFIED: 'verified',\r\n FAILED: 'failed',\r\n REFUNDED: 'refunded',\r\n CANCELLED: 'cancelled',\r\n} as const;\r\n\r\nexport type PaymentStatus = typeof PAYMENT_STATUS;\r\nexport type PaymentStatusValue = PaymentStatus[keyof PaymentStatus];\r\nexport const PAYMENT_STATUS_VALUES = Object.values(PAYMENT_STATUS);\r\n\r\n// ============ PAYMENT GATEWAY TYPES ============\r\n/**\r\n * Common gateway type constants for convenience\r\n *\r\n * ⚠️ IMPORTANT: These are NOT restrictions - just common reference values\r\n *\r\n * You can register ANY custom gateway provider by passing it to createRevenue():\r\n *\r\n * @example\r\n * ```typescript\r\n * const revenue = createRevenue({\r\n * providers: {\r\n * manual: new ManualProvider(),\r\n * bkash: new BkashProvider(), // ✅ Custom gateway\r\n * nagad: new NagadProvider(), // ✅ Custom gateway\r\n * stripe: new StripeProvider(), // ✅ Custom gateway\r\n * paypal: new PaypalProvider(), // ✅ Any gateway you want\r\n * }\r\n * });\r\n *\r\n * // Use by name\r\n * await revenue.monetization.create({ gateway: 'bkash', ... });\r\n * ```\r\n *\r\n * Reference values:\r\n * - MANUAL: Built-in manual provider (@classytic/revenue-manual)\r\n * - STRIPE: Stripe provider (build with @classytic/revenue-stripe)\r\n * - SSLCOMMERZ: SSLCommerz provider (build with @classytic/revenue-sslcommerz)\r\n *\r\n * Add your own: bkash, nagad, rocket, paypal, razorpay, flutterwave, etc.\r\n */\r\nexport const PAYMENT_GATEWAY_TYPE = {\r\n MANUAL: 'manual',\r\n STRIPE: 'stripe',\r\n SSLCOMMERZ: 'sslcommerz',\r\n} as const;\r\n\r\nexport type PaymentGatewayType = typeof PAYMENT_GATEWAY_TYPE;\r\nexport type PaymentGatewayTypeValue = PaymentGatewayType[keyof PaymentGatewayType];\r\nexport const PAYMENT_GATEWAY_TYPE_VALUES = Object.values(PAYMENT_GATEWAY_TYPE);\r\n\r\n// Backward compatibility alias\r\nexport const GATEWAY_TYPES = PAYMENT_GATEWAY_TYPE;\r\nexport const GATEWAY_TYPE_VALUES = PAYMENT_GATEWAY_TYPE_VALUES;\r\n\r\n","/**\r\n * Subscription Enums\r\n * @classytic/revenue\r\n *\r\n * All subscription-related enums and constants\r\n */\r\n\r\n// ============ SUBSCRIPTION STATUS ============\r\n/**\r\n * Subscription Status\r\n */\r\nexport const SUBSCRIPTION_STATUS = {\r\n ACTIVE: 'active',\r\n PAUSED: 'paused',\r\n CANCELLED: 'cancelled',\r\n EXPIRED: 'expired',\r\n PENDING: 'pending',\r\n INACTIVE: 'inactive',\r\n} as const;\r\n\r\nexport type SubscriptionStatus = typeof SUBSCRIPTION_STATUS;\r\nexport type SubscriptionStatusValue = SubscriptionStatus[keyof SubscriptionStatus];\r\nexport const SUBSCRIPTION_STATUS_VALUES = Object.values(SUBSCRIPTION_STATUS);\r\n\r\n// ============ PLAN KEYS ============\r\n/**\r\n * Supported plan intervals\r\n */\r\nexport const PLAN_KEYS = {\r\n MONTHLY: 'monthly',\r\n QUARTERLY: 'quarterly',\r\n YEARLY: 'yearly',\r\n} as const;\r\n\r\nexport type PlanKeys = typeof PLAN_KEYS;\r\nexport type PlanKeyValue = PlanKeys[keyof PlanKeys];\r\nexport const PLAN_KEY_VALUES = Object.values(PLAN_KEYS);\r\n\r\n","/**\r\n * Escrow/Hold Enums\r\n * @classytic/revenue\r\n *\r\n * Enums for platform-as-intermediary payment flow\r\n */\r\n\r\nexport const HOLD_STATUS = {\r\n PENDING: 'pending',\r\n HELD: 'held',\r\n RELEASED: 'released',\r\n CANCELLED: 'cancelled',\r\n EXPIRED: 'expired',\r\n PARTIALLY_RELEASED: 'partially_released',\r\n} as const;\r\n\r\nexport type HoldStatus = typeof HOLD_STATUS;\r\nexport type HoldStatusValue = HoldStatus[keyof HoldStatus];\r\nexport const HOLD_STATUS_VALUES = Object.values(HOLD_STATUS);\r\n\r\nexport const RELEASE_REASON = {\r\n PAYMENT_VERIFIED: 'payment_verified',\r\n MANUAL_RELEASE: 'manual_release',\r\n AUTO_RELEASE: 'auto_release',\r\n DISPUTE_RESOLVED: 'dispute_resolved',\r\n} as const;\r\n\r\nexport type ReleaseReason = typeof RELEASE_REASON;\r\nexport type ReleaseReasonValue = ReleaseReason[keyof ReleaseReason];\r\nexport const RELEASE_REASON_VALUES = Object.values(RELEASE_REASON);\r\n\r\nexport const HOLD_REASON = {\r\n PAYMENT_VERIFICATION: 'payment_verification',\r\n FRAUD_CHECK: 'fraud_check',\r\n MANUAL_REVIEW: 'manual_review',\r\n DISPUTE: 'dispute',\r\n COMPLIANCE: 'compliance',\r\n} as const;\r\n\r\nexport type HoldReason = typeof HOLD_REASON;\r\nexport type HoldReasonValue = HoldReason[keyof HoldReason];\r\nexport const HOLD_REASON_VALUES = Object.values(HOLD_REASON);\r\n\r\n","/**\r\n * Split Payment Enums\r\n * @classytic/revenue\r\n *\r\n * Enums for multi-party commission splits\r\n */\r\n\r\nexport const SPLIT_TYPE = {\r\n PLATFORM_COMMISSION: 'platform_commission',\r\n AFFILIATE_COMMISSION: 'affiliate_commission',\r\n REFERRAL_COMMISSION: 'referral_commission',\r\n PARTNER_COMMISSION: 'partner_commission',\r\n CUSTOM: 'custom',\r\n} as const;\r\n\r\nexport type SplitType = typeof SPLIT_TYPE;\r\nexport type SplitTypeValue = SplitType[keyof SplitType];\r\nexport const SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);\r\n\r\nexport const SPLIT_STATUS = {\r\n PENDING: 'pending',\r\n DUE: 'due',\r\n PAID: 'paid',\r\n WAIVED: 'waived',\r\n CANCELLED: 'cancelled',\r\n} as const;\r\n\r\nexport type SplitStatus = typeof SPLIT_STATUS;\r\nexport type SplitStatusValue = SplitStatus[keyof SplitStatus];\r\nexport const SPLIT_STATUS_VALUES = Object.values(SPLIT_STATUS);\r\n\r\nexport const PAYOUT_METHOD = {\r\n BANK_TRANSFER: 'bank_transfer',\r\n MOBILE_WALLET: 'mobile_wallet',\r\n PLATFORM_BALANCE: 'platform_balance',\r\n CRYPTO: 'crypto',\r\n CHECK: 'check',\r\n MANUAL: 'manual',\r\n} as const;\r\n\r\nexport type PayoutMethod = typeof PAYOUT_METHOD;\r\nexport type PayoutMethodValue = PayoutMethod[keyof PayoutMethod];\r\nexport const PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);\r\n\r\n","/**\r\n * Payment Schemas for Transaction Model\r\n * @classytic/revenue\r\n *\r\n * Schemas for payment tracking in transactions\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport {\r\n PAYMENT_STATUS_VALUES,\r\n} from '../../enums/index.js';\r\n\r\n/**\r\n * Current Payment Schema\r\n * Use this in your model: currentPayment: { type: currentPaymentSchema }\r\n *\r\n * Tracks the latest payment transaction for an entity\r\n *\r\n * Refund tracking:\r\n * - refundedAmount: Total amount refunded (caps refundable = amount - refundedAmount)\r\n * - refundedAt: When the (last) refund occurred\r\n * - Partial refunds: status remains 'verified' with refundedAmount > 0\r\n * - Full refunds: status should be updated to 'refunded'\r\n */\r\nexport const currentPaymentSchema = new Schema(\r\n {\r\n transactionId: {\r\n type: Schema.Types.ObjectId,\r\n ref: 'Transaction',\r\n index: true,\r\n },\r\n amount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n status: {\r\n type: String,\r\n enum: PAYMENT_STATUS_VALUES,\r\n default: 'pending',\r\n index: true,\r\n },\r\n method: {\r\n type: String,\r\n // Users define payment methods in their transaction model\r\n },\r\n reference: {\r\n type: String,\r\n trim: true,\r\n },\r\n verifiedAt: {\r\n type: Date,\r\n },\r\n verifiedBy: {\r\n type: Schema.Types.ObjectId,\r\n ref: 'User',\r\n },\r\n // Refund tracking fields\r\n refundedAmount: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n refundedAt: {\r\n type: Date,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Payment Summary Schema\r\n * Use this in your model: paymentSummary: { type: paymentSummarySchema }\r\n *\r\n * Tracks payment history and totals\r\n */\r\nexport const paymentSummarySchema = new Schema(\r\n {\r\n totalPayments: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n totalAmountPaid: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n lastPaymentDate: {\r\n type: Date,\r\n },\r\n lastPaymentAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Payment Details Schema (for manual payments)\r\n * Embedded in Transaction model\r\n */\r\nexport const paymentDetailsSchema = new Schema(\r\n {\r\n provider: { type: String },\r\n walletNumber: { type: String },\r\n walletType: { type: String },\r\n trxId: { type: String },\r\n bankName: { type: String },\r\n accountNumber: { type: String },\r\n accountName: { type: String },\r\n proofUrl: { type: String },\r\n },\r\n { _id: false }\r\n);\r\n\r\n/**\r\n * Tenant Snapshot Schema\r\n * Captures organization payment details at transaction time (audit trail)\r\n */\r\nexport const tenantSnapshotSchema = new Schema(\r\n {\r\n paymentInstructions: { type: String },\r\n bkashNumber: { type: String },\r\n nagadNumber: { type: String },\r\n bankAccount: { type: String },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default {\r\n currentPaymentSchema,\r\n paymentSummarySchema,\r\n paymentDetailsSchema,\r\n tenantSnapshotSchema,\r\n};\r\n\r\n","/**\r\n * Commission Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for platform commission tracking\r\n * Embedded in Transaction model\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\n\r\n/**\r\n * Commission Schema - Embedded in Transaction\r\n * Tracks platform commission with gateway fee deduction\r\n *\r\n * Usage: commission: commissionSchema\r\n */\r\nexport const commissionSchema = new Schema(\r\n {\r\n // Commission rate (e.g., 0.10 for 10%)\r\n rate: {\r\n type: Number,\r\n min: 0,\r\n max: 1,\r\n },\r\n // Gross commission amount (before gateway fees)\r\n grossAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Gateway fee rate (e.g., 0.029 for 2.9%)\r\n gatewayFeeRate: {\r\n type: Number,\r\n min: 0,\r\n max: 1,\r\n },\r\n // Gateway fee amount deducted from commission\r\n gatewayFeeAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Net commission (grossAmount - gatewayFeeAmount)\r\n netAmount: {\r\n type: Number,\r\n min: 0,\r\n },\r\n // Commission status\r\n status: {\r\n type: String,\r\n enum: ['pending', 'paid', 'waived', 'reversed'],\r\n default: 'pending',\r\n },\r\n // For affiliate tracking\r\n affiliate: {\r\n recipientId: String,\r\n recipientType: {\r\n type: String,\r\n enum: ['user', 'organization', 'partner'],\r\n },\r\n rate: Number,\r\n grossAmount: Number,\r\n netAmount: Number,\r\n },\r\n // For multi-party splits\r\n splits: [\r\n {\r\n type: String,\r\n recipientId: String,\r\n rate: Number,\r\n grossAmount: Number,\r\n netAmount: Number,\r\n },\r\n ],\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default commissionSchema;\r\n\r\n","/**\r\n * Transaction Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport * from './common.schema.js';\r\nexport * from './gateway.schema.js';\r\nexport * from './payment.schema.js';\r\nexport * from './commission.schema.js';\r\n\r\nimport { baseMetadataSchema, referenceSchema } from './common.schema.js';\r\nimport gatewaySchema from './gateway.schema.js';\r\nimport paymentSchemas from './payment.schema.js';\r\nimport commissionSchema from './commission.schema.js';\r\n\r\nexport default {\r\n baseMetadataSchema,\r\n referenceSchema,\r\n gatewaySchema,\r\n commissionSchema,\r\n ...paymentSchemas,\r\n};\r\n\r\n","/**\r\n * Plan Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for subscription plans\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport { PLAN_KEY_VALUES } from '../../enums/subscription.enums.js';\r\n\r\n/**\r\n * Plan Schema - for defining subscription plans\r\n */\r\nexport const planSchema = new Schema(\r\n {\r\n key: {\r\n type: String,\r\n enum: PLAN_KEY_VALUES,\r\n required: true,\r\n },\r\n name: {\r\n type: String,\r\n required: true,\r\n },\r\n description: {\r\n type: String,\r\n },\r\n amount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n currency: {\r\n type: String,\r\n default: 'BDT',\r\n },\r\n interval: {\r\n type: String,\r\n enum: ['day', 'week', 'month', 'year'],\r\n default: 'month',\r\n },\r\n intervalCount: {\r\n type: Number,\r\n default: 1,\r\n min: 1,\r\n },\r\n features: [\r\n {\r\n type: String,\r\n },\r\n ],\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n isActive: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default planSchema;\r\n\r\n","/**\r\n * Subscription Info Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for subscription information embedded in entities\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport { SUBSCRIPTION_STATUS_VALUES, PLAN_KEY_VALUES } from '../../enums/subscription.enums.js';\r\n\r\n/**\r\n * Subscription Info Schema\r\n * Use this in your entity models that have subscriptions\r\n *\r\n * @example\r\n * const OrganizationSchema = new Schema({\r\n * name: String,\r\n * subscription: { type: subscriptionInfoSchema },\r\n * });\r\n */\r\nexport const subscriptionInfoSchema = new Schema(\r\n {\r\n planKey: {\r\n type: String,\r\n enum: PLAN_KEY_VALUES,\r\n required: true,\r\n },\r\n status: {\r\n type: String,\r\n enum: SUBSCRIPTION_STATUS_VALUES,\r\n default: 'pending',\r\n index: true,\r\n },\r\n isActive: {\r\n type: Boolean,\r\n default: false,\r\n index: true,\r\n },\r\n startDate: {\r\n type: Date,\r\n },\r\n endDate: {\r\n type: Date,\r\n index: true,\r\n },\r\n canceledAt: {\r\n type: Date,\r\n },\r\n cancelAt: {\r\n type: Date,\r\n },\r\n pausedAt: {\r\n type: Date,\r\n },\r\n lastPaymentDate: {\r\n type: Date,\r\n },\r\n lastPaymentAmount: {\r\n type: Number,\r\n },\r\n renewalCount: {\r\n type: Number,\r\n default: 0,\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default subscriptionInfoSchema;\r\n\r\n","/**\r\n * Subscription Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { planSchema } from './plan.schema.js';\r\nexport { subscriptionInfoSchema } from './info.schema.js';\r\n\r\nimport planSchema from './plan.schema.js';\r\nimport subscriptionInfoSchema from './info.schema.js';\r\n\r\nexport default {\r\n planSchema,\r\n subscriptionInfoSchema,\r\n};\r\n\r\n","/**\r\n * Hold/Escrow Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for platform-as-intermediary escrow flow\r\n * Spread into transaction schema when needed\r\n */\r\n\r\nimport { HOLD_STATUS, HOLD_STATUS_VALUES, HOLD_REASON_VALUES } from '../../enums/escrow.enums.js';\r\n\r\nexport const holdSchema = {\r\n status: {\r\n type: String,\r\n enum: HOLD_STATUS_VALUES,\r\n default: HOLD_STATUS.PENDING,\r\n index: true,\r\n },\r\n\r\n heldAmount: {\r\n type: Number,\r\n required: false,\r\n },\r\n\r\n releasedAmount: {\r\n type: Number,\r\n default: 0,\r\n },\r\n\r\n reason: {\r\n type: String,\r\n enum: HOLD_REASON_VALUES,\r\n required: false,\r\n },\r\n\r\n holdUntil: {\r\n type: Date,\r\n required: false,\r\n },\r\n\r\n heldAt: Date,\r\n releasedAt: Date,\r\n cancelledAt: Date,\r\n\r\n releases: [\r\n {\r\n amount: Number,\r\n recipientId: String,\r\n recipientType: String,\r\n releasedAt: Date,\r\n releasedBy: String,\r\n reason: String,\r\n metadata: Object,\r\n },\r\n ],\r\n\r\n metadata: {\r\n type: Object,\r\n default: {},\r\n },\r\n} as const;\r\n\r\nexport default holdSchema;\r\n\r\n","/**\r\n * Escrow Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { holdSchema } from './hold.schema.js';\r\n\r\nimport holdSchema from './hold.schema.js';\r\n\r\nexport default {\r\n holdSchema,\r\n};\r\n\r\n","/**\r\n * Split Schema\r\n * @classytic/revenue\r\n *\r\n * Schema for multi-party commission splits\r\n */\r\n\r\nimport { Schema } from 'mongoose';\r\nimport {\r\n SPLIT_TYPE_VALUES,\r\n SPLIT_STATUS,\r\n SPLIT_STATUS_VALUES,\r\n PAYOUT_METHOD_VALUES,\r\n} from '../../enums/split.enums.js';\r\n\r\n/**\r\n * Split Schema - Embedded in Transaction\r\n */\r\nexport const splitSchema = new Schema(\r\n {\r\n type: {\r\n type: String,\r\n enum: SPLIT_TYPE_VALUES,\r\n required: true,\r\n },\r\n recipientId: {\r\n type: String,\r\n required: true,\r\n index: true,\r\n },\r\n recipientType: {\r\n type: String,\r\n enum: ['platform', 'organization', 'user', 'affiliate', 'partner'],\r\n required: true,\r\n },\r\n rate: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n max: 1,\r\n },\r\n grossAmount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n gatewayFeeRate: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n max: 1,\r\n },\r\n gatewayFeeAmount: {\r\n type: Number,\r\n default: 0,\r\n min: 0,\r\n },\r\n netAmount: {\r\n type: Number,\r\n required: true,\r\n min: 0,\r\n },\r\n status: {\r\n type: String,\r\n enum: SPLIT_STATUS_VALUES,\r\n default: SPLIT_STATUS.PENDING,\r\n index: true,\r\n },\r\n dueDate: {\r\n type: Date,\r\n },\r\n paidDate: {\r\n type: Date,\r\n },\r\n payoutMethod: {\r\n type: String,\r\n enum: PAYOUT_METHOD_VALUES,\r\n },\r\n payoutTransactionId: {\r\n type: String,\r\n },\r\n metadata: {\r\n type: Schema.Types.Mixed,\r\n default: {},\r\n },\r\n },\r\n { _id: false }\r\n);\r\n\r\nexport default splitSchema;\r\n\r\n","/**\r\n * Split Schemas Index\r\n * @classytic/revenue\r\n */\r\n\r\nexport { splitSchema } from './split.schema.js';\r\n\r\nimport splitSchema from './split.schema.js';\r\n\r\nexport default {\r\n splitSchema,\r\n};\r\n\r\n","/**\r\n * Schema Index\r\n * @classytic/revenue\r\n *\r\n * Core schemas for injection into your models\r\n *\r\n * Note: Enums are separate. Import them from '@classytic/revenue/enums'\r\n */\r\n\r\n// Re-export core schemas only\r\nexport * from './transaction/index.js';\r\nexport * from './subscription/index.js';\r\nexport * from './escrow/index.js';\r\nexport * from './split/index.js';\r\n\r\n// Default export with core schemas\r\nimport transactionSchemas from './transaction/index.js';\r\nimport subscriptionSchemas from './subscription/index.js';\r\nimport escrowSchemas from './escrow/index.js';\r\nimport splitSchemas from './split/index.js';\r\n\r\nexport default {\r\n ...transactionSchemas,\r\n ...subscriptionSchemas,\r\n ...escrowSchemas,\r\n ...splitSchemas,\r\n};\r\n\r\n"]}
@@ -136,24 +136,34 @@ declare const gatewaySchema: Schema<any, mongoose.Model<any, any, any, any, any,
136
136
  * Use this in your model: currentPayment: { type: currentPaymentSchema }
137
137
  *
138
138
  * Tracks the latest payment transaction for an entity
139
+ *
140
+ * Refund tracking:
141
+ * - refundedAmount: Total amount refunded (caps refundable = amount - refundedAmount)
142
+ * - refundedAt: When the (last) refund occurred
143
+ * - Partial refunds: status remains 'verified' with refundedAmount > 0
144
+ * - Full refunds: status should be updated to 'refunded'
139
145
  */
140
146
  declare const currentPaymentSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
141
147
  _id: false;
142
148
  }, {
143
149
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
150
+ refundedAmount: number;
144
151
  transactionId?: mongoose.Types.ObjectId | null | undefined;
145
152
  amount?: number | null | undefined;
146
153
  method?: string | null | undefined;
147
154
  verifiedAt?: NativeDate | null | undefined;
148
155
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
156
+ refundedAt?: NativeDate | null | undefined;
149
157
  reference?: string | null | undefined;
150
158
  }, mongoose.Document<unknown, {}, {
151
159
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
160
+ refundedAmount: number;
152
161
  transactionId?: mongoose.Types.ObjectId | null | undefined;
153
162
  amount?: number | null | undefined;
154
163
  method?: string | null | undefined;
155
164
  verifiedAt?: NativeDate | null | undefined;
156
165
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
166
+ refundedAt?: NativeDate | null | undefined;
157
167
  reference?: string | null | undefined;
158
168
  }, {
159
169
  id: string;
@@ -161,11 +171,13 @@ declare const currentPaymentSchema: Schema<any, mongoose.Model<any, any, any, an
161
171
  _id: false;
162
172
  }>> & Omit<{
163
173
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
174
+ refundedAmount: number;
164
175
  transactionId?: mongoose.Types.ObjectId | null | undefined;
165
176
  amount?: number | null | undefined;
166
177
  method?: string | null | undefined;
167
178
  verifiedAt?: NativeDate | null | undefined;
168
179
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
180
+ refundedAt?: NativeDate | null | undefined;
169
181
  reference?: string | null | undefined;
170
182
  } & {
171
183
  _id: mongoose.Types.ObjectId;
@@ -178,11 +190,13 @@ declare const currentPaymentSchema: Schema<any, mongoose.Model<any, any, any, an
178
190
  } | {
179
191
  [x: string]: mongoose.SchemaDefinitionProperty<any, any, mongoose.Document<unknown, {}, {
180
192
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
193
+ refundedAmount: number;
181
194
  transactionId?: mongoose.Types.ObjectId | null | undefined;
182
195
  amount?: number | null | undefined;
183
196
  method?: string | null | undefined;
184
197
  verifiedAt?: NativeDate | null | undefined;
185
198
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
199
+ refundedAt?: NativeDate | null | undefined;
186
200
  reference?: string | null | undefined;
187
201
  }, {
188
202
  id: string;
@@ -190,11 +204,13 @@ declare const currentPaymentSchema: Schema<any, mongoose.Model<any, any, any, an
190
204
  _id: false;
191
205
  }>> & Omit<{
192
206
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
207
+ refundedAmount: number;
193
208
  transactionId?: mongoose.Types.ObjectId | null | undefined;
194
209
  amount?: number | null | undefined;
195
210
  method?: string | null | undefined;
196
211
  verifiedAt?: NativeDate | null | undefined;
197
212
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
213
+ refundedAt?: NativeDate | null | undefined;
198
214
  reference?: string | null | undefined;
199
215
  } & {
200
216
  _id: mongoose.Types.ObjectId;
@@ -205,11 +221,13 @@ declare const currentPaymentSchema: Schema<any, mongoose.Model<any, any, any, an
205
221
  }> | undefined;
206
222
  }, {
207
223
  status: "pending" | "verified" | "failed" | "cancelled" | "refunded";
224
+ refundedAmount: number;
208
225
  transactionId?: mongoose.Types.ObjectId | null | undefined;
209
226
  amount?: number | null | undefined;
210
227
  method?: string | null | undefined;
211
228
  verifiedAt?: NativeDate | null | undefined;
212
229
  verifiedBy?: mongoose.Types.ObjectId | null | undefined;
230
+ refundedAt?: NativeDate | null | undefined;
213
231
  reference?: string | null | undefined;
214
232
  } & {
215
233
  _id: mongoose.Types.ObjectId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/revenue",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Enterprise revenue management system with subscriptions, payments, escrow, splits - Modern, Type-safe, Resilient",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",