@miden-npm/react 2.0.0 → 2.0.2
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 +61 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -23
- 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 = {
|
|
@@ -2285,7 +2302,7 @@ function BzpCheckoutIframe({
|
|
|
2285
2302
|
email: "",
|
|
2286
2303
|
phoneNumber: "",
|
|
2287
2304
|
narration: "",
|
|
2288
|
-
redirectUrl: "
|
|
2305
|
+
redirectUrl: ""
|
|
2289
2306
|
},
|
|
2290
2307
|
onError
|
|
2291
2308
|
}) {
|
|
@@ -2372,7 +2389,7 @@ function BzpCheckoutButton({
|
|
|
2372
2389
|
email: "",
|
|
2373
2390
|
phoneNumber: "",
|
|
2374
2391
|
narration: "",
|
|
2375
|
-
redirectUrl: "
|
|
2392
|
+
redirectUrl: ""
|
|
2376
2393
|
},
|
|
2377
2394
|
mode = "redirect",
|
|
2378
2395
|
onError
|
|
@@ -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 || "https://sandbox-merchant.buzapay.com/account/three-ds-status",
|
|
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)
|
|
@@ -3783,7 +3821,7 @@ function BzpCheckoutCard({
|
|
|
3783
3821
|
email: "",
|
|
3784
3822
|
phoneNumber: "",
|
|
3785
3823
|
narration: "",
|
|
3786
|
-
redirectUrl: "
|
|
3824
|
+
redirectUrl: ""
|
|
3787
3825
|
},
|
|
3788
3826
|
onPaymentAuthorized,
|
|
3789
3827
|
onError
|
|
@@ -3951,7 +3989,7 @@ function MidenCheckoutIframe({
|
|
|
3951
3989
|
email: "",
|
|
3952
3990
|
phoneNumber: "",
|
|
3953
3991
|
narration: "",
|
|
3954
|
-
redirectUrl: "
|
|
3992
|
+
redirectUrl: ""
|
|
3955
3993
|
},
|
|
3956
3994
|
onError
|
|
3957
3995
|
}) {
|
|
@@ -4038,7 +4076,7 @@ function MidenCheckoutButton({
|
|
|
4038
4076
|
email: "",
|
|
4039
4077
|
phoneNumber: "",
|
|
4040
4078
|
narration: "",
|
|
4041
|
-
redirectUrl: "
|
|
4079
|
+
redirectUrl: ""
|
|
4042
4080
|
},
|
|
4043
4081
|
mode = "redirect",
|
|
4044
4082
|
onError
|
|
@@ -4121,7 +4159,7 @@ function MidenCheckoutCard({
|
|
|
4121
4159
|
email: "",
|
|
4122
4160
|
phoneNumber: "",
|
|
4123
4161
|
narration: "",
|
|
4124
|
-
redirectUrl: "
|
|
4162
|
+
redirectUrl: ""
|
|
4125
4163
|
},
|
|
4126
4164
|
onPaymentAuthorized,
|
|
4127
4165
|
onError
|