@classytic/revenue 0.2.3 → 1.0.0

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.
Files changed (111) hide show
  1. package/README.md +498 -499
  2. package/dist/actions-CwG-b7fR.d.ts +519 -0
  3. package/dist/core/index.d.ts +884 -0
  4. package/dist/core/index.js +2941 -0
  5. package/dist/core/index.js.map +1 -0
  6. package/dist/enums/index.d.ts +130 -0
  7. package/dist/enums/index.js +167 -0
  8. package/dist/enums/index.js.map +1 -0
  9. package/dist/index-BnJWVXuw.d.ts +378 -0
  10. package/dist/index-ChVD3P9k.d.ts +504 -0
  11. package/dist/index.d.ts +42 -0
  12. package/dist/index.js +4353 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/providers/index.d.ts +132 -0
  15. package/dist/providers/index.js +122 -0
  16. package/dist/providers/index.js.map +1 -0
  17. package/dist/retry-80lBCmSe.d.ts +234 -0
  18. package/dist/schemas/index.d.ts +894 -0
  19. package/dist/schemas/index.js +524 -0
  20. package/dist/schemas/index.js.map +1 -0
  21. package/dist/schemas/validation.d.ts +309 -0
  22. package/dist/schemas/validation.js +249 -0
  23. package/dist/schemas/validation.js.map +1 -0
  24. package/dist/services/index.d.ts +3 -0
  25. package/dist/services/index.js +1632 -0
  26. package/dist/services/index.js.map +1 -0
  27. package/dist/split.enums-DHdM1YAV.d.ts +255 -0
  28. package/dist/split.schema-BPdFZMbU.d.ts +958 -0
  29. package/dist/utils/index.d.ts +24 -0
  30. package/dist/utils/index.js +1067 -0
  31. package/dist/utils/index.js.map +1 -0
  32. package/package.json +48 -32
  33. package/core/builder.js +0 -219
  34. package/core/container.js +0 -119
  35. package/core/errors.js +0 -262
  36. package/dist/types/core/builder.d.ts +0 -97
  37. package/dist/types/core/container.d.ts +0 -57
  38. package/dist/types/core/errors.d.ts +0 -122
  39. package/dist/types/enums/escrow.enums.d.ts +0 -24
  40. package/dist/types/enums/index.d.ts +0 -69
  41. package/dist/types/enums/monetization.enums.d.ts +0 -6
  42. package/dist/types/enums/payment.enums.d.ts +0 -16
  43. package/dist/types/enums/split.enums.d.ts +0 -25
  44. package/dist/types/enums/subscription.enums.d.ts +0 -15
  45. package/dist/types/enums/transaction.enums.d.ts +0 -24
  46. package/dist/types/index.d.ts +0 -22
  47. package/dist/types/providers/base.d.ts +0 -126
  48. package/dist/types/schemas/escrow/hold.schema.d.ts +0 -54
  49. package/dist/types/schemas/escrow/index.d.ts +0 -6
  50. package/dist/types/schemas/index.d.ts +0 -506
  51. package/dist/types/schemas/split/index.d.ts +0 -8
  52. package/dist/types/schemas/split/split.schema.d.ts +0 -142
  53. package/dist/types/schemas/subscription/index.d.ts +0 -152
  54. package/dist/types/schemas/subscription/info.schema.d.ts +0 -128
  55. package/dist/types/schemas/subscription/plan.schema.d.ts +0 -39
  56. package/dist/types/schemas/transaction/common.schema.d.ts +0 -12
  57. package/dist/types/schemas/transaction/gateway.schema.d.ts +0 -86
  58. package/dist/types/schemas/transaction/index.d.ts +0 -202
  59. package/dist/types/schemas/transaction/payment.schema.d.ts +0 -145
  60. package/dist/types/services/escrow.service.d.ts +0 -51
  61. package/dist/types/services/monetization.service.d.ts +0 -193
  62. package/dist/types/services/payment.service.d.ts +0 -112
  63. package/dist/types/services/transaction.service.d.ts +0 -40
  64. package/dist/types/utils/category-resolver.d.ts +0 -46
  65. package/dist/types/utils/commission-split.d.ts +0 -56
  66. package/dist/types/utils/commission.d.ts +0 -29
  67. package/dist/types/utils/hooks.d.ts +0 -17
  68. package/dist/types/utils/index.d.ts +0 -6
  69. package/dist/types/utils/logger.d.ts +0 -12
  70. package/dist/types/utils/subscription/actions.d.ts +0 -28
  71. package/dist/types/utils/subscription/index.d.ts +0 -2
  72. package/dist/types/utils/subscription/period.d.ts +0 -47
  73. package/dist/types/utils/transaction-type.d.ts +0 -102
  74. package/enums/escrow.enums.js +0 -36
  75. package/enums/index.d.ts +0 -116
  76. package/enums/index.js +0 -110
  77. package/enums/monetization.enums.js +0 -15
  78. package/enums/payment.enums.js +0 -64
  79. package/enums/split.enums.js +0 -37
  80. package/enums/subscription.enums.js +0 -33
  81. package/enums/transaction.enums.js +0 -69
  82. package/index.js +0 -76
  83. package/providers/base.js +0 -162
  84. package/schemas/escrow/hold.schema.js +0 -62
  85. package/schemas/escrow/index.js +0 -15
  86. package/schemas/index.d.ts +0 -33
  87. package/schemas/index.js +0 -27
  88. package/schemas/split/index.js +0 -16
  89. package/schemas/split/split.schema.js +0 -86
  90. package/schemas/subscription/index.js +0 -17
  91. package/schemas/subscription/info.schema.js +0 -115
  92. package/schemas/subscription/plan.schema.js +0 -48
  93. package/schemas/transaction/common.schema.js +0 -22
  94. package/schemas/transaction/gateway.schema.js +0 -69
  95. package/schemas/transaction/index.js +0 -20
  96. package/schemas/transaction/payment.schema.js +0 -110
  97. package/services/escrow.service.js +0 -353
  98. package/services/monetization.service.js +0 -671
  99. package/services/payment.service.js +0 -517
  100. package/services/transaction.service.js +0 -142
  101. package/utils/category-resolver.js +0 -74
  102. package/utils/commission-split.js +0 -180
  103. package/utils/commission.js +0 -83
  104. package/utils/hooks.js +0 -44
  105. package/utils/index.d.ts +0 -164
  106. package/utils/index.js +0 -16
  107. package/utils/logger.js +0 -36
  108. package/utils/subscription/actions.js +0 -68
  109. package/utils/subscription/index.js +0 -20
  110. package/utils/subscription/period.js +0 -123
  111. package/utils/transaction-type.js +0 -254
