@miden-npm/react 2.0.0 → 2.0.1
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.cjs +55 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -79,6 +79,26 @@ var getQueryParams = (url) => {
|
|
|
79
79
|
});
|
|
80
80
|
return params;
|
|
81
81
|
};
|
|
82
|
+
function buildDeviceInformation(partial) {
|
|
83
|
+
const language = navigator.language || (navigator.languages?.[0] ?? "");
|
|
84
|
+
const tzOffsetMinutes = String((/* @__PURE__ */ new Date()).getTimezoneOffset());
|
|
85
|
+
return {
|
|
86
|
+
httpBrowserLanguage: language,
|
|
87
|
+
httpBrowserJavaEnabled: typeof navigator.javaEnabled === "function" ? navigator.javaEnabled() : false,
|
|
88
|
+
httpBrowserJavaScriptEnabled: true,
|
|
89
|
+
// if this code runs, JS is enabled
|
|
90
|
+
httpBrowserColorDepth: String(screen.colorDepth ?? ""),
|
|
91
|
+
httpBrowserScreenHeight: String(screen.height ?? ""),
|
|
92
|
+
httpBrowserScreenWidth: String(screen.width ?? ""),
|
|
93
|
+
httpBrowserTimeDifference: tzOffsetMinutes,
|
|
94
|
+
userAgentBrowserValue: navigator.userAgent ?? "",
|
|
95
|
+
deviceChannel: "BROWSER",
|
|
96
|
+
deviceIpAddress: "",
|
|
97
|
+
httpAcceptContent: language,
|
|
98
|
+
// browsers don't expose Accept header; use language as a proxy (or set app value)
|
|
99
|
+
...partial
|
|
100
|
+
};
|
|
101
|
+
}
|
|
82
102
|
|
|
83
103
|
// src/utils/api.util.ts
|
|
84
104
|
var getBaseUrl = (mode, caller) => {
|
|
@@ -402,10 +422,7 @@ async function createPaymentLink(paymentObject, environment, secretKey, caller)
|
|
|
402
422
|
} catch (error) {
|
|
403
423
|
}
|
|
404
424
|
}
|
|
405
|
-
async function authorizeCardPayment(environment, {
|
|
406
|
-
merchantId,
|
|
407
|
-
...rest
|
|
408
|
-
}, caller) {
|
|
425
|
+
async function authorizeCardPayment(environment, { merchantId, ...rest }, caller) {
|
|
409
426
|
try {
|
|
410
427
|
const baseUrl = getBaseUrl(environment, caller);
|
|
411
428
|
const apiKey = {
|
|
@@ -2519,19 +2536,40 @@ function PayByCard({
|
|
|
2519
2536
|
phoneNumber: billingForm.phoneNumber ?? ""
|
|
2520
2537
|
};
|
|
2521
2538
|
const encryptedCardDetails = encryptPayload(secretKey, cardDetails);
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2539
|
+
let payload = null;
|
|
2540
|
+
let payloadMiden = null;
|
|
2541
|
+
if (caller === "buzapay") {
|
|
2542
|
+
payload = {
|
|
2543
|
+
customerId: paymentObject?.email || payForm.customerName || "",
|
|
2544
|
+
amount: String(paymentObject?.amount ?? ""),
|
|
2545
|
+
currency: paymentObject?.currency || "USD",
|
|
2546
|
+
narration: paymentObject?.narration || "Test transaction",
|
|
2547
|
+
encryptedCardDetails: encryptedCardDetails.requestParam,
|
|
2548
|
+
billingDetails,
|
|
2549
|
+
redirectUrl: paymentObject?.redirectUrl || "",
|
|
2550
|
+
paymentReference: transactionReference,
|
|
2551
|
+
isCheckout: true
|
|
2552
|
+
};
|
|
2553
|
+
} else {
|
|
2554
|
+
const deviceInformation = buildDeviceInformation();
|
|
2555
|
+
payloadMiden = {
|
|
2556
|
+
customerId: paymentObject?.email || payForm.customerName || "",
|
|
2557
|
+
amount: String(paymentObject?.amount ?? ""),
|
|
2558
|
+
currency: paymentObject?.currency || "USD",
|
|
2559
|
+
narration: paymentObject?.narration || "Test transaction",
|
|
2560
|
+
encryptedCardDetails: encryptedCardDetails.requestParam,
|
|
2561
|
+
billingDetails,
|
|
2562
|
+
redirectUrl: paymentObject?.redirectUrl || "",
|
|
2563
|
+
paymentReference: transactionReference,
|
|
2564
|
+
isCheckout: true,
|
|
2565
|
+
postBackUrl: "",
|
|
2566
|
+
saveCard: false,
|
|
2567
|
+
deviceInformation
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
const request = caller === "buzapay" ? { ...payload, merchantId: secretKey } : { ...payloadMiden, merchantId: secretKey };
|
|
2534
2571
|
let response = await authorizeCardPayment(environment, request, caller);
|
|
2572
|
+
debugger;
|
|
2535
2573
|
if (response?.responseParam) {
|
|
2536
2574
|
response = decryptPayload(environment, response.responseParam);
|
|
2537
2575
|
}
|
|
@@ -2875,7 +2913,7 @@ function PayByCard({
|
|
|
2875
2913
|
mask: "0000 0000 0000 0000",
|
|
2876
2914
|
placeholder: "0000 0000 0000 0000",
|
|
2877
2915
|
value: payForm.cardNo,
|
|
2878
|
-
preventPaste:
|
|
2916
|
+
preventPaste: false,
|
|
2879
2917
|
onChange: (e) => {
|
|
2880
2918
|
setPayForm({ ...payForm, cardNo: e });
|
|
2881
2919
|
if (payErrors.cardNo)
|