@lightspeed/online-payments-sdk 0.2.1 → 0.2.2

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.
Files changed (49) hide show
  1. package/dist/cjs/v1/{AdyenWidget.js → adyen/widget.js} +6 -6
  2. package/dist/cjs/v1/common.js +36 -0
  3. package/dist/cjs/v1/error.js +28 -0
  4. package/dist/cjs/v1/index.js +8 -5
  5. package/dist/cjs/v1/logging/common.js +4 -0
  6. package/dist/cjs/v1/logging/datadog/logger.js +30 -0
  7. package/dist/cjs/v1/logging/logger.js +13 -0
  8. package/dist/cjs/v1/logging/noop-logger.js +20 -0
  9. package/dist/cjs/v1/session.error.js +43 -0
  10. package/dist/cjs/v1/session.js +25 -0
  11. package/dist/cjs/v1/{StripeWidget.js → stripe/widget.js} +5 -5
  12. package/dist/cjs/v1/widget.error.js +43 -0
  13. package/dist/cjs/v1/widget.js +79 -43
  14. package/dist/v1/{AdyenWidget.d.ts → adyen/widget.d.ts} +2 -2
  15. package/dist/v1/{AdyenWidget.js → adyen/widget.js} +3 -3
  16. package/dist/v1/common.d.ts +2 -0
  17. package/dist/v1/common.js +35 -1
  18. package/dist/v1/error.d.ts +4 -0
  19. package/dist/v1/error.js +25 -0
  20. package/dist/v1/index.d.ts +3 -1
  21. package/dist/v1/index.js +3 -1
  22. package/dist/v1/logging/common.d.ts +15 -0
  23. package/dist/v1/logging/common.js +1 -0
  24. package/dist/v1/logging/datadog/logger.d.ts +13 -0
  25. package/dist/v1/logging/datadog/logger.js +26 -0
  26. package/dist/v1/logging/logger.d.ts +4 -0
  27. package/dist/v1/logging/logger.js +10 -0
  28. package/dist/v1/logging/noop-logger.d.ts +8 -0
  29. package/dist/v1/logging/noop-logger.js +16 -0
  30. package/dist/v1/session.d.ts +11 -0
  31. package/dist/v1/session.error.d.ts +15 -0
  32. package/dist/v1/session.error.js +40 -0
  33. package/dist/v1/session.js +21 -0
  34. package/dist/v1/{StripeWidget.d.ts → stripe/widget.d.ts} +2 -2
  35. package/dist/v1/{StripeWidget.js → stripe/widget.js} +2 -2
  36. package/dist/v1/widget.d.ts +1 -9
  37. package/dist/v1/widget.error.d.ts +15 -0
  38. package/dist/v1/widget.error.js +40 -0
  39. package/dist/v1/widget.js +78 -39
  40. package/package.json +5 -4
  41. package/dist/cjs/v1/errors.js +0 -82
  42. package/dist/v1/errors.d.ts +0 -42
  43. package/dist/v1/errors.js +0 -79
  44. /package/dist/cjs/{AdyenSession.js → v1/adyen/session.js} +0 -0
  45. /package/dist/cjs/{StripeSession.js → v1/stripe/session.js} +0 -0
  46. /package/dist/{AdyenSession.d.ts → v1/adyen/session.d.ts} +0 -0
  47. /package/dist/{AdyenSession.js → v1/adyen/session.js} +0 -0
  48. /package/dist/{StripeSession.d.ts → v1/stripe/session.d.ts} +0 -0
  49. /package/dist/{StripeSession.js → v1/stripe/session.js} +0 -0
