@proxy-checkout/server-js 0.0.4-pr-76.17.1 → 0.0.4-pr-76.19.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.
@@ -10,7 +10,13 @@ import type { MerchantProxySession } from "./sessions.js";
10
10
  import type { MerchantProxySubscription } from "./subscriptions.js";
11
11
  /** Session statuses that mean the payer has paid and entitlement may be granted. */
12
12
  export declare const PROVISIONABLE_SESSION_STATUSES: Set<string>;
13
- /** Session statuses that are terminal — no further lifecycle transitions occur. */
13
+ /**
14
+ * Session statuses that are terminal from the SDK's lifecycle perspective — the
15
+ * automatic flow has stopped and the merchant must observe the outcome. This
16
+ * includes `merchant_action_required`, which halts the session pending merchant
17
+ * intervention; classifying it here keeps a `proxy_session.merchant_action_required`
18
+ * event from silently resolving to `ignored` and being marked processed.
19
+ */
14
20
  export declare const TERMINAL_SESSION_STATUSES: Set<string>;
15
21
  /** Subscription statuses that mean the subscription is no longer active. */
16
22
  export declare const ENDED_SUBSCRIPTION_STATUSES: Set<string>;
package/dist/lifecycle.js CHANGED
@@ -9,11 +9,18 @@
9
9
  import { ProxyCheckoutValidationError } from "./errors.js";
10
10
  /** Session statuses that mean the payer has paid and entitlement may be granted. */
11
11
  export const PROVISIONABLE_SESSION_STATUSES = new Set(["paid", "provisionable"]);
12
- /** Session statuses that are terminal — no further lifecycle transitions occur. */
12
+ /**
13
+ * Session statuses that are terminal from the SDK's lifecycle perspective — the
14
+ * automatic flow has stopped and the merchant must observe the outcome. This
15
+ * includes `merchant_action_required`, which halts the session pending merchant
16
+ * intervention; classifying it here keeps a `proxy_session.merchant_action_required`
17
+ * event from silently resolving to `ignored` and being marked processed.
18
+ */
13
19
  export const TERMINAL_SESSION_STATUSES = new Set([
14
20
  "cancelled",
15
21
  "expired",
16
22
  "failed",
23
+ "merchant_action_required",
17
24
  "provisioned",
18
25
  "provisioning_failed",
19
26
  ]);
@@ -35,6 +35,7 @@ export interface MerchantProxySession {
35
35
  readonly amountMinor: number;
36
36
  readonly buyerReference: string;
37
37
  readonly cartSnapshot: JsonObject;
38
+ readonly cartVersion: number;
38
39
  readonly createdAt: string;
39
40
  readonly currency: string;
40
41
  readonly expiresAt: string;
@@ -65,10 +66,12 @@ export interface SetProxySessionCartInput extends ProxyCheckoutServerRequestOpti
65
66
  readonly amountMinor: number;
66
67
  readonly cartSnapshot: JsonObject;
67
68
  readonly currency: string;
69
+ readonly expectedCartVersion: number;
68
70
  }
69
71
  export interface ProxySessionCartResult {
70
72
  readonly amountMinor: number;
71
73
  readonly cartSnapshot: JsonObject;
74
+ readonly cartVersion: number;
72
75
  readonly currency: string;
73
76
  }
74
77
  export interface RecordProviderBindingInput extends ProxyCheckoutServerRequestOptions {
package/dist/sessions.js CHANGED
@@ -148,6 +148,7 @@ export class ProxySessionCartResource {
148
148
  return {
149
149
  amountMinor: requireInteger(body.amount_minor, "sessions.cart.set.amountMinor"),
150
150
  cartSnapshot: requireJsonObject(body.cart_snapshot, "sessions.cart.set"),
151
+ cartVersion: requireInteger(body.cart_version, "sessions.cart.set.cartVersion"),
151
152
  currency: requireString(body.currency, "sessions.cart.set.currency"),
152
153
  };
153
154
  }
@@ -182,6 +183,7 @@ function toProxySessionCartBody(input) {
182
183
  amount_minor: input.amountMinor,
183
184
  cart_snapshot: input.cartSnapshot,
184
185
  currency: input.currency,
186
+ expected_cart_version: input.expectedCartVersion,
185
187
  };
186
188
  }
