@proxy-checkout/server-js 0.1.0-prx-124.139.1 → 0.1.0-prx-124.145.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/sessions.js +50 -34
- 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/esm/sessions.js +50 -34
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
package/dist/cjs/sessions.js
CHANGED
|
@@ -277,6 +277,7 @@ function toMerchantProxySession(response) {
|
|
|
277
277
|
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
278
278
|
return {
|
|
279
279
|
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
280
|
+
currentAcquisitionAttempt,
|
|
280
281
|
presentationState,
|
|
281
282
|
providerCheckoutSessionId,
|
|
282
283
|
}),
|
|
@@ -311,6 +312,7 @@ function toPayerOpenedResult(response) {
|
|
|
311
312
|
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
312
313
|
return {
|
|
313
314
|
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
315
|
+
currentAcquisitionAttempt,
|
|
314
316
|
presentationState,
|
|
315
317
|
providerCheckoutSessionId,
|
|
316
318
|
}),
|
|
@@ -355,20 +357,9 @@ function optionalNullableString(value, field) {
|
|
|
355
357
|
return value === undefined ? null : (0, response_validators_js_1.requireNullableString)(value, field);
|
|
356
358
|
}
|
|
357
359
|
function proxySessionActionableNextStep(value, fallback) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return "merchant_action_required";
|
|
362
|
-
case "already_paid":
|
|
363
|
-
return "already_paid";
|
|
364
|
-
case "checkout_available":
|
|
365
|
-
return fallback.providerCheckoutSessionId === null
|
|
366
|
-
? "prepare_provider"
|
|
367
|
-
: "continue_payment";
|
|
368
|
-
case "unavailable":
|
|
369
|
-
return "unavailable";
|
|
370
|
-
}
|
|
371
|
-
}
|
|
360
|
+
const expected = expectedActionableNextStep(fallback);
|
|
361
|
+
if (value === undefined)
|
|
362
|
+
return expected;
|
|
372
363
|
const step = (0, response_validators_js_1.requireString)(value, "sessions.actionableNextStep");
|
|
373
364
|
switch (step) {
|
|
374
365
|
case "already_paid":
|
|
@@ -376,43 +367,68 @@ function proxySessionActionableNextStep(value, fallback) {
|
|
|
376
367
|
case "merchant_action_required":
|
|
377
368
|
case "prepare_provider":
|
|
378
369
|
case "unavailable":
|
|
370
|
+
if (step !== expected) {
|
|
371
|
+
throw new Error("Proxy API response fields sessions.status, sessions.presentationState, and sessions.actionableNextStep are inconsistent.");
|
|
372
|
+
}
|
|
379
373
|
return step;
|
|
380
374
|
default:
|
|
381
375
|
throw new Error("Proxy API response field sessions.actionableNextStep is unsupported.");
|
|
382
376
|
}
|
|
383
377
|
}
|
|
384
378
|
function proxySessionPresentationState(value, status) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
case "payer_opened":
|
|
389
|
-
case "payment_pending":
|
|
390
|
-
return "checkout_available";
|
|
391
|
-
case "paid":
|
|
392
|
-
case "provisionable":
|
|
393
|
-
case "provisioned":
|
|
394
|
-
case "provisioning_failed":
|
|
395
|
-
return "already_paid";
|
|
396
|
-
case "merchant_action_required":
|
|
397
|
-
return "action_required";
|
|
398
|
-
case "cancelled":
|
|
399
|
-
case "created":
|
|
400
|
-
case "expired":
|
|
401
|
-
case "failed":
|
|
402
|
-
return "unavailable";
|
|
403
|
-
}
|
|
404
|
-
}
|
|
379
|
+
const expected = expectedPresentationState(requireProxySessionViewStatus(status));
|
|
380
|
+
if (value === undefined)
|
|
381
|
+
return expected;
|
|
405
382
|
const state = (0, response_validators_js_1.requireString)(value, "sessions.payerOpened.presentationState");
|
|
406
383
|
switch (state) {
|
|
407
384
|
case "action_required":
|
|
408
385
|
case "already_paid":
|
|
409
386
|
case "checkout_available":
|
|
410
387
|
case "unavailable":
|
|
388
|
+
if (state !== expected) {
|
|
389
|
+
throw new Error("Proxy API response fields sessions.status and sessions.presentationState are inconsistent.");
|
|
390
|
+
}
|
|
411
391
|
return state;
|
|
412
392
|
default:
|
|
413
393
|
throw new Error("Proxy API response field sessions.payerOpened.presentationState is unsupported.");
|
|
414
394
|
}
|
|
415
395
|
}
|
|
396
|
+
function expectedPresentationState(status) {
|
|
397
|
+
switch (status) {
|
|
398
|
+
case "payer_handoff_pending":
|
|
399
|
+
case "payer_opened":
|
|
400
|
+
case "payment_pending":
|
|
401
|
+
return "checkout_available";
|
|
402
|
+
case "paid":
|
|
403
|
+
case "provisionable":
|
|
404
|
+
case "provisioned":
|
|
405
|
+
case "provisioning_failed":
|
|
406
|
+
return "already_paid";
|
|
407
|
+
case "merchant_action_required":
|
|
408
|
+
return "action_required";
|
|
409
|
+
case "cancelled":
|
|
410
|
+
case "created":
|
|
411
|
+
case "expired":
|
|
412
|
+
case "failed":
|
|
413
|
+
return "unavailable";
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function expectedActionableNextStep(input) {
|
|
417
|
+
switch (input.presentationState) {
|
|
418
|
+
case "action_required":
|
|
419
|
+
return "merchant_action_required";
|
|
420
|
+
case "already_paid":
|
|
421
|
+
return "already_paid";
|
|
422
|
+
case "unavailable":
|
|
423
|
+
return "unavailable";
|
|
424
|
+
case "checkout_available":
|
|
425
|
+
return input.providerCheckoutSessionId !== null ||
|
|
426
|
+
(input.currentAcquisitionAttempt !== null &&
|
|
427
|
+
input.currentAcquisitionAttempt.status !== "preparing")
|
|
428
|
+
? "continue_payment"
|
|
429
|
+
: "prepare_provider";
|
|
430
|
+
}
|
|
431
|
+
}
|
|
416
432
|
function requireProxySessionViewStatus(value) {
|
|
417
433
|
const status = (0, response_validators_js_1.requireString)(value, "sessions.payerOpened.status");
|
|
418
434
|
switch (status) {
|
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.1.0-prx-124.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.145.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.145.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.1.0-prx-124.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.145.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.145.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.1.0-prx-124.
|
|
5
|
+
exports.proxyCheckoutServerSdkVersion = "0.1.0-prx-124.145.1";
|
|
6
6
|
exports.proxyCheckoutServerSdkUserAgent = `${exports.proxyCheckoutServerSdkName}/${exports.proxyCheckoutServerSdkVersion}`;
|
package/dist/esm/sessions.js
CHANGED
|
@@ -272,6 +272,7 @@ function toMerchantProxySession(response) {
|
|
|
272
272
|
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
273
273
|
return {
|
|
274
274
|
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
275
|
+
currentAcquisitionAttempt,
|
|
275
276
|
presentationState,
|
|
276
277
|
providerCheckoutSessionId,
|
|
277
278
|
}),
|
|
@@ -306,6 +307,7 @@ function toPayerOpenedResult(response) {
|
|
|
306
307
|
const presentationState = proxySessionPresentationState(body.presentation_state, status);
|
|
307
308
|
return {
|
|
308
309
|
actionableNextStep: proxySessionActionableNextStep(body.actionable_next_step, {
|
|
310
|
+
currentAcquisitionAttempt,
|
|
309
311
|
presentationState,
|
|
310
312
|
providerCheckoutSessionId,
|
|
311
313
|
}),
|
|
@@ -350,20 +352,9 @@ function optionalNullableString(value, field) {
|
|
|
350
352
|
return value === undefined ? null : requireNullableString(value, field);
|
|
351
353
|
}
|
|
352
354
|
function proxySessionActionableNextStep(value, fallback) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
-
}
|
|
355
|
+
const expected = expectedActionableNextStep(fallback);
|
|
356
|
+
if (value === undefined)
|
|
357
|
+
return expected;
|
|
367
358
|
const step = requireString(value, "sessions.actionableNextStep");
|
|
368
359
|
switch (step) {
|
|
369
360
|
case "already_paid":
|
|
@@ -371,43 +362,68 @@ function proxySessionActionableNextStep(value, fallback) {
|
|
|
371
362
|
case "merchant_action_required":
|
|
372
363
|
case "prepare_provider":
|
|
373
364
|
case "unavailable":
|
|
365
|
+
if (step !== expected) {
|
|
366
|
+
throw new Error("Proxy API response fields sessions.status, sessions.presentationState, and sessions.actionableNextStep are inconsistent.");
|
|
367
|
+
}
|
|
374
368
|
return step;
|
|
375
369
|
default:
|
|
376
370
|
throw new Error("Proxy API response field sessions.actionableNextStep is unsupported.");
|
|
377
371
|
}
|
|
378
372
|
}
|
|
379
373
|
function proxySessionPresentationState(value, status) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
}
|
|
374
|
+
const expected = expectedPresentationState(requireProxySessionViewStatus(status));
|
|
375
|
+
if (value === undefined)
|
|
376
|
+
return expected;
|
|
400
377
|
const state = requireString(value, "sessions.payerOpened.presentationState");
|
|
401
378
|
switch (state) {
|
|
402
379
|
case "action_required":
|
|
403
380
|
case "already_paid":
|
|
404
381
|
case "checkout_available":
|
|
405
382
|
case "unavailable":
|
|
383
|
+
if (state !== expected) {
|
|
384
|
+
throw new Error("Proxy API response fields sessions.status and sessions.presentationState are inconsistent.");
|
|
385
|
+
}
|
|
406
386
|
return state;
|
|
407
387
|
default:
|
|
408
388
|
throw new Error("Proxy API response field sessions.payerOpened.presentationState is unsupported.");
|
|
409
389
|
}
|
|
410
390
|
}
|
|
391
|
+
function expectedPresentationState(status) {
|
|
392
|
+
switch (status) {
|
|
393
|
+
case "payer_handoff_pending":
|
|
394
|
+
case "payer_opened":
|
|
395
|
+
case "payment_pending":
|
|
396
|
+
return "checkout_available";
|
|
397
|
+
case "paid":
|
|
398
|
+
case "provisionable":
|
|
399
|
+
case "provisioned":
|
|
400
|
+
case "provisioning_failed":
|
|
401
|
+
return "already_paid";
|
|
402
|
+
case "merchant_action_required":
|
|
403
|
+
return "action_required";
|
|
404
|
+
case "cancelled":
|
|
405
|
+
case "created":
|
|
406
|
+
case "expired":
|
|
407
|
+
case "failed":
|
|
408
|
+
return "unavailable";
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function expectedActionableNextStep(input) {
|
|
412
|
+
switch (input.presentationState) {
|
|
413
|
+
case "action_required":
|
|
414
|
+
return "merchant_action_required";
|
|
415
|
+
case "already_paid":
|
|
416
|
+
return "already_paid";
|
|
417
|
+
case "unavailable":
|
|
418
|
+
return "unavailable";
|
|
419
|
+
case "checkout_available":
|
|
420
|
+
return input.providerCheckoutSessionId !== null ||
|
|
421
|
+
(input.currentAcquisitionAttempt !== null &&
|
|
422
|
+
input.currentAcquisitionAttempt.status !== "preparing")
|
|
423
|
+
? "continue_payment"
|
|
424
|
+
: "prepare_provider";
|
|
425
|
+
}
|
|
426
|
+
}
|
|
411
427
|
function requireProxySessionViewStatus(value) {
|
|
412
428
|
const status = requireString(value, "sessions.payerOpened.status");
|
|
413
429
|
switch (status) {
|
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.1.0-prx-124.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.145.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.1.0-prx-124.145.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.1.0-prx-124.
|
|
2
|
+
export const proxyCheckoutServerSdkVersion = "0.1.0-prx-124.145.1";
|
|
3
3
|
export const proxyCheckoutServerSdkUserAgent = `${proxyCheckoutServerSdkName}/${proxyCheckoutServerSdkVersion}`;
|
package/package.json
CHANGED