@proxy-checkout/stripe-server-js 0.0.0-pr-76.20.1 → 0.0.0-pr-76.22.1
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 +1 -1
- package/dist/cjs/errors.js +38 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/metadata.js +92 -0
- package/dist/cjs/open-checkout.js +203 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/psp.js +25 -0
- package/dist/cjs/sync-checkout-cart.js +84 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/version.js +5 -0
- package/dist/{metadata.js → esm/metadata.js} +10 -4
- package/dist/{open-checkout.js → esm/open-checkout.js} +75 -31
- package/dist/{types.d.ts → esm/types.d.ts} +13 -18
- package/dist/{version.d.ts → esm/version.d.ts} +1 -1
- package/dist/{version.js → esm/version.js} +1 -1
- package/package.json +10 -7
- /package/dist/{errors.d.ts → esm/errors.d.ts} +0 -0
- /package/dist/{errors.js → esm/errors.js} +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{metadata.d.ts → esm/metadata.d.ts} +0 -0
- /package/dist/{open-checkout.d.ts → esm/open-checkout.d.ts} +0 -0
- /package/dist/{psp.d.ts → esm/psp.d.ts} +0 -0
- /package/dist/{psp.js → esm/psp.js} +0 -0
- /package/dist/{sync-checkout-cart.d.ts → esm/sync-checkout-cart.d.ts} +0 -0
- /package/dist/{sync-checkout-cart.js → esm/sync-checkout-cart.js} +0 -0
- /package/dist/{types.js → esm/types.js} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Server-side Stripe adapter for Proxy Checkout. It owns the Stripe-specific integ
|
|
|
4
4
|
|
|
5
5
|
- **`requiredMetadata(proxySession)`** — the `proxy_session_id` metadata Proxy needs on the Checkout Session, Subscription, and PaymentIntent.
|
|
6
6
|
- **`assertCheckoutSessionBelongsToProxy` / `assertSubscriptionBelongsToProxy` / `assertPaymentIntentBelongsToProxy`** — provider-object ownership checks.
|
|
7
|
-
- **`openCheckout(...)`** — records payer-opened, validates the typed cart, injects required metadata, creates the Stripe Checkout Session with deterministic idempotency, records the Proxy provider binding, and returns the client secret. The merchant only supplies app-specific Stripe params.
|
|
7
|
+
- **`openCheckout(...)`** — records payer-opened, validates/reconciles the typed cart with rollback, injects required metadata, creates the Stripe Checkout Session with deterministic idempotency, records the Proxy provider binding, and returns the client secret. The merchant only supplies app-specific Stripe params.
|
|
8
8
|
- **`syncCheckoutCart(...)`** — validates the stored Proxy provider binding, then updates the Proxy cart and the Stripe Checkout `line_items` in the safest order with deterministic rollback/reconciliation (`ProxyStripeCartSyncError`).
|
|
9
9
|
|
|
10
10
|
PSP-agnostic primitives (sessions, subscriptions, webhooks, lifecycle) live in [`@proxy-checkout/server-js`](https://www.npmjs.com/package/@proxy-checkout/server-js). This package is an additive adapter on top and is dependency-free: you inject your own `Stripe` instance and your `@proxy-checkout/server-js` client.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProxyStripeCartSyncError = exports.ProxyStripeOpenCheckoutError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Raised after Stripe Checkout creation succeeds but the Proxy binding cannot
|
|
6
|
+
* be recorded or reconciled. The provider id is exposed so operators can find
|
|
7
|
+
* and expire/refund the orphaned provider object deterministically.
|
|
8
|
+
*/
|
|
9
|
+
class ProxyStripeOpenCheckoutError extends Error {
|
|
10
|
+
name = "ProxyStripeOpenCheckoutError";
|
|
11
|
+
code;
|
|
12
|
+
cause;
|
|
13
|
+
providerCheckoutSessionId;
|
|
14
|
+
reconciled = false;
|
|
15
|
+
constructor(message, details) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.cause = details.cause;
|
|
18
|
+
this.code = details.code;
|
|
19
|
+
this.providerCheckoutSessionId = details.providerCheckoutSessionId;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ProxyStripeOpenCheckoutError = ProxyStripeOpenCheckoutError;
|
|
23
|
+
class ProxyStripeCartSyncError extends Error {
|
|
24
|
+
name = "ProxyStripeCartSyncError";
|
|
25
|
+
code;
|
|
26
|
+
/** True when the Proxy cart was rolled back to its prior state after the failure. */
|
|
27
|
+
reconciled;
|
|
28
|
+
cause;
|
|
29
|
+
rollbackCause;
|
|
30
|
+
constructor(message, details) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = details.code;
|
|
33
|
+
this.reconciled = details.reconciled;
|
|
34
|
+
this.cause = details.cause;
|
|
35
|
+
this.rollbackCause = details.rollbackCause;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ProxyStripeCartSyncError = ProxyStripeCartSyncError;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proxyCheckoutStripeServerSdkVersion = exports.proxyCheckoutStripeServerSdkName = exports.syncCheckoutCart = exports.normalizePsp = exports.openCheckout = exports.requiredMetadata = exports.PROXY_SESSION_METADATA_KEY = exports.injectRequiredCheckoutSessionMetadata = exports.assertSubscriptionBelongsToProxy = exports.assertPaymentIntentBelongsToProxy = exports.assertCheckoutSessionBelongsToProxy = exports.ProxyStripeOpenCheckoutError = exports.ProxyStripeCartSyncError = void 0;
|
|
4
|
+
var errors_js_1 = require("./errors.js");
|
|
5
|
+
Object.defineProperty(exports, "ProxyStripeCartSyncError", { enumerable: true, get: function () { return errors_js_1.ProxyStripeCartSyncError; } });
|
|
6
|
+
Object.defineProperty(exports, "ProxyStripeOpenCheckoutError", { enumerable: true, get: function () { return errors_js_1.ProxyStripeOpenCheckoutError; } });
|
|
7
|
+
var metadata_js_1 = require("./metadata.js");
|
|
8
|
+
Object.defineProperty(exports, "assertCheckoutSessionBelongsToProxy", { enumerable: true, get: function () { return metadata_js_1.assertCheckoutSessionBelongsToProxy; } });
|
|
9
|
+
Object.defineProperty(exports, "assertPaymentIntentBelongsToProxy", { enumerable: true, get: function () { return metadata_js_1.assertPaymentIntentBelongsToProxy; } });
|
|
10
|
+
Object.defineProperty(exports, "assertSubscriptionBelongsToProxy", { enumerable: true, get: function () { return metadata_js_1.assertSubscriptionBelongsToProxy; } });
|
|
11
|
+
Object.defineProperty(exports, "injectRequiredCheckoutSessionMetadata", { enumerable: true, get: function () { return metadata_js_1.injectRequiredCheckoutSessionMetadata; } });
|
|
12
|
+
Object.defineProperty(exports, "PROXY_SESSION_METADATA_KEY", { enumerable: true, get: function () { return metadata_js_1.PROXY_SESSION_METADATA_KEY; } });
|
|
13
|
+
Object.defineProperty(exports, "requiredMetadata", { enumerable: true, get: function () { return metadata_js_1.requiredMetadata; } });
|
|
14
|
+
var open_checkout_js_1 = require("./open-checkout.js");
|
|
15
|
+
Object.defineProperty(exports, "openCheckout", { enumerable: true, get: function () { return open_checkout_js_1.openCheckout; } });
|
|
16
|
+
var psp_js_1 = require("./psp.js");
|
|
17
|
+
Object.defineProperty(exports, "normalizePsp", { enumerable: true, get: function () { return psp_js_1.normalizePsp; } });
|
|
18
|
+
var sync_checkout_cart_js_1 = require("./sync-checkout-cart.js");
|
|
19
|
+
Object.defineProperty(exports, "syncCheckoutCart", { enumerable: true, get: function () { return sync_checkout_cart_js_1.syncCheckoutCart; } });
|
|
20
|
+
var version_js_1 = require("./version.js");
|
|
21
|
+
Object.defineProperty(exports, "proxyCheckoutStripeServerSdkName", { enumerable: true, get: function () { return version_js_1.proxyCheckoutStripeServerSdkName; } });
|
|
22
|
+
Object.defineProperty(exports, "proxyCheckoutStripeServerSdkVersion", { enumerable: true, get: function () { return version_js_1.proxyCheckoutStripeServerSdkVersion; } });
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Required Stripe metadata placement + provider-object ownership assertions.
|
|
4
|
+
*
|
|
5
|
+
* Proxy correlates Stripe objects to a session solely through
|
|
6
|
+
* `metadata.proxy_session_id`. This module centralizes that placement so
|
|
7
|
+
* customers never have to remember which Stripe objects need the key, and
|
|
8
|
+
* provides assertions that a Stripe object actually belongs to a Proxy session.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PROXY_SESSION_METADATA_KEY = void 0;
|
|
12
|
+
exports.requiredMetadata = requiredMetadata;
|
|
13
|
+
exports.injectRequiredCheckoutSessionMetadata = injectRequiredCheckoutSessionMetadata;
|
|
14
|
+
exports.assertCheckoutSessionBelongsToProxy = assertCheckoutSessionBelongsToProxy;
|
|
15
|
+
exports.assertSubscriptionBelongsToProxy = assertSubscriptionBelongsToProxy;
|
|
16
|
+
exports.assertPaymentIntentBelongsToProxy = assertPaymentIntentBelongsToProxy;
|
|
17
|
+
const server_js_1 = require("@proxy-checkout/server-js");
|
|
18
|
+
/** The single metadata key Proxy reads to correlate a Stripe object to a session. */
|
|
19
|
+
exports.PROXY_SESSION_METADATA_KEY = "proxy_session_id";
|
|
20
|
+
/** Build the required Stripe metadata placements for a Proxy session. */
|
|
21
|
+
function requiredMetadata(proxySession) {
|
|
22
|
+
const metadata = { proxy_session_id: proxySession.id };
|
|
23
|
+
return {
|
|
24
|
+
checkoutSession: metadata,
|
|
25
|
+
paymentIntent: metadata,
|
|
26
|
+
paymentIntentData: { metadata },
|
|
27
|
+
subscription: metadata,
|
|
28
|
+
subscriptionData: { metadata },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Return Stripe Checkout Session create params with required Proxy metadata in
|
|
33
|
+
* every object Proxy may later need to correlate. Conflicting merchant-provided
|
|
34
|
+
* proxy metadata fails before any Stripe side effect.
|
|
35
|
+
*/
|
|
36
|
+
function injectRequiredCheckoutSessionMetadata(params, proxySessionId) {
|
|
37
|
+
const metadata = { proxy_session_id: proxySessionId };
|
|
38
|
+
return {
|
|
39
|
+
...params,
|
|
40
|
+
metadata: mergeProxyMetadata(params.metadata, metadata, "metadata.proxy_session_id"),
|
|
41
|
+
...(params.mode === "subscription" || params.subscription_data !== undefined
|
|
42
|
+
? {
|
|
43
|
+
subscription_data: {
|
|
44
|
+
...objectRecord(params.subscription_data),
|
|
45
|
+
metadata: mergeProxyMetadata(metadataFromNestedParams(params.subscription_data), metadata, "subscription_data.metadata.proxy_session_id"),
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
: {}),
|
|
49
|
+
...(params.mode === "payment" || params.payment_intent_data !== undefined
|
|
50
|
+
? {
|
|
51
|
+
payment_intent_data: {
|
|
52
|
+
...objectRecord(params.payment_intent_data),
|
|
53
|
+
metadata: mergeProxyMetadata(metadataFromNestedParams(params.payment_intent_data), metadata, "payment_intent_data.metadata.proxy_session_id"),
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Assert a Stripe Checkout Session carries the expected `proxy_session_id` metadata. */
|
|
60
|
+
function assertCheckoutSessionBelongsToProxy(checkoutSession, proxySessionId) {
|
|
61
|
+
assertProxyMetadata(checkoutSession.metadata, proxySessionId, "Stripe checkout session");
|
|
62
|
+
}
|
|
63
|
+
/** Assert a Stripe Subscription carries the expected `proxy_session_id` metadata. */
|
|
64
|
+
function assertSubscriptionBelongsToProxy(subscription, proxySessionId) {
|
|
65
|
+
assertProxyMetadata(subscription.metadata, proxySessionId, "Stripe subscription");
|
|
66
|
+
}
|
|
67
|
+
/** Assert a Stripe PaymentIntent carries the expected `proxy_session_id` metadata. */
|
|
68
|
+
function assertPaymentIntentBelongsToProxy(paymentIntent, proxySessionId) {
|
|
69
|
+
assertProxyMetadata(paymentIntent.metadata, proxySessionId, "Stripe payment intent");
|
|
70
|
+
}
|
|
71
|
+
function assertProxyMetadata(metadata, proxySessionId, objectLabel) {
|
|
72
|
+
const value = metadata?.[exports.PROXY_SESSION_METADATA_KEY];
|
|
73
|
+
if (value !== proxySessionId) {
|
|
74
|
+
throw new server_js_1.ProxyCheckoutValidationError(`${objectLabel} metadata.${exports.PROXY_SESSION_METADATA_KEY} (${value ?? "missing"}) does not match Proxy session ${proxySessionId}.`, { code: "provider_binding_mismatch", field: `metadata.${exports.PROXY_SESSION_METADATA_KEY}` });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function mergeProxyMetadata(existing, required, field) {
|
|
78
|
+
const existingValue = existing?.[exports.PROXY_SESSION_METADATA_KEY];
|
|
79
|
+
if (existingValue !== undefined && existingValue !== required.proxy_session_id) {
|
|
80
|
+
throw new server_js_1.ProxyCheckoutValidationError(`Stripe metadata.${exports.PROXY_SESSION_METADATA_KEY} (${existingValue}) conflicts with Proxy session ${required.proxy_session_id}.`, { code: "provider_binding_mismatch", field });
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...existing,
|
|
84
|
+
...required,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function objectRecord(value) {
|
|
88
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
89
|
+
}
|
|
90
|
+
function metadataFromNestedParams(value) {
|
|
91
|
+
return objectRecord(value).metadata;
|
|
92
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `openCheckout` — the payer-opened + provider-object creation workflow.
|
|
4
|
+
*
|
|
5
|
+
* It performs the Proxy protocol steps (record payer-opened, validate the cart,
|
|
6
|
+
* inject required metadata, create the Stripe Checkout Session, record the
|
|
7
|
+
* provider binding). Merchants provide only Stripe params, so the adapter owns
|
|
8
|
+
* metadata placement, idempotency, and binding reconciliation.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.openCheckout = openCheckout;
|
|
12
|
+
const server_js_1 = require("@proxy-checkout/server-js");
|
|
13
|
+
const errors_js_1 = require("./errors.js");
|
|
14
|
+
const metadata_js_1 = require("./metadata.js");
|
|
15
|
+
const psp_js_1 = require("./psp.js");
|
|
16
|
+
async function openCheckout(options) {
|
|
17
|
+
// Normalize the same way the API does on store, so the binding is recorded
|
|
18
|
+
// under the normalized psp and later syncCheckoutCart validations compare
|
|
19
|
+
// normalized-to-normalized.
|
|
20
|
+
const psp = (0, psp_js_1.normalizePsp)(options.psp ?? "stripe");
|
|
21
|
+
let proxySession = await options.proxy.sessions.payerOpened(options.proxySessionId, {
|
|
22
|
+
requestId: options.requestId,
|
|
23
|
+
});
|
|
24
|
+
// Parse the cart (and run the buyer-reference check) whenever a schema OR a
|
|
25
|
+
// buyer-reference extractor is provided, so the consistency check is never
|
|
26
|
+
// silently skipped just because no custom schema was passed.
|
|
27
|
+
let cart = options.cartSchema || options.getCartBuyerReference
|
|
28
|
+
? options.proxy.sessions.parseCart(proxySession, options.cartSchema ?? ((value) => value), { getBuyerReference: options.getCartBuyerReference })
|
|
29
|
+
: proxySession.cartSnapshot;
|
|
30
|
+
const offer = options.validateCart
|
|
31
|
+
? await options.validateCart({ cart, session: proxySession })
|
|
32
|
+
: undefined;
|
|
33
|
+
if (proxySession.providerCheckoutSessionId !== null) {
|
|
34
|
+
assertExistingBindingMatches(proxySession, psp);
|
|
35
|
+
const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId));
|
|
36
|
+
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(checkoutSession, proxySession.id);
|
|
37
|
+
return {
|
|
38
|
+
binding: bindingFromSession(proxySession),
|
|
39
|
+
cart,
|
|
40
|
+
checkoutSession,
|
|
41
|
+
clientSecret: checkoutSession.client_secret ?? null,
|
|
42
|
+
offer,
|
|
43
|
+
proxySession,
|
|
44
|
+
proxySessionId: proxySession.id,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let rollbackCart;
|
|
48
|
+
const reconciledCart = await options.reconcileCart?.({ cart, offer, session: proxySession });
|
|
49
|
+
if (reconciledCart) {
|
|
50
|
+
const priorCart = {
|
|
51
|
+
amountMinor: proxySession.amountMinor,
|
|
52
|
+
cartSnapshot: proxySession.cartSnapshot,
|
|
53
|
+
cartVersion: proxySession.cartVersion,
|
|
54
|
+
currency: proxySession.currency,
|
|
55
|
+
};
|
|
56
|
+
const updatedCart = await options.proxy.sessions.cart.set(proxySession.id, {
|
|
57
|
+
amountMinor: reconciledCart.amountMinor,
|
|
58
|
+
cartSnapshot: reconciledCart.cartSnapshot,
|
|
59
|
+
currency: reconciledCart.currency,
|
|
60
|
+
expectedCartVersion: proxySession.cartVersion,
|
|
61
|
+
requestId: options.requestId,
|
|
62
|
+
});
|
|
63
|
+
rollbackCart = {
|
|
64
|
+
...priorCart,
|
|
65
|
+
expectedCartVersion: updatedCart.cartVersion,
|
|
66
|
+
};
|
|
67
|
+
proxySession = {
|
|
68
|
+
...proxySession,
|
|
69
|
+
amountMinor: updatedCart.amountMinor,
|
|
70
|
+
cartSnapshot: updatedCart.cartSnapshot,
|
|
71
|
+
cartVersion: updatedCart.cartVersion,
|
|
72
|
+
currency: updatedCart.currency,
|
|
73
|
+
updatedAt: proxySession.updatedAt,
|
|
74
|
+
};
|
|
75
|
+
cart = reconciledCart.cart;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const params = await options.buildCheckoutSessionParams({
|
|
79
|
+
cart,
|
|
80
|
+
offer,
|
|
81
|
+
proxySession,
|
|
82
|
+
stripe: options.stripe,
|
|
83
|
+
});
|
|
84
|
+
const checkoutSession = (await options.stripe.checkout.sessions.create((0, metadata_js_1.injectRequiredCheckoutSessionMetadata)(params, proxySession.id), buildStripeRequestOptions(options, proxySession.id, psp)));
|
|
85
|
+
// Fail closed if the merchant forgot to place proxy_session_id metadata.
|
|
86
|
+
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(checkoutSession, proxySession.id);
|
|
87
|
+
const binding = await recordOrReconcileProviderBinding({
|
|
88
|
+
checkoutSessionId: checkoutSession.id,
|
|
89
|
+
proxy: options.proxy,
|
|
90
|
+
proxySessionId: proxySession.id,
|
|
91
|
+
psp,
|
|
92
|
+
requestId: options.requestId,
|
|
93
|
+
stripe: options.stripe,
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
binding,
|
|
97
|
+
cart,
|
|
98
|
+
checkoutSession,
|
|
99
|
+
clientSecret: checkoutSession.client_secret ?? null,
|
|
100
|
+
offer,
|
|
101
|
+
proxySession,
|
|
102
|
+
proxySessionId: proxySession.id,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (cause) {
|
|
106
|
+
if (rollbackCart) {
|
|
107
|
+
await rollbackReconciledCart({
|
|
108
|
+
cause,
|
|
109
|
+
proxy: options.proxy,
|
|
110
|
+
proxySessionId: proxySession.id,
|
|
111
|
+
requestId: options.requestId,
|
|
112
|
+
rollbackCart,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
throw cause;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function buildStripeRequestOptions(options, proxySessionId, psp) {
|
|
119
|
+
return {
|
|
120
|
+
...options.stripeRequestOptions,
|
|
121
|
+
idempotencyKey: `proxy-open-checkout:${proxySessionId}:${psp}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function assertExistingBindingMatches(proxySession, psp) {
|
|
125
|
+
if (proxySession.providerCheckoutSessionId === null) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (proxySession.providerCheckoutSessionPsp !== psp) {
|
|
129
|
+
throw new server_js_1.ProxyCheckoutValidationError(`Proxy session ${proxySession.id} is already bound under psp ${proxySession.providerCheckoutSessionPsp}.`, { code: "provider_binding_mismatch", field: "provider_checkout_session_psp" });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function bindingFromSession(proxySession) {
|
|
133
|
+
if (proxySession.providerCheckoutSessionId === null ||
|
|
134
|
+
proxySession.providerCheckoutSessionPsp === null) {
|
|
135
|
+
throw new Error("Proxy session is not bound to a provider checkout session.");
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
providerCheckoutSessionId: proxySession.providerCheckoutSessionId,
|
|
139
|
+
proxySessionId: proxySession.id,
|
|
140
|
+
psp: proxySession.providerCheckoutSessionPsp,
|
|
141
|
+
updatedAt: proxySession.updatedAt,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function rollbackReconciledCart(input) {
|
|
145
|
+
try {
|
|
146
|
+
await input.proxy.sessions.cart.set(input.proxySessionId, {
|
|
147
|
+
amountMinor: input.rollbackCart.amountMinor,
|
|
148
|
+
cartSnapshot: input.rollbackCart.cartSnapshot,
|
|
149
|
+
currency: input.rollbackCart.currency,
|
|
150
|
+
expectedCartVersion: input.rollbackCart.expectedCartVersion,
|
|
151
|
+
requestId: input.requestId,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (rollbackCause) {
|
|
155
|
+
throw new errors_js_1.ProxyStripeCartSyncError("openCheckout failed after reconciling the Proxy cart, and the rollback failed; carts may be out of sync.", {
|
|
156
|
+
cause: input.cause,
|
|
157
|
+
code: "reconciliation_failed",
|
|
158
|
+
reconciled: false,
|
|
159
|
+
rollbackCause,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function recordOrReconcileProviderBinding(input) {
|
|
164
|
+
try {
|
|
165
|
+
return await input.proxy.sessions.recordProviderBinding(input.proxySessionId, {
|
|
166
|
+
providerCheckoutSessionId: input.checkoutSessionId,
|
|
167
|
+
psp: input.psp,
|
|
168
|
+
requestId: input.requestId,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch (cause) {
|
|
172
|
+
const reconciled = await readReconciledBinding(input).catch(() => undefined);
|
|
173
|
+
if (reconciled) {
|
|
174
|
+
return reconciled;
|
|
175
|
+
}
|
|
176
|
+
if (isProxyConflict(cause)) {
|
|
177
|
+
throw cause;
|
|
178
|
+
}
|
|
179
|
+
throw new errors_js_1.ProxyStripeOpenCheckoutError("Stripe Checkout Session was created but Proxy provider binding could not be recorded.", {
|
|
180
|
+
cause,
|
|
181
|
+
code: "provider_binding_failed",
|
|
182
|
+
providerCheckoutSessionId: input.checkoutSessionId,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function readReconciledBinding(input) {
|
|
187
|
+
const current = await input.proxy.sessions.retrieve(input.proxySessionId, {
|
|
188
|
+
requestId: input.requestId,
|
|
189
|
+
});
|
|
190
|
+
if (current.providerCheckoutSessionId !== input.checkoutSessionId ||
|
|
191
|
+
current.providerCheckoutSessionPsp !== input.psp) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const checkoutSession = await input.stripe.checkout.sessions.retrieve(input.checkoutSessionId);
|
|
195
|
+
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(checkoutSession, input.proxySessionId);
|
|
196
|
+
return bindingFromSession(current);
|
|
197
|
+
}
|
|
198
|
+
function isProxyConflict(error) {
|
|
199
|
+
return (typeof error === "object" &&
|
|
200
|
+
error !== null &&
|
|
201
|
+
"statusCode" in error &&
|
|
202
|
+
error.statusCode === 409);
|
|
203
|
+
}
|
package/dist/cjs/psp.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePsp = normalizePsp;
|
|
4
|
+
const server_js_1 = require("@proxy-checkout/server-js");
|
|
5
|
+
/**
|
|
6
|
+
* Provider (psp) identifier normalization, kept in lockstep with the Proxy API.
|
|
7
|
+
*
|
|
8
|
+
* The API normalizes the psp before persisting a provider binding
|
|
9
|
+
* (`psp.trim().toLowerCase()`), then compares stored bindings against that
|
|
10
|
+
* normalized value. The SDK must normalize identically before recording or
|
|
11
|
+
* validating a binding so a caller passing the same psp with different
|
|
12
|
+
* casing/whitespace for `openCheckout` vs `syncCheckoutCart` does not get a
|
|
13
|
+
* false `provider_binding_mismatch`.
|
|
14
|
+
*/
|
|
15
|
+
/** Normalize and validate a psp identifier exactly as the Proxy API does before storing/comparing a binding. */
|
|
16
|
+
function normalizePsp(psp) {
|
|
17
|
+
const normalized = psp.trim().toLowerCase();
|
|
18
|
+
if (!/^[a-z0-9_]{1,32}$/.test(normalized)) {
|
|
19
|
+
throw new server_js_1.ProxyCheckoutValidationError("psp must be a short lowercase identifier", {
|
|
20
|
+
code: "provider_binding_mismatch",
|
|
21
|
+
field: "psp",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return normalized;
|
|
25
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `syncCheckoutCart` — coordinated Proxy + Stripe cart update.
|
|
4
|
+
*
|
|
5
|
+
* Validates ownership against the first-class Proxy provider binding (not just
|
|
6
|
+
* Stripe metadata), then updates the Proxy cart and the Stripe checkout in the
|
|
7
|
+
* safest order with deterministic rollback/reconciliation on failure.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.syncCheckoutCart = syncCheckoutCart;
|
|
11
|
+
const server_js_1 = require("@proxy-checkout/server-js");
|
|
12
|
+
const errors_js_1 = require("./errors.js");
|
|
13
|
+
const metadata_js_1 = require("./metadata.js");
|
|
14
|
+
const psp_js_1 = require("./psp.js");
|
|
15
|
+
async function syncCheckoutCart(options) {
|
|
16
|
+
// Normalize the same way the API does on store, so the binding comparison is
|
|
17
|
+
// normalized-to-normalized and a custom psp with differing casing/whitespace
|
|
18
|
+
// does not produce a false provider_binding_mismatch.
|
|
19
|
+
const psp = (0, psp_js_1.normalizePsp)(options.psp ?? "stripe");
|
|
20
|
+
const session = await options.proxy.sessions.retrieve(options.proxySessionId, {
|
|
21
|
+
requestId: options.requestId,
|
|
22
|
+
});
|
|
23
|
+
// Ownership: validate against the stored binding first, then defensively
|
|
24
|
+
// against the Stripe object's own metadata.
|
|
25
|
+
assertSessionBoundTo(session, options.checkoutSessionId, psp);
|
|
26
|
+
const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId);
|
|
27
|
+
(0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(stripeSession, options.proxySessionId);
|
|
28
|
+
const currentCart = options.cartSchema
|
|
29
|
+
? options.proxy.sessions.parseCart(session, options.cartSchema)
|
|
30
|
+
: session.cartSnapshot;
|
|
31
|
+
const next = await options.buildNextCart({
|
|
32
|
+
currentCart,
|
|
33
|
+
currentSession: session,
|
|
34
|
+
input: options.input,
|
|
35
|
+
});
|
|
36
|
+
const prior = {
|
|
37
|
+
amountMinor: session.amountMinor,
|
|
38
|
+
cartSnapshot: session.cartSnapshot,
|
|
39
|
+
cartVersion: session.cartVersion,
|
|
40
|
+
currency: session.currency,
|
|
41
|
+
};
|
|
42
|
+
// Update Proxy first; the API rejects a non-editable session before Stripe is touched.
|
|
43
|
+
const proxyCartUpdate = await options.proxy.sessions.cart.set(options.proxySessionId, {
|
|
44
|
+
amountMinor: next.amountMinor,
|
|
45
|
+
cartSnapshot: next.cartSnapshot,
|
|
46
|
+
currency: next.currency,
|
|
47
|
+
expectedCartVersion: session.cartVersion,
|
|
48
|
+
requestId: options.requestId,
|
|
49
|
+
});
|
|
50
|
+
let updatedCheckout;
|
|
51
|
+
try {
|
|
52
|
+
updatedCheckout = await options.stripe.checkout.sessions.update(options.checkoutSessionId, {
|
|
53
|
+
line_items: options.buildStripeLineItems(next.cart),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (cause) {
|
|
57
|
+
try {
|
|
58
|
+
await options.proxy.sessions.cart.set(options.proxySessionId, {
|
|
59
|
+
amountMinor: prior.amountMinor,
|
|
60
|
+
cartSnapshot: prior.cartSnapshot,
|
|
61
|
+
currency: prior.currency,
|
|
62
|
+
expectedCartVersion: proxyCartUpdate.cartVersion,
|
|
63
|
+
requestId: options.requestId,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (rollbackCause) {
|
|
67
|
+
throw new errors_js_1.ProxyStripeCartSyncError("Stripe checkout update failed and the Proxy cart rollback failed; carts may be out of sync.", { cause, code: "reconciliation_failed", reconciled: false, rollbackCause });
|
|
68
|
+
}
|
|
69
|
+
throw new errors_js_1.ProxyStripeCartSyncError("Stripe checkout update failed; the Proxy cart was rolled back to its prior state.", { cause, code: "stripe_update_failed", reconciled: true });
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
amountMinor: next.amountMinor,
|
|
73
|
+
cart: next.cart,
|
|
74
|
+
cartSnapshot: next.cartSnapshot,
|
|
75
|
+
checkoutSession: updatedCheckout,
|
|
76
|
+
currency: next.currency,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function assertSessionBoundTo(session, checkoutSessionId, psp) {
|
|
80
|
+
if (session.providerCheckoutSessionId !== checkoutSessionId ||
|
|
81
|
+
session.providerCheckoutSessionPsp !== psp) {
|
|
82
|
+
throw new server_js_1.ProxyCheckoutValidationError(`Proxy session ${session.id} is not bound to provider checkout session ${checkoutSessionId}.`, { code: "provider_binding_mismatch", field: "provider_checkout_session_id" });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal structural Stripe types.
|
|
4
|
+
*
|
|
5
|
+
* The adapter is dependency-free: merchants inject their own `Stripe` instance
|
|
6
|
+
* and objects, which are structurally compatible with these narrow interfaces.
|
|
7
|
+
* This avoids a runtime/build dependency on the `stripe` package while keeping
|
|
8
|
+
* the bits the adapter actually touches type-safe.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proxyCheckoutStripeServerSdkVersion = exports.proxyCheckoutStripeServerSdkName = void 0;
|
|
4
|
+
exports.proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
5
|
+
exports.proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.22.1";
|
|
@@ -33,16 +33,16 @@ export function injectRequiredCheckoutSessionMetadata(params, proxySessionId) {
|
|
|
33
33
|
...(params.mode === "subscription" || params.subscription_data !== undefined
|
|
34
34
|
? {
|
|
35
35
|
subscription_data: {
|
|
36
|
-
...params.subscription_data,
|
|
37
|
-
metadata: mergeProxyMetadata(params.subscription_data
|
|
36
|
+
...objectRecord(params.subscription_data),
|
|
37
|
+
metadata: mergeProxyMetadata(metadataFromNestedParams(params.subscription_data), metadata, "subscription_data.metadata.proxy_session_id"),
|
|
38
38
|
},
|
|
39
39
|
}
|
|
40
40
|
: {}),
|
|
41
41
|
...(params.mode === "payment" || params.payment_intent_data !== undefined
|
|
42
42
|
? {
|
|
43
43
|
payment_intent_data: {
|
|
44
|
-
...params.payment_intent_data,
|
|
45
|
-
metadata: mergeProxyMetadata(params.payment_intent_data
|
|
44
|
+
...objectRecord(params.payment_intent_data),
|
|
45
|
+
metadata: mergeProxyMetadata(metadataFromNestedParams(params.payment_intent_data), metadata, "payment_intent_data.metadata.proxy_session_id"),
|
|
46
46
|
},
|
|
47
47
|
}
|
|
48
48
|
: {}),
|
|
@@ -76,3 +76,9 @@ function mergeProxyMetadata(existing, required, field) {
|
|
|
76
76
|
...required,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
function objectRecord(value) {
|
|
80
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
81
|
+
}
|
|
82
|
+
function metadataFromNestedParams(value) {
|
|
83
|
+
return objectRecord(value).metadata;
|
|
84
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* metadata placement, idempotency, and binding reconciliation.
|
|
8
8
|
*/
|
|
9
9
|
import { ProxyCheckoutValidationError } from "@proxy-checkout/server-js";
|
|
10
|
-
import { ProxyStripeOpenCheckoutError } from "./errors.js";
|
|
10
|
+
import { ProxyStripeCartSyncError, ProxyStripeOpenCheckoutError } from "./errors.js";
|
|
11
11
|
import { assertCheckoutSessionBelongsToProxy, injectRequiredCheckoutSessionMetadata, } from "./metadata.js";
|
|
12
12
|
import { normalizePsp } from "./psp.js";
|
|
13
13
|
export async function openCheckout(options) {
|
|
@@ -27,8 +27,29 @@ export async function openCheckout(options) {
|
|
|
27
27
|
const offer = options.validateCart
|
|
28
28
|
? await options.validateCart({ cart, session: proxySession })
|
|
29
29
|
: undefined;
|
|
30
|
+
if (proxySession.providerCheckoutSessionId !== null) {
|
|
31
|
+
assertExistingBindingMatches(proxySession, psp);
|
|
32
|
+
const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId));
|
|
33
|
+
assertCheckoutSessionBelongsToProxy(checkoutSession, proxySession.id);
|
|
34
|
+
return {
|
|
35
|
+
binding: bindingFromSession(proxySession),
|
|
36
|
+
cart,
|
|
37
|
+
checkoutSession,
|
|
38
|
+
clientSecret: checkoutSession.client_secret ?? null,
|
|
39
|
+
offer,
|
|
40
|
+
proxySession,
|
|
41
|
+
proxySessionId: proxySession.id,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let rollbackCart;
|
|
30
45
|
const reconciledCart = await options.reconcileCart?.({ cart, offer, session: proxySession });
|
|
31
46
|
if (reconciledCart) {
|
|
47
|
+
const priorCart = {
|
|
48
|
+
amountMinor: proxySession.amountMinor,
|
|
49
|
+
cartSnapshot: proxySession.cartSnapshot,
|
|
50
|
+
cartVersion: proxySession.cartVersion,
|
|
51
|
+
currency: proxySession.currency,
|
|
52
|
+
};
|
|
32
53
|
const updatedCart = await options.proxy.sessions.cart.set(proxySession.id, {
|
|
33
54
|
amountMinor: reconciledCart.amountMinor,
|
|
34
55
|
cartSnapshot: reconciledCart.cartSnapshot,
|
|
@@ -36,6 +57,10 @@ export async function openCheckout(options) {
|
|
|
36
57
|
expectedCartVersion: proxySession.cartVersion,
|
|
37
58
|
requestId: options.requestId,
|
|
38
59
|
});
|
|
60
|
+
rollbackCart = {
|
|
61
|
+
...priorCart,
|
|
62
|
+
expectedCartVersion: updatedCart.cartVersion,
|
|
63
|
+
};
|
|
39
64
|
proxySession = {
|
|
40
65
|
...proxySession,
|
|
41
66
|
amountMinor: updatedCart.amountMinor,
|
|
@@ -46,12 +71,26 @@ export async function openCheckout(options) {
|
|
|
46
71
|
};
|
|
47
72
|
cart = reconciledCart.cart;
|
|
48
73
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
try {
|
|
75
|
+
const params = await options.buildCheckoutSessionParams({
|
|
76
|
+
cart,
|
|
77
|
+
offer,
|
|
78
|
+
proxySession,
|
|
79
|
+
stripe: options.stripe,
|
|
80
|
+
});
|
|
81
|
+
const checkoutSession = (await options.stripe.checkout.sessions.create(injectRequiredCheckoutSessionMetadata(params, proxySession.id), buildStripeRequestOptions(options, proxySession.id, psp)));
|
|
82
|
+
// Fail closed if the merchant forgot to place proxy_session_id metadata.
|
|
52
83
|
assertCheckoutSessionBelongsToProxy(checkoutSession, proxySession.id);
|
|
84
|
+
const binding = await recordOrReconcileProviderBinding({
|
|
85
|
+
checkoutSessionId: checkoutSession.id,
|
|
86
|
+
proxy: options.proxy,
|
|
87
|
+
proxySessionId: proxySession.id,
|
|
88
|
+
psp,
|
|
89
|
+
requestId: options.requestId,
|
|
90
|
+
stripe: options.stripe,
|
|
91
|
+
});
|
|
53
92
|
return {
|
|
54
|
-
binding
|
|
93
|
+
binding,
|
|
55
94
|
cart,
|
|
56
95
|
checkoutSession,
|
|
57
96
|
clientSecret: checkoutSession.client_secret ?? null,
|
|
@@ -60,32 +99,18 @@ export async function openCheckout(options) {
|
|
|
60
99
|
proxySessionId: proxySession.id,
|
|
61
100
|
};
|
|
62
101
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
proxySessionId: proxySession.id,
|
|
76
|
-
psp,
|
|
77
|
-
requestId: options.requestId,
|
|
78
|
-
stripe: options.stripe,
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
binding,
|
|
82
|
-
cart,
|
|
83
|
-
checkoutSession,
|
|
84
|
-
clientSecret: checkoutSession.client_secret ?? null,
|
|
85
|
-
offer,
|
|
86
|
-
proxySession,
|
|
87
|
-
proxySessionId: proxySession.id,
|
|
88
|
-
};
|
|
102
|
+
catch (cause) {
|
|
103
|
+
if (rollbackCart) {
|
|
104
|
+
await rollbackReconciledCart({
|
|
105
|
+
cause,
|
|
106
|
+
proxy: options.proxy,
|
|
107
|
+
proxySessionId: proxySession.id,
|
|
108
|
+
requestId: options.requestId,
|
|
109
|
+
rollbackCart,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
throw cause;
|
|
113
|
+
}
|
|
89
114
|
}
|
|
90
115
|
function buildStripeRequestOptions(options, proxySessionId, psp) {
|
|
91
116
|
return {
|
|
@@ -113,6 +138,25 @@ function bindingFromSession(proxySession) {
|
|
|
113
138
|
updatedAt: proxySession.updatedAt,
|
|
114
139
|
};
|
|
115
140
|
}
|
|
141
|
+
async function rollbackReconciledCart(input) {
|
|
142
|
+
try {
|
|
143
|
+
await input.proxy.sessions.cart.set(input.proxySessionId, {
|
|
144
|
+
amountMinor: input.rollbackCart.amountMinor,
|
|
145
|
+
cartSnapshot: input.rollbackCart.cartSnapshot,
|
|
146
|
+
currency: input.rollbackCart.currency,
|
|
147
|
+
expectedCartVersion: input.rollbackCart.expectedCartVersion,
|
|
148
|
+
requestId: input.requestId,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (rollbackCause) {
|
|
152
|
+
throw new ProxyStripeCartSyncError("openCheckout failed after reconciling the Proxy cart, and the rollback failed; carts may be out of sync.", {
|
|
153
|
+
cause: input.cause,
|
|
154
|
+
code: "reconciliation_failed",
|
|
155
|
+
reconciled: false,
|
|
156
|
+
rollbackCause,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
116
160
|
async function recordOrReconcileProviderBinding(input) {
|
|
117
161
|
try {
|
|
118
162
|
return await input.proxy.sessions.recordProviderBinding(input.proxySessionId, {
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* This avoids a runtime/build dependency on the `stripe` package while keeping
|
|
7
7
|
* the bits the adapter actually touches type-safe.
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
9
|
+
export type StripeMetadataValue = string | number | null;
|
|
10
|
+
export type StripeMetadata = Record<string, StripeMetadataValue> | null | undefined;
|
|
11
|
+
export type StripeMetadataParam = Record<string, StripeMetadataValue> | undefined;
|
|
10
12
|
export interface StripeCheckoutSessionLike {
|
|
11
13
|
readonly client_secret?: string | null;
|
|
12
14
|
readonly id: string;
|
|
@@ -22,21 +24,14 @@ export interface StripePaymentIntentLike {
|
|
|
22
24
|
}
|
|
23
25
|
export interface StripeCheckoutSessionUpdateParams {
|
|
24
26
|
readonly line_items?: unknown;
|
|
25
|
-
readonly metadata?:
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
readonly metadata?:
|
|
29
|
-
readonly mode?:
|
|
30
|
-
readonly payment_intent_data?:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
readonly subscription_data?: {
|
|
35
|
-
readonly metadata?: Record<string, string>;
|
|
36
|
-
readonly [key: string]: unknown;
|
|
37
|
-
};
|
|
38
|
-
readonly [key: string]: unknown;
|
|
39
|
-
}
|
|
27
|
+
readonly metadata?: StripeMetadataParam;
|
|
28
|
+
}
|
|
29
|
+
export type StripeCheckoutSessionCreateParams = object & {
|
|
30
|
+
readonly metadata?: StripeMetadataParam;
|
|
31
|
+
readonly mode?: "payment" | "setup" | "subscription";
|
|
32
|
+
readonly payment_intent_data?: unknown;
|
|
33
|
+
readonly subscription_data?: unknown;
|
|
34
|
+
};
|
|
40
35
|
export interface StripeRequestOptionsLike {
|
|
41
36
|
readonly idempotencyKey?: string;
|
|
42
37
|
readonly [key: string]: unknown;
|
|
@@ -46,9 +41,9 @@ export interface StripeRequestOptionsWithoutIdempotencyLike {
|
|
|
46
41
|
readonly [key: string]: unknown;
|
|
47
42
|
}
|
|
48
43
|
export interface StripeCheckoutSessionsApiLike {
|
|
49
|
-
create(params:
|
|
44
|
+
create(params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
50
45
|
retrieve(id: string, params?: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
51
|
-
update(id: string, params:
|
|
46
|
+
update(id: string, params: unknown, options?: unknown): Promise<StripeCheckoutSessionLike>;
|
|
52
47
|
}
|
|
53
48
|
export interface StripeClientLike {
|
|
54
49
|
readonly checkout: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
2
|
-
export declare const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.
|
|
2
|
+
export declare const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.22.1";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
|
|
2
|
-
export const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.
|
|
2
|
+
export const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.22.1";
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Server-side Stripe adapter for Proxy Checkout: required metadata, provider binding, openCheckout, and cart sync.",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"
|
|
4
|
+
"main": "./dist/cjs/index.js",
|
|
5
|
+
"module": "./dist/esm/index.js",
|
|
5
6
|
"name": "@proxy-checkout/stripe-server-js",
|
|
6
7
|
"private": false,
|
|
7
8
|
"sideEffects": false,
|
|
8
9
|
"type": "module",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"version": "0.0.0-pr-76.
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"version": "0.0.0-pr-76.22.1",
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@types/node": "^24.12.4",
|
|
13
14
|
"@vitest/coverage-v8": "4.1.7",
|
|
15
|
+
"stripe": "^21.0.1",
|
|
14
16
|
"typescript": "^6.0.3",
|
|
15
17
|
"vitest": "4.1.7",
|
|
16
|
-
"@proxy-checkout/server-js": "0.0.4-pr-76.
|
|
18
|
+
"@proxy-checkout/server-js": "0.0.4-pr-76.22.1"
|
|
17
19
|
},
|
|
18
20
|
"exports": {
|
|
19
21
|
".": {
|
|
20
|
-
"import": "./dist/index.js",
|
|
21
|
-
"
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js",
|
|
24
|
+
"types": "./dist/esm/index.d.ts"
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
"files": [
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"url": "git+https://github.com/linuslabs/proxy.git"
|
|
46
49
|
},
|
|
47
50
|
"scripts": {
|
|
48
|
-
"build": "
|
|
51
|
+
"build": "node ../../tools/sdk/build-dual-package.mjs",
|
|
49
52
|
"test:all": "vitest run",
|
|
50
53
|
"test:coverage": "vitest run --coverage.enabled --coverage.reportsDirectory=coverage/all",
|
|
51
54
|
"test:coverage:changed": "vitest run --coverage.enabled --coverage.reportsDirectory=coverage/changed",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|