@paykka/card-checkout-ui 0.13.17 → 0.14.0

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.
Files changed (180) hide show
  1. package/dist/card-checkout-ui.js +53 -25
  2. package/dist/card-checkout-ui.umd.cjs +53 -25
  3. package/dist/es/api/modules/boost/index.js +5 -16
  4. package/dist/es/api/modules/gcash/index.js +5 -16
  5. package/dist/es/api/modules/get-browser-params.js +1 -4
  6. package/dist/es/api/modules/grab-pay/index.js +5 -16
  7. package/dist/es/api/modules/line-pay/index.js +5 -16
  8. package/dist/es/api/modules/may-bank-qr-pay/index.js +5 -16
  9. package/dist/es/api/modules/nine-pay/index.js +5 -16
  10. package/dist/es/api/modules/opay-wallet/index.js +5 -16
  11. package/dist/es/api/modules/paga-wallet/index.js +5 -16
  12. package/dist/es/api/modules/paymaya/index.js +5 -16
  13. package/dist/es/api/modules/shopee-pay/index.js +5 -16
  14. package/dist/es/api/modules/threeDS/index.js +16 -2
  15. package/dist/es/api/modules/tng-wallet/index.js +5 -16
  16. package/dist/es/api/modules/zalopay/index.js +5 -16
  17. package/dist/es/components/AccordionItem/AccordionItem.js +0 -2
  18. package/dist/es/components/AddressField/index.js +13 -3
  19. package/dist/es/components/AliPay/index.js +64 -62
  20. package/dist/es/components/ApplePay/index.js +42 -39
  21. package/dist/es/components/CPFField/index.js +2 -1
  22. package/dist/es/components/Card/index.js +160 -133
  23. package/dist/es/components/CardExpireDateField/index.js +2 -1
  24. package/dist/es/components/CardNo/index.js +2 -2
  25. package/dist/es/components/CardNumberField/index.js +2 -1
  26. package/dist/es/components/CardSecurityCodeField/index.js +2 -1
  27. package/dist/es/components/CardSelector/index.js +3 -2
  28. package/dist/es/components/DropIn/index.js +24 -21
  29. package/dist/es/components/GooglePay/index.js +97 -88
  30. package/dist/es/components/PaymentButton/index.js +1 -1
  31. package/dist/es/components/SecuredFieldsProvider/index.js +31 -9
  32. package/dist/es/components/SecuredIframe/index.js +40 -23
  33. package/dist/es/components/SubmitButton/index.js +1 -1
  34. package/dist/es/components/ThreeDS/index.js +29 -12
  35. package/dist/es/components/WechatPay/index.js +70 -69
  36. package/dist/es/components/business/PhoneField/PhoneField.js +1 -0
  37. package/dist/es/components/index.js +7 -7
  38. package/dist/es/components/internal/CheckBox/CheckBox.js +2 -2
  39. package/dist/es/components/internal/Input/Input.js +1 -1
  40. package/dist/es/components/internal/Select/Select.js +4 -1
  41. package/dist/es/components/internal/icons/IconArrowDown.js +4 -4
  42. package/dist/es/components/internal/icons/IconBancontact.js +69 -14
  43. package/dist/es/components/internal/icons/IconBlik.js +541 -21
  44. package/dist/es/components/internal/icons/IconIdeal.js +61 -29
  45. package/dist/es/components/internal/icons/IconSkrill.js +14 -7
  46. package/dist/es/components/internal/icons/IconTrustly.js +11 -44
  47. package/dist/es/components/wallets/Bancontact/Bancontact.js +11 -8
  48. package/dist/es/components/wallets/Blik/Blik.js +12 -9
  49. package/dist/es/components/wallets/Boost/Boost.js +183 -0
  50. package/dist/es/components/wallets/Boost/boost2.js +1 -0
  51. package/dist/es/components/wallets/Boost/index.js +1 -0
  52. package/dist/es/components/wallets/Boost/type.js +1 -0
  53. package/dist/es/components/wallets/GCash/GCash.js +62 -252
  54. package/dist/es/components/wallets/GrabPay/GrabPay.js +183 -0
  55. package/dist/es/components/wallets/GrabPay/grab-pay.js +1 -0
  56. package/dist/es/components/wallets/GrabPay/index.js +1 -0
  57. package/dist/es/components/wallets/GrabPay/type.js +1 -0
  58. package/dist/es/components/wallets/IDeal/IDeal.js +11 -8
  59. package/dist/es/components/wallets/LinePay/LinePay.js +183 -0
  60. package/dist/es/components/wallets/LinePay/index.js +1 -0
  61. package/dist/es/components/wallets/LinePay/line-pay.js +1 -0
  62. package/dist/es/components/wallets/LinePay/type.js +1 -0
  63. package/dist/es/components/wallets/MayBankQRPay/MayBankQRPay.js +187 -0
  64. package/dist/es/components/wallets/MayBankQRPay/index.js +1 -0
  65. package/dist/es/components/wallets/MayBankQRPay/may-bank-qr-pay.js +1 -0
  66. package/dist/es/components/wallets/MayBankQRPay/type.js +1 -0
  67. package/dist/es/components/wallets/NinePay/NinePay.js +185 -0
  68. package/dist/es/components/wallets/NinePay/index.js +1 -0
  69. package/dist/es/components/wallets/NinePay/nine-pay.js +1 -0
  70. package/dist/es/components/wallets/NinePay/type.js +1 -0
  71. package/dist/es/components/wallets/OVO/OVO.js +7 -5
  72. package/dist/es/components/wallets/OpayWallet/OpayWallet.js +56 -218
  73. package/dist/es/components/wallets/P24/P24.js +11 -8
  74. package/dist/es/components/wallets/PagaWallet/PagaWallet.js +56 -218
  75. package/dist/es/components/wallets/Paymaya/Paymaya.js +56 -221
  76. package/dist/es/components/wallets/PicPay/PicPay.js +50 -47
  77. package/dist/es/components/wallets/Pix/Pix.js +44 -48
  78. package/dist/es/components/wallets/ShopeePay/ShopeePay.js +185 -0
  79. package/dist/es/components/wallets/ShopeePay/index.js +1 -0
  80. package/dist/es/components/wallets/ShopeePay/shopee-pay.js +1 -0
  81. package/dist/es/components/wallets/ShopeePay/type.js +1 -0
  82. package/dist/es/components/wallets/Skrill/Skrill.js +28 -26
  83. package/dist/es/components/wallets/TNGWallet/TNGWallet.js +185 -0
  84. package/dist/es/components/wallets/TNGWallet/index.js +1 -0
  85. package/dist/es/components/wallets/TNGWallet/tng-wallet.js +1 -0
  86. package/dist/es/components/wallets/TNGWallet/type.js +1 -0
  87. package/dist/es/components/wallets/Trustly/Trustly.js +15 -15
  88. package/dist/es/components/wallets/Vietqr/Vietqr.js +60 -248
  89. package/dist/es/components/wallets/Zalopay/Zalopay.js +61 -249
  90. package/dist/es/components/wallets/index.js +7 -0
  91. package/dist/es/core/checkout.js +19 -45
  92. package/dist/es/core/logger.js +1 -1
  93. package/dist/es/core/payment.js +65 -0
  94. package/dist/es/hooks/useBaseWallet.js +20 -18
  95. package/dist/es/hooks/usePayState.js +37 -25
  96. package/dist/es/hooks/usePayment.js +1 -14
  97. package/dist/es/hooks/useRetry.js +50 -26
  98. package/dist/es/index.js +7 -7
  99. package/dist/es/out/base-fraud-detection.js +4 -1
  100. package/dist/es/out/fraud-detection.js +12 -13
  101. package/dist/es/out/worldpay-ddc-manager.js +7 -14
  102. package/dist/es/out/worldpay-ddc.js +7 -5
  103. package/dist/es/style.css +1 -1
  104. package/dist/es/types/event.js +1 -0
  105. package/dist/es/types/message.js +2 -0
  106. package/dist/es/utils/payment.js +12 -12
  107. package/dist/es/utils/system-info/is-ua-webview.js +1 -20
  108. package/dist/style.css +1 -1
  109. package/dist/types/api/modules/threeDS/index.d.ts +7 -0
  110. package/dist/types/components/AddressField/type.d.ts +2 -2
  111. package/dist/types/components/CPFField/type.d.ts +1 -1
  112. package/dist/types/components/CardExpireDateField/type.d.ts +1 -1
  113. package/dist/types/components/CardNo/type.d.ts +3 -2
  114. package/dist/types/components/CardNumberField/type.d.ts +1 -1
  115. package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -1
  116. package/dist/types/components/CardSelector/type.d.ts +4 -4
  117. package/dist/types/components/GooglePay/createGooglePay.d.ts +1 -1
  118. package/dist/types/components/GooglePay/type.d.ts +6 -0
  119. package/dist/types/components/SecuredFieldsProvider/type.d.ts +2 -0
  120. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +0 -6
  121. package/dist/types/components/index.d.ts +0 -7
  122. package/dist/types/components/internal/CheckBox/type.d.ts +2 -1
  123. package/dist/types/components/internal/Select/type.d.ts +1 -1
  124. package/dist/types/components/internal/icons/IconArrowDown.d.ts +1 -1
  125. package/dist/types/components/{Boost → wallets/Boost}/Boost.d.ts +9 -4
  126. package/dist/types/components/{Boost → wallets/Boost}/type.d.ts +2 -2
  127. package/dist/types/components/wallets/GCash/GCash.d.ts +5 -0
  128. package/dist/types/components/{GrabPay → wallets/GrabPay}/GrabPay.d.ts +4 -4
  129. package/dist/types/components/wallets/GrabPay/type.d.ts +17 -0
  130. package/dist/types/components/{LinePay → wallets/LinePay}/LinePay.d.ts +9 -4
  131. package/dist/types/components/{LinePay → wallets/LinePay}/type.d.ts +2 -2
  132. package/dist/types/components/wallets/MayBankQRPay/MayBankQRPay.d.ts +15 -0
  133. package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/type.d.ts +2 -2
  134. package/dist/types/components/wallets/NinePay/NinePay.d.ts +15 -0
  135. package/dist/types/components/{NinePay → wallets/NinePay}/type.d.ts +2 -2
  136. package/dist/types/components/wallets/OpayWallet/OpayWallet.d.ts +5 -0
  137. package/dist/types/components/wallets/PagaWallet/PagaWallet.d.ts +5 -0
  138. package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +5 -0
  139. package/dist/types/components/{ShopeePay → wallets/ShopeePay}/ShopeePay.d.ts +9 -4
  140. package/dist/types/components/{ShopeePay → wallets/ShopeePay}/type.d.ts +2 -2
  141. package/dist/types/components/wallets/Skrill/type.d.ts +0 -12
  142. package/dist/types/components/{TNGWallet → wallets/TNGWallet}/TNGWallet.d.ts +9 -4
  143. package/dist/types/components/{TNGWallet → wallets/TNGWallet}/type.d.ts +2 -2
  144. package/dist/types/components/wallets/Vietqr/Vietqr.d.ts +5 -0
  145. package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +5 -0
  146. package/dist/types/components/wallets/index.d.ts +7 -0
  147. package/dist/types/core/checkout.d.ts +2 -9
  148. package/dist/types/core/payment.d.ts +21 -0
  149. package/dist/types/hooks/useBaseWallet.d.ts +2 -2
  150. package/dist/types/hooks/usePayState.d.ts +3 -1
  151. package/dist/types/hooks/useRetry.console-tests.d.ts +41 -0
  152. package/dist/types/hooks/useRetry.d.ts +22 -3
  153. package/dist/types/out/base-fraud-detection.d.ts +1 -0
  154. package/dist/types/out/config.d.ts +1 -1
  155. package/dist/types/out/fraud-detection.d.ts +2 -8
  156. package/dist/types/out/types.d.ts +3 -1
  157. package/dist/types/out/worldpay-ddc-manager.d.ts +6 -7
  158. package/dist/types/types/event.d.ts +6 -1
  159. package/dist/types/types/message.d.ts +24 -3
  160. package/dist/types/types/payment.d.ts +4 -0
  161. package/dist/types/utils/iframe.d.ts +1 -1
  162. package/dist/types/utils/payment.d.ts +10 -10
  163. package/package.json +9 -5
  164. package/dist/es/components/Boost/index.js +0 -349
  165. package/dist/es/components/GrabPay/index.js +0 -349
  166. package/dist/es/components/LinePay/index.js +0 -349
  167. package/dist/es/components/MayBankQRPay/index.js +0 -355
  168. package/dist/es/components/NinePay/index.js +0 -349
  169. package/dist/es/components/ShopeePay/index.js +0 -349
  170. package/dist/es/components/TNGWallet/index.js +0 -349
  171. package/dist/types/components/GrabPay/type.d.ts +0 -28
  172. package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +0 -10
  173. package/dist/types/components/NinePay/NinePay.d.ts +0 -10
  174. /package/dist/types/components/{Boost → wallets/Boost}/index.d.ts +0 -0
  175. /package/dist/types/components/{GrabPay → wallets/GrabPay}/index.d.ts +0 -0
  176. /package/dist/types/components/{LinePay → wallets/LinePay}/index.d.ts +0 -0
  177. /package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/index.d.ts +0 -0
  178. /package/dist/types/components/{NinePay → wallets/NinePay}/index.d.ts +0 -0
  179. /package/dist/types/components/{ShopeePay → wallets/ShopeePay}/index.d.ts +0 -0
  180. /package/dist/types/components/{TNGWallet → wallets/TNGWallet}/index.d.ts +0 -0
