@houlak/plexo-sdk 0.1.13 → 0.1.15
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/lib/handler/PlexoHandler.js +14 -12
- package/lib/handler/services/evaluator.service.js +6 -6
- package/lib/sdk/PaymentGatewayMock.js +13 -13
- package/lib/sdk/helpers/signature/signatureHelper.js +0 -4
- package/lib/sdk/mocks/mocks.js +28 -28
- package/lib/sdk/models/Transaction.d.ts +24 -24
- package/lib/sdk/models/Transaction.js +18 -18
- package/lib/sdk/models/TransactionInfo.d.ts +9 -9
- package/package.json +1 -1
|
@@ -204,23 +204,25 @@ var Purchase = function (purchase) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
204
204
|
var UnwrapInstrumentCallback = function (instrumentCallback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
205
205
|
var instrumentCallbackResponse;
|
|
206
206
|
return __generator(this, function (_a) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
instrumentCallbackResponse = {
|
|
208
|
+
response: instrumentCallback.Object.object,
|
|
209
|
+
resultCode: index_1.ResultCodes.Ok,
|
|
210
|
+
errorMessage: 'Success',
|
|
211
|
+
};
|
|
212
|
+
// await paymentGatewayClient.UnwrapInstrumentCallbackAsync(instrumentCallback)
|
|
213
|
+
return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(instrumentCallback, instrumentCallbackResponse)];
|
|
213
214
|
});
|
|
214
215
|
}); };
|
|
215
216
|
var UnwrapTransactionCallback = function (transactionCallback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
217
|
var transactionCallbackResponse;
|
|
217
218
|
return __generator(this, function (_a) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
transactionCallbackResponse = {
|
|
220
|
+
response: transactionCallback.Object.object,
|
|
221
|
+
resultCode: index_1.ResultCodes.Ok,
|
|
222
|
+
errorMessage: 'Success',
|
|
223
|
+
};
|
|
224
|
+
// await paymentGatewayClient.UnwrapTransactionCallbackAsync(transactionCallback)
|
|
225
|
+
return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(transactionCallback, transactionCallbackResponse)];
|
|
224
226
|
});
|
|
225
227
|
}); };
|
|
226
228
|
var SignInstrumentCallback = function (instrumentCallback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -44,20 +44,20 @@ var BaseResponse_1 = require("../types/BaseResponse");
|
|
|
44
44
|
var getTransactionStatus = function (transaction, transactionType) {
|
|
45
45
|
if (transactionType === index_1.TransactionType.Cancel) {
|
|
46
46
|
return {
|
|
47
|
-
status: index_1.TransactionResult[+transaction.
|
|
48
|
-
transactionResultText: transaction.
|
|
47
|
+
status: index_1.TransactionResult[+transaction.Transactions.Cancel.Status],
|
|
48
|
+
transactionResultText: transaction.Transactions.Cancel.TransactionResultText,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
if (transactionType === index_1.TransactionType.Reserve) {
|
|
52
52
|
return {
|
|
53
|
-
status: index_1.TransactionResult[+transaction.
|
|
54
|
-
transactionResultText: transaction.
|
|
53
|
+
status: index_1.TransactionResult[+transaction.Transactions.Reserve.Status],
|
|
54
|
+
transactionResultText: transaction.Transactions.Reserve.TransactionResultText,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
if (transactionType === index_1.TransactionType.Purchase) {
|
|
58
58
|
return {
|
|
59
|
-
status: index_1.TransactionResult[+transaction.
|
|
60
|
-
transactionResultText: transaction.
|
|
59
|
+
status: index_1.TransactionResult[+transaction.Transactions.Purchase.Status],
|
|
60
|
+
transactionResultText: transaction.Transactions.Purchase.TransactionResultText,
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
};
|
|
@@ -184,10 +184,10 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
184
184
|
return __generator(this, function (_a) {
|
|
185
185
|
return [2 /*return*/, {
|
|
186
186
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
187
|
-
response: __assign(__assign({}, mocks_1.mocks.transactionMock), {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
response: __assign(__assign({}, mocks_1.mocks.transactionMock), { Transactions: {
|
|
188
|
+
Purchase: mocks_1.mocks.transactionMock.Transactions.Purchase,
|
|
189
|
+
Reserve: mocks_1.mocks.transactionMock.Transactions.Reserve,
|
|
190
|
+
Cancel: __assign(__assign({}, mocks_1.mocks.transactionMock.Transactions.Cancel), { ClientReferenceId: cancel.clientReferenceId }),
|
|
191
191
|
} }),
|
|
192
192
|
}];
|
|
193
193
|
});
|
|
@@ -198,7 +198,7 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
198
198
|
return __generator(this, function (_a) {
|
|
199
199
|
return [2 /*return*/, {
|
|
200
200
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
201
|
-
response: __assign(__assign({}, mocks_1.mocks.transactionMock), {
|
|
201
|
+
response: __assign(__assign({}, mocks_1.mocks.transactionMock), { PaymentCode: __assign(__assign({}, mocks_1.mocks.transactionMock.PaymentCode), { code: request.code }) }),
|
|
202
202
|
}];
|
|
203
203
|
});
|
|
204
204
|
});
|
|
@@ -208,10 +208,10 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
208
208
|
return __generator(this, function (_a) {
|
|
209
209
|
return [2 /*return*/, {
|
|
210
210
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
211
|
-
response: __assign(__assign({}, mocks_1.mocks.transactionMock), {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
211
|
+
response: __assign(__assign({}, mocks_1.mocks.transactionMock), { Amount: payment.financialInclusion.billedAmount, Transactions: {
|
|
212
|
+
Purchase: mocks_1.mocks.transactionMock.Transactions.Purchase,
|
|
213
|
+
Reserve: __assign(__assign({}, mocks_1.mocks.transactionMock.Transactions.Reserve), { ClientReferenceId: payment.clientReferenceId, ExpirationUTC: payment.expirationUTC }),
|
|
214
|
+
Cancel: mocks_1.mocks.transactionMock.Transactions.Cancel,
|
|
215
215
|
} }),
|
|
216
216
|
}];
|
|
217
217
|
});
|
|
@@ -262,10 +262,10 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
262
262
|
return __generator(this, function (_a) {
|
|
263
263
|
return [2 /*return*/, {
|
|
264
264
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
265
|
-
response: __assign(__assign({}, mocks_1.mocks.transactionMock), {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
response: __assign(__assign({}, mocks_1.mocks.transactionMock), { Amount: payment.financialInclusion.billedAmount, Currency: __assign(__assign({}, mocks_1.mocks.transactionMock.Currency), { currencyId: payment.currencyId }), Transactions: {
|
|
266
|
+
Purchase: __assign(__assign({}, mocks_1.mocks.transactionMock.Transactions.Purchase), { ClientReferenceId: payment.clientReferenceId }),
|
|
267
|
+
Reserve: mocks_1.mocks.transactionMock.Transactions.Reserve,
|
|
268
|
+
Cancel: mocks_1.mocks.transactionMock.Transactions.Cancel,
|
|
269
269
|
} }),
|
|
270
270
|
}];
|
|
271
271
|
});
|
|
@@ -268,11 +268,9 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
|
|
|
268
268
|
switch (_a.label) {
|
|
269
269
|
case 0:
|
|
270
270
|
_a.trys.push([0, 2, , 3]);
|
|
271
|
-
logger_lib_1.default.info("FINGERPRINT TO GET PLEXO SIGNATURE --> ".concat(fingerprint));
|
|
272
271
|
return [4 /*yield*/, getPlexoKey(fingerprint)];
|
|
273
272
|
case 1:
|
|
274
273
|
plexoResponse = _a.sent();
|
|
275
|
-
logger_lib_1.default.info("FINGERPRINT RESPONSE");
|
|
276
274
|
return [3 /*break*/, 3];
|
|
277
275
|
case 2:
|
|
278
276
|
err_1 = _a.sent();
|
|
@@ -285,12 +283,10 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
|
|
|
285
283
|
return [2 /*return*/, serverResponse];
|
|
286
284
|
case 3:
|
|
287
285
|
key = "-----BEGIN CERTIFICATE-----\n".concat(plexoResponse.Object.Object.Response.Key, "\n-----END CERTIFICATE-----");
|
|
288
|
-
logger_lib_1.default.info("KEY -----> ".concat(key));
|
|
289
286
|
objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(response.Object));
|
|
290
287
|
verifySignature = (0, crypto_1.createVerify)('SHA512')
|
|
291
288
|
.update(objectBuffer)
|
|
292
289
|
.verify(key, response.Signature, 'base64');
|
|
293
|
-
logger_lib_1.default.info("VERIFY BUFFER -----> ".concat(verifySignature));
|
|
294
290
|
serverResponse = {
|
|
295
291
|
response: response.Object.object,
|
|
296
292
|
resultCode: verifySignature ? __1.ResultCodes.Ok : __1.ResultCodes.InvalidSignature,
|
package/lib/sdk/mocks/mocks.js
CHANGED
|
@@ -66,14 +66,14 @@ var financialInclusionMock = {
|
|
|
66
66
|
lawNumber: IndexSDK_1.InclusionType.Law17934,
|
|
67
67
|
};
|
|
68
68
|
var transactionInfoMock = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
ClientReferenceId: (0, crypto_1.randomUUID)(),
|
|
70
|
+
ClientMetadata: 'metadata',
|
|
71
|
+
Status: IndexSDK_1.TransactionResult.Ok,
|
|
72
|
+
TransactionCode: 1900,
|
|
73
|
+
TransactionResultText: 'OK',
|
|
74
|
+
ExecutionDateUTC: 1919276061,
|
|
75
|
+
Authorization: 'AuthorizationMock',
|
|
76
|
+
Ticket: 'TicketMock',
|
|
77
77
|
};
|
|
78
78
|
var commerceMock = {
|
|
79
79
|
commerceId: 1891,
|
|
@@ -97,27 +97,27 @@ var sessionMock = {
|
|
|
97
97
|
expirationUTC: 1919276061,
|
|
98
98
|
};
|
|
99
99
|
var transactionMock = {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
TransactionId: (0, crypto_1.randomUUID)(),
|
|
101
|
+
Commerce: commerceMock,
|
|
102
|
+
InstrumentToken: 'Token',
|
|
103
|
+
InstrumentName: 'MasterMock',
|
|
104
|
+
Issuer: issuerMock,
|
|
105
|
+
Amount: 100,
|
|
106
|
+
Installments: 1,
|
|
107
|
+
Currency: currencyMock,
|
|
108
|
+
IsAnonymous: true,
|
|
109
|
+
CurrentState: IndexSDK_1.TransactionType.Purchase,
|
|
110
|
+
InvoiceNumber: '1',
|
|
111
|
+
FinancialInclusion: financialInclusionMock,
|
|
112
|
+
Transactions: {
|
|
113
|
+
Purchase: transactionInfoMock,
|
|
114
|
+
Reserve: transactionInfoMock,
|
|
115
|
+
Cancel: transactionInfoMock,
|
|
116
116
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
FieldInformation: [],
|
|
118
|
+
IsAsyncPayment: false,
|
|
119
|
+
PaymentCode: paymentCodeMock,
|
|
120
|
+
UtcUnixTimeExpiration: 1919276061,
|
|
121
121
|
};
|
|
122
122
|
var transactionCursorMock = {
|
|
123
123
|
start: 0,
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { PaymentCode } from './CodeAction';
|
|
2
|
-
import { Commerce } from './Commerce';
|
|
3
|
-
import { Currency } from './Currency';
|
|
1
|
+
import { PaymentCode as PaymentCodeEnum } from './CodeAction';
|
|
2
|
+
import { Commerce as CommerceModel } from './Commerce';
|
|
3
|
+
import { Currency as CurrencyEnum } from './Currency';
|
|
4
4
|
import { FinancialInclusionResult } from './FinancialInclusionResult';
|
|
5
5
|
import { IssuerInfo } from './IssuerInfo';
|
|
6
6
|
import { TransactionInfo } from './TransactionInfo';
|
|
7
7
|
import { TransactionType } from './TransactionType';
|
|
8
8
|
export declare class Transaction {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
TransactionId: string;
|
|
10
|
+
Commerce: CommerceModel;
|
|
11
|
+
InstrumentToken: string;
|
|
12
|
+
InstrumentName: string;
|
|
13
|
+
Issuer: IssuerInfo;
|
|
14
|
+
Amount: number;
|
|
15
|
+
Installments: number;
|
|
16
|
+
Currency: CurrencyEnum;
|
|
17
|
+
IsAnonymous: boolean;
|
|
18
|
+
CurrentState: TransactionType;
|
|
19
|
+
InvoiceNumber: string;
|
|
20
|
+
FinancialInclusion: FinancialInclusionResult;
|
|
21
|
+
Transactions: {
|
|
22
|
+
Purchase: TransactionInfo;
|
|
23
|
+
Cancel: TransactionInfo;
|
|
24
|
+
Reserve: TransactionInfo;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
constructor(
|
|
26
|
+
FieldInformation: any;
|
|
27
|
+
IsAsyncPayment: boolean;
|
|
28
|
+
PaymentCode: PaymentCodeEnum;
|
|
29
|
+
UtcUnixTimeExpiration: number;
|
|
30
|
+
constructor(TransactionId: string, Commerce: CommerceModel, InstrumentToken: string, InstrumentName: string, Issuer: IssuerInfo, Amount: number, Installments: number, Currency: CurrencyEnum, IsAnonymous: boolean, CurrentState: TransactionType, InvoiceNumber: string, FinancialInclusion: FinancialInclusionResult, Transactions: any, FieldInformation: any, IsAsyncPayment: boolean, PaymentCode: PaymentCodeEnum, UtcUnixTimeExpiration: number);
|
|
31
31
|
}
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Transaction = void 0;
|
|
4
4
|
var Transaction = /** @class */ (function () {
|
|
5
|
-
function Transaction(
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
5
|
+
function Transaction(TransactionId, Commerce, InstrumentToken, InstrumentName, Issuer, Amount, Installments, Currency, IsAnonymous, CurrentState, InvoiceNumber, FinancialInclusion, Transactions, FieldInformation, IsAsyncPayment, PaymentCode, UtcUnixTimeExpiration) {
|
|
6
|
+
this.TransactionId = TransactionId;
|
|
7
|
+
this.Commerce = Commerce;
|
|
8
|
+
this.InstrumentToken = InstrumentToken;
|
|
9
|
+
this.InstrumentName = InstrumentName;
|
|
10
|
+
this.Issuer = Issuer;
|
|
11
|
+
this.Amount = Amount;
|
|
12
|
+
this.Installments = Installments;
|
|
13
|
+
this.Currency = Currency;
|
|
14
|
+
this.IsAnonymous = IsAnonymous;
|
|
15
|
+
this.CurrentState = CurrentState;
|
|
16
|
+
this.InvoiceNumber = InvoiceNumber;
|
|
17
|
+
this.FinancialInclusion = FinancialInclusion;
|
|
18
|
+
this.Transactions = Transactions;
|
|
19
|
+
this.FieldInformation = FieldInformation;
|
|
20
|
+
this.IsAsyncPayment = IsAsyncPayment;
|
|
21
|
+
this.PaymentCode = PaymentCode;
|
|
22
|
+
this.UtcUnixTimeExpiration = UtcUnixTimeExpiration;
|
|
23
23
|
}
|
|
24
24
|
return Transaction;
|
|
25
25
|
}());
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TransactionResult } from './TransactionResult';
|
|
2
2
|
export declare type TransactionInfo = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
ClientReferenceId: string;
|
|
4
|
+
ClientMetadata: string;
|
|
5
|
+
Status: TransactionResult;
|
|
6
|
+
TransactionCode: number;
|
|
7
|
+
TransactionResultText: string;
|
|
8
|
+
ExecutionDateUTC: number;
|
|
9
|
+
Authorization: string;
|
|
10
|
+
Ticket: string;
|
|
11
|
+
ExpirationUTC?: number;
|
|
12
12
|
};
|