@fantastic.dev/better-stripe 0.83.0 → 0.84.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 +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/couponJoins.d.ts +1 -1
- package/dist/client/billing/renewalAttach/couponJoins.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/couponJoins.js +3 -3
- package/dist/client/billing/renewalAttach/couponJoins.js.map +1 -1
- package/dist/client/billing/renewalAttach/reader.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/reader.js +5 -8
- package/dist/client/billing/renewalAttach/reader.js.map +1 -1
- package/dist/client/billing/renewalAttach/wireJson.d.ts +24 -0
- package/dist/client/billing/renewalAttach/wireJson.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/wireJson.js +51 -0
- package/dist/client/billing/renewalAttach/wireJson.js.map +1 -0
- package/dist/client/billing/renewalV2/binding.d.ts +3 -0
- package/dist/client/billing/renewalV2/binding.d.ts.map +1 -0
- package/dist/client/billing/renewalV2/binding.js +18 -0
- package/dist/client/billing/renewalV2/binding.js.map +1 -0
- package/dist/client/billing/renewalV2/index.d.ts +38 -0
- package/dist/client/billing/renewalV2/index.d.ts.map +1 -0
- package/dist/client/billing/renewalV2/index.js +70 -0
- package/dist/client/billing/renewalV2/index.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
- package/dist/client/helpers.d.ts.map +1 -1
- package/dist/client/helpers.js +2 -2
- package/dist/client/helpers.js.map +1 -1
- package/dist/client/renewal.d.ts +2 -0
- package/dist/client/renewal.d.ts.map +1 -1
- package/dist/client/renewal.js +1 -0
- package/dist/client/renewal.js.map +1 -1
- package/dist/client/singleAttemptHttpClient.d.ts +1 -1
- package/dist/client/singleAttemptHttpClient.d.ts.map +1 -1
- package/dist/client/singleAttemptHttpClient.js +1 -1
- package/dist/client/singleAttemptHttpClient.js.map +1 -1
- package/dist/client/strictStripeTransport.d.ts +4 -0
- package/dist/client/strictStripeTransport.d.ts.map +1 -0
- package/dist/client/strictStripeTransport.js +7 -0
- package/dist/client/strictStripeTransport.js.map +1 -0
- package/dist/client/usage/observationClient.d.ts +2 -2
- package/dist/client/usage/observationClient.d.ts.map +1 -1
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/earnings/triggers.d.ts +16 -16
- package/docs/renewal-context-reads.md +101 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/couponEvidence.test.ts +1 -2
- package/src/client/billing/renewalAttach/couponJoins.ts +2 -5
- package/src/client/billing/renewalAttach/reader.test.ts +1 -1
- package/src/client/billing/renewalAttach/reader.ts +6 -12
- package/src/client/billing/renewalAttach/wireJson.test.ts +265 -0
- package/src/client/billing/renewalAttach/wireJson.ts +75 -0
- package/src/client/billing/renewalV2/binding.ts +25 -0
- package/src/client/billing/renewalV2/index.test.ts +414 -0
- package/src/client/billing/renewalV2/index.ts +111 -0
- package/src/client/helpers.ts +2 -4
- package/src/client/renewal.ts +10 -0
- package/src/client/singleAttemptHttpClient.ts +1 -1
- package/src/client/strictStripeTransport.test.ts +73 -0
- package/src/client/strictStripeTransport.ts +11 -0
package/dist/client/renewal.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export type { RenewalPriceReplacementExpected } from "./billing/renewalReplaceme
|
|
|
5
5
|
export { prepareRenewalScheduleAttachment } from "./billing/renewalAttach/request.js";
|
|
6
6
|
export type { PrepareRenewalScheduleAttachmentOptions, PreparedRenewalScheduleAttachment, } from "./billing/renewalAttach/request.js";
|
|
7
7
|
export type { ReadRenewalPriceReplacementContextOptions } from "./billing/renewalAttach/reader.js";
|
|
8
|
+
export { prepareRenewalPriceReplacementV2, prepareRenewalScheduleAttachmentV2, } from "./billing/renewalV2/index.js";
|
|
9
|
+
export type { PrepareRenewalPriceReplacementV2Options, PreparedRenewalPriceReplacementV2, PrepareRenewalScheduleAttachmentV2Options, PreparedRenewalScheduleAttachmentV2, } from "./billing/renewalV2/index.js";
|
|
8
10
|
//# sourceMappingURL=renewal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal.d.ts","sourceRoot":"","sources":["../../src/client/renewal.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,YAAY,EACV,qCAAqC,EACrC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,YAAY,EACV,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,yCAAyC,EAAE,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"renewal.d.ts","sourceRoot":"","sources":["../../src/client/renewal.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,YAAY,EACV,qCAAqC,EACrC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,YAAY,EACV,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,yCAAyC,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EACL,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,uCAAuC,EACvC,iCAAiC,EACjC,yCAAyC,EACzC,mCAAmC,GACpC,MAAM,8BAA8B,CAAC"}
|
package/dist/client/renewal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Public pure renewal preparation functions and their input/result types. */
|
|
2
2
|
export { prepareRenewalPriceReplacement } from "./billing/renewalPriceReplacement.js";
|
|
3
3
|
export { prepareRenewalScheduleAttachment } from "./billing/renewalAttach/request.js";
|
|
4
|
+
export { prepareRenewalPriceReplacementV2, prepareRenewalScheduleAttachmentV2, } from "./billing/renewalV2/index.js";
|
|
4
5
|
//# sourceMappingURL=renewal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal.js","sourceRoot":"","sources":["../../src/client/renewal.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAMtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"renewal.js","sourceRoot":"","sources":["../../src/client/renewal.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAMtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAMtF,OAAO,EACL,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Stripe from "stripe";
|
|
2
|
-
/**
|
|
2
|
+
/** Guard for Stripe's closed-connection retry exception. */
|
|
3
3
|
export declare class SingleAttemptHttpClient implements Stripe.HttpClient {
|
|
4
4
|
private readonly delegate;
|
|
5
5
|
constructor(delegate: Stripe.HttpClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleAttemptHttpClient.d.ts","sourceRoot":"","sources":["../../src/client/singleAttemptHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAc5B,
|
|
1
|
+
{"version":3,"file":"singleAttemptHttpClient.d.ts","sourceRoot":"","sources":["../../src/client/singleAttemptHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAc5B,4DAA4D;AAC5D,qBAAa,uBAAwB,YAAW,MAAM,CAAC,UAAU;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAArC,YAA6B,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAI;IAE5D,aAAa,IAAI,MAAM,CAEtB;IAEK,WAAW,CACf,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,GACpD,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAgB9C;CACF;AAED,iFAAiF;AACjF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAahE"}
|
|
@@ -9,7 +9,7 @@ class SingleAttemptConnectionClosed extends Error {
|
|
|
9
9
|
this.cause = cause;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** Guard for Stripe's closed-connection retry exception. */
|
|
13
13
|
export class SingleAttemptHttpClient {
|
|
14
14
|
delegate;
|
|
15
15
|
constructor(delegate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleAttemptHttpClient.js","sourceRoot":"","sources":["../../src/client/singleAttemptHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,gFAAgF;AAChF,MAAM,6BAA8B,SAAQ,KAAK;IAEpC,aAAa;IACb,KAAK;IAFhB,YACW,aAAqB,EACrB,KAAc;QAEvB,KAAK,CACH,sHAAsH,CACvH,CAAC;6BALO,aAAa;qBACb,KAAK;IAKhB,CAAC;CACF;AAED,
|
|
1
|
+
{"version":3,"file":"singleAttemptHttpClient.js","sourceRoot":"","sources":["../../src/client/singleAttemptHttpClient.ts"],"names":[],"mappings":"AAAA,O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AAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;SAC9B,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strictStripeTransport.d.ts","sourceRoot":"","sources":["../../src/client/strictStripeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,+EAA+E;AAC/E,wBAAgB,6BAA6B,IAAI,MAAM,CAAC,UAAU,CAMjE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import { SingleAttemptHttpClient } from "./singleAttemptHttpClient.js";
|
|
3
|
+
/** No fetch redirect replay, plus the Stripe closed-connection retry guard. */
|
|
4
|
+
export function createSingleAttemptHttpClient() {
|
|
5
|
+
return new SingleAttemptHttpClient(Stripe.createFetchHttpClient((input, init) => fetch(input, { ...init, redirect: "error" })));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=strictStripeTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strictStripeTransport.js","sourceRoot":"","sources":["../../src/client/strictStripeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,+EAA+E;AAC/E,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,uBAAuB,CAChC,MAAM,CAAC,qBAAqB,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAC7C,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -59,10 +59,10 @@ export declare class UsageObservationClient extends UsageDeliveryClient {
|
|
|
59
59
|
retryable: boolean;
|
|
60
60
|
};
|
|
61
61
|
correctionHistory: {
|
|
62
|
+
reason?: undefined;
|
|
62
63
|
status: "available";
|
|
63
64
|
observedAt: number;
|
|
64
65
|
value: import("./correctionRead.js").UsageCorrectionHistoryPage;
|
|
65
|
-
reason?: undefined;
|
|
66
66
|
retryable?: undefined;
|
|
67
67
|
legacyHistoryMissing?: undefined;
|
|
68
68
|
} | {
|
|
@@ -84,10 +84,10 @@ export declare class UsageObservationClient extends UsageDeliveryClient {
|
|
|
84
84
|
retryable: boolean;
|
|
85
85
|
};
|
|
86
86
|
correctionHistory: {
|
|
87
|
+
reason?: undefined;
|
|
87
88
|
status: "available";
|
|
88
89
|
observedAt: number;
|
|
89
90
|
value: import("./correctionRead.js").UsageCorrectionHistoryPage;
|
|
90
|
-
reason?: undefined;
|
|
91
91
|
retryable?: undefined;
|
|
92
92
|
legacyHistoryMissing?: undefined;
|
|
93
93
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observationClient.d.ts","sourceRoot":"","sources":["../../../src/client/usage/observationClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,GAAG;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,8EAA8E;AAC9E,qBAAa,sBAAuB,SAAQ,mBAAmB;IACvD,UAAU,CACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GACrE,OAAO,CAAC,iBAAiB,CAAC,CAY5B;IACK,gBAAgB,CACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,yBAAyB,CAAC,CA0BpC;IACK,oBAAoB,CACxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,yBAAyB,CAAC,CA4BpC;IACK,mBAAmB,CACvB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,gBAAgB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;;;;;;;;;;OAkCnE;IACK,qBAAqB,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,gBAAgB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;;;;;;;OA+BnE;IACK,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACvD,OAAO,EAAE,4BAA4B,mHAgBtC;IACK,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B;;;;;YAqBhE,MAAM,EAAE,aAAa;YACrB,MAAM;YACN,SAAS
|
|
1
|
+
{"version":3,"file":"observationClient.d.ts","sourceRoot":"","sources":["../../../src/client/usage/observationClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,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G,EAAE,MAAM,EACX,KAAK,EAAE,gBAAgB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;;;;;;;OA+BnE;IACK,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACvD,OAAO,EAAE,4BAA4B,mHAgBtC;IACK,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B;;;;;YAqBhE,MAAM,EAAE,aAAa;YACrB,MAAM;YACN,SAAS;;;;oBAIG,WAAW;;;;;;;;oBAKX,aAAa;;;;;OAM9B;IACK,SAAS,CACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,0BAA0B,EACjC,OAAO,EAAE,4BAA4B;;;;;YArBjC,MAAM,EAAE,aAAa;YACrB,MAAM;YACN,SAAS;;;;oBAIG,WAAW;;;;;;;;oBAKX,aAAa;;;;;OAc9B;CACF"}
|
|
@@ -22,6 +22,14 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
22
22
|
requestKey: string;
|
|
23
23
|
scopeKey: string;
|
|
24
24
|
}, Promise<{
|
|
25
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
26
|
+
retryable: false;
|
|
27
|
+
status: "conflict";
|
|
28
|
+
} | {
|
|
29
|
+
reason: "policy_invalid";
|
|
30
|
+
retryable: false;
|
|
31
|
+
status: "rejected";
|
|
32
|
+
} | {
|
|
25
33
|
operation: {
|
|
26
34
|
accountId: string;
|
|
27
35
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -32,14 +40,6 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
32
40
|
} | {
|
|
33
41
|
enabled: boolean;
|
|
34
42
|
status: "unchanged";
|
|
35
|
-
} | {
|
|
36
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
37
|
-
retryable: false;
|
|
38
|
-
status: "conflict";
|
|
39
|
-
} | {
|
|
40
|
-
reason: "policy_invalid";
|
|
41
|
-
retryable: false;
|
|
42
|
-
status: "rejected";
|
|
43
43
|
} | {
|
|
44
44
|
reason: "provider_pending";
|
|
45
45
|
retryable: true;
|
|
@@ -395,6 +395,14 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
395
395
|
requestKey: string;
|
|
396
396
|
scopeKey: string;
|
|
397
397
|
}, Promise<{
|
|
398
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
399
|
+
retryable: false;
|
|
400
|
+
status: "conflict";
|
|
401
|
+
} | {
|
|
402
|
+
reason: "policy_invalid";
|
|
403
|
+
retryable: false;
|
|
404
|
+
status: "rejected";
|
|
405
|
+
} | {
|
|
398
406
|
operation: {
|
|
399
407
|
accountId: string;
|
|
400
408
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -405,14 +413,6 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
405
413
|
} | {
|
|
406
414
|
enabled: boolean;
|
|
407
415
|
status: "unchanged";
|
|
408
|
-
} | {
|
|
409
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
410
|
-
retryable: false;
|
|
411
|
-
status: "conflict";
|
|
412
|
-
} | {
|
|
413
|
-
reason: "policy_invalid";
|
|
414
|
-
retryable: false;
|
|
415
|
-
status: "rejected";
|
|
416
416
|
} | {
|
|
417
417
|
reason: "provider_pending";
|
|
418
418
|
retryable: true;
|
|
@@ -2,6 +2,14 @@ import type { Infer } from "convex/values";
|
|
|
2
2
|
import type { MutationCtx } from "../_generated/server.js";
|
|
3
3
|
import { prepareArgs, finishPreparationArgs } from "./mutationValidators.js";
|
|
4
4
|
export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prepareArgs>): Promise<{
|
|
5
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
6
|
+
retryable: false;
|
|
7
|
+
status: "conflict";
|
|
8
|
+
} | {
|
|
9
|
+
reason: "policy_invalid";
|
|
10
|
+
retryable: false;
|
|
11
|
+
status: "rejected";
|
|
12
|
+
} | {
|
|
5
13
|
operation: {
|
|
6
14
|
accountId: string;
|
|
7
15
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -12,14 +20,6 @@ export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prep
|
|
|
12
20
|
} | {
|
|
13
21
|
enabled: boolean;
|
|
14
22
|
status: "unchanged";
|
|
15
|
-
} | {
|
|
16
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
17
|
-
retryable: false;
|
|
18
|
-
status: "conflict";
|
|
19
|
-
} | {
|
|
20
|
-
reason: "policy_invalid";
|
|
21
|
-
retryable: false;
|
|
22
|
-
status: "rejected";
|
|
23
23
|
} | {
|
|
24
24
|
reason: "provider_pending";
|
|
25
25
|
retryable: true;
|
|
@@ -5,14 +5,6 @@ export declare function savePreparationHandler(ctx: MutationCtx, args: Infer<typ
|
|
|
5
5
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function beginHandler(ctx: MutationCtx, args: Infer<typeof beginArgs>): Promise<{
|
|
8
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
9
|
-
retryable: false;
|
|
10
|
-
status: "conflict";
|
|
11
|
-
} | {
|
|
12
|
-
reason: "policy_invalid";
|
|
13
|
-
retryable: false;
|
|
14
|
-
status: "rejected";
|
|
15
|
-
} | {
|
|
16
8
|
operation: {
|
|
17
9
|
accountId: string;
|
|
18
10
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -23,6 +15,14 @@ export declare function beginHandler(ctx: MutationCtx, args: Infer<typeof beginA
|
|
|
23
15
|
} | {
|
|
24
16
|
enabled: boolean;
|
|
25
17
|
status: "unchanged";
|
|
18
|
+
} | {
|
|
19
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
20
|
+
retryable: false;
|
|
21
|
+
status: "conflict";
|
|
22
|
+
} | {
|
|
23
|
+
reason: "policy_invalid";
|
|
24
|
+
retryable: false;
|
|
25
|
+
status: "rejected";
|
|
26
26
|
} | {
|
|
27
27
|
reason: "provider_pending";
|
|
28
28
|
retryable: true;
|
|
@@ -372,14 +372,6 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
|
|
|
372
372
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
373
373
|
requestKey: string;
|
|
374
374
|
result?: {
|
|
375
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
376
|
-
retryable: false;
|
|
377
|
-
status: "conflict";
|
|
378
|
-
} | {
|
|
379
|
-
reason: "policy_invalid";
|
|
380
|
-
retryable: false;
|
|
381
|
-
status: "rejected";
|
|
382
|
-
} | {
|
|
383
375
|
operation: {
|
|
384
376
|
accountId: string;
|
|
385
377
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -390,6 +382,14 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
|
|
|
390
382
|
} | {
|
|
391
383
|
enabled: boolean;
|
|
392
384
|
status: "unchanged";
|
|
385
|
+
} | {
|
|
386
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
387
|
+
retryable: false;
|
|
388
|
+
status: "conflict";
|
|
389
|
+
} | {
|
|
390
|
+
reason: "policy_invalid";
|
|
391
|
+
retryable: false;
|
|
392
|
+
status: "rejected";
|
|
393
393
|
} | {
|
|
394
394
|
reason: "provider_pending";
|
|
395
395
|
retryable: true;
|
|
@@ -3270,14 +3270,6 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
|
|
|
3270
3270
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
3271
3271
|
requestKey: string;
|
|
3272
3272
|
result?: {
|
|
3273
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
3274
|
-
retryable: false;
|
|
3275
|
-
status: "conflict";
|
|
3276
|
-
} | {
|
|
3277
|
-
reason: "policy_invalid";
|
|
3278
|
-
retryable: false;
|
|
3279
|
-
status: "rejected";
|
|
3280
|
-
} | {
|
|
3281
3273
|
operation: {
|
|
3282
3274
|
accountId: string;
|
|
3283
3275
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -3288,6 +3280,14 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
|
|
|
3288
3280
|
} | {
|
|
3289
3281
|
enabled: boolean;
|
|
3290
3282
|
status: "unchanged";
|
|
3283
|
+
} | {
|
|
3284
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
3285
|
+
retryable: false;
|
|
3286
|
+
status: "conflict";
|
|
3287
|
+
} | {
|
|
3288
|
+
reason: "policy_invalid";
|
|
3289
|
+
retryable: false;
|
|
3290
|
+
status: "rejected";
|
|
3291
3291
|
} | {
|
|
3292
3292
|
reason: "provider_pending";
|
|
3293
3293
|
retryable: true;
|
|
@@ -111,3 +111,104 @@ See the [replacement contract](renewal-price-replacements.md) and
|
|
|
111
111
|
[phase assembly](renewal-phase-assembly.md) for baseline, replay and observation
|
|
112
112
|
boundaries. Read comparison is best effort and cannot exclude concurrent
|
|
113
113
|
Dashboard or other provider writers.
|
|
114
|
+
|
|
115
|
+
## Wire JSON and transport status
|
|
116
|
+
|
|
117
|
+
Renewal reads use Stripe's public `rawRequest` for a fixed set of subscription,
|
|
118
|
+
Price, Customer and coupon GET endpoints. Each resource ID is encoded as one path
|
|
119
|
+
segment. Dot-only coupon IDs `.` and `..` are rejected before dispatch because
|
|
120
|
+
URL parsing would normalize them into different resource paths. The subscription's
|
|
121
|
+
fixed ordered expansion query is in the GET path,
|
|
122
|
+
with no GET body. Callers cannot supply endpoints, headers or expansion options.
|
|
123
|
+
The API version, platform scope and zero automatic network retries remain fixed.
|
|
124
|
+
|
|
125
|
+
Typed Stripe resource methods can convert decimal strings into SDK `Decimal`
|
|
126
|
+
objects. The raw request boundary preserves the parsed wire JSON instead,
|
|
127
|
+
including decimal string spelling, required native Plan fields and unknown
|
|
128
|
+
provider fields. The strict bounded JSON snapshot validator is unchanged. No
|
|
129
|
+
`Decimal.toString()` conversion, financial calculation or selective field
|
|
130
|
+
replacement makes unsupported evidence acceptable. This preserves JSON values,
|
|
131
|
+
not the original response whitespace or numeric token spelling.
|
|
132
|
+
|
|
133
|
+
A fulfilled SDK promise alone does not establish HTTP success. Each renewal
|
|
134
|
+
response must have actual successful transport status metadata. Fetch exposes
|
|
135
|
+
`lastResponse.status`; Node exposes `lastResponse.statusCode`. Missing, malformed,
|
|
136
|
+
contradictory or non-2xx metadata rejects the read. This nonenumerable transport
|
|
137
|
+
metadata stays outside the canonical provider body. Provider errors stay visible,
|
|
138
|
+
and these read checks do not acknowledge a schedule mutation.
|
|
139
|
+
|
|
140
|
+
The shared single-attempt client rejects fetch redirects as well as Stripe's
|
|
141
|
+
closed-connection retry exception. A 307 or 308 cannot silently replay a POST.
|
|
142
|
+
The ordinary client route keeps its existing transport behavior. Rejected
|
|
143
|
+
redirects and broken connections can leave a remote outcome unknown; callers
|
|
144
|
+
must retain the original request identity rather than rotate or resend
|
|
145
|
+
automatically. These transport safeguards do not qualify a renewal provider
|
|
146
|
+
profile or authorize attachment, configuration or entitlement changes.
|
|
147
|
+
|
|
148
|
+
## Additive async V2 preparation
|
|
149
|
+
|
|
150
|
+
Use the explicitly named V2 functions when compact SHA-256 consistency bindings
|
|
151
|
+
are needed. Existing V1 functions and retained V1 records keep their current
|
|
152
|
+
format and synchronous behavior.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import {
|
|
156
|
+
prepareRenewalPriceReplacementV2,
|
|
157
|
+
prepareRenewalScheduleAttachmentV2,
|
|
158
|
+
} from "@fantastic.dev/better-stripe";
|
|
159
|
+
|
|
160
|
+
const preparedV2 = await prepareRenewalPriceReplacementV2({
|
|
161
|
+
subscription: context.subscription,
|
|
162
|
+
targetPrice: context.targetPrice,
|
|
163
|
+
billingCustomer: context.billingCustomer,
|
|
164
|
+
expected,
|
|
165
|
+
key: logicalKey,
|
|
166
|
+
});
|
|
167
|
+
const attachRequestV2 = await prepareRenewalScheduleAttachmentV2({
|
|
168
|
+
prepared: preparedV2,
|
|
169
|
+
apiVersion: context.apiVersion,
|
|
170
|
+
attachKey,
|
|
171
|
+
firstDispatchedAt,
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Both functions are pure. They perform no provider request, generate no key,
|
|
176
|
+
persist no record and establish no provider qualification. The V2 attachment
|
|
177
|
+
builder accepts only a complete V2 preparation. It reconstructs that preparation
|
|
178
|
+
from its full provider snapshot, expected selectors and retained logical key,
|
|
179
|
+
and compares the entire result before constructing the request. A matching
|
|
180
|
+
digest alone is insufficient. V1 preparations are rejected by this builder;
|
|
181
|
+
there is no automatic migration or fallback. Existing V1 projection, receipt
|
|
182
|
+
and configure consumers do not accept V2 records. This release adds preparation
|
|
183
|
+
and request construction only, without a V2 writer or receipt constructor.
|
|
184
|
+
|
|
185
|
+
V2 retains the same raw preparation semantic checks and bounded JSON policy as
|
|
186
|
+
V1. It adds a limit of 500,000 UTF-8 bytes on each exact encoded hash preimage,
|
|
187
|
+
including its domain tuple. A record can therefore fit V1's character limit
|
|
188
|
+
and exceed V2's byte limit. Inputs are captured before awaiting hashing; changes
|
|
189
|
+
to the original caller object during the await cannot change the result. Web
|
|
190
|
+
Crypto SHA-256 must be available. Missing or rejected digest operations fail
|
|
191
|
+
without an alternate algorithm or synchronous fallback.
|
|
192
|
+
|
|
193
|
+
For a fixed family, the hash input is the UTF-8 encoding of the current bounded
|
|
194
|
+
`renewalSnapshot` canonical copy followed by `JSON.stringify`, applied to
|
|
195
|
+
`["betterstripe-renewal-binding", 2, family, completePreimage]`. Object keys use
|
|
196
|
+
the existing ordering, including JavaScript's numeric-index enumeration;
|
|
197
|
+
arrays retain their order and negative zero serializes as zero. The output is
|
|
198
|
+
`family:v2:sha256:` followed by the full 64 lowercase hexadecimal digest.
|
|
199
|
+
Families are selected internally: `renewal` for preparation and
|
|
200
|
+
`renewal-attach` for the attachment request.
|
|
201
|
+
|
|
202
|
+
The preparation preimage contains version, platform scope, expected selectors,
|
|
203
|
+
quantity and complete provider snapshot. Its logical key is separately retained
|
|
204
|
+
and validated, as in V1; changing only that valid key does not change the
|
|
205
|
+
preparation digest. Hosts must protect original key lineage through immutable
|
|
206
|
+
authorization and storage. The attachment preimage binds its entire unsigned
|
|
207
|
+
request, including stage, scope, actual API version, logical binding, POST path,
|
|
208
|
+
complete payload, explicit attachment key and original first-dispatch time.
|
|
209
|
+
Neither digest authenticates a caller, proves provenance, acknowledges a POST
|
|
210
|
+
or guarantees provider replay. Hosts retain the complete original records.
|
|
211
|
+
|
|
212
|
+
These helpers retain ordinary provider and caller metadata within their JSON
|
|
213
|
+
limits. They do not redact, encrypt or certify that input or output is safe to
|
|
214
|
+
log. Do not place secrets in metadata, and protect retained full records.
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ function controlled(value: unknown) {
|
|
|
28
28
|
"stripe-version": apiVersion,
|
|
29
29
|
}),
|
|
30
30
|
toJSON: async () => structuredClone(value),
|
|
31
|
-
getRawResponse: () => ({}),
|
|
31
|
+
getRawResponse: () => ({ statusCode: 200 }),
|
|
32
32
|
toStream: () => null,
|
|
33
33
|
} as unknown as Stripe.HttpClientResponse;
|
|
34
34
|
},
|
|
@@ -42,7 +42,6 @@ function controlled(value: unknown) {
|
|
|
42
42
|
source as Record<string, unknown>,
|
|
43
43
|
item as Record<string, unknown>,
|
|
44
44
|
false,
|
|
45
|
-
{ apiVersion, maxNetworkRetries: 0 },
|
|
46
45
|
),
|
|
47
46
|
};
|
|
48
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type Stripe from "stripe";
|
|
3
3
|
import { equal, object, unsupported } from "../renewalAggregate/shared.js";
|
|
4
|
-
import {
|
|
4
|
+
import { readRenewalWireJSON } from "./wireJson.js";
|
|
5
5
|
|
|
6
6
|
const id = z.string().min(1).max(255).regex(/\S/);
|
|
7
7
|
const discount = z
|
|
@@ -32,7 +32,6 @@ export async function joinRenewalCoupons(
|
|
|
32
32
|
subscription: Record<string, unknown>,
|
|
33
33
|
item: Record<string, unknown>,
|
|
34
34
|
livemode: boolean,
|
|
35
|
-
options: Stripe.RequestOptions,
|
|
36
35
|
) {
|
|
37
36
|
const lists = [subscription.discounts, item.discounts].map((value) => {
|
|
38
37
|
const parsed = z.array(discount).max(20).safeParse(value);
|
|
@@ -59,9 +58,7 @@ export async function joinRenewalCoupons(
|
|
|
59
58
|
: redemption.source.coupon.id;
|
|
60
59
|
let coupon = coupons.get(couponId);
|
|
61
60
|
if (!coupon) {
|
|
62
|
-
coupon = object(
|
|
63
|
-
renewalSnapshot(await stripe.coupons.retrieve(couponId, {}, options)),
|
|
64
|
-
);
|
|
61
|
+
coupon = object(await readRenewalWireJSON(stripe, "coupon", couponId));
|
|
65
62
|
if (
|
|
66
63
|
coupon.id !== couponId ||
|
|
67
64
|
coupon.object !== "coupon" ||
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
timestamp,
|
|
17
17
|
} from "../renewalAggregate/shared.js";
|
|
18
18
|
import { joinRenewalCoupons } from "./couponJoins.js";
|
|
19
|
+
import { readRenewalWireJSON } from "./wireJson.js";
|
|
19
20
|
|
|
20
21
|
const input = z.object({ expected: renewalExpected }).strict();
|
|
21
22
|
export type ReadRenewalPriceReplacementContextOptions = z.infer<typeof input>;
|
|
@@ -42,16 +43,12 @@ export async function readRenewalPriceReplacementContext(
|
|
|
42
43
|
const args = input.parse(renewalSnapshot(options));
|
|
43
44
|
supportedVersion(apiVersion);
|
|
44
45
|
const expected = args.expected;
|
|
45
|
-
const requestOptions = {
|
|
46
|
-
apiVersion: "2026-09-30.endive" as const,
|
|
47
|
-
maxNetworkRetries: 0,
|
|
48
|
-
};
|
|
49
46
|
const subscription = readSubscription.parse(
|
|
50
47
|
renewalSnapshot(
|
|
51
|
-
await
|
|
48
|
+
await readRenewalWireJSON(
|
|
49
|
+
stripe,
|
|
50
|
+
"subscription",
|
|
52
51
|
expected.subscriptionId,
|
|
53
|
-
{ expand: ["discounts", "items.data.discounts", "items.data.price"] },
|
|
54
|
-
requestOptions,
|
|
55
52
|
),
|
|
56
53
|
),
|
|
57
54
|
);
|
|
@@ -75,7 +72,7 @@ export async function readRenewalPriceReplacementContext(
|
|
|
75
72
|
unsupported("original_read_identity_mismatch");
|
|
76
73
|
const targetPrice = renewalPrice.parse(
|
|
77
74
|
renewalSnapshot(
|
|
78
|
-
await stripe
|
|
75
|
+
await readRenewalWireJSON(stripe, "price", expected.targetPriceId),
|
|
79
76
|
),
|
|
80
77
|
);
|
|
81
78
|
if (
|
|
@@ -91,9 +88,7 @@ export async function readRenewalPriceReplacementContext(
|
|
|
91
88
|
context,
|
|
92
89
|
);
|
|
93
90
|
const billingCustomer = renewalBillingCustomer.parse(
|
|
94
|
-
renewalSnapshot(
|
|
95
|
-
await stripe.customers.retrieve(customerId, {}, requestOptions),
|
|
96
|
-
),
|
|
91
|
+
renewalSnapshot(await readRenewalWireJSON(stripe, "customer", customerId)),
|
|
97
92
|
);
|
|
98
93
|
if (
|
|
99
94
|
billingCustomer.id !== customerId ||
|
|
@@ -106,7 +101,6 @@ export async function readRenewalPriceReplacementContext(
|
|
|
106
101
|
subscription,
|
|
107
102
|
item,
|
|
108
103
|
expected.livemode,
|
|
109
|
-
requestOptions,
|
|
110
104
|
);
|
|
111
105
|
const normalizedSubscription = {
|
|
112
106
|
...subscription,
|