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