@miden-npm/react 0.0.7 → 0.0.9

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
@@ -82,7 +82,7 @@ var getQueryParams = (url) => {
82
82
 
83
83
  // src/utils/api.util.ts
84
84
  var getBaseUrl = (mode) => {
85
- return mode === "sandbox" ? "https://sandbox-api.midencards.io/payment-gateway-api" : "";
85
+ return mode === "sandbox" ? "https://sandbox-api.midencards.io/payment-gateway-core-api" : "";
86
86
  };
87
87
 
88
88
  // src/utils/string.util.ts
@@ -474,10 +474,12 @@ async function generateStableCoinAddress(environment, { merchantId, ...rest }) {
474
474
 
475
475
  // src/apis/encrypt.api.ts
476
476
  import CryptoJS from "crypto-js";
477
- function encryptPayload(environment, formData = {}) {
478
- const baseUrl = getBaseUrl(environment);
479
- const key = CryptoJS.enc.Utf8.parse(baseUrl);
480
- const iv = CryptoJS.enc.Utf8.parse(baseUrl);
477
+ function encryptPayload(merchantId, formData = {}) {
478
+ const merchId = merchantId.replace("-", "");
479
+ const first16Key = merchId.slice(0, 16);
480
+ const last16Iv = merchId.slice(-16);
481
+ const key = CryptoJS.enc.Utf8.parse(first16Key);
482
+ const iv = CryptoJS.enc.Utf8.parse(last16Iv);
481
483
  const postDataObj = JSON.stringify(formData);
482
484
  const encryptedData = CryptoJS.AES.encrypt(
483
485
  CryptoJS.enc.Utf8.parse(postDataObj),
@@ -493,10 +495,12 @@ function encryptPayload(environment, formData = {}) {
493
495
  requestParam: encryptedData.toString()
494
496
  };
495
497
  }
496
- function decryptPayload(environment, payload) {
497
- const baseUrl = getBaseUrl(environment);
498
- const key = CryptoJS.enc.Utf8.parse(baseUrl);
499
- const iv = CryptoJS.enc.Utf8.parse(baseUrl);
498
+ function decryptPayload(merchantId, payload) {
499
+ const merchId = merchantId.replace("-", "");
500
+ const first16Key = merchId.slice(0, 16);
501
+ const last16Iv = merchId.slice(-16);
502
+ const key = CryptoJS.enc.Utf8.parse(first16Key);
503
+ const iv = CryptoJS.enc.Utf8.parse(last16Iv);
500
504
  const decryptedData = CryptoJS.AES.decrypt(payload, key, {
501
505
  keySize: 128 / 8,
502
506
  iv,
@@ -1994,7 +1998,7 @@ function PayByCard({
1994
1998
  emailAddress: billingForm.emailAddress ?? "",
1995
1999
  phoneNumber: billingForm.phoneNumber ?? ""
1996
2000
  };
1997
- const encryptedCardDetails = encryptPayload(environment, cardDetails);
2001
+ const encryptedCardDetails = encryptPayload(secretKey, cardDetails);
1998
2002
  const payload = {
1999
2003
  customerId: paymentObject?.email || payForm.customerName || "",
2000
2004
  amount: String(paymentObject?.amount ?? ""),
@@ -2170,7 +2174,7 @@ function PayByCard({
2170
2174
  };
2171
2175
  const cardNumberInputHandler = (event) => {
2172
2176
  setCardType(cardTypeHandler(event));
2173
- payRules.cardPin = "required|numeric";
2177
+ payRules.cardPin = cardType === "Verve" ? "required|numeric" : "";
2174
2178
  };
2175
2179
  useEffect3(() => {
2176
2180
  (async () => {
@@ -3058,12 +3062,14 @@ function BzpCheckoutCard({
3058
3062
  };
3059
3063
  const setSuccess = (event) => {
3060
3064
  setSuccessObject({ ...event });
3061
- if (successObject.paymentStatus === "pending") {
3065
+ if (event.paymentStatus === "Authorized") {
3066
+ setCheckoutState("SUCCESS");
3067
+ } else if (event.paymentStatus === "Payment failed") {
3062
3068
  setCheckoutState("PENDING");
3063
- } else if (successObject.paymentStatus === "used") {
3069
+ } else if (event.paymentStatus === "used") {
3064
3070
  setCheckoutState("USED");
3065
3071
  } else {
3066
- setCheckoutState("SUCCESS");
3072
+ setCheckoutState("PENDING");
3067
3073
  }
3068
3074
  };
3069
3075
  useEffect6(() => {