@houlak/plexo-sdk 0.1.18 → 0.1.20

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.
@@ -1,4 +1,4 @@
1
- import { Authorization, BaseServerResponse, CancelRequest, ClientSignedResponse, Commerce, CommerceIdRequest, CommerceIssuerIdRequest, CommerceRequest, DeleteInstrumentRequest, ExpressCheckoutRequest, InstrumentCallback, IssuerData, IssuerInfo, IssuerProcessor, PaymentRequest, Session, Transaction, TransactionCallback } from '../sdk/index';
1
+ import { Authorization, BaseServerResponse, CancelRequest, ClientSignedResponse, Commerce, CommerceIdRequest, CommerceIssuerIdRequest, CommerceRequest, DeleteInstrumentRequest, ExpressCheckoutRequest, InstrumentCallback, IssuerData, IssuerInfo, IssuerProcessor, PaymentRequest, ServerResponse, Session, Transaction, TransactionCallback } from '../sdk/index';
2
2
  import { BaseResponse } from './types/BaseResponse';
3
3
  export declare const PlexoHandler: {
4
4
  AddCommerce: (commerceRequest: CommerceRequest) => Promise<BaseResponse<Commerce>>;
@@ -16,6 +16,6 @@ export declare const PlexoHandler: {
16
16
  Purchase: (purchase: PaymentRequest) => Promise<BaseResponse<Transaction>>;
17
17
  UnwrapInstrumentCallback: (instrumentCallback: any) => Promise<BaseResponse<InstrumentCallback>>;
18
18
  UnwrapTransactionCallback: (transactionCallback: any) => Promise<BaseResponse<TransactionCallback>>;
19
- SignInstrumentCallback: (instrumentCallback: any) => Promise<BaseResponse<ClientSignedResponse>>;
19
+ SignInstrumentCallback: (instrumentCallback: ServerResponse<InstrumentCallback>) => Promise<BaseResponse<ClientSignedResponse>>;
20
20
  SignTransactionCallback: (transactionCallback: any) => Promise<BaseResponse<ClientSignedResponse>>;
21
21
  };
@@ -229,12 +229,10 @@ var UnwrapTransactionCallback = function (transactionCallback) { return __awaite
229
229
  });
230
230
  }); };