187
189
  function removeUndefinedValues(input) {
@@ -216,6 +218,7 @@ function toMerchantProxySession(response) {
216
218
  amountMinor: requireInteger(body.amount_minor, "sessions.retrieve.amountMinor"),
217
219
  buyerReference: requireString(body.buyer_reference, "sessions.retrieve.buyerReference"),
218
220
  cartSnapshot: requireJsonObject(body.cart_snapshot, "sessions.retrieve.cartSnapshot"),
221
+ cartVersion: requireInteger(body.cart_version, "sessions.retrieve.cartVersion"),
219
222
  createdAt: requireString(body.created_at, "sessions.retrieve.createdAt"),
220
223
  currency: requireString(body.currency, "sessions.retrieve.currency"),
221
224
  expiresAt: requireString(body.expires_at, "sessions.retrieve.expiresAt"),
@@ -240,6 +243,7 @@ function toPayerOpenedResult(response) {
240
243
  amountMinor: requireInteger(body.amount_minor, "sessions.payerOpened.amountMinor"),
241
244
  buyerReference: requireString(body.buyer_reference, "sessions.payerOpened.buyerReference"),
242
245
  cartSnapshot: requireJsonObject(body.cart_snapshot, "sessions.payerOpened.cartSnapshot"),
246
+ cartVersion: requireInteger(body.cart_version, "sessions.payerOpened.cartVersion"),
243
247
  createdAt: requireString(body.created_at, "sessions.payerOpened.createdAt"),
244
248
  currency: requireString(body.currency, "sessions.payerOpened.currency"),
245
249
  expiresAt: requireString(body.expires_at, "sessions.payerOpened.expiresAt"),
@@ -248,9 +252,8 @@ function toPayerOpenedResult(response) {
248
252
  integrationMode: requireString(body.integration_mode, "sessions.payerOpened.integrationMode"),
249
253
  metadata: requireJsonObject(body.metadata, "sessions.payerOpened.metadata"),
250
254
  payerContact: requireNullablePayerContact(body.payer_contact, "sessions.payerOpened"),
251
- // No provider binding exists yet at payer-open; it is recorded after checkout creation.
252
- providerCheckoutSessionId: null,
253
- providerCheckoutSessionPsp: null,
255
+ providerCheckoutSessionId: requireNullableString(body.provider_checkout_session_id, "sessions.payerOpened.providerCheckoutSessionId"),
256
+ providerCheckoutSessionPsp: requireNullableString(body.provider_checkout_session_psp, "sessions.payerOpened.providerCheckoutSessionPsp"),
254
257
  status,
255
258
  updatedAt: requireString(body.updated_at, "sessions.payerOpened.updatedAt"),
256
259
  };
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
2
- export declare const proxyCheckoutServerSdkVersion = "0.0.4-pr-76.17.1";
3
- export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.4-pr-76.17.1";
2
+ export declare const proxyCheckoutServerSdkVersion = "0.0.4-pr-76.19.1";
3
+ export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.4-pr-76.19.1";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
2
- export const proxyCheckoutServerSdkVersion = "0.0.4-pr-76.17.1";
2
+ export const proxyCheckoutServerSdkVersion = "0.0.4-pr-76.19.1";
3
3
  export const proxyCheckoutServerSdkUserAgent = `${proxyCheckoutServerSdkName}/${proxyCheckoutServerSdkVersion}`;
@@ -7,7 +7,12 @@
7
7
  */
8
8
  export declare const PROXY_WEBHOOK_EVENT_TYPES: {
9
9
  readonly paymentAttemptCancelled: "payment_attempt.cancelled";
10
+ readonly paymentAttemptDisputed: "payment_attempt.disputed";
11
+ readonly paymentAttemptDisputeLost: "payment_attempt.dispute_lost";
12
+ readonly paymentAttemptDisputeWon: "payment_attempt.dispute_won";
10
13
  readonly paymentAttemptFailed: "payment_attempt.failed";
14
+ readonly paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded";
15
+ readonly paymentAttemptRefunded: "payment_attempt.refunded";
11
16
  readonly paymentAttemptSucceeded: "payment_attempt.succeeded";
12
17
  readonly sessionCancelled: "proxy_session.cancelled";
13
18
  readonly sessionExpired: "proxy_session.expired";
@@ -7,7 +7,12 @@
7
7
  */
8
8
  export const PROXY_WEBHOOK_EVENT_TYPES = {
9
9
  paymentAttemptCancelled: "payment_attempt.cancelled",
10
+ paymentAttemptDisputed: "payment_attempt.disputed",
11
+ paymentAttemptDisputeLost: "payment_attempt.dispute_lost",
12
+ paymentAttemptDisputeWon: "payment_attempt.dispute_won",
10
13
  paymentAttemptFailed: "payment_attempt.failed",
14
+ paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded",
15
+ paymentAttemptRefunded: "payment_attempt.refunded",
11
16
  paymentAttemptSucceeded: "payment_attempt.succeeded",
12
17
  sessionCancelled: "proxy_session.cancelled",
13
18
  sessionExpired: "proxy_session.expired",
@@ -36,7 +41,12 @@ const SUBSCRIPTION_EVENT_TYPES = new Set([
36
41
  ]);
37
42
  const PAYMENT_ATTEMPT_EVENT_TYPES = new Set([
38
43
  PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptCancelled,
44
+ PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeLost,
45
+ PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeWon,
46
+ PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputed,
39
47
  PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptFailed,
48
+ PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptPartiallyRefunded,
49
+ PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptRefunded,
40
50
  PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptSucceeded,
41
51
  ]);
42
52
  /** True for `proxy_session.*` events. */
@@ -72,7 +72,21 @@ export class ProxyWebhooksResource {
72
72
  throw error;
73
73
  }
74
74
  if (store !== undefined) {
75
- await store.markProcessed(event.id, toProcessRecord(resolved));
75
+ try {
76
+ await store.markProcessed(event.id, toProcessRecord(resolved));
77
+ }
78
+ catch (error) {
79
+ // The fulfillment ran, but committing idempotency failed. Best-effort
80
+ // release the claim so the event is reclaimable on a later delivery
81
+ // instead of being stuck in the in-flight branch forever.
82
+ try {
83
+ await store.markFailed(event.id, error);
84
+ }
85
+ catch {
86
+ // Never let a store failure shadow the original markProcessed error.
87
+ }
88
+ throw error;
89
+ }
76
90
  }
77
91
  return {
78
92
  event,
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "sideEffects": false,
8
8
  "type": "module",
9
9
  "types": "./dist/index.d.ts",
10
- "version": "0.0.4-pr-76.17.1",
10
+ "version": "0.0.4-pr-76.19.1",
11
11
  "devDependencies": {
12
12
  "@types/node": "^24.12.4",
13
13
  "@vitest/coverage-v8": "4.1.7",