@fantastic.dev/better-stripe 0.38.0 → 0.39.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.
- package/CHANGELOG.md +20 -0
- package/MIGRATION.md +9 -0
- package/README.md +21 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +506 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +253 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +506 -2
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +253 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/costRecovery.d.ts +18 -0
- package/dist/client/costRecovery.d.ts.map +1 -1
- package/dist/client/costRecovery.js +4 -0
- package/dist/client/costRecovery.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/processingCostDeficit/index.d.ts +27 -0
- package/dist/client/processingCostDeficit/index.d.ts.map +1 -0
- package/dist/client/processingCostDeficit/index.js +54 -0
- package/dist/client/processingCostDeficit/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +284 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +527 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/helpers.d.ts +86 -0
- package/dist/component/balanceFunding/helpers.d.ts.map +1 -0
- package/dist/component/balanceFunding/helpers.js +68 -0
- package/dist/component/balanceFunding/helpers.js.map +1 -0
- package/dist/component/balanceFunding/importHandler.d.ts +13 -0
- package/dist/component/balanceFunding/importHandler.d.ts.map +1 -0
- package/dist/component/balanceFunding/importHandler.js +130 -0
- package/dist/component/balanceFunding/importHandler.js.map +1 -0
- package/dist/component/balanceFunding/lifecycleHandlers.d.ts +85 -0
- package/dist/component/balanceFunding/lifecycleHandlers.d.ts.map +1 -0
- package/dist/component/balanceFunding/lifecycleHandlers.js +60 -0
- package/dist/component/balanceFunding/lifecycleHandlers.js.map +1 -0
- package/dist/component/balanceFunding/mutationValidators.d.ts +238 -0
- package/dist/component/balanceFunding/mutationValidators.d.ts.map +1 -0
- package/dist/component/balanceFunding/mutationValidators.js +55 -0
- package/dist/component/balanceFunding/mutationValidators.js.map +1 -0
- package/dist/component/balanceFunding/mutations.d.ts +335 -0
- package/dist/component/balanceFunding/mutations.d.ts.map +1 -0
- package/dist/component/balanceFunding/mutations.js +106 -0
- package/dist/component/balanceFunding/mutations.js.map +1 -0
- package/dist/component/balanceFunding/preparationHandlers.d.ts +55 -0
- package/dist/component/balanceFunding/preparationHandlers.d.ts.map +1 -0
- package/dist/component/balanceFunding/preparationHandlers.js +165 -0
- package/dist/component/balanceFunding/preparationHandlers.js.map +1 -0
- package/dist/component/balanceFunding/queries.d.ts +151 -0
- package/dist/component/balanceFunding/queries.d.ts.map +1 -0
- package/dist/component/balanceFunding/queries.js +180 -0
- package/dist/component/balanceFunding/queries.js.map +1 -0
- package/dist/component/balanceFunding/schema.d.ts +748 -0
- package/dist/component/balanceFunding/schema.d.ts.map +1 -0
- package/dist/component/balanceFunding/schema.js +124 -0
- package/dist/component/balanceFunding/schema.js.map +1 -0
- package/dist/component/balanceFunding/stateHandlers.d.ts +58 -0
- package/dist/component/balanceFunding/stateHandlers.d.ts.map +1 -0
- package/dist/component/balanceFunding/stateHandlers.js +160 -0
- package/dist/component/balanceFunding/stateHandlers.js.map +1 -0
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +2 -0
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/costRecovery/completion.d.ts +1 -0
- package/dist/component/costRecovery/completion.d.ts.map +1 -1
- package/dist/component/costRecovery/helpers.d.ts +1 -0
- package/dist/component/costRecovery/helpers.d.ts.map +1 -1
- package/dist/component/costRecovery/mutations.d.ts +5 -0
- package/dist/component/costRecovery/mutations.d.ts.map +1 -1
- package/dist/component/costRecovery/preparation.d.ts +50 -0
- package/dist/component/costRecovery/preparation.d.ts.map +1 -0
- package/dist/component/costRecovery/preparation.js +108 -0
- package/dist/component/costRecovery/preparation.js.map +1 -0
- package/dist/component/costRecovery/queries.d.ts +1 -0
- package/dist/component/costRecovery/queries.d.ts.map +1 -1
- package/dist/component/costRecovery/reservations.d.ts +2 -0
- package/dist/component/costRecovery/reservations.d.ts.map +1 -1
- package/dist/component/costRecovery/schema.d.ts +7 -2
- package/dist/component/costRecovery/schema.d.ts.map +1 -1
- package/dist/component/costRecovery/schema.js +1 -0
- package/dist/component/costRecovery/schema.js.map +1 -1
- package/dist/component/durableExecution/runtime.d.ts +3 -0
- package/dist/component/durableExecution/runtime.d.ts.map +1 -0
- package/dist/component/durableExecution/runtime.js +12 -0
- package/dist/component/durableExecution/runtime.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +242 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/schema.d.ts +253 -1
- package/dist/component/schema.js +4 -0
- package/dist/component/schema.js.map +1 -1
- package/package.json +4 -2
- package/src/client/costRecovery.test.ts +34 -0
- package/src/client/costRecovery.ts +21 -0
- package/src/client/index.ts +1 -0
- package/src/client/processingCostDeficit/README.md +35 -0
- package/src/client/processingCostDeficit/calculator.test.ts +176 -0
- package/src/client/processingCostDeficit/index.ts +91 -0
- package/src/component/_generated/api.ts +23 -1
- package/src/component/_generated/component.ts +693 -0
- package/src/component/balanceFunding/failure.test.ts +116 -0
- package/src/component/balanceFunding/helpers.ts +102 -0
- package/src/component/balanceFunding/import.test.ts +221 -0
- package/src/component/balanceFunding/importHandler.ts +146 -0
- package/src/component/balanceFunding/lifecycleHandlers.ts +90 -0
- package/src/component/balanceFunding/lookup.test.ts +113 -0
- package/src/component/balanceFunding/mutationValidators.ts +63 -0
- package/src/component/balanceFunding/mutations.ts +136 -0
- package/src/component/balanceFunding/preparation.test.ts +146 -0
- package/src/component/balanceFunding/preparationHandlers.ts +204 -0
- package/src/component/balanceFunding/queries.ts +221 -0
- package/src/component/balanceFunding/requestLookup.test.ts +160 -0
- package/src/component/balanceFunding/schema.ts +169 -0
- package/src/component/balanceFunding/state.test.ts +352 -0
- package/src/component/balanceFunding/stateHandlers.ts +198 -0
- package/src/component/balanceFunding/validation.test.ts +100 -0
- package/src/component/convex.config.ts +2 -0
- package/src/component/costRecovery/preparation.test.ts +355 -0
- package/src/component/costRecovery/preparation.ts +124 -0
- package/src/component/costRecovery/schema.ts +1 -0
- package/src/component/durableExecution/composition.test.ts +568 -0
- package/src/component/durableExecution/runtime.ts +12 -0
- package/src/component/schema.ts +8 -0
|
@@ -1,4 +1,254 @@
|
|
|
1
1
|
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
|
+
balanceFundingPreparations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
+
accountId: string;
|
|
4
|
+
activeOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
|
|
5
|
+
consentAt: number;
|
|
6
|
+
consentReference: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
operationVersion: number;
|
|
9
|
+
preparation: {
|
|
10
|
+
customerAccount: string;
|
|
11
|
+
paymentMethodId?: string | undefined;
|
|
12
|
+
previousPaymentMethodId: string | null;
|
|
13
|
+
previousPaymentMethodTypes: string[] | null;
|
|
14
|
+
stripeSubscriptionId: string;
|
|
15
|
+
};
|
|
16
|
+
preparationOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
|
|
17
|
+
providerApiVersion: string;
|
|
18
|
+
scopeKey: string;
|
|
19
|
+
startsPaused: boolean;
|
|
20
|
+
verified: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
23
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
24
|
+
preparation: import("convex/values").VObject<{
|
|
25
|
+
customerAccount: string;
|
|
26
|
+
paymentMethodId?: string | undefined;
|
|
27
|
+
previousPaymentMethodId: string | null;
|
|
28
|
+
previousPaymentMethodTypes: string[] | null;
|
|
29
|
+
stripeSubscriptionId: string;
|
|
30
|
+
}, {
|
|
31
|
+
customerAccount: import("convex/values").VString<string, "required">;
|
|
32
|
+
stripeSubscriptionId: import("convex/values").VString<string, "required">;
|
|
33
|
+
previousPaymentMethodId: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
34
|
+
previousPaymentMethodTypes: import("convex/values").VUnion<string[] | null, [import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
35
|
+
paymentMethodId: import("convex/values").VString<string | undefined, "optional">;
|
|
36
|
+
}, "required", "customerAccount" | "paymentMethodId" | "previousPaymentMethodId" | "previousPaymentMethodTypes" | "stripeSubscriptionId">;
|
|
37
|
+
consentAt: import("convex/values").VFloat64<number, "required">;
|
|
38
|
+
consentReference: import("convex/values").VString<string, "required">;
|
|
39
|
+
providerApiVersion: import("convex/values").VString<string, "required">;
|
|
40
|
+
enabled: import("convex/values").VBoolean<boolean, "required">;
|
|
41
|
+
startsPaused: import("convex/values").VBoolean<boolean, "required">;
|
|
42
|
+
verified: import("convex/values").VBoolean<boolean, "required">;
|
|
43
|
+
preparationOperationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations"> | undefined, "optional">;
|
|
44
|
+
operationVersion: import("convex/values").VFloat64<number, "required">;
|
|
45
|
+
activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations"> | undefined, "optional">;
|
|
46
|
+
}, "required", "accountId" | "activeOperationId" | "consentAt" | "consentReference" | "enabled" | "operationVersion" | "preparation" | "preparation.customerAccount" | "preparation.paymentMethodId" | "preparation.previousPaymentMethodId" | "preparation.previousPaymentMethodTypes" | "preparation.stripeSubscriptionId" | "preparationOperationId" | "providerApiVersion" | "scopeKey" | "startsPaused" | "verified">, {
|
|
47
|
+
by_account_subscription: ["accountId", "preparation.stripeSubscriptionId", "_creationTime"];
|
|
48
|
+
}, {}, {}>;
|
|
49
|
+
balanceFundingOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
50
|
+
accountId: string;
|
|
51
|
+
cancelRequested: boolean;
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
failureCode?: "invalid_scope" | "policy_invalid" | "unsupported_source" | undefined;
|
|
54
|
+
kind: "apply" | "prepare";
|
|
55
|
+
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
56
|
+
providerKey: string;
|
|
57
|
+
providerKeys: {
|
|
58
|
+
attach?: string | undefined;
|
|
59
|
+
create?: string | undefined;
|
|
60
|
+
disable: string;
|
|
61
|
+
enable: string;
|
|
62
|
+
};
|
|
63
|
+
receipt?: {
|
|
64
|
+
customerAccount: string;
|
|
65
|
+
paymentMethodId: string | null;
|
|
66
|
+
paymentMethodTypes: string[] | null;
|
|
67
|
+
providerApiVersion: string;
|
|
68
|
+
stripeSubscriptionId: string;
|
|
69
|
+
} | undefined;
|
|
70
|
+
scopeKey: string;
|
|
71
|
+
state: "canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown";
|
|
72
|
+
version: number;
|
|
73
|
+
}, {
|
|
74
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
75
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
76
|
+
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
77
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
78
|
+
enabled: import("convex/values").VBoolean<boolean, "required">;
|
|
79
|
+
kind: import("convex/values").VUnion<"apply" | "prepare", [import("convex/values").VLiteral<"prepare", "required">, import("convex/values").VLiteral<"apply", "required">], "required", never>;
|
|
80
|
+
providerKey: import("convex/values").VString<string, "required">;
|
|
81
|
+
state: import("convex/values").VUnion<"canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"running", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
|
|
82
|
+
cancelRequested: import("convex/values").VBoolean<boolean, "required">;
|
|
83
|
+
failureCode: import("convex/values").VUnion<"invalid_scope" | "policy_invalid" | "unsupported_source" | undefined, [import("convex/values").VLiteral<"invalid_scope", "required">, import("convex/values").VLiteral<"unsupported_source", "required">, import("convex/values").VLiteral<"policy_invalid", "required">], "optional", never>;
|
|
84
|
+
providerKeys: import("convex/values").VObject<{
|
|
85
|
+
attach?: string | undefined;
|
|
86
|
+
create?: string | undefined;
|
|
87
|
+
disable: string;
|
|
88
|
+
enable: string;
|
|
89
|
+
}, {
|
|
90
|
+
enable: import("convex/values").VString<string, "required">;
|
|
91
|
+
disable: import("convex/values").VString<string, "required">;
|
|
92
|
+
create: import("convex/values").VString<string | undefined, "optional">;
|
|
93
|
+
attach: import("convex/values").VString<string | undefined, "optional">;
|
|
94
|
+
}, "required", "attach" | "create" | "disable" | "enable">;
|
|
95
|
+
receipt: import("convex/values").VObject<{
|
|
96
|
+
customerAccount: string;
|
|
97
|
+
paymentMethodId: string | null;
|
|
98
|
+
paymentMethodTypes: string[] | null;
|
|
99
|
+
providerApiVersion: string;
|
|
100
|
+
stripeSubscriptionId: string;
|
|
101
|
+
} | undefined, {
|
|
102
|
+
customerAccount: import("convex/values").VString<string, "required">;
|
|
103
|
+
stripeSubscriptionId: import("convex/values").VString<string, "required">;
|
|
104
|
+
paymentMethodId: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
105
|
+
paymentMethodTypes: import("convex/values").VUnion<string[] | null, [import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
106
|
+
providerApiVersion: import("convex/values").VString<string, "required">;
|
|
107
|
+
}, "optional", "customerAccount" | "paymentMethodId" | "paymentMethodTypes" | "providerApiVersion" | "stripeSubscriptionId">;
|
|
108
|
+
}, "required", "accountId" | "cancelRequested" | "enabled" | "failureCode" | "kind" | "preparationId" | "providerKey" | "providerKeys" | "providerKeys.attach" | "providerKeys.create" | "providerKeys.disable" | "providerKeys.enable" | "receipt" | "receipt.customerAccount" | "receipt.paymentMethodId" | "receipt.paymentMethodTypes" | "receipt.providerApiVersion" | "receipt.stripeSubscriptionId" | "scopeKey" | "state" | "version">, {
|
|
109
|
+
by_preparation_version: ["preparationId", "version", "_creationTime"];
|
|
110
|
+
}, {}, {}>;
|
|
111
|
+
balanceFundingRequests: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
112
|
+
imported?: {
|
|
113
|
+
operation?: {
|
|
114
|
+
accountId: string;
|
|
115
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
116
|
+
scopeKey: string;
|
|
117
|
+
version: number;
|
|
118
|
+
} | undefined;
|
|
119
|
+
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
120
|
+
} | undefined;
|
|
121
|
+
payload: string;
|
|
122
|
+
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
123
|
+
requestKey: string;
|
|
124
|
+
result?: {
|
|
125
|
+
operation: {
|
|
126
|
+
accountId: string;
|
|
127
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
128
|
+
scopeKey: string;
|
|
129
|
+
version: number;
|
|
130
|
+
};
|
|
131
|
+
status: "accepted";
|
|
132
|
+
} | {
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
status: "unchanged";
|
|
135
|
+
} | {
|
|
136
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
137
|
+
retryable: false;
|
|
138
|
+
status: "conflict";
|
|
139
|
+
} | {
|
|
140
|
+
reason: "policy_invalid";
|
|
141
|
+
retryable: false;
|
|
142
|
+
status: "rejected";
|
|
143
|
+
} | {
|
|
144
|
+
reason: "provider_pending";
|
|
145
|
+
retryable: true;
|
|
146
|
+
status: "not_ready";
|
|
147
|
+
} | undefined;
|
|
148
|
+
}, {
|
|
149
|
+
requestKey: import("convex/values").VString<string, "required">;
|
|
150
|
+
payload: import("convex/values").VString<string, "required">;
|
|
151
|
+
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
152
|
+
result: import("convex/values").VUnion<{
|
|
153
|
+
operation: {
|
|
154
|
+
accountId: string;
|
|
155
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
156
|
+
scopeKey: string;
|
|
157
|
+
version: number;
|
|
158
|
+
};
|
|
159
|
+
status: "accepted";
|
|
160
|
+
} | {
|
|
161
|
+
enabled: boolean;
|
|
162
|
+
status: "unchanged";
|
|
163
|
+
} | {
|
|
164
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
165
|
+
retryable: false;
|
|
166
|
+
status: "conflict";
|
|
167
|
+
} | {
|
|
168
|
+
reason: "policy_invalid";
|
|
169
|
+
retryable: false;
|
|
170
|
+
status: "rejected";
|
|
171
|
+
} | {
|
|
172
|
+
reason: "provider_pending";
|
|
173
|
+
retryable: true;
|
|
174
|
+
status: "not_ready";
|
|
175
|
+
} | undefined, [import("convex/values").VObject<{
|
|
176
|
+
operation: {
|
|
177
|
+
accountId: string;
|
|
178
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
179
|
+
scopeKey: string;
|
|
180
|
+
version: number;
|
|
181
|
+
};
|
|
182
|
+
status: "accepted";
|
|
183
|
+
}, {
|
|
184
|
+
status: import("convex/values").VLiteral<"accepted", "required">;
|
|
185
|
+
operation: import("convex/values").VObject<{
|
|
186
|
+
accountId: string;
|
|
187
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
188
|
+
scopeKey: string;
|
|
189
|
+
version: number;
|
|
190
|
+
}, {
|
|
191
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
192
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
193
|
+
operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
|
|
194
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
195
|
+
}, "required", "accountId" | "operationId" | "scopeKey" | "version">;
|
|
196
|
+
}, "required", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "status">, import("convex/values").VObject<{
|
|
197
|
+
enabled: boolean;
|
|
198
|
+
status: "unchanged";
|
|
199
|
+
}, {
|
|
200
|
+
status: import("convex/values").VLiteral<"unchanged", "required">;
|
|
201
|
+
enabled: import("convex/values").VBoolean<boolean, "required">;
|
|
202
|
+
}, "required", "enabled" | "status">, import("convex/values").VObject<{
|
|
203
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
204
|
+
retryable: false;
|
|
205
|
+
status: "conflict";
|
|
206
|
+
}, {
|
|
207
|
+
status: import("convex/values").VLiteral<"conflict", "required">;
|
|
208
|
+
reason: import("convex/values").VUnion<"identity_changed" | "revision_changed" | "scope_busy", [import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"identity_changed", "required">, import("convex/values").VLiteral<"revision_changed", "required">], "required", never>;
|
|
209
|
+
retryable: import("convex/values").VLiteral<false, "required">;
|
|
210
|
+
}, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
|
|
211
|
+
reason: "policy_invalid";
|
|
212
|
+
retryable: false;
|
|
213
|
+
status: "rejected";
|
|
214
|
+
}, {
|
|
215
|
+
status: import("convex/values").VLiteral<"rejected", "required">;
|
|
216
|
+
reason: import("convex/values").VLiteral<"policy_invalid", "required">;
|
|
217
|
+
retryable: import("convex/values").VLiteral<false, "required">;
|
|
218
|
+
}, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
|
|
219
|
+
reason: "provider_pending";
|
|
220
|
+
retryable: true;
|
|
221
|
+
status: "not_ready";
|
|
222
|
+
}, {
|
|
223
|
+
status: import("convex/values").VLiteral<"not_ready", "required">;
|
|
224
|
+
reason: import("convex/values").VLiteral<"provider_pending", "required">;
|
|
225
|
+
retryable: import("convex/values").VLiteral<true, "required">;
|
|
226
|
+
}, "required", "reason" | "retryable" | "status">], "optional", "enabled" | "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "reason" | "retryable" | "status">;
|
|
227
|
+
imported: import("convex/values").VObject<{
|
|
228
|
+
operation?: {
|
|
229
|
+
accountId: string;
|
|
230
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
231
|
+
scopeKey: string;
|
|
232
|
+
version: number;
|
|
233
|
+
} | undefined;
|
|
234
|
+
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
235
|
+
} | undefined, {
|
|
236
|
+
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
237
|
+
operation: import("convex/values").VObject<{
|
|
238
|
+
accountId: string;
|
|
239
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
240
|
+
scopeKey: string;
|
|
241
|
+
version: number;
|
|
242
|
+
} | undefined, {
|
|
243
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
244
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
245
|
+
operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
|
|
246
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
247
|
+
}, "optional", "accountId" | "operationId" | "scopeKey" | "version">;
|
|
248
|
+
}, "optional", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "preparationId">;
|
|
249
|
+
}, "required", "imported" | "imported.operation" | "imported.operation.accountId" | "imported.operation.operationId" | "imported.operation.scopeKey" | "imported.operation.version" | "imported.preparationId" | "payload" | "preparationId" | "requestKey" | "result" | "result.enabled" | "result.operation" | "result.operation.accountId" | "result.operation.operationId" | "result.operation.scopeKey" | "result.operation.version" | "result.reason" | "result.retryable" | "result.status">, {
|
|
250
|
+
by_request: ["requestKey", "_creationTime"];
|
|
251
|
+
}, {}, {}>;
|
|
2
252
|
operationEvidencePayloads: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
253
|
commissionExposure?: {
|
|
4
254
|
chargeAmount: number;
|
|
@@ -1291,6 +1541,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
1291
1541
|
maxCredit: number;
|
|
1292
1542
|
maxDebit: number;
|
|
1293
1543
|
pendingOperations: number;
|
|
1544
|
+
preparationSequence?: number | undefined;
|
|
1294
1545
|
scopeKey: string;
|
|
1295
1546
|
sourceGross?: number | undefined;
|
|
1296
1547
|
sourceId: string;
|
|
@@ -1310,6 +1561,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
1310
1561
|
maxCredit: import("convex/values").VFloat64<number, "required">;
|
|
1311
1562
|
amount: import("convex/values").VFloat64<number, "required">;
|
|
1312
1563
|
pendingOperations: import("convex/values").VFloat64<number, "required">;
|
|
1564
|
+
preparationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
1313
1565
|
invoiceItemId: import("convex/values").VString<string | undefined, "optional">;
|
|
1314
1566
|
invoiceFunding: import("convex/values").VObject<{
|
|
1315
1567
|
sourceChargeId: string;
|
|
@@ -1321,7 +1573,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
|
|
|
1321
1573
|
sourceProcessingFee: import("convex/values").VFloat64<number, "required">;
|
|
1322
1574
|
}, "optional", "sourceChargeId" | "sourceGross" | "sourceProcessingFee">;
|
|
1323
1575
|
status: import("convex/values").VUnion<"collected" | "collecting" | "open" | "released" | "releasing" | "sealed", [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"sealed", "required">, import("convex/values").VLiteral<"collecting", "required">, import("convex/values").VLiteral<"releasing", "required">, import("convex/values").VLiteral<"collected", "required">, import("convex/values").VLiteral<"released", "required">], "required", never>;
|
|
1324
|
-
}, "required", "accountId" | "amount" | "currency" | "groupKey" | "invoiceFunding" | "invoiceFunding.sourceChargeId" | "invoiceFunding.sourceGross" | "invoiceFunding.sourceProcessingFee" | "invoiceItemId" | "maxCredit" | "maxDebit" | "pendingOperations" | "scopeKey" | "sourceGross" | "sourceId" | "sourceKind" | "sourceProcessingFee" | "status">, {
|
|
1576
|
+
}, "required", "accountId" | "amount" | "currency" | "groupKey" | "invoiceFunding" | "invoiceFunding.sourceChargeId" | "invoiceFunding.sourceGross" | "invoiceFunding.sourceProcessingFee" | "invoiceItemId" | "maxCredit" | "maxDebit" | "pendingOperations" | "preparationSequence" | "scopeKey" | "sourceGross" | "sourceId" | "sourceKind" | "sourceProcessingFee" | "status">, {
|
|
1325
1577
|
by_key: ["groupKey", "_creationTime"];
|
|
1326
1578
|
}, {}, {}>;
|
|
1327
1579
|
recoveryReservations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
package/dist/component/schema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { preparationsTable as balanceFundingPreparations, operationsTable as balanceFundingOperations, requestsTable as balanceFundingRequests, } from "./balanceFunding/schema.js";
|
|
1
2
|
import { payloadsTable as operationEvidencePayloads, headersTable as operationEvidenceHeaders, } from "./operationEvidence/schema.js";
|
|
2
3
|
import { transferBatchReferencesTable } from "./financialObservations/transferReferenceSchema.js";
|
|
3
4
|
import { transferObservationsTable, transferBatchesTable, } from "./financialObservations/transferSchema.js";
|
|
@@ -21,6 +22,9 @@ import { accountsTable } from "./core/schema";
|
|
|
21
22
|
import { pricesTable, productsTable } from "./products/schema";
|
|
22
23
|
import { webhookEventsTable } from "./webhooks/schema";
|
|
23
24
|
export default defineSchema({
|
|
25
|
+
balanceFundingPreparations,
|
|
26
|
+
balanceFundingOperations,
|
|
27
|
+
balanceFundingRequests,
|
|
24
28
|
operationEvidencePayloads,
|
|
25
29
|
operationEvidenceHeaders,
|
|
26
30
|
financialTransferObservations: transferObservationsTable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,GACzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,SAAS,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,eAAe,IAAI,mBAAmB,EACtC,aAAa,IAAI,iBAAiB,EAClC,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,iBAAiB,GACnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,IAAI,sBAAsB,EAC1C,WAAW,IAAI,wBAAwB,EACvC,YAAY,IAAI,4BAA4B,GAC7C,MAAM,2BAA2B,CAAC;AACnC,OAA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ACzC,mBAAmB,EAAE,wBAAwB;IAC7C,uBAAuB,EAAE,4BAA4B;IACrD,cAAc,EAAE,aAAa;IAC7B,sBAAsB,EAAE,eAAe;IACvC,cAAc,EAAE,mBAAmB;IACnC,cAAc,EAAE,WAAW;IAC3B,gBAAgB,EAAE,aAAa;IAC/B,cAAc,EAAE,WAAW;IAC3B,oBAAoB,EAAE,iBAAiB;IACvC,qBAAqB,EAAE,gBAAgB;IACvC,eAAe,EAAE,oBAAoB;IACrC,mBAAmB,EAAE,wBAAwB;IAC7C,OAAO;IACP,QAAQ,EAAE,aAAa;IACvB,eAAe,EAAE,oBAAoB;IAErC,WAAW;IACX,QAAQ,EAAE,aAAa;IACvB,MAAM,EAAE,WAAW;IAEnB,UAAU;IACV,aAAa,EAAE,kBAAkB;IACjC,gBAAgB,EAAE,qBAAqB;IACvC,QAAQ,EAAE,aAAa;IAEvB,UAAU;IACV,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,YAAY;IACrB,iBAAiB,EAAE,sBAAsB;IACzC,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,cAAc;IACzB,mBAAmB,EAAE,wBAAwB;IAE7C,WAAW;IACX,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fantastic.dev/better-stripe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "A Convex component for Stripe V2 Accounts API integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stripe",
|
|
@@ -110,6 +110,8 @@
|
|
|
110
110
|
"check:agents": "repo-gates check-agents"
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
|
+
"@convex-dev/workflow": "0.4.10",
|
|
114
|
+
"@convex-dev/workpool": "0.4.14",
|
|
113
115
|
"@stripe/connect-js": "^3.4.6",
|
|
114
116
|
"@stripe/react-connect-js": "^3.4.4",
|
|
115
117
|
"@stripe/react-stripe-js": "^7.0.0",
|
|
@@ -145,7 +147,7 @@
|
|
|
145
147
|
"vitest": "^5.0.3"
|
|
146
148
|
},
|
|
147
149
|
"peerDependencies": {
|
|
148
|
-
"convex": "^1.
|
|
150
|
+
"convex": "^1.46.0",
|
|
149
151
|
"react": "^18.3.1 || ^19.0.0",
|
|
150
152
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
151
153
|
},
|
|
@@ -74,3 +74,37 @@ it("uses the real component through the public recovery client without any provi
|
|
|
74
74
|
reservedAmount: 0,
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
it("prepares recovery through one component mutation without a provider key", async () => {
|
|
78
|
+
const t = initConvexTest();
|
|
79
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
80
|
+
const stripe = new BetterStripe(
|
|
81
|
+
componentsGeneric().betterStripe as unknown as Component,
|
|
82
|
+
{},
|
|
83
|
+
);
|
|
84
|
+
let writes = 0;
|
|
85
|
+
const ctx = {
|
|
86
|
+
runMutation: (
|
|
87
|
+
ref: FunctionReference<"mutation">,
|
|
88
|
+
args: Record<string, unknown>,
|
|
89
|
+
) => {
|
|
90
|
+
writes++;
|
|
91
|
+
return t.mutation(ref, args);
|
|
92
|
+
},
|
|
93
|
+
} as unknown as RunCtx;
|
|
94
|
+
const opts = {
|
|
95
|
+
accountId: "acct_owner",
|
|
96
|
+
scopeKey: "store",
|
|
97
|
+
currency: "usd",
|
|
98
|
+
groupKey: "empty",
|
|
99
|
+
sourceKind: "invoice" as const,
|
|
100
|
+
sourceId: "in_empty",
|
|
101
|
+
maxDebit: 100,
|
|
102
|
+
maxCredit: 100,
|
|
103
|
+
};
|
|
104
|
+
expect(await stripe.costRecovery.prepareGroup(ctx, opts)).toMatchObject({
|
|
105
|
+
status: "prepared",
|
|
106
|
+
isDone: true,
|
|
107
|
+
group: { status: "sealed", amount: 0 },
|
|
108
|
+
});
|
|
109
|
+
expect(writes).toBe(1);
|
|
110
|
+
});
|
|
@@ -63,6 +63,7 @@ export type RecoveryGroup = RecoveryGroupOptions & {
|
|
|
63
63
|
_creationTime: number;
|
|
64
64
|
amount: number;
|
|
65
65
|
pendingOperations: number;
|
|
66
|
+
preparationSequence?: number;
|
|
66
67
|
invoiceItemId?: string;
|
|
67
68
|
invoiceFunding?: {
|
|
68
69
|
sourceChargeId: string;
|
|
@@ -82,6 +83,18 @@ export type RecoveryReservation = {
|
|
|
82
83
|
allocations: { claimId: string; claimKey: string; amount: number }[];
|
|
83
84
|
status: "reserved" | "collected" | "released" | "empty";
|
|
84
85
|
};
|
|
86
|
+
export type RecoveryPreparationResult =
|
|
87
|
+
| { status: "prepared"; group: RecoveryGroup; isDone: boolean }
|
|
88
|
+
| {
|
|
89
|
+
status: "conflict";
|
|
90
|
+
reason: "scope_busy" | "identity_changed";
|
|
91
|
+
retryable: false;
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
status: "rejected";
|
|
95
|
+
reason: "invalid_scope" | "policy_invalid";
|
|
96
|
+
retryable: false;
|
|
97
|
+
};
|
|
85
98
|
/** Host authorizes policy and scope. Provider methods verify invoice outcomes. */
|
|
86
99
|
export class CostRecoveryClient {
|
|
87
100
|
constructor(
|
|
@@ -213,6 +226,14 @@ export class CostRecoveryClient {
|
|
|
213
226
|
recordClaim(ctx: RunCtx, opts: RecoveryObservation) {
|
|
214
227
|
return this.mutate<RecoveryClaim>(ctx, "mutations/record", opts);
|
|
215
228
|
}
|
|
229
|
+
/** Authorize scope and limits first. Repeat bounded calls until isDone. */
|
|
230
|
+
prepareGroup(ctx: RunCtx, opts: RecoveryGroupOptions & { limit?: number }) {
|
|
231
|
+
return this.mutate<RecoveryPreparationResult>(
|
|
232
|
+
ctx,
|
|
233
|
+
"preparation/prepare",
|
|
234
|
+
opts,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
216
237
|
reserve(
|
|
217
238
|
ctx: RunCtx,
|
|
218
239
|
opts: RecoveryGroupOptions & { operationKey: string; limit?: number },
|
package/src/client/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as personalAccountMappingImpl from "./core/personalAccountMapping.js";
|
|
2
2
|
export type * from "./publicTypes.js";
|
|
3
3
|
export * from "./financialOutcomes/index.js";
|
|
4
|
+
export * from "./processingCostDeficit/index.js";
|
|
4
5
|
import * as accountClosuresImpl from "./core/accountClosures.js";
|
|
5
6
|
import type { PaginationOptions } from "convex/server";
|
|
6
7
|
import { reconcilePayoutAndTrigger } from "./webhooks/payoutReconciliation.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Processing-cost deficit
|
|
2
|
+
|
|
3
|
+
`calculateProcessingCostDeficit` is a pure SDK calculation. The host authorizes
|
|
4
|
+
the original same-currency source and explicitly chooses liability and rounding.
|
|
5
|
+
The helper creates no charges, claims or transfers. The example's existing
|
|
6
|
+
business policy stays in the host until its financial cutover.
|
|
7
|
+
|
|
8
|
+
All amounts use nonnegative safe integer API ledger units. Gross must be positive
|
|
9
|
+
and the original inclusive selling fee cannot exceed gross. Currency must have
|
|
10
|
+
supported package charge-currency metadata. Metadata does not establish account,
|
|
11
|
+
country or payment-method eligibility. This helper does not convert display
|
|
12
|
+
amounts or validate a provider-specific charge/transfer quantum.
|
|
13
|
+
|
|
14
|
+
Required policy fields:
|
|
15
|
+
|
|
16
|
+
- `liability.processingCosts: "uncovered"` subtracts the proportional retained
|
|
17
|
+
inclusive selling fee from processing costs and floors the liability at zero.
|
|
18
|
+
- `"all"` assigns all processing costs; `"none"` assigns none.
|
|
19
|
+
- `liability.disputeCosts: "all" | "none"` selects dispute-cost liability
|
|
20
|
+
independently. Actual credited costs should be resolved before calling.
|
|
21
|
+
- `rounding: "nearest" | "floor" | "ceil"` applies to the retained fee.
|
|
22
|
+
Nearest rounds a positive exact half up. No policy has a default.
|
|
23
|
+
|
|
24
|
+
The calculation caps overlapping refunded/disputed principal at original gross.
|
|
25
|
+
It returns normalized currency, retained fee, processing liability, dispute
|
|
26
|
+
liability and total `amountDue`. Unsafe input amounts or totals are rejected.
|
|
27
|
+
|
|
28
|
+
The old example formula's ordinary fixtures use processing `"uncovered"`,
|
|
29
|
+
disputes `"all"` and rounding `"nearest"`. USD, JPY, ISK and UGX fixture values
|
|
30
|
+
retain their historical integer-unit results. Multiplication and division now
|
|
31
|
+
use exact integers. At gross 9007199254740991, selling fee 9007199254740990 and
|
|
32
|
+
returned principal 3002399751580330, retained fee is exactly 6004799503160660.
|
|
33
|
+
The old floating-point intermediate incorrectly rounded it to 6004799503160661.
|
|
34
|
+
This correction intentionally preserves a one-unit liability that the old
|
|
35
|
+
formula lost. No host calculation changes until its caller adopts this API.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
calculateProcessingCostDeficit,
|
|
4
|
+
type ProcessingCostDeficitOptions,
|
|
5
|
+
} from "./index.js";
|
|
6
|
+
|
|
7
|
+
const original: ProcessingCostDeficitOptions = {
|
|
8
|
+
currency: "usd",
|
|
9
|
+
gross: 10000,
|
|
10
|
+
sellingFee: 900,
|
|
11
|
+
processingFee: 320,
|
|
12
|
+
principalReturned: 10000,
|
|
13
|
+
disputeFees: 0,
|
|
14
|
+
liability: { processingCosts: "uncovered", disputeCosts: "all" },
|
|
15
|
+
rounding: "nearest",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("explicit processing cost liability", () => {
|
|
19
|
+
it("passes uncovered costs on a full return under the host-selected policy", () => {
|
|
20
|
+
expect(calculateProcessingCostDeficit(original)).toEqual({
|
|
21
|
+
currency: "usd",
|
|
22
|
+
retainedFee: 0,
|
|
23
|
+
processingLiability: 320,
|
|
24
|
+
disputeLiability: 0,
|
|
25
|
+
amountDue: 320,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it.each(["usd", "jpy", "isk", "ugx"])(
|
|
29
|
+
"matches historical integer-unit rounding for ordinary %s values",
|
|
30
|
+
(currency) => {
|
|
31
|
+
for (const principalReturned of [0, 1, 1000, 5000, 9999, 10000, 12000]) {
|
|
32
|
+
for (const sellingFee of [0, 320, 490, 900]) {
|
|
33
|
+
const retainedFee = Math.round(
|
|
34
|
+
(sellingFee * (10000 - Math.min(10000, principalReturned))) / 10000,
|
|
35
|
+
);
|
|
36
|
+
const result = calculateProcessingCostDeficit({
|
|
37
|
+
...original,
|
|
38
|
+
currency,
|
|
39
|
+
principalReturned,
|
|
40
|
+
sellingFee,
|
|
41
|
+
disputeFees: 1500,
|
|
42
|
+
});
|
|
43
|
+
expect(result.retainedFee).toBe(retainedFee);
|
|
44
|
+
expect(result.amountDue).toBe(Math.max(0, 320 - retainedFee) + 1500);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
it("lets the host retain all liability instead of assuming a seller pays", () => {
|
|
50
|
+
expect(
|
|
51
|
+
calculateProcessingCostDeficit({
|
|
52
|
+
...original,
|
|
53
|
+
disputeFees: 1500,
|
|
54
|
+
liability: { processingCosts: "none", disputeCosts: "none" },
|
|
55
|
+
}),
|
|
56
|
+
).toMatchObject({
|
|
57
|
+
processingLiability: 0,
|
|
58
|
+
disputeLiability: 0,
|
|
59
|
+
amountDue: 0,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it("supports all processing costs with an independent dispute policy", () => {
|
|
63
|
+
expect(
|
|
64
|
+
calculateProcessingCostDeficit({
|
|
65
|
+
...original,
|
|
66
|
+
principalReturned: 0,
|
|
67
|
+
disputeFees: 1500,
|
|
68
|
+
liability: { processingCosts: "all", disputeCosts: "none" },
|
|
69
|
+
}),
|
|
70
|
+
).toMatchObject({
|
|
71
|
+
retainedFee: 900,
|
|
72
|
+
processingLiability: 320,
|
|
73
|
+
amountDue: 320,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
it.each([
|
|
77
|
+
["nearest", 5, 0],
|
|
78
|
+
["floor", 4, 1],
|
|
79
|
+
["ceil", 5, 0],
|
|
80
|
+
] as const)(
|
|
81
|
+
"uses the selected %s rounding for retained fee",
|
|
82
|
+
(rounding, retainedFee, amountDue) => {
|
|
83
|
+
expect(
|
|
84
|
+
calculateProcessingCostDeficit({
|
|
85
|
+
...original,
|
|
86
|
+
gross: 10,
|
|
87
|
+
sellingFee: 5,
|
|
88
|
+
processingFee: 5,
|
|
89
|
+
principalReturned: 1,
|
|
90
|
+
rounding,
|
|
91
|
+
}),
|
|
92
|
+
).toMatchObject({ retainedFee, amountDue });
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
it("does not lose a unit when an intermediate product exceeds safe integer precision", () => {
|
|
96
|
+
expect(
|
|
97
|
+
calculateProcessingCostDeficit({
|
|
98
|
+
...original,
|
|
99
|
+
gross: 9007199254740991,
|
|
100
|
+
sellingFee: 9007199254740990,
|
|
101
|
+
principalReturned: 3002399751580330,
|
|
102
|
+
processingFee: 6004799503160661,
|
|
103
|
+
}),
|
|
104
|
+
).toMatchObject({ retainedFee: 6004799503160660, amountDue: 1 });
|
|
105
|
+
});
|
|
106
|
+
it("caps overlapping returned principal at original gross and includes actual dispute costs", () => {
|
|
107
|
+
expect(
|
|
108
|
+
calculateProcessingCostDeficit({
|
|
109
|
+
...original,
|
|
110
|
+
principalReturned: 20000,
|
|
111
|
+
disputeFees: 1500,
|
|
112
|
+
}),
|
|
113
|
+
).toMatchObject({ retainedFee: 0, amountDue: 1820 });
|
|
114
|
+
});
|
|
115
|
+
it("normalizes currency codes without converting any ledger units", () => {
|
|
116
|
+
expect(
|
|
117
|
+
calculateProcessingCostDeficit({ ...original, currency: "USD" }).currency,
|
|
118
|
+
).toBe("usd");
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("invalid financial inputs", () => {
|
|
123
|
+
it.each([null, undefined])(
|
|
124
|
+
"rejects an absent options object %s",
|
|
125
|
+
(options) => {
|
|
126
|
+
expect(() =>
|
|
127
|
+
calculateProcessingCostDeficit(
|
|
128
|
+
options as unknown as ProcessingCostDeficitOptions,
|
|
129
|
+
),
|
|
130
|
+
).toThrow(RangeError);
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
it.each([
|
|
134
|
+
"gross",
|
|
135
|
+
"sellingFee",
|
|
136
|
+
"processingFee",
|
|
137
|
+
"principalReturned",
|
|
138
|
+
"disputeFees",
|
|
139
|
+
] as const)("rejects invalid %s values", (field) => {
|
|
140
|
+
for (const value of [-1, 1.5, NaN, Infinity, Number.MAX_SAFE_INTEGER + 1]) {
|
|
141
|
+
expect(() =>
|
|
142
|
+
calculateProcessingCostDeficit({ ...original, [field]: value }),
|
|
143
|
+
).toThrow(RangeError);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
it.each([
|
|
147
|
+
{ gross: 0 },
|
|
148
|
+
{ sellingFee: 10001 },
|
|
149
|
+
{ currency: "unknown" },
|
|
150
|
+
{ currency: "kwd" },
|
|
151
|
+
{ rounding: "random" },
|
|
152
|
+
{ liability: { processingCosts: "seller", disputeCosts: "all" } },
|
|
153
|
+
{ liability: { processingCosts: "uncovered", disputeCosts: "seller" } },
|
|
154
|
+
{ liability: undefined },
|
|
155
|
+
{ rounding: undefined },
|
|
156
|
+
])(
|
|
157
|
+
"rejects missing/unsupported currency, policy or amount combinations %j",
|
|
158
|
+
(invalid) => {
|
|
159
|
+
expect(() =>
|
|
160
|
+
calculateProcessingCostDeficit({
|
|
161
|
+
...original,
|
|
162
|
+
...invalid,
|
|
163
|
+
} as ProcessingCostDeficitOptions),
|
|
164
|
+
).toThrow(RangeError);
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
it("rejects an unrepresentable total even when each input is a safe integer", () => {
|
|
168
|
+
expect(() =>
|
|
169
|
+
calculateProcessingCostDeficit({
|
|
170
|
+
...original,
|
|
171
|
+
processingFee: Number.MAX_SAFE_INTEGER,
|
|
172
|
+
disputeFees: 1,
|
|
173
|
+
}),
|
|
174
|
+
).toThrow(RangeError);
|
|
175
|
+
});
|
|
176
|
+
});
|