@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.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
- const payload = {
2523
- customerId: paymentObject?.email || payForm.customerName || "",
2524
- amount: String(paymentObject?.amount ?? ""),
2525
- currency: paymentObject?.currency || "USD",
2526
- narration: paymentObject?.narration || "Test transaction",
2527
- encryptedCardDetails: encryptedCardDetails.requestParam,
2528
- billingDetails,
2529
- redirectUrl: paymentObject?.redirectUrl || "",
2530
- paymentReference: transactionReference,
2531
- isCheckout: true
2532
- };
2533
- const request = { ...payload, merchantId: secretKey };
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: true,
2916
+ preventPaste: false,
2879
2917
  onChange: (e) => {
2880
2918
  setPayForm({ ...payForm, cardNo: e });
2881
2919
  if (payErrors.cardNo)