@@ -1,69 +0,0 @@
1
- export * from "./transaction.enums.js";
2
- export * from "./payment.enums.js";
3
- export * from "./subscription.enums.js";
4
- export * from "./monetization.enums.js";
5
- export * from "./escrow.enums.js";
6
- export * from "./split.enums.js";
7
- declare namespace _default {
8
- export { TRANSACTION_TYPE };
9
- export { TRANSACTION_TYPE_VALUES };
10
- export { TRANSACTION_STATUS };
11
- export { TRANSACTION_STATUS_VALUES };
12
- export { LIBRARY_CATEGORIES };
13
- export { LIBRARY_CATEGORY_VALUES };
14
- export { PAYMENT_STATUS };
15
- export { PAYMENT_STATUS_VALUES };
16
- export { PAYMENT_GATEWAY_TYPE };
17
- export { PAYMENT_GATEWAY_TYPE_VALUES };
18
- export { GATEWAY_TYPES };
19
- export { GATEWAY_TYPE_VALUES };
20
- export { SUBSCRIPTION_STATUS };
21
- export { SUBSCRIPTION_STATUS_VALUES };
22
- export { PLAN_KEYS };
23
- export { PLAN_KEY_VALUES };
24
- export { MONETIZATION_TYPES };
25
- export { MONETIZATION_TYPE_VALUES };
26
- export { HOLD_STATUS };
27
- export { HOLD_STATUS_VALUES };
28
- export { RELEASE_REASON };
29
- export { RELEASE_REASON_VALUES };
30
- export { HOLD_REASON };
31
- export { HOLD_REASON_VALUES };
32
- export { SPLIT_TYPE };
33
- export { SPLIT_TYPE_VALUES };
34
- export { SPLIT_STATUS };
35
- export { SPLIT_STATUS_VALUES };
36
- export { PAYOUT_METHOD };
37
- export { PAYOUT_METHOD_VALUES };
38
- }
39
- export default _default;
40
- import { TRANSACTION_TYPE } from './transaction.enums.js';
41
- import { TRANSACTION_TYPE_VALUES } from './transaction.enums.js';
42
- import { TRANSACTION_STATUS } from './transaction.enums.js';
43
- import { TRANSACTION_STATUS_VALUES } from './transaction.enums.js';
44
- import { LIBRARY_CATEGORIES } from './transaction.enums.js';
45
- import { LIBRARY_CATEGORY_VALUES } from './transaction.enums.js';
46
- import { PAYMENT_STATUS } from './payment.enums.js';
47
- import { PAYMENT_STATUS_VALUES } from './payment.enums.js';
48
- import { PAYMENT_GATEWAY_TYPE } from './payment.enums.js';
49
- import { PAYMENT_GATEWAY_TYPE_VALUES } from './payment.enums.js';
50
- import { GATEWAY_TYPES } from './payment.enums.js';
51
- import { GATEWAY_TYPE_VALUES } from './payment.enums.js';
52
- import { SUBSCRIPTION_STATUS } from './subscription.enums.js';
53
- import { SUBSCRIPTION_STATUS_VALUES } from './subscription.enums.js';
54
- import { PLAN_KEYS } from './subscription.enums.js';
55
- import { PLAN_KEY_VALUES } from './subscription.enums.js';
56
- import { MONETIZATION_TYPES } from './monetization.enums.js';
57
- import { MONETIZATION_TYPE_VALUES } from './monetization.enums.js';
58
- import { HOLD_STATUS } from './escrow.enums.js';
59
- import { HOLD_STATUS_VALUES } from './escrow.enums.js';
60
- import { RELEASE_REASON } from './escrow.enums.js';
61
- import { RELEASE_REASON_VALUES } from './escrow.enums.js';
62
- import { HOLD_REASON } from './escrow.enums.js';
63
- import { HOLD_REASON_VALUES } from './escrow.enums.js';
64
- import { SPLIT_TYPE } from './split.enums.js';
65
- import { SPLIT_TYPE_VALUES } from './split.enums.js';
66
- import { SPLIT_STATUS } from './split.enums.js';
67
- import { SPLIT_STATUS_VALUES } from './split.enums.js';
68
- import { PAYOUT_METHOD } from './split.enums.js';
69
- import { PAYOUT_METHOD_VALUES } from './split.enums.js';
@@ -1,6 +0,0 @@
1
- export namespace MONETIZATION_TYPES {
2
- let FREE: string;
3
- let PURCHASE: string;
4
- let SUBSCRIPTION: string;
5
- }
6
- export const MONETIZATION_TYPE_VALUES: string[];
@@ -1,16 +0,0 @@
1
- export namespace PAYMENT_STATUS {
2
- let PENDING: string;
3
- let VERIFIED: string;
4
- let FAILED: string;
5
- let REFUNDED: string;
6
- let CANCELLED: string;
7
- }
8
- export const PAYMENT_STATUS_VALUES: string[];
9
- export namespace PAYMENT_GATEWAY_TYPE {
10
- let MANUAL: string;
11
- let STRIPE: string;
12
- let SSLCOMMERZ: string;
13
- }
14
- export const PAYMENT_GATEWAY_TYPE_VALUES: string[];
15
- export namespace GATEWAY_TYPES { }
16
- export const GATEWAY_TYPE_VALUES: string[];
@@ -1,25 +0,0 @@
1
- export namespace SPLIT_TYPE {
2
- let PLATFORM_COMMISSION: string;
3
- let AFFILIATE_COMMISSION: string;
4
- let REFERRAL_COMMISSION: string;
5
- let PARTNER_COMMISSION: string;
6
- let CUSTOM: string;
7
- }
8
- export const SPLIT_TYPE_VALUES: string[];
9
- export namespace SPLIT_STATUS {
10
- let PENDING: string;
11
- let DUE: string;
12
- let PAID: string;
13
- let WAIVED: string;
14
- let CANCELLED: string;
15
- }
16
- export const SPLIT_STATUS_VALUES: string[];
17
- export namespace PAYOUT_METHOD {
18
- let BANK_TRANSFER: string;
19
- let MOBILE_WALLET: string;
20
- let PLATFORM_BALANCE: string;
21
- let CRYPTO: string;
22
- let CHECK: string;
23
- let MANUAL: string;
24
- }
25
- export const PAYOUT_METHOD_VALUES: string[];
@@ -1,15 +0,0 @@
1
- export namespace SUBSCRIPTION_STATUS {
2
- let ACTIVE: string;
3
- let PAUSED: string;
4
- let CANCELLED: string;
5
- let EXPIRED: string;
6
- let PENDING: string;
7
- let INACTIVE: string;
8
- }
9
- export const SUBSCRIPTION_STATUS_VALUES: string[];
10
- export namespace PLAN_KEYS {
11
- let MONTHLY: string;
12
- let QUARTERLY: string;
13
- let YEARLY: string;
14
- }
15
- export const PLAN_KEY_VALUES: string[];
@@ -1,24 +0,0 @@
1
- export namespace TRANSACTION_TYPE {
2
- let INCOME: string;
3
- let EXPENSE: string;
4
- }
5
- export const TRANSACTION_TYPE_VALUES: string[];
6
- export namespace TRANSACTION_STATUS {
7
- let PENDING: string;
8
- let PAYMENT_INITIATED: string;
9
- let PROCESSING: string;
10
- let REQUIRES_ACTION: string;
11
- let VERIFIED: string;
12
- let COMPLETED: string;
13
- let FAILED: string;
14
- let CANCELLED: string;
15
- let EXPIRED: string;
16
- let REFUNDED: string;
17
- let PARTIALLY_REFUNDED: string;
18
- }
19
- export const TRANSACTION_STATUS_VALUES: string[];
20
- export namespace LIBRARY_CATEGORIES {
21
- let SUBSCRIPTION: string;
22
- let PURCHASE: string;
23
- }
24
- export const LIBRARY_CATEGORY_VALUES: string[];
@@ -1,22 +0,0 @@
1
- export { createRevenue } from "./core/builder.js";
2
- export { Container } from "./core/container.js";
3
- export * from "./core/errors.js";
4
- export * from "./enums/index.js";
5
- export * from "./schemas/index.js";
6
- export { MonetizationService } from "./services/monetization.service.js";
7
- export { PaymentService } from "./services/payment.service.js";
8
- export { TransactionService } from "./services/transaction.service.js";
9
- export { EscrowService } from "./services/escrow.service.js";
10
- declare namespace _default {
11
- export { _createRevenue as createRevenue };
12
- export { _PaymentProvider as PaymentProvider };
13
- export { RevenueError };
14
- export { _Container as Container };
15
- }
16
- export default _default;
17
- import { createRevenue as _createRevenue } from './core/builder.js';
18
- import { PaymentProvider as _PaymentProvider } from './providers/base.js';
19
- import { RevenueError } from './core/errors.js';
20
- import { Container as _Container } from './core/container.js';
21
- export { PaymentProvider, PaymentIntent, PaymentResult, RefundResult, WebhookEvent } from "./providers/base.js";
22
- export { logger, setLogger, calculateCommission, reverseCommission, addDuration, calculatePeriodRange, calculateProratedAmount, resolveIntervalToDuration, isSubscriptionActive, canRenewSubscription, canCancelSubscription, canPauseSubscription, canResumeSubscription } from "./utils/index.js";
@@ -1,126 +0,0 @@
1
- /**
2
- * Payment Provider Base Class
3
- * @classytic/revenue
4
- *
5
- * Abstract base class for all payment providers
6
- * Inspired by: Vercel AI SDK, Stripe SDK
7
- */
8
- /**
9
- * Payment Intent - standardized response from createIntent
10
- */
11
- export class PaymentIntent {
12
- constructor(data: any);
13
- id: any;
14
- provider: any;
15
- status: any;
16
- amount: any;
17
- currency: any;
18
- metadata: any;
19
- clientSecret: any;
20
- paymentUrl: any;
21
- instructions: any;
22
- raw: any;
23
- }
24
- /**
25
- * Payment Result - standardized response from verifyPayment
26
- */
27
- export class PaymentResult {
28
- constructor(data: any);
29
- id: any;
30
- provider: any;
31
- status: any;
32
- amount: any;
33
- currency: any;
34
- paidAt: any;
35
- metadata: any;
36
- raw: any;
37
- }
38
- /**
39
- * Refund Result - standardized response from refund
40
- */
41
- export class RefundResult {
42
- constructor(data: any);
43
- id: any;
44
- provider: any;
45
- status: any;
46
- amount: any;
47
- currency: any;
48
- refundedAt: any;
49
- reason: any;
50
- metadata: any;
51
- raw: any;
52
- }
53
- /**
54
- * Webhook Event - standardized webhook event
55
- */
56
- export class WebhookEvent {
57
- constructor(data: any);
58
- id: any;
59
- provider: any;
60
- type: any;
61
- data: any;
62
- createdAt: any;
63
- raw: any;
64
- }
65
- /**
66
- * Base Payment Provider
67
- * All payment providers must extend this class
68
- */
69
- export class PaymentProvider {
70
- constructor(config?: {});
71
- config: {};
72
- name: string;
73
- /**
74
- * Create a payment intent
75
- * @param {Object} params - Payment parameters
76
- * @param {number} params.amount - Amount in smallest currency unit
77
- * @param {string} params.currency - Currency code
78
- * @param {Object} params.metadata - Additional metadata
79
- * @returns {Promise<PaymentIntent>}
80
- */
81
- createIntent(params: {
82
- amount: number;
83
- currency: string;
84
- metadata: any;
85
- }): Promise<PaymentIntent>;
86
- /**
87
- * Verify a payment
88
- * @param {string} intentId - Payment intent ID
89
- * @returns {Promise<PaymentResult>}
90
- */
91
- verifyPayment(intentId: string): Promise<PaymentResult>;
92
- /**
93
- * Get payment status
94
- * @param {string} intentId - Payment intent ID
95
- * @returns {Promise<PaymentResult>}
96
- */
97
- getStatus(intentId: string): Promise<PaymentResult>;
98
- /**
99
- * Refund a payment
100
- * @param {string} paymentId - Payment ID
101
- * @param {number} amount - Amount to refund (optional, full refund if not provided)
102
- * @param {Object} options - Refund options
103
- * @returns {Promise<RefundResult>}
104
- */
105
- refund(paymentId: string, amount: number, options?: any): Promise<RefundResult>;
106
- /**
107
- * Handle webhook from provider
108
- * @param {Object} payload - Webhook payload
109
- * @param {Object} headers - Request headers (for signature verification)
110
- * @returns {Promise<WebhookEvent>}
111
- */
112
- handleWebhook(payload: any, headers?: any): Promise<WebhookEvent>;
113
- /**
114
- * Verify webhook signature (optional)
115
- * @param {Object} payload - Webhook payload
116
- * @param {string} signature - Webhook signature
117
- * @returns {boolean}
118
- */
119
- verifyWebhookSignature(payload: any, signature: string): boolean;
120
- /**
121
- * Get provider capabilities
122
- * @returns {Object}
123
- */
124
- getCapabilities(): any;
125
- }
126
- export default PaymentProvider;
@@ -1,54 +0,0 @@
1
- export namespace holdSchema {
2
- namespace status {
3
- export let type: StringConstructor;
4
- export { HOLD_STATUS_VALUES as enum };
5
- let _default: string;
6
- export { _default as default };
7
- export let index: boolean;
8
- }
9
- namespace heldAmount {
10
- let type_1: NumberConstructor;
11
- export { type_1 as type };
12
- export let required: boolean;
13
- }
14
- namespace releasedAmount {
15
- let type_2: NumberConstructor;
16
- export { type_2 as type };
17
- let _default_1: number;
18
- export { _default_1 as default };
19
- }
20
- namespace reason {
21
- let type_3: StringConstructor;
22
- export { type_3 as type };
23
- export { HOLD_REASON_VALUES as enum };
24
- let required_1: boolean;
25
- export { required_1 as required };
26
- }
27
- namespace holdUntil {
28
- let type_4: DateConstructor;
29
- export { type_4 as type };
30
- let required_2: boolean;
31
- export { required_2 as required };
32
- }
33
- let heldAt: DateConstructor;
34
- let releasedAt: DateConstructor;
35
- let cancelledAt: DateConstructor;
36
- let releases: {
37
- amount: NumberConstructor;
38
- recipientId: StringConstructor;
39
- recipientType: StringConstructor;
40
- releasedAt: DateConstructor;
41
- releasedBy: StringConstructor;
42
- reason: StringConstructor;
43
- metadata: ObjectConstructor;
44
- }[];
45
- namespace metadata {
46
- let type_5: ObjectConstructor;
47
- export { type_5 as type };
48
- let _default_2: {};
49
- export { _default_2 as default };
50
- }
51
- }
52
- export default holdSchema;
53
- import { HOLD_STATUS_VALUES } from '../../enums/escrow.enums.js';
54
- import { HOLD_REASON_VALUES } from '../../enums/escrow.enums.js';
@@ -1,6 +0,0 @@
1
- export { holdSchema };
2
- declare namespace _default {
3
- export { holdSchema };
4
- }
5
- export default _default;
6
- import { holdSchema } from './hold.schema.js';