@miden-npm/react 2.1.3 → 2.1.5

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 CHANGED
@@ -1700,7 +1700,7 @@ function BaseCard({
1700
1700
  onClose,
1701
1701
  caller = "buzapay"
1702
1702
  }) {
1703
- return caller === "buzapay" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "checkout-card-miden w-full h-screen flex flex-col items-center justify-center text-white", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-1/2", children: [
1703
+ return caller === "buzapay" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "checkout-card-miden w-full h-screen flex flex-col items-center justify-center text-white", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-[95%] sm:w-[85%] md:w-[70%] lg:w-[60%] xl:w-1/2", children: [
1704
1704
  showBackButton && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BaseBack, { back: () => onBack?.() }),
1705
1705
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex gap-2 w-full", children: [
1706
1706
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-8 w-full", children: [
@@ -1714,12 +1714,12 @@ function BaseCard({
1714
1714
  "div",
1715
1715
  {
1716
1716
  onClick: onClose,
1717
- className: "close-icon flex flex-col items-center justify-center self-start cursor-pointer hover:bg-gray-500",
1717
+ className: "hidden sm:flex close-icon flex-col items-center justify-center self-start cursor-pointer hover:bg-gray-500",
1718
1718
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-white", children: "x" })
1719
1719
  }
1720
1720
  )
1721
1721
  ] })
1722
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "checkout-card-miden w-full h-screen flex flex-col items-center justify-center text-white", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-1/2", children: [
1722
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "checkout-card-miden w-full h-screen flex flex-col items-center justify-center text-white", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-[95%] sm:w-[85%] md:w-[70%] lg:w-[60%] xl:w-1/2", children: [
1723
1723
  showBackButton && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BaseBack, { back: () => onBack?.() }),
1724
1724
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex gap-2 w-full", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-8 w-full", children: [
1725
1725
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "bg-white rounded-xl", children }),
@@ -2896,7 +2896,7 @@ function PayByCard({
2896
2896
  cardNo: "required|num_spaces",
2897
2897
  expireDate: "required",
2898
2898
  cvv: "required|numeric",
2899
- cardPin: ""
2899
+ cardPin: cardType === "Verve" ? "required" : ""
2900
2900
  // optional unless Verve
2901
2901
  };
2902
2902
  const formatAmountHandler = formatAmount(
@@ -3149,11 +3149,11 @@ function PayByCard({
3149
3149
  setIsMakingPayment(false);
3150
3150
  return;
3151
3151
  }
3152
- if (response && response.message) {
3153
- setMessage(response.message);
3154
- onError?.({
3155
- errorMessage: response.message
3156
- });
3152
+ if (response && !response.isSuccessful && caller === "miden") {
3153
+ onError?.({ errorMessage: response.responseMessage });
3154
+ }
3155
+ if (response && response.message && caller === "buzapay") {
3156
+ onError?.({ errorMessage: response.message });
3157
3157
  }
3158
3158
  setIsMakingPayment(false);
3159
3159
  } catch (err) {
@@ -3323,7 +3323,7 @@ function PayByCard({
3323
3323
  validationError: billingErrors.address2 ?? ""
3324
3324
  }
3325
3325
  ) }),
3326
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3326
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3327
3327
  BaseSelect,
3328
3328
  {
3329
3329
  label: "Select Country",
@@ -3348,8 +3348,8 @@ function PayByCard({
3348
3348
  },
3349
3349
  validationError: billingErrors.country ?? ""
3350
3350
  }
3351
- ),
3352
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3351
+ ) }),
3352
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3353
3353
  BaseSelect,
3354
3354
  {
3355
3355
  label: "Select State",
@@ -3365,8 +3365,8 @@ function PayByCard({
3365
3365
  },
3366
3366
  validationError: billingErrors.state ?? ""
3367
3367
  }
3368
- ),
3369
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3368
+ ) }),
3369
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3370
3370
  BaseInput,