@@ -199,6 +199,7 @@ const FieldIframe = (props) => {
199
199
  const inputRef = A(null);
200
200
  const { initSecuredInput, getConfigByFieldType, getCurrCardBrand, cardBin, value, brand } = useSecuredInput();
201
201
  const [hasInit, setHasInit] = h(false);
202
+ const [disabled, setDisabled] = h(false);
202
203
  const inputId = "securedInput";
203
204
  const initInput = () => {
204
205
  initSecuredInput({
@@ -294,6 +295,11 @@ const FieldIframe = (props) => {
294
295
  processValidStatusChanged("error", error);
295
296
  sendValidateMessage("error");
296
297
  }
298
+ } else if (feedbackData.action === MessageAction.SET_CONFIG) {
299
+ const data2 = feedbackData;
300
+ if (data2.disabled !== void 0) {
301
+ setDisabled(data2.disabled);
302
+ }
297
303
  }
298
304
  };
299
305
  y(() => {
@@ -367,9 +373,8 @@ const FieldIframe = (props) => {
367
373
  checkoutId
368
374
  };
369
375
  postMessageToIframe(validData, window.parent);
370
- if (status !== "success") {
376
+ if (status !== "success")
371
377
  return;
372
- }
373
378
  sendValidWithValueMessage();
374
379
  };
375
380
  const sendValidWithValueMessage = () => {
@@ -405,7 +410,7 @@ const FieldIframe = (props) => {
405
410
  ref: inputRef,
406
411
  placeholder: props.placeholder,
407
412
  autocomplete: "off",
408
- disabled: !hasInit
413
+ disabled: !hasInit || disabled
409
414
  }
410
415
  );
411
416
  };
@@ -419,49 +424,52 @@ const HiddenIframe = ({ checkoutId }) => {
419
424
  cpf: void 0
420
425
  };
421
426
  const onReceiveMessage = async (event) => {
422
- const { data } = event;
423
- const parsedData = safeParse(data);
424
- if (!Reflect.has(parsedData, "action")) {
427
+ const { data, origin } = event;
428
+ const feedbackData = safeParse(data);
429
+ if (!Reflect.has(feedbackData, "action"))
425
430
  return;
426
- }
427
- if (parsedData.checkoutId !== checkoutId) {
431
+ if (feedbackData.checkoutId !== checkoutId)
428
432
  return;
429
- }
430
- if (parsedData.action === MessageAction.VALID_WITH_VALUE) {
431
- const feedbackData = parsedData;
432
- switch (feedbackData.fieldType) {
433
+ if (feedbackData.action === MessageAction.VALID_WITH_VALUE) {
434
+ const data2 = feedbackData;
435
+ switch (data2.fieldType) {
433
436
  case EFieldType.CVV: {
434
- formData.cvv = feedbackData.value;
437
+ formData.cvv = data2.value;
435
438
  break;
436
439
  }
437
440
  case EFieldType.CARD_NUMBER: {
438
- formData.cardNo = trimAll(feedbackData.value);
441
+ formData.cardNo = trimAll(data2.value);
439
442
  break;
440
443
  }
441
444
  case EFieldType.EXPIRE_DATE: {
442
- const [expMonth, expYear] = feedbackData.value.split("/");
445
+ const [expMonth, expYear] = data2.value.split("/");
443
446
  formData.expMonth = expMonth;
444
447
  formData.expYear = `20${expYear}`;
445
448
  break;
446
449
  }
447
450
  case EInternalFieldType.CPF: {
448
- formData.cpf = limitedToNumber(trimAll(feedbackData.value));
451
+ formData.cpf = limitedToNumber(trimAll(data2.value));
449
452
  break;
450
453
  }
451
454
  }
452
- } else if (parsedData.action === MessageAction.PAYMENT) {
453
- const feedbackData = parsedData;
454
- pay(feedbackData.formData, feedbackData.locale, feedbackData.extraParams);
455
- } else if (parsedData.action === MessageAction.ENCRYPT_CARD) {
456
- const feedbackData = parsedData;
455
+ } else if (feedbackData.action === MessageAction.PAYMENT) {
456
+ const data2 = feedbackData;
457
+ pay(data2.formData, data2.locale, data2.extraParams);
458
+ } else if (feedbackData.action === MessageAction.ENCRYPT_CARD) {
459
+ const data2 = feedbackData;
457
460
  try {
458
- const res = await encryptCard({ ...feedbackData, ...formData });
461
+ const res = await encryptCard({ ...data2, ...formData });
459
462
  sendCardEncryptedMessage(res);
460
463
  } catch (error) {
461
464
  console.log("error", error);
462
465
  sendCardEncryptionFailedMessage(error);
463
466
  }
464
- }
467
+ } else if (feedbackData.action === MessageAction.DDC_CARD_BIN) {
468
+ if (origin !== cdnOrigin)
469
+ return;
470
+ sendDDCCardBinMessage(event.source);
471
+ } else
472
+ ;
465
473
  };
466
474
  y(() => {
467
475
  window.addEventListener("message", onReceiveMessage);
@@ -500,6 +508,14 @@ const HiddenIframe = ({ checkoutId }) => {
500
508
  }
501
509
  });
502
510
  };
511
+ const sendDDCCardBinMessage = (target) => {
512
+ const data = {
513
+ action: MessageAction.DDC_CARD_BIN,
514
+ checkoutId,
515
+ bin: limitedToNumber(formData.cardNo).slice(0, 9)
516
+ };
517
+ postMessageToIframe(data, target);
518
+ };
503
519
  const sendAfterPaymentMessage = (response, requestInfo) => {
504
520
  const data = {
505
521
  action: MessageAction.AFTER_PAYMENT,
@@ -541,6 +557,7 @@ const HiddenIframe = ({ checkoutId }) => {
541
557
  const sendHiddenIframeReadyMessage = () => {
542
558
  const data = {
543
559
  action: MessageAction.HIDDEN_IFRAME_READY,
560
+ name: window.name,
544
561
  checkoutId
545
562
  };
546
563
  postMessageToIframe(data, window.parent);
@@ -51,7 +51,7 @@ const SubmitButton = (props) => {
51
51
  className: normalizedClass(bem({ success: status === "success" }), className),
52
52
  style,
53
53
  loading: status === "loading",
54
- disabled: props.disabled || status === "success",
54
+ disabled: (props.disabled || status === "success") && status !== "loading",
55
55
  children: /* @__PURE__ */ u("span", { class: bem("text", { "not-verified": !props.verified }), children: content })
56
56
  }
57
57
  );
@@ -9,6 +9,7 @@ import { useBEM } from "../../hooks/useBEM.js";
9
9
  import { useI18n } from "../../hooks/useI18n.js";
10
10
  import { safeParse } from "../../utils/index.js";
11
11
  import { cdnOrigin } from "../../config.js";
12
+ import { noticeThreeDSOperate, ThreeDSAuthOperate } from "../../api/modules/threeDS/index.js";
12
13
  import { MessageAction } from "../../types/message.js";
13
14
  import { ThreeDSEventType } from "../../types/event.js";
14
15
  import { useBreakpoints } from "../../hooks/useBreakpoints.js";
@@ -28,26 +29,31 @@ const ThreeDSAuth = (props) => {
28
29
  checkoutId
29
30
  } = props;
30
31
  const breakpoints = useBreakpoints();
31
- const [continueThreeDs, setContinueThreeDs] = h(false);
32
+ const [continueThreeDS, setContinueThreeDS] = h(false);
32
33
  const messageHandler = A();
33
34
  const iframeRef = A(null);
34
35
  const [iframeName] = h(`${THREE_DS_IFRAME_NAME}-${checkoutId}-${Date.now()}`);
36
+ const innerChannelLoaded = A(false);
37
+ const authId = A(void 0);
35
38
  const { i18n } = useI18n();
36
39
  const { core } = x(CoreContext) ?? {};
37
- const handleLastThreeDs = () => {
38
- setContinueThreeDs(true);
40
+ const handleLastThreeDS = () => {
41
+ setContinueThreeDS(true);
39
42
  };
40
43
  const onChange = (status) => {
41
44
  var _a, _b;
42
45
  if (!status) {
43
46
  (_b = (_a = core == null ? void 0 : core.config) == null ? void 0 : _a.onEvent) == null ? void 0 : _b.call(_a, ThreeDSEventType.THREE_DS_CANCELLED);
44
47
  onClose == null ? void 0 : onClose();
48
+ console.log("onChange", innerChannelLoaded.current, authId.current);
49
+ if (innerChannelLoaded.current && authId.current) {
50
+ noticeThreeDSOperate(authId.current, ThreeDSAuthOperate.CANCEL);
51
+ }
45
52
  }
46
53
  };
47
54
  const modalWidth = T(() => {
48
- if (!show) {
55
+ if (!show)
49
56
  return "0";
50
- }
51
57
  return width || (breakpoints.smaller("sm") ? "90vw" : "600px");
52
58
  }, [show, width, breakpoints.matches]);
53
59
  y(() => {
@@ -62,16 +68,14 @@ const ThreeDSAuth = (props) => {
62
68
  window.removeEventListener("message", messageHandler.current);
63
69
  }
64
70
  messageHandler.current = (event) => {
65
- var _a2, _b2, _c2, _d2;
71
+ var _a2, _b2, _c2, _d2, _e, _f;
66
72
  const { data, origin } = event;
67
- if (origin !== cdnOrigin) {
73
+ if (origin !== cdnOrigin)
68
74
  return;
69
- }
70
75
  const feedbackData = safeParse(data);
71
76
  console.log(feedbackData, checkoutId);
72
- if (feedbackData.checkoutId !== checkoutId) {
77
+ if (feedbackData.checkoutId !== checkoutId)
73
78
  return;
74
- }
75
79
  switch (feedbackData.action) {
76
80
  case MessageAction.CHECK_THREE_DS: {
77
81
  onClose == null ? void 0 : onClose();
@@ -79,13 +83,26 @@ const ThreeDSAuth = (props) => {
79
83
  break;
80
84
  }
81
85
  case MessageAction.THREE_DS_AUTH_LOADED: {
86
+ const data2 = feedbackData;
82
87
  (_d2 = (_c2 = core == null ? void 0 : core.config) == null ? void 0 : _c2.onEvent) == null ? void 0 : _d2.call(_c2, ThreeDSEventType.THREE_DS_AUTH);
88
+ authId.current = data2.authId;
89
+ console.log("认证id", authId.current);
90
+ break;
91
+ }
92
+ case MessageAction.THREE_DS_INNER_CHANNEL_LOADED: {
93
+ (_f = (_e = core == null ? void 0 : core.config) == null ? void 0 : _e.onEvent) == null ? void 0 : _f.call(_e, ThreeDSEventType.THREE_DS_INNER_CHANNEL);
94
+ innerChannelLoaded.current = true;
95
+ console.log("innerChannelLoaded", innerChannelLoaded.current, authId.current);
96
+ if (authId.current) {
97
+ noticeThreeDSOperate(authId.current, ThreeDSAuthOperate.OPEN);
98
+ }
83
99
  break;
84
100
  }
85
101
  }
86
102
  };
87
103
  window.addEventListener("message", messageHandler.current);
88
104
  } else {
105
+ innerChannelLoaded.current = false;
89
106
  messageHandler.current && window.removeEventListener("message", messageHandler.current);
90
107
  }
91
108
  }, [show]);
@@ -101,7 +118,7 @@ const ThreeDSAuth = (props) => {
101
118
  maxHeight: "calc(100vh - 100px)",
102
119
  minWidth: "300px"
103
120
  },
104
- children: /* @__PURE__ */ u("div", { className: bem("content"), children: !incomplete || continueThreeDs ? /* @__PURE__ */ u(
121
+ children: /* @__PURE__ */ u("div", { className: bem("content"), children: !incomplete || continueThreeDS ? /* @__PURE__ */ u(
105
122
  "iframe",
106
123
  {
107
124
  ref: iframeRef,
@@ -125,7 +142,7 @@ const ThreeDSAuth = (props) => {
125
142
  backgroundColor: theme == null ? void 0 : theme.payButtonBackgroundColor,
126
143
  color: theme == null ? void 0 : theme.payButtonTextColor
127
144
  },
128
- onClick: handleLastThreeDs,
145
+ onClick: handleLastThreeDS,
129
146
  children: i18n.get("common.confirm")
130
147
  }
131
148
  ) })
@@ -3,7 +3,7 @@ import { isTimeoutError } from "../../api/http.js";
3
3
  import "../../utils/card-brand/brands.js";
4
4
  import "../../utils/system-info/get-browser-info.js";
5
5
  import { normalizedClass, formatAmount } from "../../utils/format.js";
6
- import { formatPaymentResult } from "../../utils/payment.js";
6
+ import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
7
7
  import { getBrowserParams } from "../../api/modules/get-browser-params.js";
8
8
  import { PaymentMethod, COMMON_CLASS_NAME, PaymentType, SessionMode } from "../../constant.js";
9
9
  import { getWechatPayInfo, wechatPay } from "../../api/modules/wechat-pay/index.js";
@@ -13,7 +13,7 @@ import "../../out/worldpay-jsc-origin.js";
13
13
  import { useBEM } from "../../hooks/useBEM.js";
14
14
  import { usePayState } from "../../hooks/usePayState.js";
15
15
  import { useRetry } from "../../hooks/useRetry.js";
16
- import { AddressField } from "../AddressField/index.js";
16
+ import { DEFAULT_ADDRESS, AddressField } from "../AddressField/index.js";
17
17
  import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
18
18
  import "../internal/Form/type.js";
19
19
  import "../internal/Form/context.js";
@@ -27,7 +27,7 @@ const { bem } = useBEM("wechat-pay");
27
27
  const fieldClassNames = bem("field");
28
28
  const WechatPay = w((props, ref) => {
29
29
  var _a;
30
- const { session, core, showEmail = false, showAddress = false } = props;
30
+ const { session, core, showEmail = false, showAddress = false, autoQuery = true } = props;
31
31
  const addressCore = core.getAddressCore();
32
32
  const emailState = createEmailCore();
33
33
  const emailFieldRef = A(null);
@@ -38,43 +38,34 @@ const WechatPay = w((props, ref) => {
38
38
  },
39
39
  startRetry: (timeout) => {
40
40
  setSubmitButtonStatus("loading");
41
- startReFetchPayInfo({
42
- timeout
43
- });
41
+ startReFetchPayInfo({ timeout });
44
42
  },
45
43
  updateAddress: () => {
46
44
  var _a2;
47
45
  if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
48
46
  return;
49
- const newForm = Object.assign(form, { address: addressCore.getAddressState() });
50
- setForm(newForm);
51
- (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
52
- validateForm();
47
+ const address = addressCore.getAddressState();
48
+ form.address = address;
49
+ setForm(form);
50
+ (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(address);
51
+ validateFormSilently();
53
52
  },
54
53
  updateEmail: () => {
55
54
  var _a2;
56
55
  if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
57
56
  return;
58
- const newForm = Object.assign(form, { email: emailState.email });
59
- setForm(newForm);
57
+ form.email = emailState.email;
58
+ setForm(form);
60
59
  (_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
61
- validateForm();
60
+ validateFormSilently();
62
61
  }
63
62
  }));
64
- const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
63
+ const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady, disabled } = usePayState(session, props.core);
65
64
  const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
66
65
  const formRef = A(null);
67
66
  const [form, setForm] = h({
68
67
  email: "",
69
- address: {
70
- country: void 0,
71
- province: void 0,
72
- city: void 0,
73
- area: void 0,
74
- postCode: void 0,
75
- address1: void 0,
76
- address2: void 0
77
- }
68
+ address: { ...DEFAULT_ADDRESS }
78
69
  });
79
70
  const [validated, setValidated] = h(false);
80
71
  const [fieldStatus, setFieldStatus] = h();
@@ -85,14 +76,10 @@ const WechatPay = w((props, ref) => {
85
76
  paymentMethod: CURR_PAYMENT_METHOD
86
77
  };
87
78
  };
88
- function validateForm() {
79
+ const validateFormSilently = () => {
89
80
  var _a2;
90
- (_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
91
- setValidated(true);
92
- }).catch(() => {
93
- setValidated(false);
94
- });
95
- }
81
+ (_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => setValidated(true)).catch(() => setValidated(false));
82
+ };
96
83
  const initFieldStatus = () => {
97
84
  const { field, sessionMode } = session.checkout;
98
85
  const { email, address } = field;
@@ -107,7 +94,7 @@ const WechatPay = w((props, ref) => {
107
94
  setFieldStatus({ ...field });
108
95
  };
109
96
  y(() => {
110
- validateForm();
97
+ validateFormSilently();
111
98
  }, [form]);
112
99
  const processOnSuccess = (res) => {
113
100
  var _a2, _b;
@@ -119,11 +106,12 @@ const WechatPay = w((props, ref) => {
119
106
  (_b = props.onSuccess) == null ? void 0 : _b.call(props, result, getPaymentMethodContext());
120
107
  };
121
108
  y(() => {
109
+ var _a2;
122
110
  if (!sessionReady) {
123
111
  return;
124
112
  }
125
113
  const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
126
- if (!supportMethods.includes(PaymentMethod.WECHAT_PAY)) {
114
+ if (!supportMethods.includes(CURR_PAYMENT_METHOD)) {
127
115
  return;
128
116
  }
129
117
  initFieldStatus();
@@ -131,10 +119,15 @@ const WechatPay = w((props, ref) => {
131
119
  country && addressCore.setCountry(country);
132
120
  form.email = bill.email ?? "";
133
121
  form.address.country = country;
122
+ if (autoQuery && ((_a2 = core.payment) == null ? void 0 : _a2.currPaymentMethod.value) === CURR_PAYMENT_METHOD) {
123
+ setSubmitButtonStatus("loading");
124
+ startReFetchPayInfo();
125
+ }
134
126
  }, [sessionReady]);
135
127
  const onTimeout = q(
136
128
  (message) => {
137
129
  var _a2;
130
+ core.payment.resetCurrPaymentMethod();
138
131
  setErrorMsg(message || i18n.get("common.payTimeout"));
139
132
  setSubmitButtonStatus("unSubmit");
140
133
  (_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry", getPaymentMethodContext());
@@ -167,7 +160,7 @@ const WechatPay = w((props, ref) => {
167
160
  },
168
161
  channelUserId: await ((_a2 = props.onGetOpenId) == null ? void 0 : _a2.call(props)),
169
162
  payment: {
170
- paymentMethod: PaymentMethod.WECHAT_PAY
163
+ paymentMethod: CURR_PAYMENT_METHOD
171
164
  },
172
165
  browser: await getBrowserParams({
173
166
  fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
@@ -175,65 +168,70 @@ const WechatPay = w((props, ref) => {
175
168
  };
176
169
  };
177
170
  async function pay(search = false, timeout) {
178
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
171
+ var _a2, _b, _c, _d, _e, _f;
179
172
  try {
173
+ core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
180
174
  const requestOptions = { locale: i18n.locale, timeout };
181
175
  let res = null;
182
176
  if (search) {
183
- const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.WECHAT_PAY);
177
+ const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", CURR_PAYMENT_METHOD);
184
178
  res = await getWechatPayInfo(
185
179
  {
186
180
  sessionId: session.sessionId,
187
181
  clientKey: session.clientKey,
188
- paymentMethod: PaymentMethod.WECHAT_PAY
182
+ paymentMethod: CURR_PAYMENT_METHOD
189
183
  },
190
184
  extraParams,
191
185
  requestOptions
192
186
  );
193
187
  } else {
194
- const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.WECHAT_PAY);
188
+ const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", CURR_PAYMENT_METHOD);
195
189
  res = await wechatPay(await getPaymentParams(), extraParams, requestOptions);
196
190
  }
197
- const { status, orderStatus, errorMessage, payInfo, errorCode, sessionId } = res;
191
+ const { errorMessage, payInfo, errorCode, sessionId } = res;
198
192
  sessionId && (session.sessionId = sessionId);
199
193
  !search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res, getPaymentMethodContext()));
200
- if (status === "PROCESSING") {
201
- if (!orderStatus) {
202
- setSubmitButtonStatus("unSubmit");
203
- return { end: true };
204
- } else if (orderStatus === "SUCCESS") {
194
+ let end = true;
195
+ await processPaymentStatus(res, {
196
+ onProcessing: async () => {
197
+ var _a3;
198
+ if (!search) {
199
+ await ((_a3 = props.onCallWxPayBox) == null ? void 0 : _a3.call(props, payInfo));
200
+ startReFetchPayInfo();
201
+ }
202
+ end = false;
203
+ },
204
+ onSuccess: () => {
205
205
  processOnSuccess(res);
206
- return { end: true };
207
- } else if (orderStatus === "FAILURE") {
206
+ },
207
+ onFailure: () => {
208
+ var _a3;
209
+ core.payment.resetCurrPaymentMethod();
208
210
  errorMessage && setErrorMsg(errorMessage);
209
211
  setSubmitButtonStatus("unSubmit");
210
- (_f = props.onError) == null ? void 0 : _f.call(
212
+ (_a3 = props.onError) == null ? void 0 : _a3.call(
211
213
  props,
212
214
  new PayKKaError("API_ERROR", errorMessage, { code: errorCode }),
213
215
  getPaymentMethodContext()
214
216
  );
215
- return { end: true };
216
- } else if (orderStatus === "PROCESSING") {
217
- if (!search) {
218
- await ((_g = props.onCallWxPayBox) == null ? void 0 : _g.call(props, payInfo));
219
- startReFetchPayInfo();
220
- }
221
- return { end: false };
222
- } else if (orderStatus === "CANCELED") {
217
+ },
218
+ onCanceled: () => {
219
+ var _a3;
220
+ core.payment.resetCurrPaymentMethod();
221
+ setSubmitButtonStatus("unSubmit");
222
+ (_a3 = props.onTimeout) == null ? void 0 : _a3.call(props, "channel", getPaymentMethodContext());
223
+ },
224
+ onExpired: () => {
225
+ var _a3;
226
+ setSubmitButtonStatus("unSubmit");
227
+ (_a3 = props.onExpired) == null ? void 0 : _a3.call(props, getPaymentMethodContext());
228
+ },
229
+ onDefault: () => {
230
+ core.payment.resetCurrPaymentMethod();
223
231
  setSubmitButtonStatus("unSubmit");
224
- (_h = props.onTimeout) == null ? void 0 : _h.call(props, "channel", getPaymentMethodContext());
225
- return { end: true };
226
232
  }
227
- } else if (status === "SUCCESS") {
228
- processOnSuccess(res);
229
- return { end: true };
230
- } else if (status === "EXPIRED") {
231
- setSubmitButtonStatus("unSubmit");
232
- (_i = props.onExpired) == null ? void 0 : _i.call(props, getPaymentMethodContext());
233
- return { end: true };
234
- }
235
- setSubmitButtonStatus("unSubmit");
236
- return { end: true };
233
+ });
234
+ return { end };
237
235
  } catch (error) {
238
236
  if (isTimeoutError(error)) {
239
237
  if (search) {
@@ -243,9 +241,10 @@ const WechatPay = w((props, ref) => {
243
241
  return { end: true };
244
242
  }
245
243
  } else {
244
+ core.payment.resetCurrPaymentMethod();
246
245
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
247
246
  message && setErrorMsg(message);
248
- (_j = props.onError) == null ? void 0 : _j.call(
247
+ (_f = props.onError) == null ? void 0 : _f.call(
249
248
  props,
250
249
  new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
251
250
  getPaymentMethodContext()
@@ -282,6 +281,7 @@ const WechatPay = w((props, ref) => {
282
281
  {
283
282
  className: bem("button"),
284
283
  status: submitButtonStatus,
284
+ disabled,
285
285
  text,
286
286
  loadingText: i18n.get("common.payProcessing"),
287
287
  successText: i18n.get("common.paySuccess"),
@@ -292,7 +292,7 @@ const WechatPay = w((props, ref) => {
292
292
  };
293
293
  const setFormRef = (dom) => {
294
294
  formRef.current = dom;
295
- dom && validateForm();
295
+ dom && validateFormSilently();
296
296
  };
297
297
  const Email = () => {
298
298
  return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
@@ -300,7 +300,7 @@ const WechatPay = w((props, ref) => {
300
300
  {
301
301
  ref: emailFieldRef,
302
302
  value: form.email,
303
- disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
303
+ disabled: (fieldStatus == null ? void 0 : fieldStatus.email.disabled) || disabled
304
304
  }
305
305
  ) }) });
306
306
  };
@@ -310,6 +310,7 @@ const WechatPay = w((props, ref) => {
310
310
  {
311
311
  ref: addressFieldRef,
312
312
  value: form.address,
313
+ disabled,
313
314
  onChange: (value) => setForm(Object.assign(form, { address: value }))
314
315
  }
315
316
  ) }) });
@@ -98,6 +98,7 @@ const PhoneField = (props) => {
98
98
  options: phoneList,
99
99
  filterable: false,
100
100
  inputClassName: bem("areaCode-input"),
101
+ disabled,
101
102
  onSelect: (v) => {
102
103
  formContext == null ? void 0 : formContext.setForm((prev) => ({ ...prev, areaCode: String(v) }));
103
104
  }
@@ -29,13 +29,13 @@ import "./Sepa/index.js";
29
29
  import "./EncryptedCard/index.js";
30
30
  import "./CombinedCardInfo/index.js";
31
31
  import "./DropIn/index.js";
32
- import "./Boost/index.js";
33
- import "./LinePay/index.js";
34
- import "./MayBankQRPay/index.js";
35
- import "./NinePay/index.js";
36
- import "./GrabPay/index.js";
37
- import "./TNGWallet/index.js";
38
- import "./ShopeePay/index.js";
32
+ import "./wallets/Boost/Boost.js";
33
+ import "./wallets/GrabPay/GrabPay.js";
34
+ import "./wallets/LinePay/LinePay.js";
35
+ import "./wallets/NinePay/NinePay.js";
36
+ import "./wallets/MayBankQRPay/MayBankQRPay.js";
37
+ import "./wallets/ShopeePay/ShopeePay.js";
38
+ import "./wallets/TNGWallet/TNGWallet.js";
39
39
  import "./wallets/GCash/GCash.js";
40
40
  import "./wallets/Paymaya/Paymaya.js";
41
41
  import "./wallets/Zalopay/Zalopay.js";
@@ -10,14 +10,14 @@ import "../../../out/worldpay-jsc-origin.js";
10
10
  import { IconChecked } from "../icons/iconChecked.js";
11
11
  const { bem } = useBEM("check-box");
12
12
  const CheckBox = (props) => {
13
- const { checked, onChange, label, style } = props;
13
+ const { checked, onChange, label, style, disabled } = props;
14
14
  const handleChange = () => {
15
15
  onChange == null ? void 0 : onChange(!checked);
16
16
  };
17
17
  return /* @__PURE__ */ u(
18
18
  "div",
19
19
  {
20
- className: normalizedClass(COMMON_CLASS_NAME, bem({ checked })),
20
+ className: normalizedClass(COMMON_CLASS_NAME, bem({ checked, disabled })),
21
21
  onClick: handleChange,
22
22
  style,
23
23
  children: [
@@ -108,7 +108,7 @@ const Input = w((props, ref) => {
108
108
  autocomplete: "off"
109
109
  }
110
110
  ),
111
- !!rightIcon && /* @__PURE__ */ u("div", { class: inputBEM.bem("right-icon"), children: rightIcon })
111
+ !!rightIcon && /* @__PURE__ */ u("div", { class: inputBEM.bem("right-icon", { disabled }), children: rightIcon })
112
112
  ] }) });
113
113
  });
114
114
  export {
@@ -16,6 +16,7 @@ import { SelectMenu } from "./SelectMenu.js";
16
16
  import { SelectMenuItem } from "./SelectMenuItem.js";
17
17
  const { bem } = useBEM("select");
18
18
  const Select = w((props, ref) => {
19
+ const { disabled } = props;
19
20
  const formItemContext = x(FormItemContext);
20
21
  let status = props.status ?? (formItemContext == null ? void 0 : formItemContext.validationResult.status);
21
22
  if (status === "unValidate")
@@ -160,6 +161,7 @@ const Select = w((props, ref) => {
160
161
  /* @__PURE__ */ u(FormItemContext.Provider, { value: null, children: /* @__PURE__ */ u(
161
162
  Input,
162
163
  {
164
+ disabled,
163
165
  ref: inputRef,
164
166
  value: inputValue,
165
167
  status,
@@ -180,7 +182,8 @@ const Select = w((props, ref) => {
180
182
  class: bem("render-label", [
181
183
  {
182
184
  placeholder: isFocus,
183
- hidden: isInputChange
185
+ hidden: isInputChange,
186
+ disabled
184
187
  }
185
188
  ]),
186
189
  onClick: onClickDisplay,
@@ -4,7 +4,7 @@ import { isUndefined } from "../../../utils/is.js";
4
4
  import "../../../utils/card-brand/brands.js";
5
5
  import "../../../utils/system-info/get-browser-info.js";
6
6
  import { normalizedClass } from "../../../utils/format.js";
7
- function IconArrowDown({ size, style, className }) {
7
+ const IconArrowDown = ({ size, style, className }) => {
8
8
  const computedSize = !isUndefined(size) ? `${size}px` : "1em";
9
9
  return /* @__PURE__ */ u(
10
10
  "svg",
@@ -12,17 +12,17 @@ function IconArrowDown({ size, style, className }) {
12
12
  width: computedSize,
13
13
  height: computedSize,
14
14
  viewBox: "0 0 16 16",
15
- fill: "none",
15
+ fill: "currentColor",
16
16
  xmlns: "http://www.w3.org/2000/svg",
17
17
  style,
18
18
  className: normalizedClass(COMMON_CLASS_NAME, className),
19
19
  children: [
20
- /* @__PURE__ */ u("g", { id: "icon-wrapper", "clip-path": "url(#clip0_543_1600)", children: /* @__PURE__ */ u("g", { id: "direction/down", children: /* @__PURE__ */ u("path", { id: "Vector", "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M13.6719 6.28589L12.7291 5.34308L8.01502 10.0571L3.30098 5.34308L2.35817 6.28589L7.54358 11.4713C7.54358 11.4713 7.54362 11.4713 8.01502 10.9999L7.54358 11.4713L8.01502 11.9427L13.6719 6.28589Z", fill: "#1F1F1F" }) }) }),
20
+ /* @__PURE__ */ u("g", { id: "icon-wrapper", "clip-path": "url(#clip0_543_1600)", children: /* @__PURE__ */ u("g", { id: "direction/down", children: /* @__PURE__ */ u("path", { id: "Vector", "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M13.6719 6.28589L12.7291 5.34308L8.01502 10.0571L3.30098 5.34308L2.35817 6.28589L7.54358 11.4713C7.54358 11.4713 7.54362 11.4713 8.01502 10.9999L7.54358 11.4713L8.01502 11.9427L13.6719 6.28589Z", fill: "currentColor" }) }) }),
21
21
  /* @__PURE__ */ u("defs", { children: /* @__PURE__ */ u("clipPath", { id: "clip0_543_1600", children: /* @__PURE__ */ u("rect", { width: "16", height: "16", fill: "white" }) }) })
22
22
  ]
23
23
  }
24
24
  );
25
- }
25
+ };
26
26
  export {
27
27
  IconArrowDown
28
28
  };