@@ -0,0 +1,15 @@
1
+ export declare const SERVICE_NAME = "lsp-online-payments-sdk";
2
+ export type LogLevel = 'info' | 'warn' | 'error' | 'debug';
3
+ type BaseLoggingContext = {
4
+ env: string;
5
+ };
6
+ export type LoggerConfig<P extends string, C extends object> = {
7
+ provider: P;
8
+ params: C & BaseLoggingContext;
9
+ };
10
+ export interface Logger<T extends object> {
11
+ init: (config: LoggerConfig<string, T>['params']) => void;
12
+ setSessionContext: (context: Record<string, string>) => void;
13
+ log: (status: LogLevel, message: string, context?: Record<string, unknown>) => void;
14
+ }
15
+ export {};
@@ -0,0 +1 @@
1
+ export var SERVICE_NAME = 'lsp-online-payments-sdk';
@@ -0,0 +1,13 @@
1
+ import { Logger as ILogger, LoggerConfig, LogLevel } from '../common';
2
+ import { LogsInitConfiguration } from '@datadog/browser-logs';
3
+ export type DatadogLoggerConfig = LoggerConfig<'datadog', {
4
+ site: LogsInitConfiguration['site'];
5
+ token: string;
6
+ }>;
7
+ export type LoggerConfigParams = DatadogLoggerConfig['params'];
8
+ export declare class Logger implements ILogger<LoggerConfigParams> {
9
+ init(config: LoggerConfigParams): void;
10
+ setSessionContext(context: Record<string, string>): void;
11
+ log(status: LogLevel, message: string, context?: Record<string, unknown>): void;
12
+ }
13
+ export declare const getLogger: () => Logger;
@@ -0,0 +1,26 @@
1
+ import { datadogLogs } from '@datadog/browser-logs';
2
+ var Logger = /** @class */ (function () {
3
+ function Logger() {
4
+ }
5
+ Logger.prototype.init = function (config) {
6
+ var site = config.site, token = config.token, env = config.env;
7
+ var logsConfig = {
8
+ clientToken: token,
9
+ site: site,
10
+ service: 'lsp-online-payments-sdk',
11
+ env: env,
12
+ };
13
+ datadogLogs.init(logsConfig);
14
+ };
15
+ Logger.prototype.setSessionContext = function (context) {
16
+ // setting global context removes all existing context
17
+ datadogLogs.setGlobalContext(context);
18
+ };
19
+ Logger.prototype.log = function (status, message, context) {
20
+ datadogLogs.logger.log(message, context, status);
21
+ };
22
+ return Logger;
23
+ }());
24
+ export { Logger };
25
+ var datadogLogger = new Logger();
26
+ export var getLogger = function () { return datadogLogger; };
@@ -0,0 +1,4 @@
1
+ import { Logger } from './common';
2
+ import { DatadogLoggerConfig } from './datadog/logger';
3
+ export type LoggingConfig = DatadogLoggerConfig;
4
+ export declare function getLogger<T extends LoggingConfig>(config: T | undefined): Logger<T['params']>;
@@ -0,0 +1,10 @@
1
+ import { getLogger as getDatadogLogger, } from './datadog/logger';
2
+ import { getLogger as getNoopLogger } from './noop-logger';
3
+ export function getLogger(config) {
4
+ if ((config === null || config === void 0 ? void 0 : config.provider) === 'datadog') {
5
+ var ddLogger = getDatadogLogger();
6
+ ddLogger.init(config.params);
7
+ return ddLogger;
8
+ }
9
+ return getNoopLogger();
10
+ }
@@ -0,0 +1,8 @@
1
+ import { Logger } from './common';
2
+ declare class NoopLogger implements Logger<{}> {
3
+ init(): void;
4
+ setSessionContext(): void;
5
+ log(): void;
6
+ }
7
+ export declare const getLogger: () => NoopLogger;
8
+ export {};
@@ -0,0 +1,16 @@
1
+ var NoopLogger = /** @class */ (function () {
2
+ function NoopLogger() {
3
+ }
4
+ NoopLogger.prototype.init = function () {
5
+ // No operation
6
+ };
7
+ NoopLogger.prototype.setSessionContext = function () {
8
+ // No operation
9
+ };
10
+ NoopLogger.prototype.log = function () {
11
+ // No operation
12
+ };
13
+ return NoopLogger;
14
+ }());
15
+ var noopLogger = new NoopLogger();
16
+ export var getLogger = function () { return noopLogger; };
@@ -0,0 +1,11 @@
1
+ import { LoggingConfig } from './logging/logger';
2
+ import { AdyenSession } from './adyen/session';
3
+ import { StripeSession } from './stripe/session';
4
+ type BaseSession = {
5
+ metadata: Record<string, string>;
6
+ logging?: LoggingConfig;
7
+ };
8
+ export type Session = BaseSession & (AdyenSession | StripeSession);
9
+ export declare function decodePaymentSessionToContext(paymentSession: string): Session;
10
+ export declare function isTokenValid(token: unknown): token is Session;
11
+ export {};
@@ -0,0 +1,15 @@
1
+ import { BaseError } from './error';
2
+ /**
3
+ * Error thrown when the session structure is invalid.
4
+ * @typedef {Error} InvalidSessionStructureError
5
+ */
6
+ export declare class InvalidSessionStructureError extends BaseError {
7
+ constructor();
8
+ }
9
+ /**
10
+ * Error thrown when the session is invalid.
11
+ * @typedef {Error} InvalidSessionError
12
+ */
13
+ export declare class InvalidSessionError extends BaseError {
14
+ constructor();
15
+ }
@@ -0,0 +1,40 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { BaseError } from './error';
17
+ /**
18
+ * Error thrown when the session structure is invalid.
19
+ * @typedef {Error} InvalidSessionStructureError
20
+ */
21
+ var InvalidSessionStructureError = /** @class */ (function (_super) {
22
+ __extends(InvalidSessionStructureError, _super);
23
+ function InvalidSessionStructureError() {
24
+ return _super.call(this, 'InvalidSessionStructure', 'The contents of the session are invalid') || this;
25
+ }
26
+ return InvalidSessionStructureError;
27
+ }(BaseError));
28
+ export { InvalidSessionStructureError };
29
+ /**
30
+ * Error thrown when the session is invalid.
31
+ * @typedef {Error} InvalidSessionError
32
+ */
33
+ var InvalidSessionError = /** @class */ (function (_super) {
34
+ __extends(InvalidSessionError, _super);
35
+ function InvalidSessionError() {
36
+ return _super.call(this, 'InvalidSessionError', 'The provided session is invalid. Verify the correct session is being passed') || this;
37
+ }
38
+ return InvalidSessionError;
39
+ }(BaseError));
40
+ export { InvalidSessionError };
@@ -0,0 +1,21 @@
1
+ import { InvalidSessionStructureError, InvalidSessionError, } from './session.error';
2
+ export function decodePaymentSessionToContext(paymentSession) {
3
+ try {
4
+ var decoded = atob(paymentSession);
5
+ var jsonToken = JSON.parse(decoded);
6
+ if (jsonToken && isTokenValid(jsonToken)) {
7
+ return jsonToken;
8
+ }
9
+ throw new InvalidSessionStructureError();
10
+ }
11
+ catch (e) {
12
+ throw new InvalidSessionError();
13
+ }
14
+ }
15
+ export function isTokenValid(token) {
16
+ var t = token;
17
+ if (t && !!t.psp && !!t.context) {
18
+ return true;
19
+ }
20
+ return false;
21
+ }
@@ -1,6 +1,6 @@
1
1
  import type { SetupIntent, PaymentIntent } from '@stripe/stripe-js';
