@proxy-checkout/server-js 0.0.8 → 0.1.0-prx-124.139.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 +13 -1
- package/dist/cjs/client.d.cts +2 -0
- package/dist/cjs/client.d.ts +2 -0
- package/dist/cjs/client.js +4 -1
- package/dist/cjs/errors.d.cts +1 -1
- package/dist/cjs/errors.d.ts +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 +4 -3
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/provider-acquisitions.d.cts +106 -0
- package/dist/cjs/provider-acquisitions.d.ts +106 -0
- package/dist/cjs/provider-acquisitions.js +168 -0
- package/dist/cjs/sessions.d.cts +36 -4
- package/dist/cjs/sessions.d.ts +36 -4
- package/dist/cjs/sessions.js +132 -7
- 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 +21 -0
- package/dist/cjs/webhook-events.d.ts +21 -0
- package/dist/cjs/webhook-events.js +48 -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.d.ts +2 -0
- package/dist/esm/client.js +4 -1
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/events.d.ts +10 -2
- package/dist/esm/events.js +29 -2
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/provider-acquisitions.d.ts +106 -0
- package/dist/esm/provider-acquisitions.js +164 -0
- package/dist/esm/sessions.d.ts +36 -4
- package/dist/esm/sessions.js +132 -7
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +1 -1
- package/dist/esm/webhook-events.d.ts +21 -0
- package/dist/esm/webhook-events.js +46 -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/esm/sessions.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface ProxySessionHandoff extends ProxySession {
|
|
|
37
37
|
readonly status: "payer_handoff_pending" | "payer_opened";
|
|
38
38
|
}
|
|
39
39
|
export interface MerchantProxySession {
|
|
40
|
+
readonly actionableNextStep: ProxySessionActionableNextStep;
|
|
40
41
|
readonly amountMinor: number;
|
|
41
42
|
readonly beneficiaryContact: {
|
|
42
43
|
readonly email: string | null;
|
|
@@ -45,8 +46,10 @@ export interface MerchantProxySession {
|
|
|
45
46
|
readonly buyerReference: string;
|
|
46
47
|
readonly cartSnapshot: JsonObject;
|
|
47
48
|
readonly cartVersion: number;
|
|
49
|
+
readonly completedAcquisitionAttemptId: string | null;
|
|
48
50
|
readonly createdAt: string;
|
|
49
51
|
readonly currency: string;
|
|
52
|
+
readonly currentAcquisitionAttempt: ProxySessionAcquisitionSummary | null;
|
|
50
53
|
readonly expiresAt: string;
|
|
51
54
|
readonly id: string;
|
|
52
55
|
readonly idempotencyKey: string | null;
|
|
@@ -57,14 +60,27 @@ export interface MerchantProxySession {
|
|
|
57
60
|
readonly phone: string | null;
|
|
58
61
|
} | null;
|
|
59
62
|
readonly payerDestinationUrl: string | null;
|
|
63
|
+
readonly presentationState: ProxySessionPresentationState;
|
|
60
64
|
readonly providerCheckoutSessionId: string | null;
|
|
61
65
|
readonly providerCheckoutSessionPsp: string | null;
|
|
62
66
|
readonly status: string;
|
|
63
67
|
readonly updatedAt: string;
|
|
64
68
|
}
|
|
69
|
+
export interface ProxySessionAcquisitionSummary {
|
|
70
|
+
readonly attemptNumber: number;
|
|
71
|
+
readonly checkoutUiMode: string | null;
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly integrationPath: string;
|
|
74
|
+
readonly status: string;
|
|
75
|
+
readonly statusReason: string | null;
|
|
76
|
+
}
|
|
77
|
+
export type ProxySessionActionableNextStep = "already_paid" | "continue_payment" | "merchant_action_required" | "prepare_provider" | "unavailable";
|
|
65
78
|
export interface PayerOpenedResult extends MerchantProxySession {
|
|
66
|
-
readonly
|
|
79
|
+
readonly presentationState: ProxySessionPresentationState;
|
|
80
|
+
readonly status: ProxySessionViewStatus;
|
|
67
81
|
}
|
|
82
|
+
export type ProxySessionPresentationState = "action_required" | "already_paid" | "checkout_available" | "unavailable";
|
|
83
|
+
export type ProxySessionViewStatus = "cancelled" | "created" | "expired" | "failed" | "merchant_action_required" | "paid" | "payer_handoff_pending" | "payer_opened" | "payment_pending" | "provisionable" | "provisioned" | "provisioning_failed";
|
|
68
84
|
/** A merchant session with its cart snapshot validated against a merchant schema. */
|
|
69
85
|
export interface TypedMerchantProxySession<TCart> extends MerchantProxySession {
|
|
70
86
|
readonly cart: TCart;
|
|
@@ -84,10 +100,22 @@ export interface ProxySessionCartResult {
|
|
|
84
100
|
readonly cartVersion: number;
|
|
85
101
|
readonly currency: string;
|
|
86
102
|
}
|
|
87
|
-
|
|
103
|
+
interface RecordProviderBindingBaseInput extends ProxyCheckoutServerRequestOptions {
|
|
104
|
+
readonly expectedCartVersion?: number;
|
|
88
105
|
readonly providerCheckoutSessionId: string;
|
|
89
|
-
readonly psp: string;
|
|
90
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Input for the deprecated provider-binding compatibility adapter.
|
|
109
|
+
* Canonical Stripe literals require `commercialMode` at compile time; dynamic
|
|
110
|
+
* or untyped inputs remain protected by the matching runtime validation.
|
|
111
|
+
*/
|
|
112
|
+
export type RecordProviderBindingInput<TPsp extends string = string> = RecordProviderBindingBaseInput & {
|
|
113
|
+
readonly psp: TPsp;
|
|
114
|
+
} & (Lowercase<TPsp> extends "stripe" ? {
|
|
115
|
+
readonly commercialMode: "one_time" | "subscription";
|
|
116
|
+
} : {
|
|
117
|
+
readonly commercialMode?: "one_time" | "subscription";
|
|
118
|
+
});
|
|
91
119
|
export interface ProxySessionProviderBinding {
|
|
92
120
|
readonly providerCheckoutSessionId: string;
|
|
93
121
|
readonly proxySessionId: string;
|
|
@@ -181,8 +209,11 @@ export declare class ProxySessionsResource {
|
|
|
181
209
|
* Bind a provider (PSP) checkout object to a Proxy session so later cart sync
|
|
182
210
|
* can verify ownership. Idempotent for the same provider object; conflicts when
|
|
183
211
|
* the session is already bound to a different one.
|
|
212
|
+
*
|
|
213
|
+
* @deprecated Prefer provider acquisition attempts or a provider-specific
|
|
214
|
+
* helper such as `@proxy-checkout/stripe-server-js` `openCheckout(...)`.
|
|
184
215
|
*/
|
|
185
|
-
recordProviderBinding(proxySessionId: string, input: RecordProviderBindingInput): Promise<ProxySessionProviderBinding>;
|
|
216
|
+
recordProviderBinding<const TPsp extends string>(proxySessionId: string, input: RecordProviderBindingInput<TPsp>): Promise<ProxySessionProviderBinding>;
|
|
186
217
|
markProvisioned(proxySessionId: string, input?: MarkProxySessionProvisionedInput): Promise<ProxySessionProvisioningAcknowledgement>;
|
|
187
218
|
markProvisioningFailed(proxySessionId: string, input: MarkProxySessionProvisioningFailedInput): Promise<ProxySessionProvisioningAcknowledgement>;
|
|
188
219
|
}
|
|
@@ -191,3 +222,4 @@ export declare class ProxySessionCartResource {
|
|
|
191
222
|
constructor(httpClient: ProxyCheckoutHttpClient);
|
|
192
223
|
set(proxySessionId: string, input: SetProxySessionCartInput): Promise<ProxySessionCartResult>;
|
|
193
224
|
}
|
|
225
|
+
export {};
|
package/dist/esm/sessions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseProxyCart } from "./cart.js";
|
|
2
2
|
import { assertCartBuyerReference } from "./consistency.js";
|
|
3
|
+
import { ProxyCheckoutValidationError } from "./errors.js";
|
|
3
4
|
import { requireInteger, requireJsonObject, requireNullableString, requireString, } from "./response-validators.js";
|
|
4
5
|
export const proxyCheckoutServerEndpoints = [
|
|
5
6
|
{
|
|
@@ -136,9 +137,19 @@ export class ProxySessionsResource {
|
|
|
136
137
|
* Bind a provider (PSP) checkout object to a Proxy session so later cart sync
|
|
137
138
|
* can verify ownership. Idempotent for the same provider object; conflicts when
|
|
138
139
|
* the session is already bound to a different one.
|
|
140
|
+
*
|
|
141
|
+
* @deprecated Prefer provider acquisition attempts or a provider-specific
|
|
142
|
+
* helper such as `@proxy-checkout/stripe-server-js` `openCheckout(...)`.
|
|
139
143
|
*/
|
|
140
144
|
async recordProviderBinding(proxySessionId, input) {
|
|
145
|
+
if (input.psp.trim().toLowerCase() === "stripe" && input.commercialMode === undefined) {
|
|
146
|
+
throw new ProxyCheckoutValidationError("Stripe provider bindings require commercialMode so Proxy can infer the acquisition safely.", { code: "commercial_mode_required", field: "commercialMode" });
|
|
147
|
+
}
|
|
141
148
|
const response = await this.httpClient.request("POST", `/proxy_sessions/${encodeURIComponent(proxySessionId)}/provider_bindings`, {
|
|
149
|
+
...(input.commercialMode === undefined ? {} : { commercial_mode: input.commercialMode }),
|
|
150
|
+
...(input.expectedCartVersion === undefined
|
|
151
|
+
? {}
|
|
152
|
+
: { expected_cart_version: input.expectedCartVersion }),
|
|
142
153
|
provider_checkout_session_id: input.providerCheckoutSessionId,
|
|
143
154
|
psp: input.psp,
|
|
144
155
|
}, { requestId: input.requestId });
|
|
@@ -255,14 +266,24 @@ function toProxySessionHandoff(response) {
|
|
|
255
266
|
}
|
|
256
267
|
function toMerchantProxySession(response) {
|
|
257
268
|
const body = requireJsonObject(response, "sessions.retrieve");
|
|
269
|
+
const status = requireString(body.status, "sessions.retrieve.status");
|
|
270
|
+
const currentAcquisitionAttempt = optionalAcquisitionSummary(body.current_acquisition_attempt, "sessions.retrieve.currentAcquisitionAttempt");
|
|
271
|
+
const providerCheckoutSessionId = requireNullableString(body.provider_checkout_session_id, "sessions.retrieve.providerCheckoutSessionId");
|
|
272
|
+
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
258
273
|
return {
|
|
274
|
+
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
275
|
+
presentationState,
|
|
276
|
+
providerCheckoutSessionId,
|
|
277
|
+
}),
|
|
259
278
|
amountMinor: requireInteger(body.amount_minor, "sessions.retrieve.amountMinor"),
|
|
260
279
|
beneficiaryContact: requireNullableContact(body.beneficiary_contact, "sessions.retrieve.beneficiaryContact"),
|
|
261
280
|
buyerReference: requireString(body.buyer_reference, "sessions.retrieve.buyerReference"),
|
|
262
281
|
cartSnapshot: requireJsonObject(body.cart_snapshot, "sessions.retrieve.cartSnapshot"),
|
|
263
282
|
cartVersion: requireInteger(body.cart_version, "sessions.retrieve.cartVersion"),
|
|
283
|
+
completedAcquisitionAttemptId: optionalNullableString(body.completed_acquisition_attempt_id, "sessions.retrieve.completedAcquisitionAttemptId"),
|
|
264
284
|
createdAt: requireString(body.created_at, "sessions.retrieve.createdAt"),
|
|
265
285
|
currency: requireString(body.currency, "sessions.retrieve.currency"),
|
|
286
|
+
currentAcquisitionAttempt,
|
|
266
287
|
expiresAt: requireString(body.expires_at, "sessions.retrieve.expiresAt"),
|
|
267
288
|
id: requireString(body.id, "sessions.retrieve.id"),
|
|
268
289
|
idempotencyKey: requireNullableString(body.idempotency_key, "sessions.retrieve.idempotencyKey"),
|
|
@@ -270,26 +291,33 @@ function toMerchantProxySession(response) {
|
|
|
270
291
|
metadata: requireJsonObject(body.metadata, "sessions.retrieve.metadata"),
|
|
271
292
|
payerContact: requireNullableContact(body.payer_contact, "sessions.retrieve.payerContact"),
|
|
272
293
|
payerDestinationUrl: requireNullableString(body.payer_destination_url, "sessions.retrieve.payerDestinationUrl"),
|
|
273
|
-
|
|
294
|
+
presentationState,
|
|
295
|
+
providerCheckoutSessionId,
|
|
274
296
|
providerCheckoutSessionPsp: requireNullableString(body.provider_checkout_session_psp, "sessions.retrieve.providerCheckoutSessionPsp"),
|
|
275
|
-
status
|
|
297
|
+
status,
|
|
276
298
|
updatedAt: requireString(body.updated_at, "sessions.retrieve.updatedAt"),
|
|
277
299
|
};
|
|
278
300
|
}
|
|
279
301
|
function toPayerOpenedResult(response) {
|
|
280
302
|
const body = requireJsonObject(response, "sessions.payerOpened");
|
|
281
|
-
const status =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
303
|
+
const status = requireProxySessionViewStatus(body.status);
|
|
304
|
+
const currentAcquisitionAttempt = optionalAcquisitionSummary(body.current_acquisition_attempt, "sessions.payerOpened.currentAcquisitionAttempt");
|
|
305
|
+
const providerCheckoutSessionId = requireNullableString(body.provider_checkout_session_id, "sessions.payerOpened.providerCheckoutSessionId");
|
|
306
|
+
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
285
307
|
return {
|
|
308
|
+
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
309
|
+
presentationState,
|
|
310
|
+
providerCheckoutSessionId,
|
|
311
|
+
}),
|
|
286
312
|
amountMinor: requireInteger(body.amount_minor, "sessions.payerOpened.amountMinor"),
|
|
287
313
|
beneficiaryContact: requireNullableContact(body.beneficiary_contact, "sessions.payerOpened.beneficiaryContact"),
|
|
288
314
|
buyerReference: requireString(body.buyer_reference, "sessions.payerOpened.buyerReference"),
|
|
289
315
|
cartSnapshot: requireJsonObject(body.cart_snapshot, "sessions.payerOpened.cartSnapshot"),
|
|
290
316
|
cartVersion: requireInteger(body.cart_version, "sessions.payerOpened.cartVersion"),
|
|
317
|
+
completedAcquisitionAttemptId: optionalNullableString(body.completed_acquisition_attempt_id, "sessions.payerOpened.completedAcquisitionAttemptId"),
|
|
291
318
|
createdAt: requireString(body.created_at, "sessions.payerOpened.createdAt"),
|
|
292
319
|
currency: requireString(body.currency, "sessions.payerOpened.currency"),
|
|
320
|
+
currentAcquisitionAttempt,
|
|
293
321
|
expiresAt: requireString(body.expires_at, "sessions.payerOpened.expiresAt"),
|
|
294
322
|
id: requireString(body.id, "sessions.payerOpened.id"),
|
|
295
323
|
idempotencyKey: requireNullableString(body.idempotency_key, "sessions.payerOpened.idempotencyKey"),
|
|
@@ -297,12 +325,109 @@ function toPayerOpenedResult(response) {
|
|
|
297
325
|
metadata: requireJsonObject(body.metadata, "sessions.payerOpened.metadata"),
|
|
298
326
|
payerContact: requireNullableContact(body.payer_contact, "sessions.payerOpened.payerContact"),
|
|
299
327
|
payerDestinationUrl: requireNullableString(body.payer_destination_url, "sessions.payerOpened.payerDestinationUrl"),
|
|
300
|
-
|
|
328
|
+
presentationState,
|
|
329
|
+
providerCheckoutSessionId,
|
|
301
330
|
providerCheckoutSessionPsp: requireNullableString(body.provider_checkout_session_psp, "sessions.payerOpened.providerCheckoutSessionPsp"),
|
|
302
331
|
status,
|
|
303
332
|
updatedAt: requireString(body.updated_at, "sessions.payerOpened.updatedAt"),
|
|
304
333
|
};
|
|
305
334
|
}
|
|
335
|
+
function optionalAcquisitionSummary(value, field) {
|
|
336
|
+
if (value === null || value === undefined) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
const acquisition = requireJsonObject(value, field);
|
|
340
|
+
return {
|
|
341
|
+
attemptNumber: requireInteger(acquisition.attempt_number, `${field}.attemptNumber`),
|
|
342
|
+
checkoutUiMode: requireNullableString(acquisition.checkout_ui_mode, `${field}.checkoutUiMode`),
|
|
343
|
+
id: requireString(acquisition.id, `${field}.id`),
|
|
344
|
+
integrationPath: requireString(acquisition.integration_path, `${field}.integrationPath`),
|
|
345
|
+
status: requireString(acquisition.status, `${field}.status`),
|
|
346
|
+
statusReason: requireNullableString(acquisition.status_reason, `${field}.statusReason`),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function optionalNullableString(value, field) {
|
|
350
|
+
return value === undefined ? null : requireNullableString(value, field);
|
|
351
|
+
}
|
|
352
|
+
function proxySessionActionableNextStep(value, fallback) {
|
|
353
|
+
if (value === undefined) {
|
|
354
|
+
switch (fallback.presentationState) {
|
|
355
|
+
case "action_required":
|
|
356
|
+
return "merchant_action_required";
|
|
357
|
+
case "already_paid":
|
|
358
|
+
return "already_paid";
|
|
359
|
+
case "checkout_available":
|
|
360
|
+
return fallback.providerCheckoutSessionId === null
|
|
361
|
+
? "prepare_provider"
|
|
362
|
+
: "continue_payment";
|
|
363
|
+
case "unavailable":
|
|
364
|
+
return "unavailable";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const step = requireString(value, "sessions.actionableNextStep");
|
|
368
|
+
switch (step) {
|
|
369
|
+
case "already_paid":
|
|
370
|
+
case "continue_payment":
|
|
371
|
+
case "merchant_action_required":
|
|
372
|
+
case "prepare_provider":
|
|
373
|
+
case "unavailable":
|
|
374
|
+
return step;
|
|
375
|
+
default:
|
|
376
|
+
throw new Error("Proxy API response field sessions.actionableNextStep is unsupported.");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function proxySessionPresentationState(value, status) {
|
|
380
|
+
if (value === undefined) {
|
|
381
|
+
switch (requireProxySessionViewStatus(status)) {
|
|
382
|
+
case "payer_handoff_pending":
|
|
383
|
+
case "payer_opened":
|
|
384
|
+
case "payment_pending":
|
|
385
|
+
return "checkout_available";
|
|
386
|
+
case "paid":
|
|
387
|
+
case "provisionable":
|
|
388
|
+
case "provisioned":
|
|
389
|
+
case "provisioning_failed":
|
|
390
|
+
return "already_paid";
|
|
391
|
+
case "merchant_action_required":
|
|
392
|
+
return "action_required";
|
|
393
|
+
case "cancelled":
|
|
394
|
+
case "created":
|
|
395
|
+
case "expired":
|
|
396
|
+
case "failed":
|
|
397
|
+
return "unavailable";
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const state = requireString(value, "sessions.payerOpened.presentationState");
|
|
401
|
+
switch (state) {
|
|
402
|
+
case "action_required":
|
|
403
|
+
case "already_paid":
|
|
404
|
+
case "checkout_available":
|
|
405
|
+
case "unavailable":
|
|
406
|
+
return state;
|
|
407
|
+
default:
|
|
408
|
+
throw new Error("Proxy API response field sessions.payerOpened.presentationState is unsupported.");
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function requireProxySessionViewStatus(value) {
|
|
412
|
+
const status = requireString(value, "sessions.payerOpened.status");
|
|
413
|
+
switch (status) {
|
|
414
|
+
case "cancelled":
|
|
415
|
+
case "created":
|
|
416
|
+
case "expired":
|
|
417
|
+
case "failed":
|
|
418
|
+
case "merchant_action_required":
|
|
419
|
+
case "paid":
|
|
420
|
+
case "payer_handoff_pending":
|
|
421
|
+
case "payer_opened":
|
|
422
|
+
case "payment_pending":
|
|
423
|
+
case "provisionable":
|
|
424
|
+
case "provisioned":
|
|
425
|
+
case "provisioning_failed":
|
|
426
|
+
return status;
|
|
427
|
+
default:
|
|
428
|
+
throw new Error("Proxy API response field sessions.payerOpened.status is unsupported.");
|
|
429
|
+
}
|
|
430
|
+
}
|
|
306
431
|
function requireNullableContact(value, field) {
|
|
307
432
|
if (value === null || value === undefined) {
|
|
308
433
|
return null;
|
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.139.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.139.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.139.1";
|
|
3
3
|
export const proxyCheckoutServerSdkUserAgent = `${proxyCheckoutServerSdkName}/${proxyCheckoutServerSdkVersion}`;
|
|
@@ -7,18 +7,35 @@
|
|
|
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 paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required";
|
|
16
|
+
readonly paymentAttemptRefunded: "payment_attempt.refunded";
|
|
11
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 providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required";
|
|
12
22
|
readonly sessionCancelled: "proxy_session.cancelled";
|
|
13
23
|
readonly sessionExpired: "proxy_session.expired";
|
|
14
24
|
readonly sessionFailed: "proxy_session.failed";
|
|
15
25
|
readonly sessionMerchantActionRequired: "proxy_session.merchant_action_required";
|
|
16
26
|
readonly sessionPaid: "proxy_session.paid";
|
|
17
27
|
readonly sessionProvisionable: "proxy_session.provisionable";
|
|
28
|
+
readonly shopifyFulfillmentObserved: "shopify.fulfillment_observed";
|
|
29
|
+
readonly shopifyRefundObserved: "shopify.refund_observed";
|
|
30
|
+
readonly shopifySubscriptionPaymentObserved: "shopify.subscription_payment_observed";
|
|
31
|
+
readonly shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed";
|
|
18
32
|
readonly subscriptionCancelled: "subscription.cancelled";
|
|
19
33
|
readonly subscriptionCancelScheduled: "subscription.cancel_scheduled";
|
|
34
|
+
readonly subscriptionChanged: "subscription.changed";
|
|
35
|
+
readonly subscriptionConfigurationActionRequired: "subscription.configuration_action_required";
|
|
20
36
|
readonly subscriptionPaymentFailed: "subscription.payment_failed";
|
|
21
37
|
readonly subscriptionRenewed: "subscription.renewed";
|
|
38
|
+
readonly subscriptionTrialEnding: "subscription.trial_ending";
|
|
22
39
|
};
|
|
23
40
|
export type ProxyWebhookEventType = (typeof PROXY_WEBHOOK_EVENT_TYPES)[keyof typeof PROXY_WEBHOOK_EVENT_TYPES];
|
|
24
41
|
/** True for `proxy_session.*` events. */
|
|
@@ -27,3 +44,7 @@ export declare function isProxySessionEvent(eventType: string): boolean;
|
|
|
27
44
|
export declare function isProxySubscriptionEvent(eventType: string): boolean;
|
|
28
45
|
/** True for `payment_attempt.*` events. */
|
|
29
46
|
export declare function isProxyPaymentAttemptEvent(eventType: string): boolean;
|
|
47
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
48
|
+
export declare function isProxyProviderAcquisitionEvent(eventType: string): boolean;
|
|
49
|
+
/** True for observation-only `shopify.*` commerce events. */
|
|
50
|
+
export declare function isProxyShopifyEvent(eventType: string): boolean;
|
|
@@ -7,18 +7,35 @@
|
|
|
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
|
+
paymentAttemptReconciliationRequired: "payment_attempt.reconciliation_required",
|
|
16
|
+
paymentAttemptRefunded: "payment_attempt.refunded",
|
|
11
17
|
paymentAttemptSucceeded: "payment_attempt.succeeded",
|
|
18
|
+
providerAcquisitionCancelled: "provider_acquisition.cancelled",
|
|
19
|
+
providerAcquisitionExpired: "provider_acquisition.expired",
|
|
20
|
+
providerAcquisitionFailed: "provider_acquisition.failed",
|
|
21
|
+
providerAcquisitionReconciliationRequired: "provider_acquisition.reconciliation_required",
|
|
12
22
|
sessionCancelled: "proxy_session.cancelled",
|
|
13
23
|
sessionExpired: "proxy_session.expired",
|
|
14
24
|
sessionFailed: "proxy_session.failed",
|
|
15
25
|
sessionMerchantActionRequired: "proxy_session.merchant_action_required",
|
|
16
26
|
sessionPaid: "proxy_session.paid",
|
|
17
27
|
sessionProvisionable: "proxy_session.provisionable",
|
|
28
|
+
shopifyFulfillmentObserved: "shopify.fulfillment_observed",
|
|
29
|
+
shopifyRefundObserved: "shopify.refund_observed",
|
|
30
|
+
shopifySubscriptionPaymentObserved: "shopify.subscription_payment_observed",
|
|
31
|
+
shopifySubscriptionRefundObserved: "shopify.subscription_refund_observed",
|
|
18
32
|
subscriptionCancelled: "subscription.cancelled",
|
|
19
33
|
subscriptionCancelScheduled: "subscription.cancel_scheduled",
|
|
34
|
+
subscriptionChanged: "subscription.changed",
|
|
35
|
+
subscriptionConfigurationActionRequired: "subscription.configuration_action_required",
|
|
20
36
|
subscriptionPaymentFailed: "subscription.payment_failed",
|
|
21
37
|
subscriptionRenewed: "subscription.renewed",
|
|
38
|
+
subscriptionTrialEnding: "subscription.trial_ending",
|
|
22
39
|
};
|
|
23
40
|
const SESSION_EVENT_TYPES = new Set([
|
|
24
41
|
PROXY_WEBHOOK_EVENT_TYPES.sessionCancelled,
|
|
@@ -31,14 +48,35 @@ const SESSION_EVENT_TYPES = new Set([
|
|
|
31
48
|
const SUBSCRIPTION_EVENT_TYPES = new Set([
|
|
32
49
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelScheduled,
|
|
33
50
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionCancelled,
|
|
51
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionChanged,
|
|
52
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionConfigurationActionRequired,
|
|
34
53
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionPaymentFailed,
|
|
35
54
|
PROXY_WEBHOOK_EVENT_TYPES.subscriptionRenewed,
|
|
55
|
+
PROXY_WEBHOOK_EVENT_TYPES.subscriptionTrialEnding,
|
|
36
56
|
]);
|
|
37
57
|
const PAYMENT_ATTEMPT_EVENT_TYPES = new Set([
|
|
38
58
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptCancelled,
|
|
59
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeLost,
|
|
60
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputeWon,
|
|
61
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptDisputed,
|
|
39
62
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptFailed,
|
|
63
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptPartiallyRefunded,
|
|
64
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptReconciliationRequired,
|
|
65
|
+
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptRefunded,
|
|
40
66
|
PROXY_WEBHOOK_EVENT_TYPES.paymentAttemptSucceeded,
|
|
41
67
|
]);
|
|
68
|
+
const PROVIDER_ACQUISITION_EVENT_TYPES = new Set([
|
|
69
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionCancelled,
|
|
70
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionExpired,
|
|
71
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionFailed,
|
|
72
|
+
PROXY_WEBHOOK_EVENT_TYPES.providerAcquisitionReconciliationRequired,
|
|
73
|
+
]);
|
|
74
|
+
const SHOPIFY_EVENT_TYPES = new Set([
|
|
75
|
+
PROXY_WEBHOOK_EVENT_TYPES.shopifyFulfillmentObserved,
|
|
76
|
+
PROXY_WEBHOOK_EVENT_TYPES.shopifyRefundObserved,
|
|
77
|
+
PROXY_WEBHOOK_EVENT_TYPES.shopifySubscriptionPaymentObserved,
|
|
78
|
+
PROXY_WEBHOOK_EVENT_TYPES.shopifySubscriptionRefundObserved,
|
|
79
|
+
]);
|
|
42
80
|
/** True for `proxy_session.*` events. */
|
|
43
81
|
export function isProxySessionEvent(eventType) {
|
|
44
82
|
return SESSION_EVENT_TYPES.has(eventType);
|
|
@@ -51,3 +89,11 @@ export function isProxySubscriptionEvent(eventType) {
|
|
|
51
89
|
export function isProxyPaymentAttemptEvent(eventType) {
|
|
52
90
|
return PAYMENT_ATTEMPT_EVENT_TYPES.has(eventType);
|
|
53
91
|
}
|
|
92
|
+
/** True for non-granting `provider_acquisition.*` progress wakeups. */
|
|
93
|
+
export function isProxyProviderAcquisitionEvent(eventType) {
|
|
94
|
+
return PROVIDER_ACQUISITION_EVENT_TYPES.has(eventType);
|
|
95
|
+
}
|
|
96
|
+
/** True for observation-only `shopify.*` commerce events. */
|
|
97
|
+
export function isProxyShopifyEvent(eventType) {
|
|
98
|
+
return SHOPIFY_EVENT_TYPES.has(eventType);
|
|
99
|
+
}
|
|
@@ -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,
|