@konplit-services/common 1.0.152 → 1.0.154
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,3 +1,4 @@
|
|
|
1
|
+
import { TRANSACTION_CHARGES_TYPE } from "../../../helper";
|
|
1
2
|
import { StreamEvent, StreamName, Subjects } from "../../subjects";
|
|
2
3
|
export interface TransactionCompletedEvent {
|
|
3
4
|
subject: Subjects.TransactionCompleted;
|
|
@@ -5,7 +6,9 @@ export interface TransactionCompletedEvent {
|
|
|
5
6
|
streamEvents: StreamEvent.Event;
|
|
6
7
|
data: {
|
|
7
8
|
merchantId: string;
|
|
9
|
+
accountId?: string;
|
|
8
10
|
transactionId: string;
|
|
11
|
+
trasactionType?: TRANSACTION_CHARGES_TYPE;
|
|
9
12
|
amount: number;
|
|
10
13
|
};
|
|
11
14
|
}
|
package/build/helper/keys.d.ts
CHANGED
|
@@ -67,4 +67,23 @@ declare const generateBase64Key: (client_id: string, secret_key: string) => stri
|
|
|
67
67
|
* @returns Base64 encoded key for BVN
|
|
68
68
|
*/
|
|
69
69
|
declare const generateBase64KeyNibssBVN: () => string;
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Interface for the input parameters required to generate the MAC.
|
|
72
|
+
*/
|
|
73
|
+
interface MACParams {
|
|
74
|
+
initiatingAmount: string;
|
|
75
|
+
initiatingCurrencyCode: string;
|
|
76
|
+
initiatingPaymentMethodCode: string;
|
|
77
|
+
terminatingAmount: string;
|
|
78
|
+
terminatingCurrencyCode: string;
|
|
79
|
+
terminatingPaymentMethodCode: string;
|
|
80
|
+
terminatingCountryCode: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Generates a MAC (Message Authentication Code) using SHA-512.
|
|
84
|
+
*
|
|
85
|
+
* @param params - An object containing the required parameters.
|
|
86
|
+
* @returns The generated MAC as a hexadecimal string.
|
|
87
|
+
*/
|
|
88
|
+
declare const generateMAC: (params: MACParams) => string;
|
|
89
|
+
export { MACParams, generateMAC, hashingKey, generateSignMD5, generateSignMD5Fedilty, authData, generateOrderId, generateBase64Key, generateSignatureCipher, generateBase64KeyNibssBVN, generateTransactionID, };
|
package/build/helper/keys.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateTransactionID = exports.generateBase64KeyNibssBVN = exports.generateSignatureCipher = exports.generateBase64Key = exports.generateOrderId = exports.authData = exports.generateSignMD5Fedilty = exports.generateSignMD5 = exports.hashingKey = void 0;
|
|
26
|
+
exports.generateTransactionID = exports.generateBase64KeyNibssBVN = exports.generateSignatureCipher = exports.generateBase64Key = exports.generateOrderId = exports.authData = exports.generateSignMD5Fedilty = exports.generateSignMD5 = exports.hashingKey = exports.generateMAC = void 0;
|
|
27
27
|
const crypto = __importStar(require("crypto"));
|
|
28
28
|
const forge = __importStar(require("node-forge"));
|
|
29
29
|
const timestamp_1 = require("./timestamp");
|
|
@@ -176,3 +176,24 @@ const generateBase64KeyNibssBVN = () => {
|
|
|
176
176
|
return Buffer.from(dataToString).toString("base64");
|
|
177
177
|
};
|
|
178
178
|
exports.generateBase64KeyNibssBVN = generateBase64KeyNibssBVN;
|
|
179
|
+
/**
|
|
180
|
+
* Generates a MAC (Message Authentication Code) using SHA-512.
|
|
181
|
+
*
|
|
182
|
+
* @param params - An object containing the required parameters.
|
|
183
|
+
* @returns The generated MAC as a hexadecimal string.
|
|
184
|
+
*/
|
|
185
|
+
const generateMAC = (params) => {
|
|
186
|
+
const { initiatingAmount, initiatingCurrencyCode, initiatingPaymentMethodCode, terminatingAmount, terminatingCurrencyCode, terminatingPaymentMethodCode, terminatingCountryCode, } = params;
|
|
187
|
+
// Concatenate all input parameters
|
|
188
|
+
const data = initiatingAmount +
|
|
189
|
+
initiatingCurrencyCode +
|
|
190
|
+
initiatingPaymentMethodCode +
|
|
191
|
+
terminatingAmount +
|
|
192
|
+
terminatingCurrencyCode +
|
|
193
|
+
terminatingPaymentMethodCode +
|
|
194
|
+
terminatingCountryCode;
|
|
195
|
+
// Create the hash using SHA-512
|
|
196
|
+
const hash = crypto.createHash("sha512").update(data, "utf8").digest("hex");
|
|
197
|
+
return hash;
|
|
198
|
+
};
|
|
199
|
+
exports.generateMAC = generateMAC;
|