2
- import { StripeContext } from 'src/StripeSession';
3
- import { Callbacks, DefaultValues, ResultCode, WidgetController, WidgetInterface } from './common';
2
+ import { StripeContext } from './session';
3
+ import { Callbacks, DefaultValues, ResultCode, WidgetController, WidgetInterface } from '../common';
4
4
  export declare function mapStripeResultCode(code: SetupIntent.Status | PaymentIntent.Status): ResultCode;
5
5
  export declare function mount(mountElement: HTMLElement, context: StripeContext, listeners: Callbacks, defaultValues?: DefaultValues): Promise<WidgetController>;
6
6
  export declare const StripeWidget: WidgetInterface<StripeContext>;
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
13
  function verb(n) { return function (v) { return step([n, v]); }; }
14
14
  function step(op) {
15
15
  if (f) throw new TypeError("Generator is already executing.");
@@ -1,14 +1,6 @@
1
- import { StripeSession } from 'src/StripeSession';
2
- import { AdyenSession } from 'src/AdyenSession';
3
- import { Callbacks, WidgetController, DefaultValues } from 'src/v1/common';
4
- type Session = {
5
- metadata: Record<string, string>;
6
- } & (AdyenSession | StripeSession);
1
+ import { Callbacks, WidgetController, DefaultValues } from './common';
7
2
  export type PaymentWidgetConfiguration = {
8
3
  mountPoint: HTMLElement;
9
4
  defaultValues?: DefaultValues;
10
5
  } & Callbacks;
11
6
  export declare function mountPaymentWidget(session: string, { mountPoint, onComplete, onFail, defaultValues }: PaymentWidgetConfiguration): Promise<WidgetController>;
12
- export declare function decodePaymentSessionToContext(paymentSession: string): Session;
13
- export declare function isTokenValid(token: unknown): token is Session;
14
- export {};
@@ -0,0 +1,15 @@
1
+ import { BaseError } from './error';
2
+ /**
3
+ * Error thrown when the location is unsupported.
4
+ * @typedef {Error} UnsupportedLocationError
5
+ */
6
+ export declare class UnsupportedLocationError extends BaseError {
7
+ constructor();
8
+ }
9
+ /**
10
+ * Error thrown when the session structure is invalid.
11
+ * @typedef {Error} PaymentProcessingError
12
+ */
13
+ export declare class PaymentProcessingError extends BaseError {
14
+ constructor(message: string);
15
+ }
@@ -0,0 +1,40 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { BaseError } from './error';
17
+ /**
18
+ * Error thrown when the location is unsupported.
19
+ * @typedef {Error} UnsupportedLocationError
20
+ */
21
+ var UnsupportedLocationError = /** @class */ (function (_super) {
22
+ __extends(UnsupportedLocationError, _super);
23
+ function UnsupportedLocationError() {
24
+ return _super.call(this, 'UnsupportedLocation', 'The location you are attempting to process with is not supported') || this;
25
+ }
26
+ return UnsupportedLocationError;
27
+ }(BaseError));
28
+ export { UnsupportedLocationError };
29
+ /**
30
+ * Error thrown when the session structure is invalid.
31
+ * @typedef {Error} PaymentProcessingError
32
+ */
33
+ var PaymentProcessingError = /** @class */ (function (_super) {
34
+ __extends(PaymentProcessingError, _super);
35
+ function PaymentProcessingError(message) {
36
+ return _super.call(this, 'PaymentProcessing', "An error occurred while processing the payment. ".concat(message)) || this;
37
+ }
38
+ return PaymentProcessingError;
39
+ }(BaseError));
40
+ export { PaymentProcessingError };
package/dist/v1/widget.js CHANGED
@@ -1,41 +1,80 @@
1
- import { AdyenWidget } from './AdyenWidget';
2
- import { InvalidSessionError, InvalidSessionStructureError, UnsupportedLocationError, } from './errors';
3
- import { StripeWidget } from './StripeWidget';
4
- export function mountPaymentWidget(session, _a) {
5
- var mountPoint = _a.mountPoint, onComplete = _a.onComplete, onFail = _a.onFail, defaultValues = _a.defaultValues;
6
- var decodedSession = decodePaymentSessionToContext(session);
7
- switch (decodedSession.psp) {
8
- case 'ADYEN':
9
- return AdyenWidget.mount(mountPoint, decodedSession.context, {
10
- onComplete: onComplete,
11
- onFail: onFail,
12
- });
13
- case 'STRIPE':
14
- return StripeWidget.mount(mountPoint, decodedSession.context, {
15
- onComplete: onComplete,
16
- onFail: onFail,
17
- }, defaultValues);
18
- default:
19
- throw new UnsupportedLocationError();
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
20
35
  }
21
- }
22
- export function decodePaymentSessionToContext(paymentSession) {
23
- try {
24
- var decoded = atob(paymentSession);
25
- var jsonToken = JSON.parse(decoded);
26
- if (jsonToken && isTokenValid(jsonToken)) {
27
- return jsonToken;
28
- }
29
- throw new InvalidSessionStructureError();
30
- }
31
- catch (e) {
32
- throw new InvalidSessionError();
33
- }
34
- }
35
- export function isTokenValid(token) {
36
- var t = token;
37
- if (t && !!t.psp && !!t.context) {
38
- return true;
39
- }
40
- return false;
36
+ };
37
+ import { AdyenWidget } from './adyen/widget';
38
+ import { withLogging, } from './common';
39
+ import { StripeWidget } from './stripe/widget';
40
+ import { decodePaymentSessionToContext } from './session';
41
+ import { UnsupportedLocationError } from './widget.error';
42
+ import { getLogger } from './logging/logger';
43
+ export function mountPaymentWidget(session_1, _a) {
44
+ return __awaiter(this, arguments, void 0, function (session, _b) {
45
+ var decodedSession, logger, handlers, widgetController, _c;
46
+ var mountPoint = _b.mountPoint, onComplete = _b.onComplete, onFail = _b.onFail, defaultValues = _b.defaultValues;
47
+ return __generator(this, function (_d) {
48
+ switch (_d.label) {
49
+ case 0:
50
+ decodedSession = decodePaymentSessionToContext(session);
51
+ logger = getLogger(decodedSession.logging);
52
+ logger.setSessionContext(decodedSession.metadata);
53
+ handlers = {
54
+ onComplete: withLogging(logger, 'complete', onComplete || (function () { })),
55
+ onFail: withLogging(logger, 'fail', onFail || (function () { })),
56
+ };
57
+ logger.log('info', 'mount', { sessionContext: decodedSession.context });
58
+ _c = decodedSession.psp;
59
+ switch (_c) {
60
+ case 'ADYEN': return [3 /*break*/, 1];
61
+ case 'STRIPE': return [3 /*break*/, 3];
62
+ }
63
+ return [3 /*break*/, 5];
64
+ case 1: return [4 /*yield*/, AdyenWidget.mount(mountPoint, decodedSession.context, handlers)];
65
+ case 2:
66
+ widgetController = _d.sent();
67
+ return [3 /*break*/, 6];
68
+ case 3: return [4 /*yield*/, StripeWidget.mount(mountPoint, decodedSession.context, handlers, defaultValues)];
69
+ case 4:
70
+ widgetController = _d.sent();
71
+ return [3 /*break*/, 6];
72
+ case 5: throw new UnsupportedLocationError();
73
+ case 6:
74
+ widgetController.submit = withLogging(logger, 'submit', widgetController.submit);
75
+ widgetController.unmount = withLogging(logger, 'unmount', widgetController.unmount);
76
+ return [2 /*return*/, widgetController];
77
+ }
78
+ });
79
+ });
41
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/online-payments-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Process online-payments with Lightspeed Payments",
5
5
  "author": "Lightspeed Commerce Inc.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -27,10 +27,10 @@
27
27
  "build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs --downlevelIteration --declaration false"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/jest": "^29.5.13",
30
+ "@types/jest": "^30.0.0",
31
31
  "gts": "^6.0.2",
32
- "jest": "^29.7.0",
33
- "jest-environment-jsdom": "^29.7.0",
32
+ "jest": "^30.0.0",
33
+ "jest-environment-jsdom": "^30.0.0",
34
34
  "jest-junit": "^16.0.0",
35
35
  "rollup": "^4.34.8",
36
36
  "ts-jest": "^29.2.5",
@@ -39,6 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@adyen/adyen-web": "^6.8.0",
42
+ "@datadog/browser-logs": "^6.10.1",
42
43
  "@stripe/stripe-js": "^7.3.0"
43
44
  }
44
45
  }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.PaymentProcessingError = exports.InvalidSessionError = exports.InvalidSessionStructureError = exports.UnsupportedLocationError = exports.ErrorCode = void 0;
