@proxy-checkout/stripe-server-js 0.1.0-prx-146.162.1 → 0.1.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/README.md +15 -113
- package/dist/cjs/errors.d.cts +1 -68
- package/dist/cjs/errors.d.ts +1 -68
- package/dist/cjs/errors.js +1 -86
- package/dist/cjs/index.d.cts +4 -10
- package/dist/cjs/index.d.ts +4 -10
- package/dist/cjs/index.js +1 -24
- package/dist/cjs/metadata.d.cts +2 -26
- package/dist/cjs/metadata.d.ts +2 -26
- package/dist/cjs/metadata.js +3 -73
- package/dist/cjs/open-checkout.d.cts +0 -21
- package/dist/cjs/open-checkout.d.ts +0 -21
- package/dist/cjs/open-checkout.js +38 -310
- package/dist/cjs/sync-checkout-cart.d.cts +3 -3
- package/dist/cjs/sync-checkout-cart.d.ts +3 -3
- package/dist/cjs/sync-checkout-cart.js +22 -92
- package/dist/cjs/types.d.cts +0 -199
- package/dist/cjs/types.d.ts +0 -199
- package/dist/cjs/version.d.cts +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/errors.d.ts +1 -68
- package/dist/esm/errors.js +0 -80
- package/dist/esm/index.d.ts +4 -10
- package/dist/esm/index.js +2 -7
- package/dist/esm/metadata.d.ts +2 -26
- package/dist/esm/metadata.js +2 -69
- package/dist/esm/open-checkout.d.ts +0 -21
- package/dist/esm/open-checkout.js +40 -312
- package/dist/esm/sync-checkout-cart.d.ts +3 -3
- package/dist/esm/sync-checkout-cart.js +23 -93
- package/dist/esm/types.d.ts +0 -199
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/acquisition.d.cts +0 -189
- package/dist/cjs/acquisition.d.ts +0 -189
- package/dist/cjs/acquisition.js +0 -789
- package/dist/cjs/compatibility.d.cts +0 -66
- package/dist/cjs/compatibility.d.ts +0 -66
- package/dist/cjs/compatibility.js +0 -174
- package/dist/cjs/open-payment-intent.d.cts +0 -35
- package/dist/cjs/open-payment-intent.d.ts +0 -35
- package/dist/cjs/open-payment-intent.js +0 -157
- package/dist/cjs/open-setup-intent.d.cts +0 -49
- package/dist/cjs/open-setup-intent.d.ts +0 -49
- package/dist/cjs/open-setup-intent.js +0 -157
- package/dist/cjs/open-subscription.d.cts +0 -75
- package/dist/cjs/open-subscription.d.ts +0 -75
- package/dist/cjs/open-subscription.js +0 -307
- package/dist/cjs/subscription-params.d.cts +0 -33
- package/dist/cjs/subscription-params.d.ts +0 -33
- package/dist/cjs/subscription-params.js +0 -237
- package/dist/esm/acquisition.d.ts +0 -189
- package/dist/esm/acquisition.js +0 -763
- package/dist/esm/compatibility.d.ts +0 -66
- package/dist/esm/compatibility.js +0 -168
- package/dist/esm/open-payment-intent.d.ts +0 -35
- package/dist/esm/open-payment-intent.js +0 -154
- package/dist/esm/open-setup-intent.d.ts +0 -49
- package/dist/esm/open-setup-intent.js +0 -153
- package/dist/esm/open-subscription.d.ts +0 -75
- package/dist/esm/open-subscription.js +0 -304
- package/dist/esm/subscription-params.d.ts +0 -33
- package/dist/esm/subscription-params.js +0 -232
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* safest order with deterministic rollback/reconciliation on failure.
|
|
7
7
|
*/
|
|
8
8
|
import { type JsonObject, type MerchantProxySession, type ProxyCartValidator, type ProxyCheckoutServerClient } from "@proxy-checkout/server-js";
|
|
9
|
-
import type { StripeCheckoutSessionLike,
|
|
9
|
+
import type { StripeCheckoutSessionLike, StripeClientLike, StripeRequestOptionsWithoutIdempotencyLike } from "./types.js";
|
|
10
10
|
/** The next cart, expressed both as Proxy state and the typed merchant cart. */
|
|
11
11
|
export interface SyncedCart<TCart> {
|
|
12
12
|
readonly amountMinor: number;
|
|
@@ -14,7 +14,7 @@ export interface SyncedCart<TCart> {
|
|
|
14
14
|
readonly cartSnapshot: JsonObject;
|
|
15
15
|
readonly currency: string;
|
|
16
16
|
}
|
|
17
|
-
export interface SyncCheckoutCartOptions<TStripe extends
|
|
17
|
+
export interface SyncCheckoutCartOptions<TStripe extends StripeClientLike, TCart, TInput> {
|
|
18
18
|
/** Compute the next cart from current state and the merchant input. */
|
|
19
19
|
readonly buildNextCart: (input: {
|
|
20
20
|
currentCart: TCart;
|
|
@@ -44,4 +44,4 @@ export interface SyncCheckoutCartResult<TCart> {
|
|
|
44
44
|
readonly checkoutSession: StripeCheckoutSessionLike;
|
|
45
45
|
readonly currency: string;
|
|
46
46
|
}
|
|
47
|
-
export declare function syncCheckoutCart<TStripe extends
|
|
47
|
+
export declare function syncCheckoutCart<TStripe extends StripeClientLike, TCart, TInput>(options: SyncCheckoutCartOptions<TStripe, TCart, TInput>): Promise<SyncCheckoutCartResult<TCart>>;
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.syncCheckoutCart = syncCheckoutCart;
|
|
11
11
|
const server_js_1 = require("@proxy-checkout/server-js");
|
|
12
|
-
const acquisition_js_1 = require("./acquisition.js");
|
|
13
12
|
const errors_js_1 = require("./errors.js");
|
|
14
13
|
const metadata_js_1 = require("./metadata.js");
|
|
15
14
|
const psp_js_1 = require("./psp.js");
|
|
@@ -21,32 +20,11 @@ async function syncCheckoutCart(options) {
|
|
|
21
20
|
const session = await options.proxy.sessions.retrieve(options.proxySessionId, {
|
|
22
21
|
requestId: options.requestId,
|
|
23
22
|
});
|
|
24
|
-
// Ownership: validate the stored binding
|
|
25
|
-
//
|
|
23
|
+
// Ownership: validate against the stored binding first, then defensively
|
|
24
|
+
// against the Stripe object's own metadata.
|
|
26
25
|
assertSessionBoundTo(session, options.checkoutSessionId, psp);
|
|
27
|
-
const acquisition = session.currentAcquisitionAttempt === null
|
|
28
|
-
? null
|
|
29
|
-
: await resolveExplicitCheckoutAcquisition(options, session);
|
|
30
|
-
if (acquisition)
|
|
31
|
-
(0, acquisition_js_1.assertNoConnectRequestOptions)(options.stripeRequestOptions);
|
|
32
|
-
if (acquisition?.checkoutUiMode === "hosted") {
|
|
33
|
-
throw new errors_js_1.ProxyStripeCartSyncError("Hosted Stripe Checkout Sessions do not support line-item mutation. Expire the bound Session, wait for Proxy to observe provider-confirmed expiry, update the versioned Proxy cart, supersede the terminal acquisition, and call openCheckout again.", {
|
|
34
|
-
cause: new Error("Stripe hosted Checkout requires provider-confirmed replacement"),
|
|
35
|
-
code: "hosted_replacement_required",
|
|
36
|
-
reconciled: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
26
|
const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId, undefined, options.stripeRequestOptions);
|
|
40
|
-
|
|
41
|
-
(0, metadata_js_1.assertProviderObjectBelongsToAcquisition)(stripeSession, {
|
|
42
|
-
acquisitionAttemptId: acquisition.id,
|
|
43
|
-
integrationPath: "checkout_session",
|
|
44
|
-
proxySessionId: options.proxySessionId,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(stripeSession, options.proxySessionId);
|
|
49
|
-
}
|
|
27
|
+
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(stripeSession, options.proxySessionId);
|
|
50
28
|
const currentCart = options.cartSchema
|
|
51
29
|
? options.proxy.sessions.parseCart(session, options.cartSchema)
|
|
52
30
|
: session.cartSnapshot;
|
|
@@ -55,6 +33,12 @@ async function syncCheckoutCart(options) {
|
|
|
55
33
|
currentSession: session,
|
|
56
34
|
input: options.input,
|
|
57
35
|
});
|
|
36
|
+
const prior = {
|
|
37
|
+
amountMinor: session.amountMinor,
|
|
38
|
+
cartSnapshot: session.cartSnapshot,
|
|
39
|
+
cartVersion: session.cartVersion,
|
|
40
|
+
currency: session.currency,
|
|
41
|
+
};
|
|
58
42
|
const stripeUpdateParams = {
|
|
59
43
|
line_items: options.buildStripeLineItems(next.cart),
|
|
60
44
|
};
|
|
@@ -76,22 +60,19 @@ async function syncCheckoutCart(options) {
|
|
|
76
60
|
updatedCheckout = await options.stripe.checkout.sessions.update(options.checkoutSessionId, stripeUpdateParams, stripeUpdateOptions);
|
|
77
61
|
}
|
|
78
62
|
catch (retryCause) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch (cause) {
|
|
94
|
-
throw new errors_js_1.ProxyStripeCartSyncError("Stripe checkout was updated, but Proxy could not confirm the provider-authored cart revision; payment remains non-provisionable until reconciliation succeeds.", { cause, code: "reconciliation_failed", reconciled: false });
|
|
63
|
+
try {
|
|
64
|
+
await options.proxy.sessions.cart.set(options.proxySessionId, {
|
|
65
|
+
amountMinor: prior.amountMinor,
|
|
66
|
+
cartSnapshot: prior.cartSnapshot,
|
|
67
|
+
currency: prior.currency,
|
|
68
|
+
expectedCartVersion: proxyCartUpdate.cartVersion,
|
|
69
|
+
requestId: options.requestId,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (rollbackCause) {
|
|
73
|
+
throw new errors_js_1.ProxyStripeCartSyncError("Stripe checkout update failed after an idempotent retry and the Proxy cart rollback failed; carts may be out of sync.", { cause: retryCause, code: "reconciliation_failed", reconciled: false, rollbackCause });
|
|
74
|
+
}
|
|
75
|
+
throw new errors_js_1.ProxyStripeCartSyncError("Stripe checkout update failed after an idempotent retry; the Proxy cart rollback was attempted, but Stripe state may still be ambiguous.", { cause: retryCause, code: "stripe_update_failed", reconciled: false });
|
|
95
76
|
}
|
|
96
77
|
}
|
|
97
78
|
return {
|
|
@@ -102,57 +83,6 @@ async function syncCheckoutCart(options) {
|
|
|
102
83
|
currency: proxyCartUpdate.currency,
|
|
103
84
|
};
|
|
104
85
|
}
|
|
105
|
-
async function confirmCheckoutCartRevision(options, input) {
|
|
106
|
-
const checkoutSession = await (0, acquisition_js_1.retrieveCheckoutSessionWithLineEvidence)({
|
|
107
|
-
id: options.checkoutSessionId,
|
|
108
|
-
initial: input.checkoutSession,
|
|
109
|
-
requestOptions: options.stripeRequestOptions,
|
|
110
|
-
stripe: options.stripe,
|
|
111
|
-
});
|
|
112
|
-
const confirmation = (0, acquisition_js_1.checkoutCartConfirmation)({
|
|
113
|
-
cartVersion: input.cartVersion,
|
|
114
|
-
checkoutSession,
|
|
115
|
-
expectedLineItems: input.expectedLineItems,
|
|
116
|
-
});
|
|
117
|
-
const acquisition = input.acquisition;
|
|
118
|
-
if (acquisition.commercialMode !== "one_time" ||
|
|
119
|
-
acquisition.integrationPath !== "checkout_session") {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (acquisition.pricingMode === "fixed" &&
|
|
123
|
-
confirmation.amountMinor !== input.expectedAmountMinor) {
|
|
124
|
-
throw new Error("Stripe Checkout total does not match the fixed Proxy cart amount.");
|
|
125
|
-
}
|
|
126
|
-
if (confirmation.currency !== input.currency) {
|
|
127
|
-
throw new Error("Stripe Checkout currency does not match the Proxy cart currency.");
|
|
128
|
-
}
|
|
129
|
-
await options.proxy.providerAcquisitions.confirmProviderAcquisitionCart(options.proxySessionId, acquisition.id, {
|
|
130
|
-
...confirmation,
|
|
131
|
-
expectedVersion: acquisition.version,
|
|
132
|
-
requestId: options.requestId,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
async function resolveExplicitCheckoutAcquisition(options, session) {
|
|
136
|
-
const summary = session.currentAcquisitionAttempt;
|
|
137
|
-
if (summary === null || summary.integrationPath !== "checkout_session") {
|
|
138
|
-
throw acquisitionBindingMismatch(session.id, "current_acquisition_attempt.integration_path", "The current Proxy acquisition is not a Checkout Session acquisition.");
|
|
139
|
-
}
|
|
140
|
-
const acquisitions = await options.proxy.providerAcquisitions.listProviderAcquisitions(session.id, { requestId: options.requestId });
|
|
141
|
-
const acquisition = acquisitions.find((candidate) => candidate.id === summary.id);
|
|
142
|
-
if (acquisition?.psp !== "stripe" ||
|
|
143
|
-
acquisition.integrationPath !== "checkout_session" ||
|
|
144
|
-
acquisition.providerRootObjectType !== "checkout_session" ||
|
|
145
|
-
acquisition.providerRootObjectId !== options.checkoutSessionId) {
|
|
146
|
-
throw acquisitionBindingMismatch(session.id, "current_acquisition_attempt", "The current Proxy acquisition is not bound to the requested Stripe Checkout Session.");
|
|
147
|
-
}
|
|
148
|
-
return acquisition;
|
|
149
|
-
}
|
|
150
|
-
function acquisitionBindingMismatch(proxySessionId, field, message) {
|
|
151
|
-
return new server_js_1.ProxyCheckoutValidationError(`${message} Proxy session: ${proxySessionId}.`, {
|
|
152
|
-
code: "provider_binding_mismatch",
|
|
153
|
-
field,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
86
|
function buildStripeUpdateRequestOptions(options, cartVersion) {
|
|
157
87
|
return {
|
|
158
88
|
...options.stripeRequestOptions,
|
package/dist/cjs/types.d.cts
CHANGED
|
@@ -10,109 +10,17 @@ export type StripeMetadataValue = string | number | null;
|
|
|
10
10
|
export type StripeMetadata = Record<string, StripeMetadataValue> | null | undefined;
|
|
11
11
|
export type StripeMetadataParam = Record<string, StripeMetadataValue> | undefined;
|
|
12
12
|
export interface StripeCheckoutSessionLike {
|
|
13
|
-
readonly amount_subtotal?: number | null;
|
|
14
|
-
readonly amount_total?: number | null;
|
|
15
13
|
readonly client_secret?: string | null;
|
|
16
|
-
readonly currency?: string | null;
|
|
17
|
-
readonly customer?: null | string | {
|
|
18
|
-
readonly id: string;
|
|
19
|
-
};
|
|
20
14
|
readonly id: string;
|
|
21
|
-
readonly line_items?: StripeCheckoutLineItemListLike | null;
|
|
22
15
|
readonly metadata?: StripeMetadata;
|
|
23
|
-
readonly mode?: "payment" | "setup" | "subscription" | null;
|
|
24
|
-
readonly payment_intent?: string | {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
} | null;
|
|
27
|
-
readonly payment_status?: "no_payment_required" | "paid" | "unpaid" | string;
|
|
28
|
-
readonly status?: "complete" | "expired" | "open" | string | null;
|
|
29
|
-
readonly ui_mode?: string | null;
|
|
30
|
-
readonly url?: string | null;
|
|
31
|
-
}
|
|
32
|
-
export interface StripeCheckoutLineItemListLike {
|
|
33
|
-
readonly data?: readonly StripeCheckoutLineItemLike[];
|
|
34
|
-
readonly has_more?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface StripeCheckoutLineItemLike {
|
|
37
|
-
readonly description?: string | null;
|
|
38
|
-
readonly id?: string;
|
|
39
|
-
readonly price?: string | {
|
|
40
|
-
readonly currency?: string | null;
|
|
41
|
-
readonly id?: string;
|
|
42
|
-
readonly product?: string | {
|
|
43
|
-
readonly id?: string;
|
|
44
|
-
} | null;
|
|
45
|
-
readonly recurring?: {
|
|
46
|
-
readonly interval?: string;
|
|
47
|
-
readonly interval_count?: number;
|
|
48
|
-
readonly usage_type?: string;
|
|
49
|
-
} | null;
|
|
50
|
-
readonly type?: "one_time" | "recurring" | string;
|
|
51
|
-
readonly unit_amount?: number | null;
|
|
52
|
-
readonly unit_amount_decimal?: unknown;
|
|
53
|
-
} | null;
|
|
54
|
-
readonly quantity?: number | null;
|
|
55
|
-
}
|
|
56
|
-
export interface StripeCheckoutLineItemPageLike extends StripeCheckoutLineItemListLike {
|
|
57
16
|
}
|
|
58
17
|
export interface StripeSubscriptionLike {
|
|
59
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
60
|
-
readonly default_payment_method?: string | StripeObjectReferenceLike | null;
|
|
61
18
|
readonly id: string;
|
|
62
|
-
readonly latest_invoice?: string | StripeInvoiceLike | null;
|
|
63
19
|
readonly metadata?: StripeMetadata;
|
|
64
|
-
readonly status?: string | null;
|
|
65
20
|
}
|
|
66
21
|
export interface StripePaymentIntentLike {
|
|
67
|
-
readonly amount?: number;
|
|
68
|
-
readonly amount_received?: number;
|
|
69
|
-
readonly capture_method?: "automatic" | "automatic_async" | "manual" | string;
|
|
70
|
-
readonly client_secret?: string | null;
|
|
71
|
-
readonly currency?: string;
|
|
72
|
-
readonly customer?: null | string | {
|
|
73
|
-
readonly id: string;
|
|
74
|
-
};
|
|
75
|
-
readonly id: string;
|
|
76
|
-
readonly metadata?: StripeMetadata;
|
|
77
|
-
readonly status?: "canceled" | "processing" | "requires_action" | "requires_capture" | "requires_confirmation" | "requires_payment_method" | "succeeded" | string;
|
|
78
|
-
}
|
|
79
|
-
export interface StripeObjectReferenceLike {
|
|
80
|
-
readonly id: string;
|
|
81
|
-
}
|
|
82
|
-
export interface StripeSetupIntentLike {
|
|
83
|
-
readonly client_secret?: string | null;
|
|
84
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
85
22
|
readonly id: string;
|
|
86
23
|
readonly metadata?: StripeMetadata;
|
|
87
|
-
readonly payment_method?: string | StripeObjectReferenceLike | null;
|
|
88
|
-
readonly payment_method_types?: readonly string[];
|
|
89
|
-
readonly status?: string;
|
|
90
|
-
readonly usage?: string;
|
|
91
|
-
}
|
|
92
|
-
export interface StripePaymentMethodLike {
|
|
93
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
94
|
-
readonly id: string;
|
|
95
|
-
}
|
|
96
|
-
export interface StripePriceLike {
|
|
97
|
-
readonly active?: boolean;
|
|
98
|
-
readonly currency?: string;
|
|
99
|
-
readonly id: string;
|
|
100
|
-
readonly recurring?: {
|
|
101
|
-
readonly interval?: string;
|
|
102
|
-
readonly interval_count?: number;
|
|
103
|
-
readonly usage_type?: string;
|
|
104
|
-
} | null;
|
|
105
|
-
readonly unit_amount?: number | null;
|
|
106
|
-
}
|
|
107
|
-
export interface StripeInvoiceLike {
|
|
108
|
-
readonly amount_due?: number;
|
|
109
|
-
readonly confirmation_secret?: {
|
|
110
|
-
readonly client_secret?: string | null;
|
|
111
|
-
readonly type?: string;
|
|
112
|
-
} | null;
|
|
113
|
-
readonly id: string;
|
|
114
|
-
readonly payment_intent?: string | StripePaymentIntentLike | null;
|
|
115
|
-
readonly status?: string | null;
|
|
116
24
|
}
|
|
117
25
|
export interface StripeCheckoutSessionUpdateParams {
|
|
118
26
|
readonly line_items?: unknown;
|
|
@@ -124,77 +32,10 @@ export type StripeCheckoutSessionCreateParams = object & {
|
|
|
124
32
|
readonly enabled?: boolean;
|
|
125
33
|
};
|
|
126
34
|
};
|
|
127
|
-
readonly line_items?: unknown;
|
|
128
35
|
readonly metadata?: StripeMetadataParam;
|
|
129
36
|
readonly mode?: "payment" | "setup" | "subscription";
|
|
130
37
|
readonly payment_intent_data?: unknown;
|
|
131
|
-
readonly return_url?: string;
|
|
132
|
-
readonly success_url?: string;
|
|
133
38
|
readonly subscription_data?: unknown;
|
|
134
|
-
readonly ui_mode?: string;
|
|
135
|
-
};
|
|
136
|
-
export type StripePaymentIntentCreateParams = object & {
|
|
137
|
-
readonly amount?: number;
|
|
138
|
-
readonly application_fee_amount?: number;
|
|
139
|
-
readonly application_fee_percent?: number;
|
|
140
|
-
readonly capture_method?: string;
|
|
141
|
-
readonly currency?: string;
|
|
142
|
-
readonly metadata?: StripeMetadataParam;
|
|
143
|
-
readonly on_behalf_of?: unknown;
|
|
144
|
-
readonly transfer_data?: unknown;
|
|
145
|
-
};
|
|
146
|
-
export type StripeSetupIntentCreateParams = object & {
|
|
147
|
-
readonly customer?: string;
|
|
148
|
-
readonly metadata?: StripeMetadataParam;
|
|
149
|
-
readonly payment_method?: unknown;
|
|
150
|
-
readonly payment_method_types?: readonly string[];
|
|
151
|
-
readonly usage?: string;
|
|
152
|
-
};
|
|
153
|
-
export interface StripeSubscriptionItemCreateParamsLike {
|
|
154
|
-
readonly price?: string;
|
|
155
|
-
readonly price_data?: unknown;
|
|
156
|
-
readonly quantity?: number;
|
|
157
|
-
}
|
|
158
|
-
export interface StripeSubscriptionPaymentSettingsLike {
|
|
159
|
-
readonly payment_method_options?: {
|
|
160
|
-
readonly card?: {
|
|
161
|
-
readonly request_three_d_secure?: "any" | "automatic";
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Narrow create shape used by the direct Subscription helper. Additional
|
|
167
|
-
* merchant fields remain structurally accepted, then the runtime option policy
|
|
168
|
-
* rejects fields that would move pricing or collection outside the supported
|
|
169
|
-
* fixed `charge_automatically` contract.
|
|
170
|
-
*/
|
|
171
|
-
export type StripeSubscriptionCreateParams = object & {
|
|
172
|
-
readonly add_invoice_items?: unknown;
|
|
173
|
-
readonly application_fee_percent?: unknown;
|
|
174
|
-
readonly automatic_tax?: {
|
|
175
|
-
readonly enabled?: boolean;
|
|
176
|
-
} | null;
|
|
177
|
-
readonly billing_cycle_anchor?: unknown;
|
|
178
|
-
readonly cancel_at?: unknown;
|
|
179
|
-
readonly collection_method?: string;
|
|
180
|
-
readonly customer?: string;
|
|
181
|
-
readonly days_until_due?: unknown;
|
|
182
|
-
readonly default_payment_method?: string;
|
|
183
|
-
readonly discounts?: readonly unknown[];
|
|
184
|
-
readonly expand?: readonly string[];
|
|
185
|
-
readonly invoice_settings?: unknown;
|
|
186
|
-
readonly items?: readonly StripeSubscriptionItemCreateParamsLike[];
|
|
187
|
-
readonly metadata?: StripeMetadataParam;
|
|
188
|
-
readonly off_session?: unknown;
|
|
189
|
-
readonly on_behalf_of?: unknown;
|
|
190
|
-
readonly payment_behavior?: string;
|
|
191
|
-
readonly payment_settings?: StripeSubscriptionPaymentSettingsLike;
|
|
192
|
-
readonly pending_invoice_item_interval?: unknown;
|
|
193
|
-
readonly proration_behavior?: string;
|
|
194
|
-
readonly schedule?: unknown;
|
|
195
|
-
readonly transfer_data?: unknown;
|
|
196
|
-
readonly trial_end?: number | "now";
|
|
197
|
-
readonly trial_period_days?: number;
|
|
198
39
|
};
|
|
199
40
|
export interface StripeRequestOptionsLike {
|
|
200
41
|
readonly idempotencyKey?: string;
|
|
@@ -206,51 +47,11 @@ export interface StripeRequestOptionsWithoutIdempotencyLike {
|
|
|
206
47
|
}
|
|
207
48
|
export interface StripeCheckoutSessionsApiLike {
|
|
208
49
|
create(params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
209
|
-
listLineItems?(id: string, params?: unknown, options?: unknown): Promise<StripeCheckoutLineItemPageLike>;
|
|
210
50
|
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
211
|
-
}
|
|
212
|
-
/** Checkout Session mutation is used only by the legacy cart-sync helper. */
|
|
213
|
-
export interface StripeMutableCheckoutSessionsApiLike extends StripeCheckoutSessionsApiLike {
|
|
214
51
|
update(id: string, params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
215
52
|
}
|
|
216
|
-
export interface StripePaymentIntentsApiLike {
|
|
217
|
-
create(params: unknown, options?: unknown): Promise<StripePaymentIntentLike>;
|
|
218
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePaymentIntentLike>;
|
|
219
|
-
}
|
|
220
|
-
export interface StripeSetupIntentsApiLike {
|
|
221
|
-
create(params: unknown, options?: unknown): Promise<StripeSetupIntentLike>;
|
|
222
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeSetupIntentLike>;
|
|
223
|
-
}
|
|
224
|
-
export interface StripeSubscriptionsApiLike {
|
|
225
|
-
create(params: unknown, options?: unknown): Promise<StripeSubscriptionLike>;
|
|
226
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeSubscriptionLike>;
|
|
227
|
-
}
|
|
228
|
-
export interface StripePaymentMethodsApiLike {
|
|
229
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePaymentMethodLike>;
|
|
230
|
-
}
|
|
231
|
-
export interface StripePricesApiLike {
|
|
232
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePriceLike>;
|
|
233
|
-
}
|
|
234
|
-
export interface StripeSetupIntentClientLike {
|
|
235
|
-
readonly setupIntents: StripeSetupIntentsApiLike;
|
|
236
|
-
}
|
|
237
|
-
export interface StripeDirectSubscriptionClientLike {
|
|
238
|
-
readonly paymentMethods: StripePaymentMethodsApiLike;
|
|
239
|
-
readonly prices: StripePricesApiLike;
|
|
240
|
-
readonly subscriptions: StripeSubscriptionsApiLike;
|
|
241
|
-
}
|
|
242
|
-
export type StripeSetupSubscriptionClientLike = StripeDirectSubscriptionClientLike & StripeSetupIntentClientLike;
|
|
243
53
|
export interface StripeClientLike {
|
|
244
54
|
readonly checkout: {
|
|
245
55
|
readonly sessions: StripeCheckoutSessionsApiLike;
|
|
246
56
|
};
|
|
247
|
-
readonly paymentIntents?: StripePaymentIntentsApiLike;
|
|
248
|
-
}
|
|
249
|
-
export interface StripeMutableCheckoutClientLike extends StripeClientLike {
|
|
250
|
-
readonly checkout: {
|
|
251
|
-
readonly sessions: StripeMutableCheckoutSessionsApiLike;
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
export interface StripePaymentIntentClientLike {
|
|
255
|
-
readonly paymentIntents: StripePaymentIntentsApiLike;
|
|
256
57
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -10,109 +10,17 @@ export type StripeMetadataValue = string | number | null;
|
|
|
10
10
|
export type StripeMetadata = Record<string, StripeMetadataValue> | null | undefined;
|
|
11
11
|
export type StripeMetadataParam = Record<string, StripeMetadataValue> | undefined;
|
|
12
12
|
export interface StripeCheckoutSessionLike {
|
|
13
|
-
readonly amount_subtotal?: number | null;
|
|
14
|
-
readonly amount_total?: number | null;
|
|
15
13
|
readonly client_secret?: string | null;
|
|
16
|
-
readonly currency?: string | null;
|
|
17
|
-
readonly customer?: null | string | {
|
|
18
|
-
readonly id: string;
|
|
19
|
-
};
|
|
20
14
|
readonly id: string;
|
|
21
|
-
readonly line_items?: StripeCheckoutLineItemListLike | null;
|
|
22
15
|
readonly metadata?: StripeMetadata;
|
|
23
|
-
readonly mode?: "payment" | "setup" | "subscription" | null;
|
|
24
|
-
readonly payment_intent?: string | {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
} | null;
|
|
27
|
-
readonly payment_status?: "no_payment_required" | "paid" | "unpaid" | string;
|
|
28
|
-
readonly status?: "complete" | "expired" | "open" | string | null;
|
|
29
|
-
readonly ui_mode?: string | null;
|
|
30
|
-
readonly url?: string | null;
|
|
31
|
-
}
|
|
32
|
-
export interface StripeCheckoutLineItemListLike {
|
|
33
|
-
readonly data?: readonly StripeCheckoutLineItemLike[];
|
|
34
|
-
readonly has_more?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface StripeCheckoutLineItemLike {
|
|
37
|
-
readonly description?: string | null;
|
|
38
|
-
readonly id?: string;
|
|
39
|
-
readonly price?: string | {
|
|
40
|
-
readonly currency?: string | null;
|
|
41
|
-
readonly id?: string;
|
|
42
|
-
readonly product?: string | {
|
|
43
|
-
readonly id?: string;
|
|
44
|
-
} | null;
|
|
45
|
-
readonly recurring?: {
|
|
46
|
-
readonly interval?: string;
|
|
47
|
-
readonly interval_count?: number;
|
|
48
|
-
readonly usage_type?: string;
|
|
49
|
-
} | null;
|
|
50
|
-
readonly type?: "one_time" | "recurring" | string;
|
|
51
|
-
readonly unit_amount?: number | null;
|
|
52
|
-
readonly unit_amount_decimal?: unknown;
|
|
53
|
-
} | null;
|
|
54
|
-
readonly quantity?: number | null;
|
|
55
|
-
}
|
|
56
|
-
export interface StripeCheckoutLineItemPageLike extends StripeCheckoutLineItemListLike {
|
|
57
16
|
}
|
|
58
17
|
export interface StripeSubscriptionLike {
|
|
59
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
60
|
-
readonly default_payment_method?: string | StripeObjectReferenceLike | null;
|
|
61
18
|
readonly id: string;
|
|
62
|
-
readonly latest_invoice?: string | StripeInvoiceLike | null;
|
|
63
19
|
readonly metadata?: StripeMetadata;
|
|
64
|
-
readonly status?: string | null;
|
|
65
20
|
}
|
|
66
21
|
export interface StripePaymentIntentLike {
|
|
67
|
-
readonly amount?: number;
|
|
68
|
-
readonly amount_received?: number;
|
|
69
|
-
readonly capture_method?: "automatic" | "automatic_async" | "manual" | string;
|
|
70
|
-
readonly client_secret?: string | null;
|
|
71
|
-
readonly currency?: string;
|
|
72
|
-
readonly customer?: null | string | {
|
|
73
|
-
readonly id: string;
|
|
74
|
-
};
|
|
75
|
-
readonly id: string;
|
|
76
|
-
readonly metadata?: StripeMetadata;
|
|
77
|
-
readonly status?: "canceled" | "processing" | "requires_action" | "requires_capture" | "requires_confirmation" | "requires_payment_method" | "succeeded" | string;
|
|
78
|
-
}
|
|
79
|
-
export interface StripeObjectReferenceLike {
|
|
80
|
-
readonly id: string;
|
|
81
|
-
}
|
|
82
|
-
export interface StripeSetupIntentLike {
|
|
83
|
-
readonly client_secret?: string | null;
|
|
84
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
85
22
|
readonly id: string;
|
|
86
23
|
readonly metadata?: StripeMetadata;
|
|
87
|
-
readonly payment_method?: string | StripeObjectReferenceLike | null;
|
|
88
|
-
readonly payment_method_types?: readonly string[];
|
|
89
|
-
readonly status?: string;
|
|
90
|
-
readonly usage?: string;
|
|
91
|
-
}
|
|
92
|
-
export interface StripePaymentMethodLike {
|
|
93
|
-
readonly customer?: string | StripeObjectReferenceLike | null;
|
|
94
|
-
readonly id: string;
|
|
95
|
-
}
|
|
96
|
-
export interface StripePriceLike {
|
|
97
|
-
readonly active?: boolean;
|
|
98
|
-
readonly currency?: string;
|
|
99
|
-
readonly id: string;
|
|
100
|
-
readonly recurring?: {
|
|
101
|
-
readonly interval?: string;
|
|
102
|
-
readonly interval_count?: number;
|
|
103
|
-
readonly usage_type?: string;
|
|
104
|
-
} | null;
|
|
105
|
-
readonly unit_amount?: number | null;
|
|
106
|
-
}
|
|
107
|
-
export interface StripeInvoiceLike {
|
|
108
|
-
readonly amount_due?: number;
|
|
109
|
-
readonly confirmation_secret?: {
|
|
110
|
-
readonly client_secret?: string | null;
|
|
111
|
-
readonly type?: string;
|
|
112
|
-
} | null;
|
|
113
|
-
readonly id: string;
|
|
114
|
-
readonly payment_intent?: string | StripePaymentIntentLike | null;
|
|
115
|
-
readonly status?: string | null;
|
|
116
24
|
}
|
|
117
25
|
export interface StripeCheckoutSessionUpdateParams {
|
|
118
26
|
readonly line_items?: unknown;
|
|
@@ -124,77 +32,10 @@ export type StripeCheckoutSessionCreateParams = object & {
|
|
|
124
32
|
readonly enabled?: boolean;
|
|
125
33
|
};
|
|
126
34
|
};
|
|
127
|
-
readonly line_items?: unknown;
|
|
128
35
|
readonly metadata?: StripeMetadataParam;
|
|
129
36
|
readonly mode?: "payment" | "setup" | "subscription";
|
|
130
37
|
readonly payment_intent_data?: unknown;
|
|
131
|
-
readonly return_url?: string;
|
|
132
|
-
readonly success_url?: string;
|
|
133
38
|
readonly subscription_data?: unknown;
|
|
134
|
-
readonly ui_mode?: string;
|
|
135
|
-
};
|
|
136
|
-
export type StripePaymentIntentCreateParams = object & {
|
|
137
|
-
readonly amount?: number;
|
|
138
|
-
readonly application_fee_amount?: number;
|
|
139
|
-
readonly application_fee_percent?: number;
|
|
140
|
-
readonly capture_method?: string;
|
|
141
|
-
readonly currency?: string;
|
|
142
|
-
readonly metadata?: StripeMetadataParam;
|
|
143
|
-
readonly on_behalf_of?: unknown;
|
|
144
|
-
readonly transfer_data?: unknown;
|
|
145
|
-
};
|
|
146
|
-
export type StripeSetupIntentCreateParams = object & {
|
|
147
|
-
readonly customer?: string;
|
|
148
|
-
readonly metadata?: StripeMetadataParam;
|
|
149
|
-
readonly payment_method?: unknown;
|
|
150
|
-
readonly payment_method_types?: readonly string[];
|
|
151
|
-
readonly usage?: string;
|
|
152
|
-
};
|
|
153
|
-
export interface StripeSubscriptionItemCreateParamsLike {
|
|
154
|
-
readonly price?: string;
|
|
155
|
-
readonly price_data?: unknown;
|
|
156
|
-
readonly quantity?: number;
|
|
157
|
-
}
|
|
158
|
-
export interface StripeSubscriptionPaymentSettingsLike {
|
|
159
|
-
readonly payment_method_options?: {
|
|
160
|
-
readonly card?: {
|
|
161
|
-
readonly request_three_d_secure?: "any" | "automatic";
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Narrow create shape used by the direct Subscription helper. Additional
|
|
167
|
-
* merchant fields remain structurally accepted, then the runtime option policy
|
|
168
|
-
* rejects fields that would move pricing or collection outside the supported
|
|
169
|
-
* fixed `charge_automatically` contract.
|
|
170
|
-
*/
|
|
171
|
-
export type StripeSubscriptionCreateParams = object & {
|
|
172
|
-
readonly add_invoice_items?: unknown;
|
|
173
|
-
readonly application_fee_percent?: unknown;
|
|
174
|
-
readonly automatic_tax?: {
|
|
175
|
-
readonly enabled?: boolean;
|
|
176
|
-
} | null;
|
|
177
|
-
readonly billing_cycle_anchor?: unknown;
|
|
178
|
-
readonly cancel_at?: unknown;
|
|
179
|
-
readonly collection_method?: string;
|
|
180
|
-
readonly customer?: string;
|
|
181
|
-
readonly days_until_due?: unknown;
|
|
182
|
-
readonly default_payment_method?: string;
|
|
183
|
-
readonly discounts?: readonly unknown[];
|
|
184
|
-
readonly expand?: readonly string[];
|
|
185
|
-
readonly invoice_settings?: unknown;
|
|
186
|
-
readonly items?: readonly StripeSubscriptionItemCreateParamsLike[];
|
|
187
|
-
readonly metadata?: StripeMetadataParam;
|
|
188
|
-
readonly off_session?: unknown;
|
|
189
|
-
readonly on_behalf_of?: unknown;
|
|
190
|
-
readonly payment_behavior?: string;
|
|
191
|
-
readonly payment_settings?: StripeSubscriptionPaymentSettingsLike;
|
|
192
|
-
readonly pending_invoice_item_interval?: unknown;
|
|
193
|
-
readonly proration_behavior?: string;
|
|
194
|
-
readonly schedule?: unknown;
|
|
195
|
-
readonly transfer_data?: unknown;
|
|
196
|
-
readonly trial_end?: number | "now";
|
|
197
|
-
readonly trial_period_days?: number;
|
|
198
39
|
};
|
|
199
40
|
export interface StripeRequestOptionsLike {
|
|
200
41
|
readonly idempotencyKey?: string;
|
|
@@ -206,51 +47,11 @@ export interface StripeRequestOptionsWithoutIdempotencyLike {
|
|
|
206
47
|
}
|
|
207
48
|
export interface StripeCheckoutSessionsApiLike {
|
|
208
49
|
create(params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
209
|
-
listLineItems?(id: string, params?: unknown, options?: unknown): Promise<StripeCheckoutLineItemPageLike>;
|
|
210
50
|
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
211
|
-
}
|
|
212
|
-
/** Checkout Session mutation is used only by the legacy cart-sync helper. */
|
|
213
|
-
export interface StripeMutableCheckoutSessionsApiLike extends StripeCheckoutSessionsApiLike {
|
|
214
51
|
update(id: string, params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
215
52
|
}
|
|
216
|
-
export interface StripePaymentIntentsApiLike {
|
|
217
|
-
create(params: unknown, options?: unknown): Promise<StripePaymentIntentLike>;
|
|
218
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePaymentIntentLike>;
|
|
219
|
-
}
|
|
220
|
-
export interface StripeSetupIntentsApiLike {
|
|
221
|
-
create(params: unknown, options?: unknown): Promise<StripeSetupIntentLike>;
|
|
222
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeSetupIntentLike>;
|
|
223
|
-
}
|
|
224
|
-
export interface StripeSubscriptionsApiLike {
|
|
225
|
-
create(params: unknown, options?: unknown): Promise<StripeSubscriptionLike>;
|
|
226
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeSubscriptionLike>;
|
|
227
|
-
}
|
|
228
|
-
export interface StripePaymentMethodsApiLike {
|
|
229
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePaymentMethodLike>;
|
|
230
|
-
}
|
|
231
|
-
export interface StripePricesApiLike {
|
|
232
|
-
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripePriceLike>;
|
|
233
|
-
}
|
|
234
|
-
export interface StripeSetupIntentClientLike {
|
|
235
|
-
readonly setupIntents: StripeSetupIntentsApiLike;
|
|
236
|
-
}
|
|
237
|
-
export interface StripeDirectSubscriptionClientLike {
|
|
238
|
-
readonly paymentMethods: StripePaymentMethodsApiLike;
|
|
239
|
-
readonly prices: StripePricesApiLike;
|
|
240
|
-
readonly subscriptions: StripeSubscriptionsApiLike;
|
|
241
|
-
}
|
|
242
|
-
export type StripeSetupSubscriptionClientLike = StripeDirectSubscriptionClientLike & StripeSetupIntentClientLike;
|
|
243
53
|
export interface StripeClientLike {
|
|
244
54
|
readonly checkout: {
|
|
245
55
|
readonly sessions: StripeCheckoutSessionsApiLike;
|
|
246
56
|
};
|
|
247
|
-
readonly paymentIntents?: StripePaymentIntentsApiLike;
|
|
248
|
-
}
|
|
249
|
-
export interface StripeMutableCheckoutClientLike extends StripeClientLike {
|
|
250
|
-
readonly checkout: {
|
|
251
|
-
readonly sessions: StripeMutableCheckoutSessionsApiLike;
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
export interface StripePaymentIntentClientLike {
|
|
255
|
-
readonly paymentIntents: StripePaymentIntentsApiLike;
|
|
256
57
|
}
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
2
|
-
export declare const proxyCheckoutStripeServerSdkVersion = "0.1.0
|
|
2
|
+
export declare const proxyCheckoutStripeServerSdkVersion = "0.1.0";
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
2
|
-
export declare const proxyCheckoutStripeServerSdkVersion = "0.1.0
|
|
2
|
+
export declare const proxyCheckoutStripeServerSdkVersion = "0.1.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.proxyCheckoutStripeServerSdkVersion = exports.proxyCheckoutStripeServerSdkName = void 0;
|
|
4
4
|
exports.proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
5
|
-
exports.proxyCheckoutStripeServerSdkVersion = "0.1.0
|
|
5
|
+
exports.proxyCheckoutStripeServerSdkVersion = "0.1.0";
|