231
231
  var SignInstrumentCallback = function (instrumentCallback) { return __awaiter(void 0, void 0, void 0, function () {
232
- var instrumentCallbackCamelCase, signInstrumentCallbackResponse;
232
+ var signInstrumentCallbackResponse;
233
233
  return __generator(this, function (_a) {
234
234
  switch (_a.label) {
235
- case 0:
236
- instrumentCallbackCamelCase = utils_1.caseUtils.toCamelKeys(instrumentCallback);
237
- return [4 /*yield*/, paymentGatewayClient.SignInstrumentCallback(instrumentCallbackCamelCase)];
235
+ case 0: return [4 /*yield*/, paymentGatewayClient.SignInstrumentCallback(instrumentCallback)];
238
236
  case 1:
239
237
  signInstrumentCallbackResponse = _a.sent();
240
238
  return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(instrumentCallback, signInstrumentCallbackResponse)];
@@ -242,12 +240,10 @@ var SignInstrumentCallback = function (instrumentCallback) { return __awaiter(vo
242
240
  });
243
241
  }); };
244
242
  var SignTransactionCallback = function (transactionCallback) { return __awaiter(void 0, void 0, void 0, function () {
245
- var transactionCallbackCamelCase, signTransactionCallbackResponse;
243
+ var signTransactionCallbackResponse;
246
244
  return __generator(this, function (_a) {
247
245
  switch (_a.label) {
248
- case 0:
249
- transactionCallbackCamelCase = utils_1.caseUtils.toCamelKeys(transactionCallback);
250
- return [4 /*yield*/, paymentGatewayClient.SignTransactionCallback(transactionCallbackCamelCase)];
246
+ case 0: return [4 /*yield*/, paymentGatewayClient.SignTransactionCallback(transactionCallback)];
251
247
  case 1:
252
248
  signTransactionCallbackResponse = _a.sent();
253
249
  return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(transactionCallback, signTransactionCallbackResponse)];
@@ -2,7 +2,6 @@ import { ESMap } from 'typescript';
2
2
  import { AuthorizationType } from '..';
3
3
  import { ActionType } from './ActionType';
4
4
  import { AuthorizationInfo } from './AuthorizationInfo';
5
- import { WebFormSettingsDto } from './WebFormSettingsDto';
6
5
  export declare class Authorization extends AuthorizationInfo {
7
6
  action: ActionType;
8
7
  redirectUri: string;
@@ -13,6 +12,5 @@ export declare class Authorization extends AuthorizationInfo {
13
12
  optionalMetadata?: string;
14
13
  promotionInfoIssuers?: ESMap<string, string>;
15
14
  extendableInstrumentToken?: string;
16
- webFormSettings?: WebFormSettingsDto;
17
15
  constructor(action: ActionType, redirectUri: string, limitIssuers: string[], optionalCommerceId: number, type: AuthorizationType, metaReference: string);
18
16
  }
@@ -1,7 +1,7 @@
1
1
  import { PaymentProcessor } from './PaymentProcessor';
2
2
  export declare class IssuerProcessor {
3
- issuerId: number;
4
- name: string;
5
- paymentProcessors: PaymentProcessor[];
6
- constructor(issuerId: number, name: string, paymentProcessors: PaymentProcessor[]);
3
+ IssuerId: number;
4
+ Name: string;
5
+ PaymentProcessors: PaymentProcessor[];
6
+ constructor(IssuerId: number, Name: string, PaymentProcessors: PaymentProcessor[]);
7
7
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IssuerProcessor = void 0;
4
4
  var IssuerProcessor = /** @class */ (function () {
5
- function IssuerProcessor(issuerId, name, paymentProcessors) {
6
- this.issuerId = issuerId;
7
- this.name = name;
8
- this.paymentProcessors = paymentProcessors;
5
+ function IssuerProcessor(IssuerId, Name, PaymentProcessors) {
6
+ this.IssuerId = IssuerId;
7
+ this.Name = Name;
8
+ this.PaymentProcessors = PaymentProcessors;
9
9
  }
10
10
  return IssuerProcessor;
11
11
  }());
@@ -61,7 +61,7 @@ var sort = function (object) {
61
61
  object.map(function (item) { return newArray_1.push(sort(item)); });
62
62
  return newArray_1;
63
63
  }
64
- if (typeof object === 'object') {
64
+ if (object && typeof object === 'object') {
65
65
  var newObject_1 = {};
66
66
  Object.keys(object)
67
67
  .sort()
@@ -77,13 +77,15 @@ var deleteObjectUndefined = function (object) {
77
77
  object = object
78
78
  .filter(function (item) { return item !== undefined || !item.length; })
79
79
  .map(function (item) {
80
- return typeof item === 'object' || Array.isArray(item) ? deleteObjectUndefined(item) : null;
80
+ return (item && typeof item === 'object') || Array.isArray(item)
81
+ ? deleteObjectUndefined(item)
82
+ : null;
81
83
  });
82
84
  return;
83
85
  }
84
- if (typeof object === 'object') {
86
+ if (object && typeof object === 'object') {
85
87
  Object.keys(object).map(function (key) {
86
- if (typeof object[key] === 'object') {
88
+ if (object[key] && typeof object[key] === 'object') {
87
89
  if (Object.entries(object[key]).length === 0) {
88
90
  delete object[key];
89
91
  }
@@ -123,6 +125,9 @@ var getCertificate = function () { return __awaiter(void 0, void 0, void 0, func
123
125
  case 0: return [4 /*yield*/, pem.readPkcs12(pfx, { p12Password: config_1.config.plexoClient.certificatePassword }, function (_err, cert) { return __awaiter(void 0, void 0, void 0, function () {
124
126
  var privateKey, stringifiedCert;
125
127
  return __generator(this, function (_a) {
128
+ if (_err) {
129
+ return [2 /*return*/, reject(_err)];
130
+ }
126
131
  privateKey = cert.key;
127
132
  stringifiedCert = cert.cert;
128
133
  resolve({ privateKey: privateKey, cert: stringifiedCert });
@@ -155,7 +160,6 @@ var getSignatureFromPlexo = function (objectToSign) { return __awaiter(void 0, v
155
160
  case 0: return [4 /*yield*/, getCertificate()];
156
161
  case 1:
157
162
  cert = _a.sent();
158
- logger_lib_1.default.debug({ cert: cert });
159
163
  privateKey = cert.privateKey;
160
164
  stringifiedCert = cert.cert
161
165
  .toString()
@@ -230,7 +234,7 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
230
234
  });
231
235
  }); };
232
236
  var getPlexoSignature = function (fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
233
- var serverResponse, plexoResponse, err_1, key, objectInPascalCase, objectBuffer, verifySignature;
237
+ var serverResponse, plexoResponse, err_1, key, objectInPascalCase, objectSorted, objectBuffer, verifySignature;
234
238
  return __generator(this, function (_a) {
235
239
  switch (_a.label) {
236
240
  case 0:
@@ -249,22 +253,17 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
249
253
  };
250
254
  return [2 /*return*/, serverResponse];
251
255
  case 3:
252
- logger_lib_1.default.debug({
253
- plexoResponse: plexoResponse
254
- });
255
- key = "-----BEGIN CERTIFICATE-----\n".concat(plexoResponse.Object.Object.Response.Key, "\n-----END CERTIFICATE-----");
256
- objectInPascalCase = utils_1.caseUtils.toPascalKeys((0, exports.canonizeJson)(response.object));
257
- objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(objectInPascalCase));
256
+ key = (0, crypto_1.createPublicKey)("-----BEGIN CERTIFICATE-----\n".concat(plexoResponse.Object.Object.Response.Key, "\n-----END CERTIFICATE-----"));
257
+ objectInPascalCase = utils_1.caseUtils.toPascalKeys(response.object);
258
+ objectSorted = sort(objectInPascalCase);
259
+ objectBuffer = Buffer.from(JSON.stringify(objectSorted));
258
260
  verifySignature = (0, crypto_1.createVerify)('SHA512')
259
261
  .update(objectBuffer)
260
- .verify(key, response.signature);
261
- logger_lib_1.default.debug({
262
- verifySignature: verifySignature,
263
- });
262
+ .verify(key, response.signature, 'base64');
264
263
  serverResponse = {
265
264
  response: response.object.object,
266
265
  resultCode: verifySignature ? __1.ResultCodes.Ok : __1.ResultCodes.InvalidSignature,
267
- errorMessage: verifySignature ? "Signature do not match" : 'Success',
266
+ errorMessage: verifySignature ? 'Success' : 'Signature do not match',
268
267
  };
269
268
  return [2 /*return*/, serverResponse];
270
269
  }
@@ -54,7 +54,7 @@ var paymentInstrumentMock = {
54
54
  issuer: issuerMock,
55
55
  supportedCurrencies: [currencyMock],
56
56
  status: IndexSDK_1.CardStatus.Ok,
57
- instrumentExpirationUTC: 1919276061,
57
+ instrumentExpirationUtc: 1919276061,
58
58
  creditLimits: [amountLimitMock],
59
59
  additionalRequirements: [timeLimitMock],
60
60
  instrumentInformation: null,
@@ -82,3 +82,4 @@ export { TransactionResult } from './TransactionResult';
82
82
  export { TransactionType } from './TransactionType';
83
83
  export { UIOptionsDto } from './UIOptionsDto';
84
84
  export { WebFormSettingsDto } from './WebFormSettingsDto';
85
+ export { PlexoErrorEnum } from '../enums/plexo-error-enum';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionCallback = exports.Transaction = exports.TokenizationSettingsDto = exports.StateObject = exports.SignedObject = exports.ServerSignedResponse = exports.ServerSignedRequest = exports.ServerSignedCallback = exports.ServerResponse = exports.ResultCodes = exports.ReserveRequest = exports.Reserve = exports.ReferenceType = exports.Reference = exports.PaymentRequest = exports.PaymentProcessor = exports.IssuerSignedRequest = exports.IssuerRequest = exports.IssuerProcessor = exports.InstrumentWithMetadata = exports.InstrumentCallback = exports.InclusionType = exports.IdentificationType = exports.GenericStateObject = exports.GenericSignedObject = exports.GenericServerSignedResponse = exports.GenericIssuerSignedRequest = exports.GenericIssuerRequest = exports.GenericClientSignedRequest = exports.GenericClientRequest = exports.FieldType = exports.FieldInfoPaymentProcessors = exports.ExpressCheckoutSettingsDto = exports.DisplayOptionsDto = exports.DeleteInstrumentRequest = exports.CodeAction = exports.ClientSignedResponse = exports.ClientSignedRequest = exports.ClientResponse = exports.ClientRequest = exports.CardTypes = exports.CardStatus = exports.CancelRequest = exports.BuiltInPagesOptionsDto = exports.BaseServerResponse = exports.AuthorizationType = exports.AuthorizationInfo = exports.Authorization = exports.ActionType = exports.BaseResponse = void 0;
4
- exports.WebFormSettingsDto = exports.UIOptionsDto = exports.TransactionType = exports.TransactionResult = void 0;
4
+ exports.PlexoErrorEnum = exports.WebFormSettingsDto = exports.UIOptionsDto = exports.TransactionType = exports.TransactionResult = void 0;
5
5
  var BaseResponse_1 = require("../../handler/types/BaseResponse");
6
6
  Object.defineProperty(exports, "BaseResponse", { enumerable: true, get: function () { return BaseResponse_1.BaseResponse; } });
7
7
  var ActionType_1 = require("./ActionType");
@@ -110,3 +110,5 @@ var UIOptionsDto_1 = require("./UIOptionsDto");
110
110
  Object.defineProperty(exports, "UIOptionsDto", { enumerable: true, get: function () { return UIOptionsDto_1.UIOptionsDto; } });
111
111
  var WebFormSettingsDto_1 = require("./WebFormSettingsDto");
112
112
  Object.defineProperty(exports, "WebFormSettingsDto", { enumerable: true, get: function () { return WebFormSettingsDto_1.WebFormSettingsDto; } });
113
+ var plexo_error_enum_1 = require("../enums/plexo-error-enum");
114
+ Object.defineProperty(exports, "PlexoErrorEnum", { enumerable: true, get: function () { return plexo_error_enum_1.PlexoErrorEnum; } });
@@ -9,7 +9,7 @@ export declare type PaymentInstrument = {
9
9
  issuer: IssuerInfo;
10
10
  supportedCurrencies: Currency[];
11
11
  status: CardStatus;
12
- instrumentExpirationUTC: number;
12
+ instrumentExpirationUtc: number;
13
13
  anonInstrumentUsageTimeLimit?: number;
14
14
  creditLimits: AmountLimit[];
15
15
  additionalRequirements: TimeLimit[];
@@ -8,15 +8,26 @@ var specialWords = [
8
8
  { word: 'VatAmount', substitute: 'VATAmount' },
9
9
  { word: 'InstrumentExpirationUtc', substitute: 'InstrumentExpirationUTC' },
10
10
  ];
11
+ var camelCaseSpecialWords = [
12
+ {
13
+ word: 'instrumentExpirationUtc',
14
+ substitute: 'instrumentExpirationUTC',
15
+ },
16
+ ];
11
17
  var toCamelKeys = function (object) {
12
18
  var parsedObject = (0, js_convert_case_1.camelKeys)(object, { recursive: true, recursiveInArray: true });
19
+ camelCaseSpecialWords.forEach(function (specialWord) {
20
+ if (JSON.stringify(parsedObject).includes(specialWord.word)) {
21
+ substituteWordRecursively(parsedObject, specialWord.word, specialWord.substitute);
22
+ }
23
+ });
13
24
  return parsedObject;
14
25
  };
15
26
  var substituteWordRecursively = function (theParsedObject, word, substitute) {
16
27
  var deleteObject = function (obj, key) {
17
28
  delete obj[key];
18
29
  };
19
- if (typeof theParsedObject === 'object') {
30
+ if (theParsedObject && typeof theParsedObject === 'object') {
20
31
  Object.keys(theParsedObject).map(function (key) {
21
32
  if (key === word) {
22
33
  Object.defineProperty(theParsedObject, substitute, Object.getOwnPropertyDescriptor(theParsedObject, word) || '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@houlak/plexo-sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Node SDK for Plexo payment services",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,4 +0,0 @@
1
- export declare class BuiltInPagesOptionsDto {
2
- checkoutSuccessPage?: boolean;
3
- checkoutErrorPage?: boolean;
4
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuiltInPagesOptionsDto = void 0;
4
- var BuiltInPagesOptionsDto = /** @class */ (function () {
5
- function BuiltInPagesOptionsDto() {
6
- }
7
- return BuiltInPagesOptionsDto;
8
- }());
9
- exports.BuiltInPagesOptionsDto = BuiltInPagesOptionsDto;
@@ -1,7 +0,0 @@
1
- export declare class DisplayOptionsDto {
2
- titles?: boolean;
3
- details?: boolean;
4
- footer?: boolean;
5
- logo?: boolean;
6
- accessibility?: boolean;
7
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DisplayOptionsDto = void 0;
4
- var DisplayOptionsDto = /** @class */ (function () {
5
- function DisplayOptionsDto() {
6
- }
7
- return DisplayOptionsDto;
8
- }());
9
- exports.DisplayOptionsDto = DisplayOptionsDto;
@@ -1,6 +0,0 @@
1
- import { BuiltInPagesOptionsDto } from './BuiltInPagesOptionsDto';
2
- import { DisplayOptionsDto } from './DisplayOptionsDto';
3
- export declare class ExpressCheckoutSettingsDto {
4
- displayOptionsDto?: DisplayOptionsDto;
5
- builtInPages?: BuiltInPagesOptionsDto;
6
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExpressCheckoutSettingsDto = void 0;
4
- var ExpressCheckoutSettingsDto = /** @class */ (function () {
5
- function ExpressCheckoutSettingsDto() {
6
- }
7
- return ExpressCheckoutSettingsDto;
8
- }());
9
- exports.ExpressCheckoutSettingsDto = ExpressCheckoutSettingsDto;
@@ -1,4 +0,0 @@
1
- import { DisplayOptionsDto } from './DisplayOptionsDto';
2
- export declare class TokenizationSettingsDto {
3
- display?: DisplayOptionsDto;
4
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenizationSettingsDto = void 0;
4
- var TokenizationSettingsDto = /** @class */ (function () {
5
- function TokenizationSettingsDto() {
6
- }
7
- return TokenizationSettingsDto;
8
- }());
9
- exports.TokenizationSettingsDto = TokenizationSettingsDto;
@@ -1,7 +0,0 @@
1
- export declare class UIOptionsDto {
2
- colors: any;
3
- theme: string;
4
- autoDarkTheme: boolean;
5
- logoURL: string;
6
- constructor(colors: any, theme: string, autoDarkTheme: boolean, logoURL: string);
7
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UIOptionsDto = void 0;
4
- var UIOptionsDto = /** @class */ (function () {
5
- function UIOptionsDto(colors, theme, autoDarkTheme, logoURL) {
6
- this.colors = colors;
7
- this.theme = theme;
8
- this.autoDarkTheme = autoDarkTheme;
9
- this.logoURL = logoURL;
10
- }
11
- return UIOptionsDto;
12
- }());
13
- exports.UIOptionsDto = UIOptionsDto;
@@ -1,8 +0,0 @@
1
- import { ExpressCheckoutSettingsDto } from './ExpressCheckoutSettingsDto';
2
- import { TokenizationSettingsDto } from './TokenizationSettingsDto';
3
- import { UIOptionsDto } from './UIOptionsDto';
4
- export declare class WebFormSettingsDto {
5
- ui?: UIOptionsDto;
6
- expressCheckout?: ExpressCheckoutSettingsDto;
7
- tokenization?: TokenizationSettingsDto;
8
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebFormSettingsDto = void 0;
4
- var WebFormSettingsDto = /** @class */ (function () {
5
- function WebFormSettingsDto() {
6
- }
7
- return WebFormSettingsDto;
8
- }());
9
- exports.WebFormSettingsDto = WebFormSettingsDto;