@7365admin1/core 3.34.4-staging.20 → 3.34.4-staging.21
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/index.js +45 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64503,34 +64503,62 @@ var import_axios3 = __toESM(require("axios"));
|
|
|
64503
64503
|
|
|
64504
64504
|
// src/utils/payment-signature.util.ts
|
|
64505
64505
|
var crypto3 = __toESM(require("crypto"));
|
|
64506
|
+
function hasOwn(obj, key) {
|
|
64507
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
64508
|
+
}
|
|
64509
|
+
function sha512(input) {
|
|
64510
|
+
return crypto3.createHash("sha512").update(input).digest("hex");
|
|
64511
|
+
}
|
|
64512
|
+
function assertSecret(secretKey) {
|
|
64513
|
+
if (!secretKey) {
|
|
64514
|
+
throw new Error("Payment signature: missing secret key.");
|
|
64515
|
+
}
|
|
64516
|
+
}
|
|
64506
64517
|
function paymentSignature(params, secretKey) {
|
|
64507
|
-
|
|
64518
|
+
assertSecret(secretKey);
|
|
64519
|
+
const fieldOrder = [
|
|
64520
|
+
"mid",
|
|
64521
|
+
"order_id",
|
|
64522
|
+
"payment_type",
|
|
64523
|
+
"amount",
|
|
64524
|
+
"ccy",
|
|
64525
|
+
"card_no",
|
|
64526
|
+
"exp_date",
|
|
64527
|
+
"cvv2"
|
|
64528
|
+
];
|
|
64508
64529
|
let concatenated = "";
|
|
64509
64530
|
fieldOrder.forEach((v) => {
|
|
64510
|
-
if (!params
|
|
64531
|
+
if (!hasOwn(params, v)) {
|
|
64511
64532
|
return;
|
|
64512
|
-
}
|
|
64513
|
-
|
|
64533
|
+
}
|
|
64534
|
+
const raw = String(params[v] ?? "");
|
|
64535
|
+
if (v === "cvv2") {
|
|
64536
|
+
concatenated += raw.slice(-1);
|
|
64514
64537
|
} else if (v === "card_no") {
|
|
64515
|
-
concatenated +=
|
|
64538
|
+
concatenated += raw.substring(0, 6) + raw.slice(-4);
|
|
64516
64539
|
} else {
|
|
64517
|
-
concatenated +=
|
|
64540
|
+
concatenated += raw;
|
|
64518
64541
|
}
|
|
64519
64542
|
});
|
|
64520
64543
|
concatenated += secretKey;
|
|
64521
|
-
|
|
64522
|
-
return signature;
|
|
64544
|
+
return sha512(concatenated);
|
|
64523
64545
|
}
|
|
64524
64546
|
function genericSignature(params, secretKey) {
|
|
64525
|
-
|
|
64547
|
+
assertSecret(secretKey);
|
|
64548
|
+
const paramsCopy = {
|
|
64549
|
+
...params
|
|
64550
|
+
};
|
|
64526
64551
|
delete paramsCopy["signature"];
|
|
64527
|
-
const
|
|
64528
|
-
|
|
64529
|
-
|
|
64530
|
-
|
|
64531
|
-
|
|
64532
|
-
|
|
64533
|
-
|
|
64552
|
+
const concatenated = Object.keys(paramsCopy).sort().map((key) => {
|
|
64553
|
+
const value = paramsCopy[key];
|
|
64554
|
+
if (value !== null && typeof value === "object") {
|
|
64555
|
+
throw new Error(
|
|
64556
|
+
`Payment signature: non-primitive value for field "${key}".`
|
|
64557
|
+
);
|
|
64558
|
+
}
|
|
64559
|
+
return String(value ?? "");
|
|
64560
|
+
}).join("") + secretKey;
|
|
64561
|
+
return sha512(concatenated);
|
|
64534
64562
|
}
|
|
64535
64563
|
|
|
64536
64564
|
// src/repositories/reddot-payment.repository.ts
|
|
@@ -64953,7 +64981,7 @@ var useRedDotPaymentSvc = () => {
|
|
|
64953
64981
|
};
|
|
64954
64982
|
if (!process.env.MERCHANT_ENQUIRY) {
|
|
64955
64983
|
throw new Error(
|
|
64956
|
-
"
|
|
64984
|
+
"MERCHANT_ENQUIRY environment variable is not defined."
|
|
64957
64985
|
);
|
|
64958
64986
|
}
|
|
64959
64987
|
const url = process.env.MERCHANT_ENQUIRY;
|