@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.cjs
CHANGED
|
@@ -124,6 +124,26 @@ var getQueryParams = (url) => {
|
|
|
124
124
|
});
|
|
125
125
|
return params;
|
|
126
126
|
};
|
|
127
|
+
function buildDeviceInformation(partial) {
|
|
128
|
+
const language = navigator.language || (navigator.languages?.[0] ?? "");
|
|
129
|
+
const tzOffsetMinutes = String((/* @__PURE__ */ new Date()).getTimezoneOffset());
|
|
130
|
+
return {
|
|
131
|
+
httpBrowserLanguage: language,
|
|
132
|
+
httpBrowserJavaEnabled: typeof navigator.javaEnabled === "function" ? navigator.javaEnabled() : false,
|
|
133
|
+
httpBrowserJavaScriptEnabled: true,
|
|
134
|
+
// if this code runs, JS is enabled
|
|
135
|
+
httpBrowserColorDepth: String(screen.colorDepth ?? ""),
|
|
136
|
+
httpBrowserScreenHeight: String(screen.height ?? ""),
|
|
137
|
+
httpBrowserScreenWidth: String(screen.width ?? ""),
|
|
138
|
+
httpBrowserTimeDifference: tzOffsetMinutes,
|
|
139
|
+
userAgentBrowserValue: navigator.userAgent ?? "",
|
|
140
|
+
deviceChannel: "BROWSER",
|
|
141
|
+
deviceIpAddress: "",
|
|
142
|
+
httpAcceptContent: language,
|
|
143
|
+
// browsers don't expose Accept header; use language as a proxy (or set app value)
|
|
144
|
+
...partial
|
|
145
|
+
};
|
|
146
|
+
}
|
|
127
147
|
|
|
128
148
|
// src/utils/api.util.ts
|
|
129
149
|
var getBaseUrl = (mode, caller) => {
|
|
@@ -447,10 +467,7 @@ async function createPaymentLink(paymentObject, environment, secretKey, caller)
|
|
|
447
467
|
} catch (error) {
|
|
448
468
|
}
|
|
449
469
|
}
|
|
450
|
-
async function authorizeCardPayment(environment, {
|
|
451
|
-
merchantId,
|
|
452
|
-
...rest
|
|
453
|
-
}, caller) {
|
|
470
|
+
async function authorizeCardPayment(environment, { merchantId, ...rest }, caller) {
|
|
454
471
|
try {
|
|
455
472
|
const baseUrl = getBaseUrl(environment, caller);
|
|
456
473
|
const apiKey = {
|
|
@@ -2564,19 +2581,40 @@ function PayByCard({
|
|
|
2564
2581
|
phoneNumber: billingForm.phoneNumber ?? ""
|
|
2565
2582
|
};
|
|
2566
2583
|
const encryptedCardDetails = encryptPayload(secretKey, cardDetails);
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2584
|
+
let payload = null;
|
|
2585
|
+
let payloadMiden = null;
|
|
2586
|
+
if (caller === "buzapay") {
|
|
2587
|
+
payload = {
|
|
2588
|
+
customerId: paymentObject?.email || payForm.customerName || "",
|
|
2589
|
+
amount: String(paymentObject?.amount ?? ""),
|
|
2590
|
+
currency: paymentObject?.currency || "USD",
|
|
2591
|
+
narration: paymentObject?.narration || "Test transaction",
|
|
2592
|
+
encryptedCardDetails: encryptedCardDetails.requestParam,
|
|
2593
|
+
billingDetails,
|
|
2594
|
+
redirectUrl: paymentObject?.redirectUrl || "",
|
|
2595
|
+
paymentReference: transactionReference,
|
|
2596
|
+
isCheckout: true
|
|
2597
|
+
};
|
|
2598
|
+
} else {
|
|
2599
|
+
const deviceInformation = buildDeviceInformation();
|
|
2600
|
+
payloadMiden = {
|
|
2601
|
+
customerId: paymentObject?.email || payForm.customerName || "",
|
|
2602
|
+
amount: String(paymentObject?.amount ?? ""),
|
|
2603
|
+
currency: paymentObject?.currency || "USD",
|
|
2604
|
+
narration: paymentObject?.narration || "Test transaction",
|
|
2605
|
+
encryptedCardDetails: encryptedCardDetails.requestParam,
|
|
2606
|
+
billingDetails,
|
|
2607
|
+
redirectUrl: paymentObject?.redirectUrl || "",
|
|
2608
|
+
paymentReference: transactionReference,
|
|
2609
|
+
isCheckout: true,
|
|
2610
|
+
postBackUrl: "",
|
|
2611
|
+
saveCard: false,
|
|
2612
|
+
deviceInformation
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
const request = caller === "buzapay" ? { ...payload, merchantId: secretKey } : { ...payloadMiden, merchantId: secretKey };
|
|
2579
2616
|
let response = await authorizeCardPayment(environment, request, caller);
|
|
2617
|
+
debugger;
|
|
2580
2618
|
if (response?.responseParam) {
|
|
2581
2619
|
response = decryptPayload(environment, response.responseParam);
|
|
2582
2620
|
}
|
|
@@ -2920,7 +2958,7 @@ function PayByCard({
|
|
|
2920
2958
|
mask: "0000 0000 0000 0000",
|
|
2921
2959
|
placeholder: "0000 0000 0000 0000",
|
|
2922
2960
|
value: payForm.cardNo,
|
|
2923
|
-
preventPaste:
|
|
2961
|
+
preventPaste: false,
|
|
2924
2962
|
onChange: (e) => {
|
|
2925
2963
|
setPayForm({ ...payForm, cardNo: e });
|
|
2926
2964
|
if (payErrors.cardNo)
|