@proxy-checkout/stripe-server-js 0.0.0-pr-76.24.1 → 0.0.0-pr-76.26.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.
@@ -27,12 +27,12 @@ async function openCheckout(options) {
27
27
  let cart = options.cartSchema || options.getCartBuyerReference
28
28
  ? options.proxy.sessions.parseCart(proxySession, options.cartSchema ?? ((value) => value), { getBuyerReference: options.getCartBuyerReference })
29
29
  : proxySession.cartSnapshot;
30
- const offer = options.validateCart
30
+ let offer = options.validateCart
31
31
  ? await options.validateCart({ cart, session: proxySession })
32
32
  : undefined;
33
33
  if (proxySession.providerCheckoutSessionId !== null) {
34
34
  assertExistingBindingMatches(proxySession, psp);
35
- const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId));
35
+ const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId, undefined, options.stripeRequestOptions));
36
36
  (0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(checkoutSession, proxySession.id);
37
37
  return {
38
38
  binding: bindingFromSession(proxySession),
@@ -75,6 +75,9 @@ async function openCheckout(options) {
75
75
  cart = reconciledCart.cart;
76
76
  }
77
77
  try {
78
+ if (reconciledCart && options.validateCart) {
79
+ offer = await options.validateCart({ cart, session: proxySession });
80
+ }
78
81
  const params = await options.buildCheckoutSessionParams({
79
82
  cart,
80
83
  offer,
@@ -91,6 +94,7 @@ async function openCheckout(options) {
91
94
  psp,
92
95
  requestId: options.requestId,
93
96
  stripe: options.stripe,
97
+ stripeRequestOptions: options.stripeRequestOptions,
94
98
  });
95
99
  return {
96
100
  binding,
@@ -191,7 +195,7 @@ async function readReconciledBinding(input) {
191
195
  current.providerCheckoutSessionPsp !== input.psp) {
192
196
  return undefined;
193
197
  }
194
- const checkoutSession = await input.stripe.checkout.sessions.retrieve(input.checkoutSessionId);
198
+ const checkoutSession = await input.stripe.checkout.sessions.retrieve(input.checkoutSessionId, undefined, input.stripeRequestOptions);
195
199
  (0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(checkoutSession, input.proxySessionId);
196
200
  return bindingFromSession(current);
197
201
  }
@@ -23,7 +23,7 @@ async function syncCheckoutCart(options) {
23
23
  // Ownership: validate against the stored binding first, then defensively
24
24
  // against the Stripe object's own metadata.
25
25
  assertSessionBoundTo(session, options.checkoutSessionId, psp);
26
- const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId);
26
+ const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId, undefined, options.stripeRequestOptions);
27
27
  (0, metadata_js_1.assertCheckoutSessionBelongsToProxy)(stripeSession, options.proxySessionId);
28
28
  const currentCart = options.cartSchema
29
29
  ? options.proxy.sessions.parseCart(session, options.cartSchema)
@@ -51,7 +51,7 @@ async function syncCheckoutCart(options) {
51
51
  try {
52
52
  updatedCheckout = await options.stripe.checkout.sessions.update(options.checkoutSessionId, {
53
53
  line_items: options.buildStripeLineItems(next.cart),
54
- });
54
+ }, options.stripeRequestOptions);
55
55
  }
56
56
  catch (cause) {
57
57
  try {
@@ -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.0.0-pr-76.24.1";
5
+ exports.proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.26.1";
@@ -24,12 +24,12 @@ export async function openCheckout(options) {
24
24
  let cart = options.cartSchema || options.getCartBuyerReference
25
25
  ? options.proxy.sessions.parseCart(proxySession, options.cartSchema ?? ((value) => value), { getBuyerReference: options.getCartBuyerReference })
26
26
  : proxySession.cartSnapshot;
27
- const offer = options.validateCart
27
+ let offer = options.validateCart
28
28
  ? await options.validateCart({ cart, session: proxySession })
29
29
  : undefined;
30
30
  if (proxySession.providerCheckoutSessionId !== null) {
31
31
  assertExistingBindingMatches(proxySession, psp);
32
- const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId));
32
+ const checkoutSession = (await options.stripe.checkout.sessions.retrieve(proxySession.providerCheckoutSessionId, undefined, options.stripeRequestOptions));
33
33
  assertCheckoutSessionBelongsToProxy(checkoutSession, proxySession.id);
34
34
  return {
35
35
  binding: bindingFromSession(proxySession),
@@ -72,6 +72,9 @@ export async function openCheckout(options) {
72
72
  cart = reconciledCart.cart;
73
73
  }
74
74
  try {
75
+ if (reconciledCart && options.validateCart) {
76
+ offer = await options.validateCart({ cart, session: proxySession });
77
+ }
75
78
  const params = await options.buildCheckoutSessionParams({
76
79
  cart,
77
80
  offer,
@@ -88,6 +91,7 @@ export async function openCheckout(options) {
88
91
  psp,
89
92
  requestId: options.requestId,
90
93
  stripe: options.stripe,
94
+ stripeRequestOptions: options.stripeRequestOptions,
91
95
  });
92
96
  return {
93
97
  binding,
@@ -188,7 +192,7 @@ async function readReconciledBinding(input) {
188
192
  current.providerCheckoutSessionPsp !== input.psp) {
189
193
  return undefined;
190
194
  }
191
- const checkoutSession = await input.stripe.checkout.sessions.retrieve(input.checkoutSessionId);
195
+ const checkoutSession = await input.stripe.checkout.sessions.retrieve(input.checkoutSessionId, undefined, input.stripeRequestOptions);
192
196
  assertCheckoutSessionBelongsToProxy(checkoutSession, input.proxySessionId);
193
197
  return bindingFromSession(current);
194
198
  }
@@ -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, StripeClientLike } from "./types.js";
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;
@@ -34,6 +34,8 @@ export interface SyncCheckoutCartOptions<TStripe extends StripeClientLike, TCart
34
34
  readonly psp?: string;
35
35
  readonly requestId?: string;
36
36
  readonly stripe: TStripe;
37
+ /** Optional Stripe request options, e.g. Stripe Connect account scoping. */
38
+ readonly stripeRequestOptions?: StripeRequestOptionsWithoutIdempotencyLike;
37
39
  }
38
40
  export interface SyncCheckoutCartResult<TCart> {
39
41
  readonly amountMinor: number;
@@ -20,7 +20,7 @@ export async function syncCheckoutCart(options) {
20
20
  // Ownership: validate against the stored binding first, then defensively
21
21
  // against the Stripe object's own metadata.
22
22
  assertSessionBoundTo(session, options.checkoutSessionId, psp);
23
- const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId);
23
+ const stripeSession = await options.stripe.checkout.sessions.retrieve(options.checkoutSessionId, undefined, options.stripeRequestOptions);
24
24
  assertCheckoutSessionBelongsToProxy(stripeSession, options.proxySessionId);
25
25
  const currentCart = options.cartSchema
26
26
  ? options.proxy.sessions.parseCart(session, options.cartSchema)
@@ -48,7 +48,7 @@ export async function syncCheckoutCart(options) {
48
48
  try {
49
49
  updatedCheckout = await options.stripe.checkout.sessions.update(options.checkoutSessionId, {
50
50
  line_items: options.buildStripeLineItems(next.cart),
51
- });
51
+ }, options.stripeRequestOptions);
52
52
  }
53
53
  catch (cause) {
54
54
  try {
@@ -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.24.1";
2
+ export declare const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.26.1";
@@ -1,2 +1,2 @@
1
1
  export const proxyCheckoutStripeServerSdkName = "@proxy-checkout/stripe-server-js";
2
- export const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.24.1";
2
+ export const proxyCheckoutStripeServerSdkVersion = "0.0.0-pr-76.26.1";
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "sideEffects": false,
9
9
  "type": "module",
10
10
  "types": "./dist/esm/index.d.ts",
11
- "version": "0.0.0-pr-76.24.1",
11
+ "version": "0.0.0-pr-76.26.1",
12
12
  "devDependencies": {
13
13
  "@types/node": "^24.12.4",
14
14
  "@vitest/coverage-v8": "4.1.7",
15
15
  "stripe": "^21.0.1",
16
16
  "typescript": "^6.0.3",
17
17
  "vitest": "4.1.7",
18
- "@proxy-checkout/server-js": "0.0.4-pr-76.24.1"
18
+ "@proxy-checkout/server-js": "0.0.4-pr-76.26.1"
19
19
  },
20
20
  "exports": {
21
21
  ".": {