@dineway-ai/plugin-payment 0.2.6 → 0.2.7
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.
- package/package.json +3 -2
- package/src/admin/subscriptions.tsx +150 -16
- package/src/configuration/repository.ts +7 -3
- package/src/database/index.ts +12 -0
- package/src/database/migrations/001_stripe_configuration.ts +100 -0
- package/src/database/migrations/002_subscriptions.ts +168 -0
- package/src/database/migrations/003_purchases.ts +193 -0
- package/src/database/migrations/adoption.ts +27 -0
- package/src/database/types.ts +137 -0
- package/src/index.ts +2 -0
- package/src/subscriptions/funding.ts +256 -0
- package/src/subscriptions/index.ts +1 -0
- package/src/subscriptions/projection.ts +39 -7
- package/src/subscriptions/purchases.ts +329 -0
- package/src/subscriptions/refunds.ts +134 -0
- package/src/subscriptions/repository.ts +352 -13
- package/src/subscriptions/routes.ts +8 -0
- package/src/subscriptions/schemas.ts +45 -0
- package/src/subscriptions/service.ts +479 -200
- package/src/subscriptions/types.ts +90 -0
- package/src/types.ts +1 -0
|
@@ -62,6 +62,8 @@ export interface MemberSubscription {
|
|
|
62
62
|
cancelAtPeriodEnd: boolean;
|
|
63
63
|
verifiedAt: number;
|
|
64
64
|
lastError: string | null;
|
|
65
|
+
purchaseReference?: string | null;
|
|
66
|
+
revision?: number;
|
|
65
67
|
}
|
|
66
68
|
export interface PaidSubscriptionPeriod {
|
|
67
69
|
id: string;
|
|
@@ -70,6 +72,94 @@ export interface PaidSubscriptionPeriod {
|
|
|
70
72
|
planCode: string;
|
|
71
73
|
startsAt: number;
|
|
72
74
|
endsAt: number;
|
|
75
|
+
eligible?: boolean;
|
|
76
|
+
evidence?: InvoiceFundingEvidence;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Supplied by a trusted session adapter, never by a browser request body. */
|
|
80
|
+
export interface BillingSubject {
|
|
81
|
+
realm: string;
|
|
82
|
+
id: string;
|
|
83
|
+
email: string;
|
|
84
|
+
emailVerified: boolean;
|
|
85
|
+
}
|
|
86
|
+
export type PurchasePricing =
|
|
87
|
+
| { kind: "catalogue"; planCode: string; interval: SubscriptionInterval }
|
|
88
|
+
| {
|
|
89
|
+
kind: "dynamic";
|
|
90
|
+
name: string;
|
|
91
|
+
amount: number;
|
|
92
|
+
currency: string;
|
|
93
|
+
interval: "day" | "week" | "month" | "year";
|
|
94
|
+
intervalCount: number;
|
|
95
|
+
};
|
|
96
|
+
export interface SubscriptionPurchaseInput {
|
|
97
|
+
reference: string;
|
|
98
|
+
groupKey: string;
|
|
99
|
+
pricing: PurchasePricing;
|
|
100
|
+
firstPeriodCredit?: number;
|
|
101
|
+
returnPath: string;
|
|
102
|
+
locale?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface PurchaseContract extends SubscriptionPurchaseInput {
|
|
105
|
+
amount: number;
|
|
106
|
+
currency: string;
|
|
107
|
+
interval: "day" | "week" | "month" | "year";
|
|
108
|
+
intervalCount: number;
|
|
109
|
+
priceId: string | null;
|
|
110
|
+
couponId: string | null;
|
|
111
|
+
}
|
|
112
|
+
export interface SubscriptionPurchase {
|
|
113
|
+
reference: string;
|
|
114
|
+
userId: string;
|
|
115
|
+
contract: PurchaseContract;
|
|
116
|
+
createdAt: number;
|
|
117
|
+
expiresAt: number;
|
|
118
|
+
sessionId: string | null;
|
|
119
|
+
subscriptionId: string | null;
|
|
120
|
+
closed: boolean;
|
|
121
|
+
cancelMode: "period_end" | "immediate" | null;
|
|
122
|
+
lastError: string | null;
|
|
123
|
+
}
|
|
124
|
+
export interface RefundEvidence {
|
|
125
|
+
id: string;
|
|
126
|
+
amount: number;
|
|
127
|
+
status: string;
|
|
128
|
+
metadata: Record<string, string>;
|
|
129
|
+
}
|
|
130
|
+
export interface ChargeEvidence {
|
|
131
|
+
id: string;
|
|
132
|
+
paymentIntentId: string | null;
|
|
133
|
+
customerId: string | null;
|
|
134
|
+
currency: string;
|
|
135
|
+
amount: number;
|
|
136
|
+
captured: number;
|
|
137
|
+
refunded: number;
|
|
138
|
+
settled: boolean;
|
|
139
|
+
refunds: RefundEvidence[];
|
|
140
|
+
disputes: { id: string; amount: number; status: string }[];
|
|
141
|
+
}
|
|
142
|
+
export interface InvoiceFundingEvidence {
|
|
143
|
+
verifiedAt: number;
|
|
144
|
+
currency: string;
|
|
145
|
+
amount: number;
|
|
146
|
+
credit: number;
|
|
147
|
+
cash: number;
|
|
148
|
+
charges: ChargeEvidence[];
|
|
149
|
+
paymentMethodId: string | null;
|
|
150
|
+
reason: string | null;
|
|
151
|
+
}
|
|
152
|
+
export interface SubscriptionSnapshot {
|
|
153
|
+
subscription: MemberSubscription;
|
|
154
|
+
subject: BillingSubject | null;
|
|
155
|
+
purchase: SubscriptionPurchase | null;
|
|
156
|
+
periods: PaidSubscriptionPeriod[];
|
|
157
|
+
}
|
|
158
|
+
export interface SubscriptionChange {
|
|
159
|
+
id: string;
|
|
160
|
+
revision: number;
|
|
161
|
+
createdAt: number;
|
|
162
|
+
snapshot: SubscriptionSnapshot;
|
|
73
163
|
}
|
|
74
164
|
export interface MemberBilling {
|
|
75
165
|
customer: boolean;
|
package/src/types.ts
CHANGED