19
- var ErrorCode;
20
- (function (ErrorCode) {
21
- ErrorCode["UnsupportedLocation"] = "UnsupportedLocation";
22
- ErrorCode["InvalidSessionStructure"] = "InvalidSessionStructure";
23
- ErrorCode["InvalidSessionError"] = "InvalidSessionError";
24
- ErrorCode["PaymentProcessingError"] = "PaymentProcessingError";
25
- })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
26
- var BaseError = /** @class */ (function (_super) {
27
- __extends(BaseError, _super);
28
- function BaseError(code, message) {
29
- var _this = _super.call(this, message) || this;
30
- _this.code = code;
31
- return _this;
32
- }
33
- return BaseError;
34
- }(Error));
35
- /**
36
- * Error thrown when the location is unsupported.
37
- * @typedef {Error} UnsupportedLocationError
38
- */
39
- var UnsupportedLocationError = /** @class */ (function (_super) {
40
- __extends(UnsupportedLocationError, _super);
41
- function UnsupportedLocationError() {
42
- return _super.call(this, ErrorCode.UnsupportedLocation, 'The location you are attempting to process with is not supported') || this;
43
- }
44
- return UnsupportedLocationError;
45
- }(BaseError));
46
- exports.UnsupportedLocationError = UnsupportedLocationError;
47
- /**
48
- * Error thrown when the session structure is invalid.
49
- * @typedef {Error} InvalidSessionStructureError
50
- */
51
- var InvalidSessionStructureError = /** @class */ (function (_super) {
52
- __extends(InvalidSessionStructureError, _super);
53
- function InvalidSessionStructureError() {
54
- return _super.call(this, ErrorCode.InvalidSessionStructure, 'The contents of the session are invalid') || this;
55
- }
56
- return InvalidSessionStructureError;
57
- }(BaseError));
58
- exports.InvalidSessionStructureError = InvalidSessionStructureError;
59
- /**
60
- * Error thrown when the session is invalid.
61
- * @typedef {Error} InvalidSessionError
62
- */
63
- var InvalidSessionError = /** @class */ (function (_super) {
64
- __extends(InvalidSessionError, _super);
65
- function InvalidSessionError() {
66
- return _super.call(this, ErrorCode.InvalidSessionError, 'The provided session is invalid. Verify the correct session is being passed') || this;
67
- }
68
- return InvalidSessionError;
69
- }(BaseError));
70
- exports.InvalidSessionError = InvalidSessionError;
71
- /**
72
- * Error thrown when the session structure is invalid.
73
- * @typedef {Error} PaymentProcessingError
74
- */
75
- var PaymentProcessingError = /** @class */ (function (_super) {
76
- __extends(PaymentProcessingError, _super);
77
- function PaymentProcessingError(message) {
78
- return _super.call(this, ErrorCode.PaymentProcessingError, "An error occurred while processing the payment. ".concat(message)) || this;
79
- }
80
- return PaymentProcessingError;
81
- }(BaseError));
82
- exports.PaymentProcessingError = PaymentProcessingError;
@@ -1,42 +0,0 @@
1
- export declare enum ErrorCode {
2
- UnsupportedLocation = "UnsupportedLocation",
3
- InvalidSessionStructure = "InvalidSessionStructure",
4
- InvalidSessionError = "InvalidSessionError",
5
- PaymentProcessingError = "PaymentProcessingError"
6
- }
7
- export interface CustomError {
8
- code: ErrorCode;
9
- }
10
- declare class BaseError extends Error implements CustomError {
11
- code: ErrorCode;
12
- constructor(code: ErrorCode, message: string);
13
- }
14
- /**
15
- * Error thrown when the location is unsupported.
16
- * @typedef {Error} UnsupportedLocationError
17
- */
18
- export declare class UnsupportedLocationError extends BaseError {
19
- constructor();
20
- }
21
- /**
22
- * Error thrown when the session structure is invalid.
23
- * @typedef {Error} InvalidSessionStructureError
24
- */
25
- export declare class InvalidSessionStructureError extends BaseError {
26
- constructor();
27
- }
28
- /**
29
- * Error thrown when the session is invalid.
30
- * @typedef {Error} InvalidSessionError
31
- */
32
- export declare class InvalidSessionError extends BaseError {
33
- constructor();
34
- }
35
- /**
36
- * Error thrown when the session structure is invalid.
37
- * @typedef {Error} PaymentProcessingError
38
- */
39
- export declare class PaymentProcessingError extends BaseError {
40
- constructor(message: string);
41
- }
42
- export {};
package/dist/v1/errors.js DELETED
@@ -1,79 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- export var ErrorCode;
17
- (function (ErrorCode) {
18
- ErrorCode["UnsupportedLocation"] = "UnsupportedLocation";
19
- ErrorCode["InvalidSessionStructure"] = "InvalidSessionStructure";
20
- ErrorCode["InvalidSessionError"] = "InvalidSessionError";
21
- ErrorCode["PaymentProcessingError"] = "PaymentProcessingError";
22
- })(ErrorCode || (ErrorCode = {}));
23
- var BaseError = /** @class */ (function (_super) {
24
- __extends(BaseError, _super);
25
- function BaseError(code, message) {
26
- var _this = _super.call(this, message) || this;
27
- _this.code = code;
28
- return _this;
29
- }
30
- return BaseError;
31
- }(Error));
32
- /**
33
- * Error thrown when the location is unsupported.
34
- * @typedef {Error} UnsupportedLocationError
35
- */
36
- var UnsupportedLocationError = /** @class */ (function (_super) {
37
- __extends(UnsupportedLocationError, _super);
38
- function UnsupportedLocationError() {
39
- return _super.call(this, ErrorCode.UnsupportedLocation, 'The location you are attempting to process with is not supported') || this;
40
- }
41
- return UnsupportedLocationError;
42
- }(BaseError));
43
- export { UnsupportedLocationError };
44
- /**
45
- * Error thrown when the session structure is invalid.
46
- * @typedef {Error} InvalidSessionStructureError
47
- */
48
- var InvalidSessionStructureError = /** @class */ (function (_super) {
49
- __extends(InvalidSessionStructureError, _super);
50
- function InvalidSessionStructureError() {
51
- return _super.call(this, ErrorCode.InvalidSessionStructure, 'The contents of the session are invalid') || this;
52
- }
53
- return InvalidSessionStructureError;
54
- }(BaseError));
55
- export { InvalidSessionStructureError };
56
- /**
57
- * Error thrown when the session is invalid.
58
- * @typedef {Error} InvalidSessionError
59
- */
60
- var InvalidSessionError = /** @class */ (function (_super) {
61
- __extends(InvalidSessionError, _super);
62
- function InvalidSessionError() {
63
- return _super.call(this, ErrorCode.InvalidSessionError, 'The provided session is invalid. Verify the correct session is being passed') || this;
64
- }
65
- return InvalidSessionError;
66
- }(BaseError));
67
- export { InvalidSessionError };
68
- /**
69
- * Error thrown when the session structure is invalid.
70
- * @typedef {Error} PaymentProcessingError
71
- */
72
- var PaymentProcessingError = /** @class */ (function (_super) {
73
- __extends(PaymentProcessingError, _super);
74
- function PaymentProcessingError(message) {
75
- return _super.call(this, ErrorCode.PaymentProcessingError, "An error occurred while processing the payment. ".concat(message)) || this;
76
- }
77
- return PaymentProcessingError;
78
- }(BaseError));
79
- export { PaymentProcessingError };