@proxy-checkout/server-js 0.0.8-prx-124.136.1 → 0.1.0-prx-124.137.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/dist/cjs/client.js +1 -1
- package/dist/cjs/events.d.cts +10 -2
- package/dist/cjs/events.d.ts +10 -2
- package/dist/cjs/events.js +28 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/version.d.cts +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/webhook-events.d.cts +16 -0
- package/dist/cjs/webhook-events.d.ts +16 -0
- package/dist/cjs/webhook-events.js +35 -0
- package/dist/cjs/webhook-handler.d.cts +1 -0
- package/dist/cjs/webhook-handler.d.ts +1 -0
- package/dist/cjs/webhook-handler.js +7 -0
- package/dist/esm/client.js +1 -1
- package/dist/esm/events.d.ts +10 -2
- package/dist/esm/events.js +29 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +1 -1
- package/dist/esm/webhook-events.d.ts +16 -0
- package/dist/esm/webhook-events.js +34 -0
- package/dist/esm/webhook-handler.d.ts +1 -0
- package/dist/esm/webhook-handler.js +7 -0
- package/package.json +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -33,7 +33,7 @@ class ProxyCheckoutServerClient {
|
|
|
33
33
|
});
|
|
34
34
|
this.providerAcquisitions = new provider_acquisitions_js_1.ProxyProviderAcquisitionsResource(httpClient);
|
|
35
35
|
this.subscriptions = new subscriptions_js_1.ProxySubscriptionsResource(httpClient, this.sessions);
|
|
36
|
-
this.events = new events_js_1.ProxyEventsResource(this.sessions, this.subscriptions);
|
|
36
|
+
this.events = new events_js_1.ProxyEventsResource(this.sessions, this.subscriptions, this.providerAcquisitions);
|
|
37
37
|
this.webhooks = new webhook_handler_js_1.ProxyWebhooksResource(this.events, this.sessions);
|
|
38
38
|
this.webhookEndpoints = new webhooks_js_1.ProxyWebhookEndpointsResource(httpClient);
|
|
39
39
|
}
|
package/dist/cjs/events.d.cts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* lifecycle decision. It never grants from webhook payload fields, and it
|
|
7
7
|
* classifies subscription events from current state rather than event order.
|
|
8
8
|
*/
|
|
9
|
+
import type { ProviderAcquisition, ProxyProviderAcquisitionsResource } from "./provider-acquisitions.js";
|
|
9
10
|
import type { MerchantProxySession, ProxySessionsResource } from "./sessions.js";
|
|
10
11
|
import type { MerchantProxySubscription, ProxySubscriptionsResource } from "./subscriptions.js";
|
|
11
12
|
import type { ProxyCheckoutServerRequestOptions } from "./types.js";
|
|
@@ -66,23 +67,30 @@ export interface ResolvedPaymentAttempt extends ResolvedBase {
|
|
|
66
67
|
readonly sessionId: string | null;
|
|
67
68
|
readonly subscriptionId: string | null;
|
|
68
69
|
}
|
|
70
|
+
export interface ResolvedAcquisitionProgress extends ResolvedBase {
|
|
71
|
+
readonly acquisition: ProviderAcquisition;
|
|
72
|
+
readonly kind: "acquisition_progress";
|
|
73
|
+
readonly session: MerchantProxySession;
|
|
74
|
+
}
|
|
69
75
|
export interface ResolvedIgnored extends ResolvedBase {
|
|
70
76
|
readonly kind: "ignored";
|
|
71
77
|
readonly reason: string;
|
|
72
78
|
readonly sessionId: string | null;
|
|
73
79
|
readonly subscriptionId: string | null;
|
|
74
80
|
}
|
|
75
|
-
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedIgnored;
|
|
81
|
+
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedAcquisitionProgress | ResolvedIgnored;
|
|
76
82
|
export type ResolvedProxyEventKind = ResolvedProxyEvent["kind"];
|
|
77
83
|
export declare class ProxyEventsResource {
|
|
78
84
|
private readonly sessions;
|
|
79
85
|
private readonly subscriptions;
|
|
80
|
-
|
|
86
|
+
private readonly providerAcquisitions;
|
|
87
|
+
constructor(sessions: ProxySessionsResource, subscriptions: ProxySubscriptionsResource, providerAcquisitions: ProxyProviderAcquisitionsResource);
|
|
81
88
|
/**
|
|
82
89
|
* Resolve a signed webhook event into a current-state lifecycle decision by
|
|
83
90
|
* re-reading the authoritative session/subscription with the secret key.
|
|
84
91
|
*/
|
|
85
92
|
resolveCurrentState(event: ProxyWebhookEvent, options?: ResolveProxyEventOptions): Promise<ResolvedProxyEvent>;
|
|
93
|
+
private resolveProviderAcquisitionEvent;
|
|
86
94
|
private resolveSessionEvent;
|
|
87
95
|
private resolveSubscriptionEvent;
|
|
88
96
|
}
|
package/dist/cjs/events.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* lifecycle decision. It never grants from webhook payload fields, and it
|
|
7
7
|
* classifies subscription events from current state rather than event order.
|
|
8
8
|
*/
|
|
9
|
+
import type { ProviderAcquisition, ProxyProviderAcquisitionsResource } from "./provider-acquisitions.js";
|
|
9
10
|
import type { MerchantProxySession, ProxySessionsResource } from "./sessions.js";
|
|
10
11
|
import type { MerchantProxySubscription, ProxySubscriptionsResource } from "./subscriptions.js";
|
|
11
12
|
import type { ProxyCheckoutServerRequestOptions } from "./types.js";
|
|
@@ -66,23 +67,30 @@ export interface ResolvedPaymentAttempt extends ResolvedBase {
|
|
|
66
67
|
readonly sessionId: string | null;
|
|
67
68
|
readonly subscriptionId: string | null;
|
|
68
69
|
}
|
|
70
|
+
export interface ResolvedAcquisitionProgress extends ResolvedBase {
|
|
71
|
+
readonly acquisition: ProviderAcquisition;
|
|
72
|
+
readonly kind: "acquisition_progress";
|
|
73
|
+
readonly session: MerchantProxySession;
|
|
74
|
+
}
|
|
69
75
|
export interface ResolvedIgnored extends ResolvedBase {
|
|
70
76
|
readonly kind: "ignored";
|
|
71
77
|
readonly reason: string;
|
|
72
78
|
readonly sessionId: string | null;
|
|
73
79
|
readonly subscriptionId: string | null;
|
|
74
80
|
}
|
|
75
|
-
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedIgnored;
|
|
81
|
+
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedAcquisitionProgress | ResolvedIgnored;
|
|
76
82
|
export type ResolvedProxyEventKind = ResolvedProxyEvent["kind"];
|
|
77
83
|
export declare class ProxyEventsResource {
|
|
78
84
|
private readonly sessions;
|
|
79
85
|
private readonly subscriptions;
|
|
80
|
-
|
|
86
|
+
private readonly providerAcquisitions;
|
|
87
|
+
constructor(sessions: ProxySessionsResource, subscriptions: ProxySubscriptionsResource, providerAcquisitions: ProxyProviderAcquisitionsResource);
|
|
81
88
|
/**
|
|
82
89
|
* Resolve a signed webhook event into a current-state lifecycle decision by
|
|
83
90
|
* re-reading the authoritative session/subscription with the secret key.
|
|
84
91
|
*/
|
|
85
92
|
resolveCurrentState(event: ProxyWebhookEvent, options?: ResolveProxyEventOptions): Promise<ResolvedProxyEvent>;
|
|
93
|
+
private resolveProviderAcquisitionEvent;
|
|
86
94
|
private resolveSessionEvent;
|
|
87
95
|
private resolveSubscriptionEvent;
|
|
88
96
|
}
|
package/dist/cjs/events.js
CHANGED
|
@@ -15,15 +15,20 @@ const webhook_events_js_1 = require("./webhook-events.js");
|
|
|
15
15
|
class ProxyEventsResource {
|
|
16
16
|
sessions;
|
|
17
17
|
subscriptions;
|
|
18
|
-
|
|
18
|
+
providerAcquisitions;
|
|
19
|
+
constructor(sessions, subscriptions, providerAcquisitions) {
|
|
19
20
|
this.sessions = sessions;
|
|
20
21
|
this.subscriptions = subscriptions;
|
|
22
|
+
this.providerAcquisitions = providerAcquisitions;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Resolve a signed webhook event into a current-state lifecycle decision by
|
|
24
26
|
* re-reading the authoritative session/subscription with the secret key.
|
|
25
27
|
*/
|
|
26
28
|
async resolveCurrentState(event, options = {}) {
|
|
29
|
+
if ((0, webhook_events_js_1.isProxyProviderAcquisitionEvent)(event.type)) {
|
|
30
|
+
return this.resolveProviderAcquisitionEvent(event, options);
|
|
31
|
+
}
|
|
27
32
|
if ((0, webhook_events_js_1.isProxySubscriptionEvent)(event.type)) {
|
|
28
33
|
return this.resolveSubscriptionEvent(event, options);
|
|
29
34
|
}
|
|
@@ -44,6 +49,28 @@ class ProxyEventsResource {
|
|
|
44
49
|
subscriptionId: readEventString(event.data.subscription_id),
|
|
45
50
|
});
|
|
46
51
|
}
|
|
52
|
+
async resolveProviderAcquisitionEvent(event, options) {
|
|
53
|
+
const sessionId = extractSessionId(event);
|
|
54
|
+
const acquisitionAttemptId = readEventString(event.data.provider_acquisition_attempt_id);
|
|
55
|
+
if (sessionId === null || acquisitionAttemptId === null) {
|
|
56
|
+
return ignored(event, "Provider acquisition event is missing current-state identifiers.", {
|
|
57
|
+
sessionId,
|
|
58
|
+
subscriptionId: null,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const [session, acquisitions] = await Promise.all([
|
|
62
|
+
this.sessions.retrieve(sessionId, options),
|
|
63
|
+
this.providerAcquisitions.listProviderAcquisitions(sessionId, options),
|
|
64
|
+
]);
|
|
65
|
+
const acquisition = acquisitions.find((candidate) => candidate.id === acquisitionAttemptId);
|
|
66
|
+
if (!acquisition) {
|
|
67
|
+
return ignored(event, `Provider acquisition ${acquisitionAttemptId} is no longer visible for session ${sessionId}.`, { sessionId, subscriptionId: null });
|
|
68
|
+
}
|
|
69
|
+
if (acquisition.proxySessionId !== session.id) {
|
|
70
|
+
throw new Error("Proxy provider acquisition current state disagreed with its session");
|
|
71
|
+
}
|
|
72
|
+
return { acquisition, event, kind: "acquisition_progress", session };
|
|
73
|
+
}
|
|
47
74
|
async resolveSessionEvent(event, options) {
|
|
48
75
|
const sessionId = extractSessionId(event);
|
|
49
76
|
if (sessionId === null) {
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2,13 +2,13 @@ export { type ProxyCartParseOptions, type ProxyCartValidator, parseProxyCart, }
|
|
|
2
2
|
export { createProxyCheckoutServerClient, ProxyCheckoutServerClient, } from "./client.js";
|
|
3
3
|
export { assertCartBuyerReference, assertSubscriptionMatchesSession, } from "./consistency.js";
|
|
4
4
|
export { isProxySessionNotFoundError, PROXY_SESSION_NOT_FOUND_ERROR_CODE, ProxyCheckoutApiError, type ProxyCheckoutApiErrorDetails, type ProxyCheckoutValidationCode, ProxyCheckoutValidationError, } from "./errors.js";
|
|
5
|
-
export { ProxyEventsResource, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
5
|
+
export { ProxyEventsResource, type ResolvedAcquisitionProgress, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
6
6
|
export { AT_RISK_SUBSCRIPTION_STATUSES, ENDED_SUBSCRIPTION_STATUSES, isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, PROVISIONABLE_SESSION_STATUSES, parseOptionalProxyDate, requireProxyDate, subscriptionAccessEndsAt, subscriptionWillRenew, TERMINAL_SESSION_STATUSES, } from "./lifecycle.js";
|
|
7
7
|
export { type AttachProviderAcquisitionObjectInput, type ProviderAcquisition, type ProviderAcquisitionCheckoutUiMode, type ProviderAcquisitionCommercialMode, type ProviderAcquisitionIntegrationPath, type ProviderAcquisitionObjectType, type ProviderAcquisitionObservedCheckoutUiMode, type ProviderAcquisitionPricingMode, type ProviderAcquisitionReservation, ProxyProviderAcquisitionsResource, proxyCheckoutProviderAcquisitionEndpoints, type ReserveProviderAcquisitionInput, type SupersedeProviderAcquisitionInput, } from "./provider-acquisitions.js";
|
|
8
8
|
export { type CreateProxySessionHandoffInput, type CreateProxySessionInput, type CreateProxySessionOptions, type MarkProxySessionProvisionedInput, type MarkProxySessionProvisioningFailedInput, type MerchantProxySession, type PayerHandoffResult, type PayerOpenedResult, type ProxySession, type ProxySessionAcquisitionSummary, type ProxySessionActionableNextStep, ProxySessionCartResource, type ProxySessionCartResult, type ProxySessionHandoff, type ProxySessionPresentationState, type ProxySessionProviderBinding, type ProxySessionProvisioningAcknowledgement, ProxySessionsResource, type ProxySessionViewStatus, proxyCheckoutServerEndpoints, type RecordProviderBindingInput, type SetProxySessionCartInput, type TypedMerchantProxySession, } from "./sessions.js";
|
|
9
9
|
export { type MerchantProxySubscription, ProxySubscriptionsResource, type ProxySubscriptionWithSession, type ProxySubscriptionWithUntypedSession, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
|
|
10
10
|
export type { JsonObject, JsonPrimitive, JsonValue, ProxyCheckoutFetch, ProxyCheckoutServerClientOptions, ProxyCheckoutServerRequestOptions, } from "./types.js";
|
|
11
11
|
export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
|
|
12
|
-
export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
12
|
+
export { isProxyPaymentAttemptEvent, isProxyProviderAcquisitionEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
13
13
|
export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, type ProxyWebhookClaimResult, type ProxyWebhookHandlerOptions, type ProxyWebhookOutcome, type ProxyWebhookPayloadInput, type ProxyWebhookProcessRecord, type ProxyWebhookProcessResult, type ProxyWebhookProvisioningFailure, type ProxyWebhookProvisioningSuccess, type ProxyWebhookProvisioningSuccessResult, type ProxyWebhookRequestInput, type ProxyWebhookStore, ProxyWebhooksResource, } from "./webhook-handler.js";
|
|
14
14
|
export { type ConstructProxyWebhookEventInput, type CreateWebhookEndpointInput, constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, type ProxyWebhookEvent, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, type RotateWebhookEndpointSecretInput, type UpdateWebhookEndpointInput, type VerifyProxyWebhookSignatureInput, verifyProxyWebhookSignature, type WebhookEndpoint, type WebhookEndpointSecretResult, } from "./webhooks.js";
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ export { type ProxyCartParseOptions, type ProxyCartValidator, parseProxyCart, }
|
|
|
2
2
|
export { createProxyCheckoutServerClient, ProxyCheckoutServerClient, } from "./client.js";
|
|
3
3
|
export { assertCartBuyerReference, assertSubscriptionMatchesSession, } from "./consistency.js";
|
|
4
4
|
export { isProxySessionNotFoundError, PROXY_SESSION_NOT_FOUND_ERROR_CODE, ProxyCheckoutApiError, type ProxyCheckoutApiErrorDetails, type ProxyCheckoutValidationCode, ProxyCheckoutValidationError, } from "./errors.js";
|
|
5
|
-
export { ProxyEventsResource, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
5
|
+
export { ProxyEventsResource, type ResolvedAcquisitionProgress, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
6
6
|
export { AT_RISK_SUBSCRIPTION_STATUSES, ENDED_SUBSCRIPTION_STATUSES, isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, PROVISIONABLE_SESSION_STATUSES, parseOptionalProxyDate, requireProxyDate, subscriptionAccessEndsAt, subscriptionWillRenew, TERMINAL_SESSION_STATUSES, } from "./lifecycle.js";
|
|
7
7
|
export { type AttachProviderAcquisitionObjectInput, type ProviderAcquisition, type ProviderAcquisitionCheckoutUiMode, type ProviderAcquisitionCommercialMode, type ProviderAcquisitionIntegrationPath, type ProviderAcquisitionObjectType, type ProviderAcquisitionObservedCheckoutUiMode, type ProviderAcquisitionPricingMode, type ProviderAcquisitionReservation, ProxyProviderAcquisitionsResource, proxyCheckoutProviderAcquisitionEndpoints, type ReserveProviderAcquisitionInput, type SupersedeProviderAcquisitionInput, } from "./provider-acquisitions.js";
|
|
8
8
|
export { type CreateProxySessionHandoffInput, type CreateProxySessionInput, type CreateProxySessionOptions, type MarkProxySessionProvisionedInput, type MarkProxySessionProvisioningFailedInput, type MerchantProxySession, type PayerHandoffResult, type PayerOpenedResult, type ProxySession, type ProxySessionAcquisitionSummary, type ProxySessionActionableNextStep, ProxySessionCartResource, type ProxySessionCartResult, type ProxySessionHandoff, type ProxySessionPresentationState, type ProxySessionProviderBinding, type ProxySessionProvisioningAcknowledgement, ProxySessionsResource, type ProxySessionViewStatus, proxyCheckoutServerEndpoints, type RecordProviderBindingInput, type SetProxySessionCartInput, type TypedMerchantProxySession, } from "./sessions.js";
|
|
9
9
|
export { type MerchantProxySubscription, ProxySubscriptionsResource, type ProxySubscriptionWithSession, type ProxySubscriptionWithUntypedSession, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
|
|
10
10
|
export type { JsonObject, JsonPrimitive, JsonValue, ProxyCheckoutFetch, ProxyCheckoutServerClientOptions, ProxyCheckoutServerRequestOptions, } from "./types.js";
|
|
11
11
|
export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
|
|
12
|
-
export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
12
|
+
export { isProxyPaymentAttemptEvent, isProxyProviderAcquisitionEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
13
13
|
export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, type ProxyWebhookClaimResult, type ProxyWebhookHandlerOptions, type ProxyWebhookOutcome, type ProxyWebhookPayloadInput, type ProxyWebhookProcessRecord, type ProxyWebhookProcessResult, type ProxyWebhookProvisioningFailure, type ProxyWebhookProvisioningSuccess, type ProxyWebhookProvisioningSuccessResult, type ProxyWebhookRequestInput, type ProxyWebhookStore, ProxyWebhooksResource, } from "./webhook-handler.js";
|
|
14
14
|
export { type ConstructProxyWebhookEventInput, type CreateWebhookEndpointInput, constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, type ProxyWebhookEvent, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, type RotateWebhookEndpointSecretInput, type UpdateWebhookEndpointInput, type VerifyProxyWebhookSignatureInput, verifyProxyWebhookSignature, type WebhookEndpoint, type WebhookEndpointSecretResult, } from "./webhooks.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyProxyWebhookSignature = exports.proxyCheckoutWebhookEndpointEndpoints = exports.ProxyWebhookSignatureVerificationError = exports.ProxyWebhookEndpointsResource = exports.PROXY_SIGNATURE_HEADER = exports.constructProxyWebhookEvent = exports.ProxyWebhooksResource = exports.PROXY_WEBHOOK_RETRY_AFTER_SECONDS = exports.PROXY_WEBHOOK_EVENT_TYPES = exports.isProxySubscriptionEvent = exports.isProxyShopifyEvent = exports.isProxySessionEvent = exports.isProxyPaymentAttemptEvent = exports.proxyCheckoutServerSdkVersion = exports.proxyCheckoutServerSdkUserAgent = exports.proxyCheckoutServerSdkName = exports.proxyCheckoutSubscriptionEndpoints = exports.ProxySubscriptionsResource = exports.proxyCheckoutServerEndpoints = exports.ProxySessionsResource = exports.ProxySessionCartResource = exports.proxyCheckoutProviderAcquisitionEndpoints = exports.ProxyProviderAcquisitionsResource = exports.TERMINAL_SESSION_STATUSES = exports.subscriptionWillRenew = exports.subscriptionAccessEndsAt = exports.requireProxyDate = exports.parseOptionalProxyDate = exports.PROVISIONABLE_SESSION_STATUSES = exports.isSubscriptionPaymentAtRisk = exports.isSubscriptionEnded = exports.isSessionTerminal = exports.isSessionProvisionable = exports.ENDED_SUBSCRIPTION_STATUSES = exports.AT_RISK_SUBSCRIPTION_STATUSES = exports.ProxyEventsResource = exports.ProxyCheckoutValidationError = exports.ProxyCheckoutApiError = exports.PROXY_SESSION_NOT_FOUND_ERROR_CODE = exports.isProxySessionNotFoundError = exports.assertSubscriptionMatchesSession = exports.assertCartBuyerReference = exports.ProxyCheckoutServerClient = exports.createProxyCheckoutServerClient = exports.parseProxyCart = void 0;
|
|
3
|
+
exports.verifyProxyWebhookSignature = exports.proxyCheckoutWebhookEndpointEndpoints = exports.ProxyWebhookSignatureVerificationError = exports.ProxyWebhookEndpointsResource = exports.PROXY_SIGNATURE_HEADER = exports.constructProxyWebhookEvent = exports.ProxyWebhooksResource = exports.PROXY_WEBHOOK_RETRY_AFTER_SECONDS = exports.PROXY_WEBHOOK_EVENT_TYPES = exports.isProxySubscriptionEvent = exports.isProxyShopifyEvent = exports.isProxySessionEvent = exports.isProxyProviderAcquisitionEvent = exports.isProxyPaymentAttemptEvent = exports.proxyCheckoutServerSdkVersion = exports.proxyCheckoutServerSdkUserAgent = exports.proxyCheckoutServerSdkName = exports.proxyCheckoutSubscriptionEndpoints = exports.ProxySubscriptionsResource = exports.proxyCheckoutServerEndpoints = exports.ProxySessionsResource = exports.ProxySessionCartResource = exports.proxyCheckoutProviderAcquisitionEndpoints = exports.ProxyProviderAcquisitionsResource = exports.TERMINAL_SESSION_STATUSES = exports.subscriptionWillRenew = exports.subscriptionAccessEndsAt = exports.requireProxyDate = exports.parseOptionalProxyDate = exports.PROVISIONABLE_SESSION_STATUSES = exports.isSubscriptionPaymentAtRisk = exports.isSubscriptionEnded = exports.isSessionTerminal = exports.isSessionProvisionable = exports.ENDED_SUBSCRIPTION_STATUSES = exports.AT_RISK_SUBSCRIPTION_STATUSES = exports.ProxyEventsResource = exports.ProxyCheckoutValidationError = exports.ProxyCheckoutApiError = exports.PROXY_SESSION_NOT_FOUND_ERROR_CODE = exports.isProxySessionNotFoundError = exports.assertSubscriptionMatchesSession = exports.assertCartBuyerReference = exports.ProxyCheckoutServerClient = exports.createProxyCheckoutServerClient = exports.parseProxyCart = void 0;
|
|
4
4
|
var cart_js_1 = require("./cart.js");
|
|
5
5
|
Object.defineProperty(exports, "parseProxyCart", { enumerable: true, get: function () { return cart_js_1.parseProxyCart; } });
|
|
6
6
|
var client_js_1 = require("./client.js");
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "proxyCheckoutServerSdkUserAgent", { enumerable:
|
|
|
45
45
|
Object.defineProperty(exports, "proxyCheckoutServerSdkVersion", { enumerable: true, get: function () { return version_js_1.proxyCheckoutServerSdkVersion; } });
|
|
46
46
|
var webhook_events_js_1 = require("./webhook-events.js");
|
|
47
47
|
Object.defineProperty(exports, "isProxyPaymentAttemptEvent", { enumerable: true, get: function () { return webhook_events_js_1.isProxyPaymentAttemptEvent; } });
|
|
48
|
+
Object.defineProperty(exports, "isProxyProviderAcquisitionEvent", { enumerable: true, get: function () { return webhook_events_js_1.isProxyProviderAcquisitionEvent; } });
|
|
48
49
|
Object.defineProperty(exports, "isProxySessionEvent", { enumerable: true, get: function () { return webhook_events_js_1.isProxySessionEvent; } });
|
|
49
50
|
Object.defineProperty(exports, "isProxyShopifyEvent", { enumerable: true, get: function () { return webhook_events_js_1.isProxyShopifyEvent; } });
|
|
50
51
|
Object.defineProperty(exports, "isProxySubscriptionEvent", { enumerable: true, get: function () { return webhook_events_js_1.isProxySubscriptionEvent; } });
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export declare const proxyCheckoutServerSdkVersion = "0.0
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.137.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.137.1";
|
package/dist/cjs/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
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.137.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.137.1";
|
package/dist/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.proxyCheckoutServerSdkUserAgent = exports.proxyCheckoutServerSdkVersion = exports.proxyCheckoutServerSdkName = void 0;
|
|
4
4
|
exports.proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
5
|
-
exports.proxyCheckoutServerSdkVersion = "0.0
|
|
5
|
+
exports.proxyCheckoutServerSdkVersion = "0.1.0-prx-124.137.1";
|
|
6
6
|
exports.proxyCheckoutServerSdkUserAgent = `${exports.proxyCheckoutServerSdkName}/${exports.proxyCheckoutServerSdkVersion}`;
|
|
@@ -7,10 +7,21 @@
|
|
|
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";
|
|
11
14
|
readonly paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded";
|
|
15
|
+
readonly paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required";
|
|
12
16
|
readonly paymentAttemptRefunded: "payment_attempt.refunded";
|
|
13
17
|
readonly paymentAttemptSucceeded: "payment_attempt.succeeded";
|
|
18
|
+
readonly providerAcquisitionCancelled: "provider_acquisition.cancelled";
|
|
19
|
+
readonly providerAcquisitionExpired: "provider_acquisition.expired";
|
|
20
|
+
readonly providerAcquisitionFailed: "provider_acquisition.failed";
|
|
21
|
+
readonly providerAcquisitionPrepared: "provider_acquisition.prepared";
|
|
22
|
+
readonly providerAcquisitionProcessing: "provider_acquisition.processing";
|
|
23
|
+
readonly providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required";
|
|
24
|
+
readonly providerAcquisitionRequiresAction: "provider_acquisition.requires_action";
|
|
14
25
|
readonly sessionCancelled: "proxy_session.cancelled";
|
|
15
26
|
readonly sessionExpired: "proxy_session.expired";
|
|
16
27
|
readonly sessionFailed: "proxy_session.failed";
|
|
@@ -23,8 +34,11 @@ export declare const PROXY_WEBHOOK_EVENT_TYPES: {
|
|
|
23
34
|
readonly shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed";
|
|
24
35
|
readonly subscriptionCancelled: "subscription.cancelled";
|
|
25
36
|
readonly subscriptionCancelScheduled: "subscription.cancel_scheduled";
|
|
37
|
+
readonly subscriptionChanged: "subscription.changed";
|
|
38
|
+
readonly subscriptionConfigurationActionRequired: "subscription.configuration_action_required";
|
|
26
39
|
readonly subscriptionPaymentFailed: "subscription.payment_failed";
|
|
27
40
|
readonly subscriptionRenewed: "subscription.renewed";
|
|
41
|
+
readonly subscriptionTrialEnding: "subscription.trial_ending";
|
|
28
42
|
};
|
|
29
43
|
export type ProxyWebhookEventType = (typeof PROXY_WEBHOOK_EVENT_TYPES)[keyof typeof PROXY_WEBHOOK_EVENT_TYPES];
|
|
30
44
|
/** True for `proxy_session.*` events. */
|
|
@@ -33,5 +47,7 @@ export declare function isProxySessionEvent(eventType: string): boolean;
|
|
|
33
47
|
export declare function isProxySubscriptionEvent(eventType: string): boolean;
|
|
34
48
|
/** True for `payment_attempt.*` events. */
|
|
35
49
|
export declare function isProxyPaymentAttemptEvent(eventType: string): boolean;
|
|
50
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
51
|
+
export declare function isProxyProviderAcquisitionEvent(eventType: string): boolean;
|
|
36
52
|
/** True for observation-only `shopify.*` commerce events. */
|
|
37
53
|
export declare function isProxyShopifyEvent(eventType: string): boolean;
|
|
@@ -7,10 +7,21 @@
|
|
|
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";
|
|
11
14
|
readonly paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded";
|
|
15
|
+
readonly paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required";
|
|
12
16
|
readonly paymentAttemptRefunded: "payment_attempt.refunded";
|
|
13
17
|
readonly paymentAttemptSucceeded: "payment_attempt.succeeded";
|
|
18
|
+
readonly providerAcquisitionCancelled: "provider_acquisition.cancelled";
|
|
19
|
+
readonly providerAcquisitionExpired: "provider_acquisition.expired";
|
|
20
|
+
readonly providerAcquisitionFailed: "provider_acquisition.failed";
|
|
21
|
+
readonly providerAcquisitionPrepared: "provider_acquisition.prepared";
|
|
22
|
+
readonly providerAcquisitionProcessing: "provider_acquisition.processing";
|
|
23
|
+
readonly providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required";
|
|
24
|
+
readonly providerAcquisitionRequiresAction: "provider_acquisition.requires_action";
|
|
14
25
|
readonly sessionCancelled: "proxy_session.cancelled";
|
|
15
26
|
readonly sessionExpired: "proxy_session.expired";
|
|
16
27
|
readonly sessionFailed: "proxy_session.failed";
|
|
@@ -23,8 +34,11 @@ export declare const PROXY_WEBHOOK_EVENT_TYPES: {
|
|
|
23
34
|
readonly shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed";
|
|
24
35
|
readonly subscriptionCancelled: "subscription.cancelled";
|
|
25
36
|
readonly subscriptionCancelScheduled: "subscription.cancel_scheduled";
|
|
37
|
+
readonly subscriptionChanged: "subscription.changed";
|
|
38
|
+
readonly subscriptionConfigurationActionRequired: "subscription.configuration_action_required";
|
|
26
39
|
readonly subscriptionPaymentFailed: "subscription.payment_failed";
|
|
27
40
|
readonly subscriptionRenewed: "subscription.renewed";
|
|
41
|
+
readonly subscriptionTrialEnding: "subscription.trial_ending";
|
|
28
42
|
};
|
|
29
43
|
export type ProxyWebhookEventType = (typeof PROXY_WEBHOOK_EVENT_TYPES)[keyof typeof PROXY_WEBHOOK_EVENT_TYPES];
|
|
30
44
|
/** True for `proxy_session.*` events. */
|
|
@@ -33,5 +47,7 @@ export declare function isProxySessionEvent(eventType: string): boolean;
|
|
|
33
47
|
export declare function isProxySubscriptionEvent(eventType: string): boolean;
|
|
34
48
|
/** True for `payment_attempt.*` events. */
|
|
35
49
|
export declare function isProxyPaymentAttemptEvent(eventType: string): boolean;
|
|
50
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
51
|
+
export declare function isProxyProviderAcquisitionEvent(eventType: string): boolean;
|
|
36
52
|
/** True for observation-only `shopify.*` commerce events. */
|
|
37
53
|
export declare function isProxyShopifyEvent(eventType: string): boolean;
|
|
@@ -11,13 +11,25 @@ exports.PROXY_WEBHOOK_EVENT_TYPES = void 0;
|
|
|
11
11
|
exports.isProxySessionEvent = isProxySessionEvent;
|
|
12
12
|
exports.isProxySubscriptionEvent = isProxySubscriptionEvent;
|
|
13
13
|
exports.isProxyPaymentAttemptEvent = isProxyPaymentAttemptEvent;
|
|
14
|
+
exports.isProxyProviderAcquisitionEvent = isProxyProviderAcquisitionEvent;
|
|
14
15
|
exports.isProxyShopifyEvent = isProxyShopifyEvent;
|
|
15
16
|
exports.PROXY_WEBHOOK_EVENT_TYPES = {
|
|
16
17
|
paymentAttemptCancelled: "payment_attempt.cancelled",
|
|
18
|
+
paymentAttemptDisputed: "payment_attempt.disputed",
|
|
19
|
+
paymentAttemptDisputeLost: "payment_attempt.dispute_lost",
|
|
20
|
+
paymentAttemptDisputeWon: "payment_attempt.dispute_won",
|
|
17
21
|
paymentAttemptFailed: "payment_attempt.failed",
|
|
18
22
|
paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded",
|
|
23
|
+
paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required",
|
|
19
24
|
paymentAttemptRefunded: "payment_attempt.refunded",
|
|
20
25
|
paymentAttemptSucceeded: "payment_attempt.succeeded",
|
|
26
|
+
providerAcquisitionCancelled: "provider_acquisition.cancelled",
|
|
27
|
+
providerAcquisitionExpired: "provider_acquisition.expired",
|
|
28
|
+
providerAcquisitionFailed: "provider_acquisition.failed",
|
|
29
|
+
providerAcquisitionPrepared: "provider_acquisition.prepared",
|
|
30
|
+
providerAcquisitionProcessing: "provider_acquisition.processing",
|
|
31
|
+
providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required",
|
|
32
|
+
providerAcquisitionRequiresAction: "provider_acquisition.requires_action",
|
|
21
33
|
sessionCancelled: "proxy_session.cancelled",
|
|
22
34
|
sessionExpired: "proxy_session.expired",
|
|
23
35
|
sessionFailed: "proxy_session.failed",
|
|
@@ -30,8 +42,11 @@ exports.PROXY_WEBHOOK_EVENT_TYPES = {
|
|
|
30
42
|
shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed",
|
|
31
43
|
subscriptionCancelled: "subscription.cancelled",
|
|
32
44
|
subscriptionCancelScheduled: "subscription.cancel_scheduled",
|
|
45
|
+
subscriptionChanged: "subscription.changed",
|
|
46
|
+
subscriptionConfigurationActionRequired: "subscription.configuration_action_required",
|
|
33
47
|
subscriptionPaymentFailed: "subscription.payment_failed",
|
|
34
48
|
subscriptionRenewed: "subscription.renewed",
|
|
49
|
+
subscriptionTrialEnding: "subscription.trial_ending",
|
|
35
50
|
};
|
|
36
51
|
const SESSION_EVENT_TYPES = new Set([
|
|
37
52
|
exports.PROXY_WEBHOOK_EVENT_TYPES.sessionCancelled,
|
|
@@ -44,16 +59,32 @@ const SESSION_EVENT_TYPES = new Set([
|
|
|
44
59
|
const SUBSCRIPTION_EVENT_TYPES = new Set([
|
|
45
60
|
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelScheduled,
|
|
46
61
|
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelled,
|
|
62
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionChanged,
|
|
63
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionConfigurationActionRequired,
|
|
47
64
|
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionPaymentFailed,
|
|
48
65
|
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionRenewed,
|
|
66
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.subscriptionTrialEnding,
|
|
49
67
|
]);
|
|
50
68
|
const PAYMENT_ATTEMPT_EVENT_TYPES = new Set([
|
|
51
69
|
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptCancelled,
|
|
70
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeLost,
|
|
71
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeWon,
|
|
72
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputed,
|
|
52
73
|
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptFailed,
|
|
53
74
|
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptPartiallyRefunded,
|
|
75
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptReconciliationRequired,
|
|
54
76
|
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptRefunded,
|
|
55
77
|
exports.PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptSucceeded,
|
|
56
78
|
]);
|
|
79
|
+
const PROVIDER_ACQUISITION_EVENT_TYPES = new Set([
|
|
80
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionCancelled,
|
|
81
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionExpired,
|
|
82
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionFailed,
|
|
83
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionPrepared,
|
|
84
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionProcessing,
|
|
85
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionReconciliationRequired,
|
|
86
|
+
exports.PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionRequiresAction,
|
|
87
|
+
]);
|
|
57
88
|
const SHOPIFY_EVENT_TYPES = new Set([
|
|
58
89
|
exports.PROXY_WEBHOOK_EVENT_TYPES.shopifyFulfillmentObserved,
|
|
59
90
|
exports.PROXY_WEBHOOK_EVENT_TYPES.shopifyRefundObserved,
|
|
@@ -72,6 +103,10 @@ function isProxySubscriptionEvent(eventType) {
|
|
|
72
103
|
function isProxyPaymentAttemptEvent(eventType) {
|
|
73
104
|
return PAYMENT_ATTEMPT_EVENT_TYPES.has(eventType);
|
|
74
105
|
}
|
|
106
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
107
|
+
function isProxyProviderAcquisitionEvent(eventType) {
|
|
108
|
+
return PROVIDER_ACQUISITION_EVENT_TYPES.has(eventType);
|
|
109
|
+
}
|
|
75
110
|
/** True for observation-only `shopify.*` commerce events. */
|
|
76
111
|
function isProxyShopifyEvent(eventType) {
|
|
77
112
|
return SHOPIFY_EVENT_TYPES.has(eventType);
|
|
@@ -17,6 +17,7 @@ export type ProxyWebhookClaimResult = "claimed" | "duplicate" | "processing";
|
|
|
17
17
|
export type ProxyWebhookOutcome = "duplicate" | "ignored" | "processed" | "processing";
|
|
18
18
|
/** Compact, lifecycle-free audit record handed to a {@link ProxyWebhookStore}. */
|
|
19
19
|
export interface ProxyWebhookProcessRecord {
|
|
20
|
+
readonly acquisitionAttemptId?: string | null;
|
|
20
21
|
readonly kind: ResolvedProxyEventKind;
|
|
21
22
|
readonly paymentAttemptId?: string | null;
|
|
22
23
|
readonly sessionId: string | null;
|
|
@@ -17,6 +17,7 @@ export type ProxyWebhookClaimResult = "claimed" | "duplicate" | "processing";
|
|
|
17
17
|
export type ProxyWebhookOutcome = "duplicate" | "ignored" | "processed" | "processing";
|
|
18
18
|
/** Compact, lifecycle-free audit record handed to a {@link ProxyWebhookStore}. */
|
|
19
19
|
export interface ProxyWebhookProcessRecord {
|
|
20
|
+
readonly acquisitionAttemptId?: string | null;
|
|
20
21
|
readonly kind: ResolvedProxyEventKind;
|
|
21
22
|
readonly paymentAttemptId?: string | null;
|
|
22
23
|
readonly sessionId: string | null;
|
|
@@ -198,6 +198,13 @@ function jsonResponse(status, body) {
|
|
|
198
198
|
}
|
|
199
199
|
function toProcessRecord(resolved) {
|
|
200
200
|
switch (resolved.kind) {
|
|
201
|
+
case "acquisition_progress":
|
|
202
|
+
return {
|
|
203
|
+
acquisitionAttemptId: resolved.acquisition.id,
|
|
204
|
+
kind: resolved.kind,
|
|
205
|
+
sessionId: resolved.session.id,
|
|
206
|
+
subscriptionId: null,
|
|
207
|
+
};
|
|
201
208
|
case "ignored":
|
|
202
209
|
return {
|
|
203
210
|
kind: resolved.kind,
|
package/dist/esm/client.js
CHANGED
|
@@ -29,7 +29,7 @@ export class ProxyCheckoutServerClient {
|
|
|
29
29
|
});
|
|
30
30
|
this.providerAcquisitions = new ProxyProviderAcquisitionsResource(httpClient);
|
|
31
31
|
this.subscriptions = new ProxySubscriptionsResource(httpClient, this.sessions);
|
|
32
|
-
this.events = new ProxyEventsResource(this.sessions, this.subscriptions);
|
|
32
|
+
this.events = new ProxyEventsResource(this.sessions, this.subscriptions, this.providerAcquisitions);
|
|
33
33
|
this.webhooks = new ProxyWebhooksResource(this.events, this.sessions);
|
|
34
34
|
this.webhookEndpoints = new ProxyWebhookEndpointsResource(httpClient);
|
|
35
35
|
}
|
package/dist/esm/events.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* lifecycle decision. It never grants from webhook payload fields, and it
|
|
7
7
|
* classifies subscription events from current state rather than event order.
|
|
8
8
|
*/
|
|
9
|
+
import type { ProviderAcquisition, ProxyProviderAcquisitionsResource } from "./provider-acquisitions.js";
|
|
9
10
|
import type { MerchantProxySession, ProxySessionsResource } from "./sessions.js";
|
|
10
11
|
import type { MerchantProxySubscription, ProxySubscriptionsResource } from "./subscriptions.js";
|
|
11
12
|
import type { ProxyCheckoutServerRequestOptions } from "./types.js";
|
|
@@ -66,23 +67,30 @@ export interface ResolvedPaymentAttempt extends ResolvedBase {
|
|
|
66
67
|
readonly sessionId: string | null;
|
|
67
68
|
readonly subscriptionId: string | null;
|
|
68
69
|
}
|
|
70
|
+
export interface ResolvedAcquisitionProgress extends ResolvedBase {
|
|
71
|
+
readonly acquisition: ProviderAcquisition;
|
|
72
|
+
readonly kind: "acquisition_progress";
|
|
73
|
+
readonly session: MerchantProxySession;
|
|
74
|
+
}
|
|
69
75
|
export interface ResolvedIgnored extends ResolvedBase {
|
|
70
76
|
readonly kind: "ignored";
|
|
71
77
|
readonly reason: string;
|
|
72
78
|
readonly sessionId: string | null;
|
|
73
79
|
readonly subscriptionId: string | null;
|
|
74
80
|
}
|
|
75
|
-
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedIgnored;
|
|
81
|
+
export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedAcquisitionProgress | ResolvedIgnored;
|
|
76
82
|
export type ResolvedProxyEventKind = ResolvedProxyEvent["kind"];
|
|
77
83
|
export declare class ProxyEventsResource {
|
|
78
84
|
private readonly sessions;
|
|
79
85
|
private readonly subscriptions;
|
|
80
|
-
|
|
86
|
+
private readonly providerAcquisitions;
|
|
87
|
+
constructor(sessions: ProxySessionsResource, subscriptions: ProxySubscriptionsResource, providerAcquisitions: ProxyProviderAcquisitionsResource);
|
|
81
88
|
/**
|
|
82
89
|
* Resolve a signed webhook event into a current-state lifecycle decision by
|
|
83
90
|
* re-reading the authoritative session/subscription with the secret key.
|
|
84
91
|
*/
|
|
85
92
|
resolveCurrentState(event: ProxyWebhookEvent, options?: ResolveProxyEventOptions): Promise<ResolvedProxyEvent>;
|
|
93
|
+
private resolveProviderAcquisitionEvent;
|
|
86
94
|
private resolveSessionEvent;
|
|
87
95
|
private resolveSubscriptionEvent;
|
|
88
96
|
}
|
package/dist/esm/events.js
CHANGED
|
@@ -8,19 +8,24 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { assertSubscriptionMatchesSession } from "./consistency.js";
|
|
10
10
|
import { isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, subscriptionAccessEndsAt, subscriptionWillRenew, } from "./lifecycle.js";
|
|
11
|
-
import { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxySubscriptionEvent, } from "./webhook-events.js";
|
|
11
|
+
import { isProxyPaymentAttemptEvent, isProxyProviderAcquisitionEvent, isProxySessionEvent, isProxySubscriptionEvent, } from "./webhook-events.js";
|
|
12
12
|
export class ProxyEventsResource {
|
|
13
13
|
sessions;
|
|
14
14
|
subscriptions;
|
|
15
|
-
|
|
15
|
+
providerAcquisitions;
|
|
16
|
+
constructor(sessions, subscriptions, providerAcquisitions) {
|
|
16
17
|
this.sessions = sessions;
|
|
17
18
|
this.subscriptions = subscriptions;
|
|
19
|
+
this.providerAcquisitions = providerAcquisitions;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Resolve a signed webhook event into a current-state lifecycle decision by
|
|
21
23
|
* re-reading the authoritative session/subscription with the secret key.
|
|
22
24
|
*/
|
|
23
25
|
async resolveCurrentState(event, options = {}) {
|
|
26
|
+
if (isProxyProviderAcquisitionEvent(event.type)) {
|
|
27
|
+
return this.resolveProviderAcquisitionEvent(event, options);
|
|
28
|
+
}
|
|
24
29
|
if (isProxySubscriptionEvent(event.type)) {
|
|
25
30
|
return this.resolveSubscriptionEvent(event, options);
|
|
26
31
|
}
|
|
@@ -41,6 +46,28 @@ export class ProxyEventsResource {
|
|
|
41
46
|
subscriptionId: readEventString(event.data.subscription_id),
|
|
42
47
|
});
|
|
43
48
|
}
|
|
49
|
+
async resolveProviderAcquisitionEvent(event, options) {
|
|
50
|
+
const sessionId = extractSessionId(event);
|
|
51
|
+
const acquisitionAttemptId = readEventString(event.data.provider_acquisition_attempt_id);
|
|
52
|
+
if (sessionId === null || acquisitionAttemptId === null) {
|
|
53
|
+
return ignored(event, "Provider acquisition event is missing current-state identifiers.", {
|
|
54
|
+
sessionId,
|
|
55
|
+
subscriptionId: null,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const [session, acquisitions] = await Promise.all([
|
|
59
|
+
this.sessions.retrieve(sessionId, options),
|
|
60
|
+
this.providerAcquisitions.listProviderAcquisitions(sessionId, options),
|
|
61
|
+
]);
|
|
62
|
+
const acquisition = acquisitions.find((candidate) => candidate.id === acquisitionAttemptId);
|
|
63
|
+
if (!acquisition) {
|
|
64
|
+
return ignored(event, `Provider acquisition ${acquisitionAttemptId} is no longer visible for session ${sessionId}.`, { sessionId, subscriptionId: null });
|
|
65
|
+
}
|
|
66
|
+
if (acquisition.proxySessionId !== session.id) {
|
|
67
|
+
throw new Error("Proxy provider acquisition current state disagreed with its session");
|
|
68
|
+
}
|
|
69
|
+
return { acquisition, event, kind: "acquisition_progress", session };
|
|
70
|
+
}
|
|
44
71
|
async resolveSessionEvent(event, options) {
|
|
45
72
|
const sessionId = extractSessionId(event);
|
|
46
73
|
if (sessionId === null) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ export { type ProxyCartParseOptions, type ProxyCartValidator, parseProxyCart, }
|
|
|
2
2
|
export { createProxyCheckoutServerClient, ProxyCheckoutServerClient, } from "./client.js";
|
|
3
3
|
export { assertCartBuyerReference, assertSubscriptionMatchesSession, } from "./consistency.js";
|
|
4
4
|
export { isProxySessionNotFoundError, PROXY_SESSION_NOT_FOUND_ERROR_CODE, ProxyCheckoutApiError, type ProxyCheckoutApiErrorDetails, type ProxyCheckoutValidationCode, ProxyCheckoutValidationError, } from "./errors.js";
|
|
5
|
-
export { ProxyEventsResource, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
5
|
+
export { ProxyEventsResource, type ResolvedAcquisitionProgress, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
|
|
6
6
|
export { AT_RISK_SUBSCRIPTION_STATUSES, ENDED_SUBSCRIPTION_STATUSES, isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, PROVISIONABLE_SESSION_STATUSES, parseOptionalProxyDate, requireProxyDate, subscriptionAccessEndsAt, subscriptionWillRenew, TERMINAL_SESSION_STATUSES, } from "./lifecycle.js";
|
|
7
7
|
export { type AttachProviderAcquisitionObjectInput, type ProviderAcquisition, type ProviderAcquisitionCheckoutUiMode, type ProviderAcquisitionCommercialMode, type ProviderAcquisitionIntegrationPath, type ProviderAcquisitionObjectType, type ProviderAcquisitionObservedCheckoutUiMode, type ProviderAcquisitionPricingMode, type ProviderAcquisitionReservation, ProxyProviderAcquisitionsResource, proxyCheckoutProviderAcquisitionEndpoints, type ReserveProviderAcquisitionInput, type SupersedeProviderAcquisitionInput, } from "./provider-acquisitions.js";
|
|
8
8
|
export { type CreateProxySessionHandoffInput, type CreateProxySessionInput, type CreateProxySessionOptions, type MarkProxySessionProvisionedInput, type MarkProxySessionProvisioningFailedInput, type MerchantProxySession, type PayerHandoffResult, type PayerOpenedResult, type ProxySession, type ProxySessionAcquisitionSummary, type ProxySessionActionableNextStep, ProxySessionCartResource, type ProxySessionCartResult, type ProxySessionHandoff, type ProxySessionPresentationState, type ProxySessionProviderBinding, type ProxySessionProvisioningAcknowledgement, ProxySessionsResource, type ProxySessionViewStatus, proxyCheckoutServerEndpoints, type RecordProviderBindingInput, type SetProxySessionCartInput, type TypedMerchantProxySession, } from "./sessions.js";
|
|
9
9
|
export { type MerchantProxySubscription, ProxySubscriptionsResource, type ProxySubscriptionWithSession, type ProxySubscriptionWithUntypedSession, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
|
|
10
10
|
export type { JsonObject, JsonPrimitive, JsonValue, ProxyCheckoutFetch, ProxyCheckoutServerClientOptions, ProxyCheckoutServerRequestOptions, } from "./types.js";
|
|
11
11
|
export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
|
|
12
|
-
export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
12
|
+
export { isProxyPaymentAttemptEvent, isProxyProviderAcquisitionEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
|
|
13
13
|
export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, type ProxyWebhookClaimResult, type ProxyWebhookHandlerOptions, type ProxyWebhookOutcome, type ProxyWebhookPayloadInput, type ProxyWebhookProcessRecord, type ProxyWebhookProcessResult, type ProxyWebhookProvisioningFailure, type ProxyWebhookProvisioningSuccess, type ProxyWebhookProvisioningSuccessResult, type ProxyWebhookRequestInput, type ProxyWebhookStore, ProxyWebhooksResource, } from "./webhook-handler.js";
|
|
14
14
|
export { type ConstructProxyWebhookEventInput, type CreateWebhookEndpointInput, constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, type ProxyWebhookEvent, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, type RotateWebhookEndpointSecretInput, type UpdateWebhookEndpointInput, type VerifyProxyWebhookSignatureInput, verifyProxyWebhookSignature, type WebhookEndpoint, type WebhookEndpointSecretResult, } from "./webhooks.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,6 @@ export { ProxyProviderAcquisitionsResource, proxyCheckoutProviderAcquisitionEndp
|
|
|
8
8
|
export { ProxySessionCartResource, ProxySessionsResource, proxyCheckoutServerEndpoints, } from "./sessions.js";
|
|
9
9
|
export { ProxySubscriptionsResource, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
|
|
10
10
|
export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
|
|
11
|
-
export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, } from "./webhook-events.js";
|
|
11
|
+
export { isProxyPaymentAttemptEvent, isProxyProviderAcquisitionEvent, isProxySessionEvent, isProxyShopifyEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, } from "./webhook-events.js";
|
|
12
12
|
export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, ProxyWebhooksResource, } from "./webhook-handler.js";
|
|
13
13
|
export { constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, verifyProxyWebhookSignature, } from "./webhooks.js";
|
package/dist/esm/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
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.137.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.137.1";
|
package/dist/esm/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export const proxyCheckoutServerSdkVersion = "0.0
|
|
2
|
+
export const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.137.1";
|
|
3
3
|
export const proxyCheckoutServerSdkUserAgent = `${proxyCheckoutServerSdkName}/${proxyCheckoutServerSdkVersion}`;
|
|
@@ -7,10 +7,21 @@
|
|
|
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";
|
|
11
14
|
readonly paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded";
|
|
15
|
+
readonly paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required";
|
|
12
16
|
readonly paymentAttemptRefunded: "payment_attempt.refunded";
|
|
13
17
|
readonly paymentAttemptSucceeded: "payment_attempt.succeeded";
|
|
18
|
+
readonly providerAcquisitionCancelled: "provider_acquisition.cancelled";
|
|
19
|
+
readonly providerAcquisitionExpired: "provider_acquisition.expired";
|
|
20
|
+
readonly providerAcquisitionFailed: "provider_acquisition.failed";
|
|
21
|
+
readonly providerAcquisitionPrepared: "provider_acquisition.prepared";
|
|
22
|
+
readonly providerAcquisitionProcessing: "provider_acquisition.processing";
|
|
23
|
+
readonly providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required";
|
|
24
|
+
readonly providerAcquisitionRequiresAction: "provider_acquisition.requires_action";
|
|
14
25
|
readonly sessionCancelled: "proxy_session.cancelled";
|
|
15
26
|
readonly sessionExpired: "proxy_session.expired";
|
|
16
27
|
readonly sessionFailed: "proxy_session.failed";
|
|
@@ -23,8 +34,11 @@ export declare const PROXY_WEBHOOK_EVENT_TYPES: {
|
|
|
23
34
|
readonly shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed";
|
|
24
35
|
readonly subscriptionCancelled: "subscription.cancelled";
|
|
25
36
|
readonly subscriptionCancelScheduled: "subscription.cancel_scheduled";
|
|
37
|
+
readonly subscriptionChanged: "subscription.changed";
|
|
38
|
+
readonly subscriptionConfigurationActionRequired: "subscription.configuration_action_required";
|
|
26
39
|
readonly subscriptionPaymentFailed: "subscription.payment_failed";
|
|
27
40
|
readonly subscriptionRenewed: "subscription.renewed";
|
|
41
|
+
readonly subscriptionTrialEnding: "subscription.trial_ending";
|
|
28
42
|
};
|
|
29
43
|
export type ProxyWebhookEventType = (typeof PROXY_WEBHOOK_EVENT_TYPES)[keyof typeof PROXY_WEBHOOK_EVENT_TYPES];
|
|
30
44
|
/** True for `proxy_session.*` events. */
|
|
@@ -33,5 +47,7 @@ export declare function isProxySessionEvent(eventType: string): boolean;
|
|
|
33
47
|
export declare function isProxySubscriptionEvent(eventType: string): boolean;
|
|
34
48
|
/** True for `payment_attempt.*` events. */
|
|
35
49
|
export declare function isProxyPaymentAttemptEvent(eventType: string): boolean;
|
|
50
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
51
|
+
export declare function isProxyProviderAcquisitionEvent(eventType: string): boolean;
|
|
36
52
|
/** True for observation-only `shopify.*` commerce events. */
|
|
37
53
|
export declare function isProxyShopifyEvent(eventType: string): boolean;
|
|
@@ -7,10 +7,21 @@
|
|
|
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",
|
|
11
14
|
paymentAttemptPartiallyRefunded: "payment_attempt.partially_refunded",
|
|
15
|
+
paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required",
|
|
12
16
|
paymentAttemptRefunded: "payment_attempt.refunded",
|
|
13
17
|
paymentAttemptSucceeded: "payment_attempt.succeeded",
|
|
18
|
+
providerAcquisitionCancelled: "provider_acquisition.cancelled",
|
|
19
|
+
providerAcquisitionExpired: "provider_acquisition.expired",
|
|
20
|
+
providerAcquisitionFailed: "provider_acquisition.failed",
|
|
21
|
+
providerAcquisitionPrepared: "provider_acquisition.prepared",
|
|
22
|
+
providerAcquisitionProcessing: "provider_acquisition.processing",
|
|
23
|
+
providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required",
|
|
24
|
+
providerAcquisitionRequiresAction: "provider_acquisition.requires_action",
|
|
14
25
|
sessionCancelled: "proxy_session.cancelled",
|
|
15
26
|
sessionExpired: "proxy_session.expired",
|
|
16
27
|
sessionFailed: "proxy_session.failed",
|
|
@@ -23,8 +34,11 @@ export const PROXY_WEBHOOK_EVENT_TYPES = {
|
|
|
23
34
|
shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed",
|
|
24
35
|
subscriptionCancelled: "subscription.cancelled",
|
|
25
36
|
subscriptionCancelScheduled: "subscription.cancel_scheduled",
|
|
37
|
+
subscriptionChanged: "subscription.changed",
|
|
38
|
+
subscriptionConfigurationActionRequired: "subscription.configuration_action_required",
|
|
26
39
|
subscriptionPaymentFailed: "subscription.payment_failed",
|
|
27
40
|
subscriptionRenewed: "subscription.renewed",
|
|
41
|
+
subscriptionTrialEnding: "subscription.trial_ending",
|
|
28
42
|
};
|
|
29
43
|
const SESSION_EVENT_TYPES = new Set([
|
|
30
44
|
PROXY_WEBHOOK_EVENT_TYPES.sessionCancelled,
|
|
@@ -37,16 +51,32 @@ const SESSION_EVENT_TYPES = new Set([
|
|
|
37
51
|
const SUBSCRIPTION_EVENT_TYPES = new Set([
|
|
38
52
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelScheduled,
|
|
39
53
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelled,
|
|
54
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionChanged,
|
|
55
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionConfigurationActionRequired,
|
|
40
56
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionPaymentFailed,
|
|
41
57
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionRenewed,
|
|
58
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionTrialEnding,
|
|
42
59
|
]);
|
|
43
60
|
const PAYMENT_ATTEMPT_EVENT_TYPES = new Set([
|
|
44
61
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptCancelled,
|
|
62
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeLost,
|
|
63
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeWon,
|
|
64
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputed,
|
|
45
65
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptFailed,
|
|
46
66
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptPartiallyRefunded,
|
|
67
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptReconciliationRequired,
|
|
47
68
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptRefunded,
|
|
48
69
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptSucceeded,
|
|
49
70
|
]);
|
|
71
|
+
const PROVIDER_ACQUISITION_EVENT_TYPES = new Set([
|
|
72
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionCancelled,
|
|
73
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionExpired,
|
|
74
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionFailed,
|
|
75
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionPrepared,
|
|
76
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionProcessing,
|
|
77
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionReconciliationRequired,
|
|
78
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionRequiresAction,
|
|
79
|
+
]);
|
|
50
80
|
const SHOPIFY_EVENT_TYPES = new Set([
|
|
51
81
|
PROXY_WEBHOOK_EVENT_TYPES.shopifyFulfillmentObserved,
|
|
52
82
|
PROXY_WEBHOOK_EVENT_TYPES.shopifyRefundObserved,
|
|
@@ -65,6 +95,10 @@ export function isProxySubscriptionEvent(eventType) {
|
|
|
65
95
|
export function isProxyPaymentAttemptEvent(eventType) {
|
|
66
96
|
return PAYMENT_ATTEMPT_EVENT_TYPES.has(eventType);
|
|
67
97
|
}
|
|
98
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
99
|
+
export function isProxyProviderAcquisitionEvent(eventType) {
|
|
100
|
+
return PROVIDER_ACQUISITION_EVENT_TYPES.has(eventType);
|
|
101
|
+
}
|
|
68
102
|
/** True for observation-only `shopify.*` commerce events. */
|
|
69
103
|
export function isProxyShopifyEvent(eventType) {
|
|
70
104
|
return SHOPIFY_EVENT_TYPES.has(eventType);
|
|
@@ -17,6 +17,7 @@ export type ProxyWebhookClaimResult = "claimed" | "duplicate" | "processing";
|
|
|
17
17
|
export type ProxyWebhookOutcome = "duplicate" | "ignored" | "processed" | "processing";
|
|
18
18
|
/** Compact, lifecycle-free audit record handed to a {@link ProxyWebhookStore}. */
|
|
19
19
|
export interface ProxyWebhookProcessRecord {
|
|
20
|
+
readonly acquisitionAttemptId?: string | null;
|
|
20
21
|
readonly kind: ResolvedProxyEventKind;
|
|
21
22
|
readonly paymentAttemptId?: string | null;
|
|
22
23
|
readonly sessionId: string | null;
|
|
@@ -194,6 +194,13 @@ function jsonResponse(status, body) {
|
|
|
194
194
|
}
|
|
195
195
|
function toProcessRecord(resolved) {
|
|
196
196
|
switch (resolved.kind) {
|
|
197
|
+
case "acquisition_progress":
|
|
198
|
+
return {
|
|
199
|
+
acquisitionAttemptId: resolved.acquisition.id,
|
|
200
|
+
kind: resolved.kind,
|
|
201
|
+
sessionId: resolved.session.id,
|
|
202
|
+
subscriptionId: null,
|
|
203
|
+
};
|
|
197
204
|
case "ignored":
|
|
198
205
|
return {
|
|
199
206
|
kind: resolved.kind,
|
package/package.json
CHANGED