3371
3371
  {
3372
3372
  label: "City",
@@ -3380,8 +3380,8 @@ function PayByCard({
3380
3380
  },
3381
3381
  validationError: billingErrors.city ?? ""
3382
3382
  }
3383
- ),
3384
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3383
+ ) }),
3384
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2 sm:col-span-1", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3385
3385
  BaseInput,
3386
3386
  {
3387
3387
  label: "Postal Code",
@@ -3395,7 +3395,7 @@ function PayByCard({
3395
3395
  },
3396
3396
  validationError: billingErrors.postalCode ?? ""
3397
3397
  }
3398
- ),
3398
+ ) }),
3399
3399
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3400
3400
  BaseInput,
3401
3401
  {
@@ -3463,10 +3463,10 @@ function PayByCard({
3463
3463
  label: "Card Number",
3464
3464
  required: true,
3465
3465
  rules: ["numeric"],
3466
- mask: "0000 0000 0000 0000",
3466
+ mask: "0000 0000 0000 0000 000",
3467
3467
  placeholder: "0000 0000 0000 0000",
3468
3468
  value: payForm.cardNo,
3469
- preventPaste: false,
3469
+ preventPaste: true,
3470
3470
  onChange: (e) => {
3471
3471
  setPayForm({ ...payForm, cardNo: e });
3472
3472
  if (payErrors.cardNo)
@@ -3617,11 +3617,19 @@ var PayByTransfer = ({
3617
3617
  caller
3618
3618
  );
3619
3619
  if (response?.isSuccessful) {
3620
- setPaymentAccountDetails(response);
3620
+ setPaymentAccountDetails(
3621
+ caller === "buzapay" ? response.data : response
3622
+ );
3621
3623
  startTimer();
3622
3624
  setMessage("Virtual account generated successfully for payment.");
3623
3625
  setIsMakingPayment(true);
3624
3626
  setFormIndex(1);
3627
+ } else {
3628
+ setIsMakingPayment(false);
3629
+ setMessage("Payment failed.");
3630
+ onError?.({
3631
+ errorMessage: "Payment failed."
3632
+ });
3625
3633
  }
3626
3634
  } catch (err) {
3627
3635
  setIsMakingPayment(false);
@@ -3643,10 +3651,12 @@ var PayByTransfer = ({
3643
3651
  caller
3644
3652
  );
3645
3653
  if (response?.isSuccessful) {
3646
- setPaymentReferenceDetails(response.data);
3647
- const made = response.data?.paymentStatus === "Payment Received";
3654
+ setPaymentReferenceDetails(
3655
+ caller === "buzapay" ? response.data : response
3656
+ );
3657
+ const made = paymentReferenceDetails?.paymentStatus === "Payment Received";
3648
3658
  setPaymentMade(made);
3649
- const noServerStatus = response.data?.finalTransactionStatus == null || response.data?.paymentStatus == null;
3659
+ const noServerStatus = paymentReferenceDetails?.finalTransactionStatus == null || paymentReferenceDetails?.paymentStatus == null;
3650
3660
  if (noServerStatus) {
3651
3661
  if (isConfirmCall) {
3652
3662
  setMessage("Transaction not confirmed !!");
@@ -3655,7 +3665,7 @@ var PayByTransfer = ({
3655
3665
  setPaymentReferenceStatus("pending");
3656
3666
  onPaymentAuthorized?.({
3657
3667
  paymentId: transactionReference,
3658
- paymentDate: response?.data?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3668
+ paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3659
3669
  paymentStatus: "pending",
3660
3670
  message
3661
3671
  });
@@ -3663,18 +3673,18 @@ var PayByTransfer = ({
3663
3673
  setPaymentReferenceStatus("confirmed");
3664
3674
  onPaymentAuthorized?.({
3665
3675
  paymentId: transactionReference,
3666
- paymentDate: response?.data?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3676
+ paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3667
3677
  paymentStatus: "confirmed",
3668
3678
  message
3669
3679
  });
3670
3680
  }
3671
- } else if (response.data?.finalTransactionStatus === "Success" || response.data?.paymentStatus === "Received" || response.data?.paymentStatus === "Payment Received") {
3681
+ } else if (paymentReferenceDetails?.finalTransactionStatus === "Success" || paymentReferenceDetails?.paymentStatus === "Received" || paymentReferenceDetails?.paymentStatus === "Payment Received") {
3672
3682
  setPaymentReferenceStatus("confirmed");
3673
3683
  setIsPaymentConfirmed(true);
3674
3684
  setMessage("Transaction confirmed !!");
3675
3685
  onPaymentAuthorized?.({
3676
3686
  paymentId: transactionReference,
3677
- paymentDate: response?.data?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3687
+ paymentDate: paymentReferenceDetails?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3678
3688
  paymentStatus: "confirmed",
3679
3689
  message
3680
3690
  });
@@ -3684,7 +3694,7 @@ var PayByTransfer = ({
3684
3694
  setMessage(response.responseMessage || "");
3685
3695
  onPaymentAuthorized?.({
3686
3696
  paymentId: transactionReference,
3687
- paymentDate: null,
3697
+ paymentDate: (/* @__PURE__ */ new Date()).toISOString(),
3688
3698
  paymentStatus: "used",
3689
3699
  message
3690
3700
  });
@@ -4433,7 +4443,7 @@ function BzpCheckoutCard({
4433
4443
  {
4434
4444
  className: checkoutState === "SUCCESS" || checkoutState === "USED" && paymentType === "BANK_TRANSFER" ? "col-span-3" : "col-span-2",
4435
4445
  children: [
4436
- checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex items-center justify-between px-12 py-8", children: [
4446
+ checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-6 sm:flex-row sm:items-center justify-between p-6 sm:px-10 sm:py-8", children: [
4437
4447
  paymentObject.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4438
4448
  BaseImage,
4439
4449
  {
@@ -4452,15 +4462,15 @@ function BzpCheckoutCard({
4452
4462
  }
4453
4463
  ),
4454
4464
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-1", children: [
4455
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-body-2xs font-regular text-sub-copy text-right", children: paymentObject.merchantName }),
4456
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "text-body-2xs font-regular text-sub-copy text-right", children: [
4465
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-body-2xs font-regular text-sub-copy sm:text-right", children: paymentObject.merchantName }),
4466
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "text-body-2xs font-regular text-sub-copy sm:text-right", children: [
4457
4467
  "Pay:",
4458
4468
  " ",
4459
4469
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "text-orange-500 font-extrabold", children: formatAmount(paymentObject.amount, paymentObject.currency) })
4460
4470
  ] })
4461
4471
  ] })
4462
4472
  ] }),
4463
- checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "max-h-[32rem] overflow-y-scroll px-10 pb-10 pt-2", children: paymentType === "CARD" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4473
+ checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "max-h-[32rem] overflow-y-scroll px-6 sm:px-10 pb-10 pt-2", children: paymentType === "CARD" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4464
4474
  PayByCard,
4465
4475
  {
4466
4476
  secretKey,
@@ -4795,7 +4805,7 @@ function MidenCheckoutCard({
4795
4805
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(IconMidenLogo, {}),
4796
4806
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(IconClose, { color: "black", className: "cursor-pointer" })
4797
4807
  ] }),
4798
- checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "px-14 pt-4 pb-8 flex flex-col gap-6 max-h-[32rem] overflow-y-scroll", children: [
4808
+ checkoutState === "PENDING" && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "px-6 md:px-10 lg:px-14 pt-4 pb-8 flex flex-col gap-6 max-h-[32rem] overflow-y-scroll", children: [
4799
4809
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex items-center justify-between py-3 px-4 bg-[#F8FDFF] border border-[#DAE4E8] rounded-lg", children: [
4800
4810
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4801
4811
  BaseLabelInfo,