@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
@@ -16,7 +16,7 @@ import { IconCardNo } from "../internal/icons/IconCardNo.js";
16
16
  import { IconSwitch } from "../internal/icons/IconSwitch.js";
17
17
  import { IconAdd } from "../internal/icons/IconAdd.js";
18
18
  const CardSelector = (props) => {
19
- const { cardList = [], onCardChange, onClickEdit, className, style, onClickChange, value } = props;
19
+ const { cardList = [], onCardChange, onClickEdit, className, style, onClickChange, value, disabled } = props;
20
20
  const { i18n } = useI18n();
21
21
  const { bem } = useBEM("card-selector");
22
22
  const selectRef = A(null);
@@ -55,7 +55,7 @@ const CardSelector = (props) => {
55
55
  ] });
56
56
  };
57
57
  const getChangeIcon = () => {
58
- return /* @__PURE__ */ u("div", { className: bem("change"), onClick: onClickChange, children: [
58
+ return /* @__PURE__ */ u("div", { className: bem("change", { disabled }), onClick: onClickChange, children: [
59
59
  /* @__PURE__ */ u(IconSwitch, {}),
60
60
  /* @__PURE__ */ u("span", { style: { marginLeft: "4px" }, children: i18n.get("card.cardSelector.change") })
61
61
  ] });
@@ -91,6 +91,7 @@ const CardSelector = (props) => {
91
91
  {
92
92
  value: currToken,
93
93
  ref: selectRef,
94
+ disabled,
94
95
  options: formatCardOptions(),
95
96
  renderLabel,
96
97
  onSelect: onSelectCard,
@@ -7,13 +7,13 @@ import { CardPaymentMethods, PaymentMethod, PaymentCategory, SessionMode, Paymen
7
7
  import { Card } from "../Card/index.js";
8
8
  import { ApplePay } from "../ApplePay/index.js";
9
9
  import { GooglePay } from "../GooglePay/index.js";
10
- import { Boost } from "../Boost/index.js";
11
- import { NinePay } from "../NinePay/index.js";
12
- import { LinePay } from "../LinePay/index.js";
13
- import { TNGWallet } from "../TNGWallet/index.js";
14
- import { MayBankQRPay } from "../MayBankQRPay/index.js";
15
- import { ShopeePay } from "../ShopeePay/index.js";
16
- import { GrabPay } from "../GrabPay/index.js";
10
+ import { Boost } from "../wallets/Boost/Boost.js";
11
+ import { NinePay } from "../wallets/NinePay/NinePay.js";
12
+ import { LinePay } from "../wallets/LinePay/LinePay.js";
13
+ import { TNGWallet } from "../wallets/TNGWallet/TNGWallet.js";
14
+ import { MayBankQRPay } from "../wallets/MayBankQRPay/MayBankQRPay.js";
15
+ import { ShopeePay } from "../wallets/ShopeePay/ShopeePay.js";
16
+ import { GrabPay } from "../wallets/GrabPay/GrabPay.js";
17
17
  import { GCash } from "../wallets/GCash/GCash.js";
18
18
  import { Paymaya } from "../wallets/Paymaya/Paymaya.js";
19
19
  import { Zalopay } from "../wallets/Zalopay/Zalopay.js";
@@ -243,6 +243,7 @@ const paymentCategoryOptionMap = {
243
243
  };
244
244
  const { bem } = useBEM("drop-in");
245
245
  const DropIn = w((props, ref) => {
246
+ var _a;
246
247
  const {
247
248
  paymentMethods: paymentMethodsConfig,
248
249
  layout = "accordion",
@@ -262,22 +263,22 @@ const DropIn = w((props, ref) => {
262
263
  const componentInstMap = A({});
263
264
  F(ref, () => ({
264
265
  payment: () => {
265
- var _a, _b;
266
+ var _a2, _b;
266
267
  if (activePaymentCategory) {
267
- const instRef = (_a = componentInstMap.current[activePaymentCategory]) == null ? void 0 : _a.ref;
268
+ const instRef = (_a2 = componentInstMap.current[activePaymentCategory]) == null ? void 0 : _a2.ref;
268
269
  (_b = instRef == null ? void 0 : instRef.payment) == null ? void 0 : _b.call(instRef);
269
270
  }
270
271
  }
271
272
  }));
272
273
  y(() => {
273
- var _a, _b;
274
+ var _a2, _b;
274
275
  if (!activePaymentCategory) {
275
276
  return;
276
277
  }
277
278
  const currCompInst = componentInstMap.current[activePaymentCategory];
278
279
  if (currCompInst) {
279
280
  const ref2 = currCompInst.ref;
280
- (_a = ref2.updateAddress) == null ? void 0 : _a.call(ref2);
281
+ (_a2 = ref2.updateAddress) == null ? void 0 : _a2.call(ref2);
281
282
  (_b = ref2.updateEmail) == null ? void 0 : _b.call(ref2);
282
283
  }
283
284
  }, [activePaymentCategory]);
@@ -295,7 +296,7 @@ const DropIn = w((props, ref) => {
295
296
  }
296
297
  }, [headerPaymentCategories]);
297
298
  const createComponent = (category) => {
298
- const { onError, onSuccess, onTimeout, onExpired, onSubmit, onAuthorized } = props;
299
+ const { onError, onSuccess, onTimeout, onExpired, onSubmit, onAuthorized, onSubmitResponse } = props;
299
300
  return createCheckoutChild(
300
301
  props.core,
301
302
  PaymentComponentMap[category],
@@ -305,7 +306,8 @@ const DropIn = w((props, ref) => {
305
306
  onTimeout,
306
307
  onExpired,
307
308
  onSubmit,
308
- onAuthorized
309
+ onAuthorized,
310
+ onSubmitResponse
309
311
  },
310
312
  {
311
313
  ...paymentMethodsConfig == null ? void 0 : paymentMethodsConfig[category],
@@ -373,11 +375,11 @@ const DropIn = w((props, ref) => {
373
375
  setActivePaymentCategory(newPaymentCategory);
374
376
  };
375
377
  y(() => {
376
- var _a, _b, _c;
378
+ var _a2, _b, _c, _d;
377
379
  if (!sessionReady || !i18n.ready.value) {
378
380
  return;
379
381
  }
380
- if (((_a = session.checkout) == null ? void 0 : _a.sessionMode) === SessionMode.COMPONENT) {
382
+ if (((_a2 = session.checkout) == null ? void 0 : _a2.sessionMode) === SessionMode.COMPONENT) {
381
383
  (_c = (_b = props.core.config).onInitError) == null ? void 0 : _c.call(
382
384
  _b,
383
385
  new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
@@ -393,21 +395,22 @@ const DropIn = w((props, ref) => {
393
395
  return;
394
396
  }
395
397
  initPaymentCategories(enablePaymentMethods);
396
- if (core.processingPaymentMethod) {
397
- const category = PaymentMethod2CategoryMap[core.processingPaymentMethod];
398
+ const currPaymentMethod = (_d = core.payment) == null ? void 0 : _d.currPaymentMethod.value;
399
+ if (currPaymentMethod) {
400
+ const category = PaymentMethod2CategoryMap[currPaymentMethod];
398
401
  category && setActivePaymentCategory(category);
399
- core.enablePaymentMethod.value = core.processingPaymentMethod;
400
402
  }
401
403
  }, [sessionReady, i18n.ready.value]);
402
404
  y(() => {
403
- if (core.enablePaymentMethod.value) {
405
+ var _a2, _b;
406
+ if ((_a2 = core.payment) == null ? void 0 : _a2.currPaymentMethod.value) {
404
407
  setEnablePaymentMethod(
405
- PaymentMethod2CategoryMap[core.enablePaymentMethod.value]
408
+ PaymentMethod2CategoryMap[(_b = core.payment) == null ? void 0 : _b.currPaymentMethod.value]
406
409
  );
407
410
  } else {
408
411
  setEnablePaymentMethod(void 0);
409
412
  }
410
- }, [core.enablePaymentMethod.value]);
413
+ }, [(_a = core.payment) == null ? void 0 : _a.currPaymentMethod.value]);
411
414
  const HeaderField = () => {
412
415
  return /* @__PURE__ */ u(b, { children: headerPaymentCategories == null ? void 0 : headerPaymentCategories.map((category) => /* @__PURE__ */ u(
413
416
  "div",
@@ -5,7 +5,7 @@ import "../../utils/system-info/get-browser-info.js";
5
5
  import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
6
6
  import { GooglePayEventType } from "../../types/event.js";
7
7
  import { deepMerge } from "../../utils/object.js";
8
- import { formatPaymentResult } from "../../utils/payment.js";
8
+ import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
9
9
  import { getBrowserParams } from "../../api/modules/get-browser-params.js";
10
10
  import { PaymentMethod, SessionMode } from "../../constant.js";
11
11
  import { getGooglePayInfo, googlePay } from "../../api/modules/google-pay/index.js";
@@ -18,7 +18,7 @@ import { useRetry } from "../../hooks/useRetry.js";
18
18
  import { Info } from "../internal/Info/Info.js";
19
19
  import { loadScript } from "../../utils/load.js";
20
20
  import { ThreeDSAuth } from "../ThreeDS/index.js";
21
- const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse) => {
21
+ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse, onCancel) => {
22
22
  const {
23
23
  transAmount,
24
24
  theme: { merchantName }
@@ -163,8 +163,10 @@ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse
163
163
  try {
164
164
  await paymentsClient2.loadPaymentData(paymentDataRequest);
165
165
  } catch (err) {
166
+ core.payment.resetCurrPaymentMethod();
166
167
  if ((err == null ? void 0 : err.statusCode) === "CANCELED") {
167
168
  (_b = (_a = core.config).onEvent) == null ? void 0 : _b.call(_a, GooglePayEventType.GOOGLE_PAY_CANCELLED);
169
+ onCancel == null ? void 0 : onCancel();
168
170
  } else {
169
171
  (_c = core.logger) == null ? void 0 : _c.reportErrorEvent(new PayKKaError(
170
172
  "ERROR",
@@ -211,7 +213,7 @@ const GooglePay = w((props, ref) => {
211
213
  F(ref, () => ({
212
214
  checkThreeDS
213
215
  }));
214
- const { sessionReady, i18n, fraudDetection } = usePayState(session, props.core);
216
+ const { sessionReady, i18n, fraudDetection, disabled } = usePayState(session, props.core);
215
217
  const [errorMsg, setErrorMsg] = h("");
216
218
  const [showGooglePay, setShowGooglePay] = h(false);
217
219
  const [showThreeDSModal, setShowThreeDSModal] = h(false);
@@ -224,9 +226,10 @@ const GooglePay = w((props, ref) => {
224
226
  };
225
227
  const onTimeout = q(
226
228
  (message) => {
227
- var _a2;
229
+ var _a2, _b;
230
+ (_a2 = core.payment) == null ? void 0 : _a2.resetCurrPaymentMethod();
228
231
  setErrorMsg(message || i18n.get("common.payTimeout"));
229
- (_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry", getPaymentMethodContext());
232
+ (_b = props.onTimeout) == null ? void 0 : _b.call(props, "retry", getPaymentMethodContext());
230
233
  },
231
234
  [i18n, props.onTimeout]
232
235
  );
@@ -326,12 +329,13 @@ const GooglePay = w((props, ref) => {
326
329
  };
327
330
  };
328
331
  async function pay(token, billAddress, search = false, timeout) {
329
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
332
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
330
333
  setErrorMsg("");
331
334
  if (!search) {
332
335
  (_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, void 0, getPaymentMethodContext());
333
336
  }
334
337
  try {
338
+ core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
335
339
  const requestOptions = { locale: i18n.locale, timeout };
336
340
  let res = null;
337
341
  if (search) {
@@ -353,31 +357,36 @@ const GooglePay = w((props, ref) => {
353
357
  requestOptions
354
358
  );
355
359
  }
356
- const { status, orderStatus, errorMessage, payInfo = {}, errorCode, sessionId } = res;
360
+ const { errorMessage, payInfo = {}, errorCode, sessionId } = res;
357
361
  const { threeDSUrl } = payInfo;
358
362
  sessionId && (session.sessionId = sessionId);
359
363
  !search && ((_f = props.onSubmitResponse) == null ? void 0 : _f.call(props, res, getPaymentMethodContext()));
360
- if (status === "PROCESSING") {
361
- if (orderStatus === "SUCCESS") {
362
- processOnSuccess(res);
363
- return {
364
- end: true,
365
- res: { transactionState: "SUCCESS" }
366
- };
367
- } else if (orderStatus === "PROCESSING") {
364
+ let result = {
365
+ end: true,
366
+ res: { transactionState: "SUCCESS" }
367
+ };
368
+ await processPaymentStatus(res, {
369
+ onProcessing: async () => {
368
370
  const res2 = await startReFetchPayInfo();
369
- return (res2 == null ? void 0 : res2.end) === true ? {
370
- end: true,
371
- res: res2.res
372
- } : await startReFetchPayInfo();
373
- } else if (orderStatus === "FAILURE") {
371
+ if ((res2 == null ? void 0 : res2.end) === true) {
372
+ result = res2.res;
373
+ } else {
374
+ result = await startReFetchPayInfo();
375
+ }
376
+ },
377
+ onSuccess: () => {
378
+ processOnSuccess(res);
379
+ },
380
+ onFailure: () => {
381
+ var _a3, _b2;
374
382
  errorMessage && setErrorMsg(errorMessage);
375
- (_g = props.onError) == null ? void 0 : _g.call(
383
+ (_a3 = core.payment) == null ? void 0 : _a3.resetCurrPaymentMethod();
384
+ (_b2 = props.onError) == null ? void 0 : _b2.call(
376
385
  props,
377
386
  new PayKKaError("API_ERROR", errorMessage, { code: errorCode }),
378
387
  getPaymentMethodContext()
379
388
  );
380
- return {
389
+ result = {
381
390
  end: true,
382
391
  res: {
383
392
  transactionState: "ERROR",
@@ -388,48 +397,31 @@ const GooglePay = w((props, ref) => {
388
397
  }
389
398
  }
390
399
  };
391
- } else if (orderStatus === "AUTHORIZED") {
392
- (_h = props.onAuthorized) == null ? void 0 : _h.call(props, getPaymentMethodContext());
393
- return {
394
- end: true,
395
- res: { transactionState: "SUCCESS" }
396
- };
397
- } else if (orderStatus === "IN_THREED") {
400
+ },
401
+ onAuthorized: () => {
402
+ var _a3;
403
+ (_a3 = props.onAuthorized) == null ? void 0 : _a3.call(props, getPaymentMethodContext());
404
+ },
405
+ onInThreeDS: () => {
398
406
  threeDSUrl && processThreeDS(threeDSUrl, false);
399
- return {
400
- end: true,
401
- res: { transactionState: "SUCCESS" }
402
- };
403
- } else if (orderStatus === "IN_PREVIOUS_THREED") {
407
+ },
408
+ onInPreviousThreeDS: () => {
404
409
  threeDSUrl && processThreeDS(threeDSUrl, true);
405
- return {
406
- end: true,
407
- res: { transactionState: "SUCCESS" }
408
- };
409
- } else if (!orderStatus) {
410
- return {
410
+ },
411
+ onExpired: () => {
412
+ var _a3;
413
+ (_a3 = props.onExpired) == null ? void 0 : _a3.call(props, getPaymentMethodContext());
414
+ },
415
+ onDefault: () => {
416
+ var _a3;
417
+ (_a3 = core.payment) == null ? void 0 : _a3.resetCurrPaymentMethod();
418
+ result = {
411
419
  end: true,
412
- res: { transactionState: "SUCCESS" }
420
+ res: { transactionState: "ERROR" }
413
421
  };
414
422
  }
415
- } else if (status === "SUCCESS") {
416
- processOnSuccess(res);
417
- return {
418
- end: true,
419
- res: { transactionState: "SUCCESS" }
420
- };
421
- } else if (status === "EXPIRED") {
422
- (_i = props.onExpired) == null ? void 0 : _i.call(props, getPaymentMethodContext());
423
- return {
424
- end: true,
425
- res: { transactionState: "SUCCESS" }
426
- };
427
- }
428
- processOnSuccess(res);
429
- return {
430
- end: false,
431
- res: { transactionState: "SUCCESS" }
432
- };
423
+ });
424
+ return result;
433
425
  } catch (error) {
434
426
  if (isTimeoutError(error)) {
435
427
  if (search) {
@@ -449,9 +441,10 @@ const GooglePay = w((props, ref) => {
449
441
  };
450
442
  }
451
443
  } else {
444
+ (_g = core.payment) == null ? void 0 : _g.resetCurrPaymentMethod();
452
445
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
453
446
  setErrorMsg(message);
454
- (_j = props.onError) == null ? void 0 : _j.call(
447
+ (_h = props.onError) == null ? void 0 : _h.call(
455
448
  props,
456
449
  new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
457
450
  getPaymentMethodContext()
@@ -478,7 +471,7 @@ const GooglePay = w((props, ref) => {
478
471
  }
479
472
  );
480
473
  async function checkThreeDS(search = false) {
481
- var _a2, _b, _c, _d, _e;
474
+ var _a2, _b, _c, _d;
482
475
  if (!session)
483
476
  return { end: true };
484
477
  try {
@@ -493,35 +486,48 @@ const GooglePay = w((props, ref) => {
493
486
  locale: i18n.locale
494
487
  }
495
488
  );
496
- const { status, orderStatus, errorMessage } = res;
497
- if (status === "PROCESSING") {
498
- if (orderStatus === "PROCESSING") {
489
+ const { errorMessage } = res;
490
+ let end = true;
491
+ await processPaymentStatus(res, {
492
+ onProcessing: () => {
499
493
  startReFetchPayInfo();
500
- } else if (orderStatus === "FAILURE") {
494
+ stopReFetchCardPay3DSInfo();
495
+ },
496
+ onSuccess: () => {
497
+ processOnSuccess(res);
498
+ stopReFetchCardPay3DSInfo();
499
+ },
500
+ onFailure: () => {
501
+ var _a3;
502
+ (_a3 = core.payment) == null ? void 0 : _a3.resetCurrPaymentMethod();
501
503
  errorMessage && setErrorMsg(errorMessage);
502
- } else if (orderStatus === "AUTHORIZED") {
503
- (_c = props.onAuthorized) == null ? void 0 : _c.call(props, getPaymentMethodContext());
504
- } else if (orderStatus === "IN_THREED") {
504
+ stopReFetchCardPay3DSInfo();
505
+ },
506
+ onAuthorized: () => {
507
+ var _a3;
508
+ (_a3 = props.onAuthorized) == null ? void 0 : _a3.call(props, getPaymentMethodContext());
509
+ stopReFetchCardPay3DSInfo();
510
+ },
511
+ onInThreeDS: () => {
505
512
  !search && startReFetchCardPay3DSInfo();
506
- return { end: false };
507
- } else if (orderStatus === "IN_PREVIOUS_THREED") {
513
+ end = false;
514
+ },
515
+ onInPreviousThreeDS: () => {
508
516
  setErrorMsg(i18n.get("common.pay3DSIncomplete"));
509
- } else if (!orderStatus) {
517
+ stopReFetchCardPay3DSInfo();
518
+ },
519
+ onExpired: () => {
520
+ var _a3;
521
+ stopReFetchCardPay3DSInfo();
522
+ (_a3 = props.onExpired) == null ? void 0 : _a3.call(props, getPaymentMethodContext());
523
+ },
524
+ onDefault: () => {
525
+ var _a3;
526
+ stopReFetchCardPay3DSInfo();
527
+ (_a3 = core.payment) == null ? void 0 : _a3.resetCurrPaymentMethod();
510
528
  }
511
- stopReFetchCardPay3DSInfo();
512
- return { end: true };
513
- } else if (status === "SUCCESS") {
514
- processOnSuccess(res);
515
- stopReFetchCardPay3DSInfo();
516
- return { end: true };
517
- } else if (status === "EXPIRED") {
518
- (_d = props.onExpired) == null ? void 0 : _d.call(props, getPaymentMethodContext());
519
- stopReFetchCardPay3DSInfo();
520
- return { end: true };
521
- }
522
- processOnSuccess(res);
523
- stopReFetchCardPay3DSInfo();
524
- return { end: true };
529
+ });
530
+ return { end };
525
531
  } catch (error) {
526
532
  if (isTimeoutError(error)) {
527
533
  if (search) {
@@ -533,11 +539,13 @@ const GooglePay = w((props, ref) => {
533
539
  } else {
534
540
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
535
541
  setErrorMsg(message);
536
- (_e = props.onError) == null ? void 0 : _e.call(
542
+ (_c = props.onError) == null ? void 0 : _c.call(
537
543
  props,
538
544
  new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
539
545
  getPaymentMethodContext()
540
546
  );
547
+ (_d = core.payment) == null ? void 0 : _d.resetCurrPaymentMethod();
548
+ stopReFetchCardPay3DSInfo();
541
549
  return { end: true };
542
550
  }
543
551
  }
@@ -555,13 +563,14 @@ const GooglePay = w((props, ref) => {
555
563
  (_b = (_a2 = core.config).onEvent) == null ? void 0 : _b.call(_a2, GooglePayEventType.GOOGLE_PAY_BUTTON_CLICKED);
556
564
  (_c = props.onBtnClick) == null ? void 0 : _c.call(props);
557
565
  },
558
- props.onCanUse
566
+ props.onCanUse,
567
+ props.onCancel
559
568
  );
560
569
  onGooglePayLoaded(containRef.current);
561
570
  }
562
571
  }, [sessionReady, containRef, i18n.ready.value, showGooglePay]);
563
572
  const Button = () => {
564
- return /* @__PURE__ */ u("div", { style: "width: 100%; height: 44px", children: /* @__PURE__ */ u("div", { id: "container", style: "width:100%; height: 44px", ref: containRef }) });
573
+ return /* @__PURE__ */ u("div", { style: "width: 100%; height: 44px", className: bem("button", { disabled }), children: /* @__PURE__ */ u("div", { id: "container", style: "width:100%; height: 44px", ref: containRef }) });
565
574
  };
566
575
  return /* @__PURE__ */ u("div", { children: sessionReady && showGooglePay && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
567
576
  !!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
@@ -47,7 +47,7 @@ const PaymentButton = (props) => {
47
47
  style: props.style,
48
48
  icon: Icon(),
49
49
  loading: status === "loading",
50
- disabled: props.disabled || status === "success",
50
+ disabled: (props.disabled || status === "success") && status !== "loading",
51
51
  onClick: props.onClick,
52
52
  children: /* @__PURE__ */ u("span", { className: bem("text", { "not-verified": !verified }), children: text || props.children })
53
53
  }
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import "../../utils/card-brand/brands.js";
8
8
  import "../../utils/system-info/get-browser-info.js";
9
- import { w, A, F, y, q, u } from "../../core.js";
9
+ import { w, A, y, F, q, u } from "../../core.js";
10
10
  import { SessionMode } from "../../constant.js";
11
11
  import { cdnUrl, cdnOrigin, apiUrl, apiPrefix } from "../../config.js";
12
12
  import { MessageAction } from "../../types/message.js";
@@ -84,7 +84,7 @@ class SecuredField {
84
84
  }
85
85
  }
86
86
  const SecuredFieldsProvider = w((props, ref) => {
87
- const { sessionMode, i18n, targetElement, checkoutId, onEvent, core } = props;
87
+ const { sessionMode, i18n, targetElement, checkoutId, onEvent, core, disabled = false } = props;
88
88
  const rootNodeRef = A(null);
89
89
  const hiddenIframe = A(null);
90
90
  const payment = (formData, extraParams) => {
@@ -97,6 +97,23 @@ const SecuredFieldsProvider = w((props, ref) => {
97
97
  };
98
98
  postMessageToIframe(data, hiddenIframe.current.contentWindow, cdnOrigin);
99
99
  };
100
+ const sendSetConfigMessage = (iframeWindow) => {
101
+ console.log("disabled", disabled, iframeWindow);
102
+ const data = {
103
+ action: MessageAction.SET_CONFIG,
104
+ checkoutId,
105
+ disabled
106
+ };
107
+ postMessageToIframe(data, iframeWindow, cdnOrigin);
108
+ };
109
+ y(() => {
110
+ Object.values(securedFieldMap.current).forEach((field) => {
111
+ var _a;
112
+ if ((_a = field == null ? void 0 : field.iframe) == null ? void 0 : _a.contentWindow) {
113
+ sendSetConfigMessage(field.iframe.contentWindow);
114
+ }
115
+ });
116
+ }, [disabled]);
100
117
  F(ref, () => ({
101
118
  payment,
102
119
  reload: () => {
@@ -154,7 +171,8 @@ const SecuredFieldsProvider = w((props, ref) => {
154
171
  };
155
172
  const initHiddenIframe = async () => {
156
173
  const iframeEl = createIframe(`${cdnUrl}/secured-iframe.html`);
157
- iframeEl.name = `${HIDDEN_IFRAME_NAME}-${checkoutId}-${Date.now()}`;
174
+ const hiddenIframeName = `${HIDDEN_IFRAME_NAME}-${checkoutId}-${Date.now()}`;
175
+ iframeEl.name = hiddenIframeName;
158
176
  iframeEl.width = "0";
159
177
  iframeEl.height = "0";
160
178
  iframeEl.style.border = "none";
@@ -211,7 +229,7 @@ const SecuredFieldsProvider = w((props, ref) => {
211
229
  return isFieldIframe || isHiddenIframe;
212
230
  };
213
231
  const onReceiveMessage = q((event) => {
214
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
232
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
215
233
  const { data, origin, source } = event;
216
234
  if (origin !== cdnOrigin) {
217
235
  return;
@@ -277,20 +295,24 @@ const SecuredFieldsProvider = w((props, ref) => {
277
295
  break;
278
296
  case MessageAction.ACTIVATED:
279
297
  (_l = props.onActivated) == null ? void 0 : _l.call(props, feedbackData);
298
+ sendSetConfigMessage(source);
299
+ break;
300
+ case MessageAction.HIDDEN_IFRAME_READY:
301
+ (_m = props.onHiddenIframeReady) == null ? void 0 : _m.call(props, feedbackData);
280
302
  break;
281
303
  case MessageAction.CARD_ENCRYPTED:
282
- (_m = props.onCardEncrypted) == null ? void 0 : _m.call(props, feedbackData);
304
+ (_n = props.onCardEncrypted) == null ? void 0 : _n.call(props, feedbackData);
283
305
  break;
284
306
  case MessageAction.CARD_ENCRYPTION_FAILED:
285
- (_n = props.onCardEncryptionFailed) == null ? void 0 : _n.call(props, feedbackData);
307
+ (_o = props.onCardEncryptionFailed) == null ? void 0 : _o.call(props, feedbackData);
286
308
  break;
287
309
  case MessageAction.VALIDATED:
288
- (_o = props.onValidated) == null ? void 0 : _o.call(props, feedbackData);
310
+ (_p = props.onValidated) == null ? void 0 : _p.call(props, feedbackData);
289
311
  break;
290
312
  case MessageAction.IFRAME_ERROR: {
291
313
  const data2 = feedbackData;
292
- (_r = core == null ? void 0 : core.logger) == null ? void 0 : _r.reportErrorEvent(
293
- new PayKKaError(EPayKKaError.ERROR, (_p = data2.error) == null ? void 0 : _p.message, { cause: (_q = data2.error) == null ? void 0 : _q.stack })
314
+ (_s = core == null ? void 0 : core.logger) == null ? void 0 : _s.reportErrorEvent(
315
+ new PayKKaError(EPayKKaError.ERROR, (_q = data2.error) == null ? void 0 : _q.message, { cause: (_r = data2.error) == null ? void 0 : _r.stack })
294
316
  );
295
317
  break;
296
318
  }