@paykka/card-checkout-ui 0.11.5 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/card-checkout-ui.js +17 -17
  2. package/dist/card-checkout-ui.umd.cjs +17 -17
  3. package/dist/es/api/index.js +1 -0
  4. package/dist/es/api/modules/address/index.js +9 -9
  5. package/dist/es/api/modules/ali-pay/index.js +10 -49
  6. package/dist/es/api/modules/apple-pay/index.js +13 -59
  7. package/dist/es/api/modules/boost/index.js +8 -48
  8. package/dist/es/api/modules/card/index.js +10 -54
  9. package/dist/es/api/modules/checkout/index.js +14 -14
  10. package/dist/es/api/modules/checkout/map.js +25 -18
  11. package/dist/es/api/modules/encrypted-card/index.js +3 -2
  12. package/dist/es/api/modules/gcash/index.js +8 -48
  13. package/dist/es/api/modules/google-pay/index.js +10 -56
  14. package/dist/es/api/modules/grab-pay/index.js +8 -48
  15. package/dist/es/api/modules/index.js +1 -0
  16. package/dist/es/api/modules/line-pay/index.js +8 -48
  17. package/dist/es/api/modules/map.js +17 -11
  18. package/dist/es/api/modules/may-bank-qr-pay/index.js +8 -48
  19. package/dist/es/api/modules/nine-pay/index.js +8 -48
  20. package/dist/es/api/modules/paymaya/index.js +8 -48
  21. package/dist/es/api/modules/risk/index.js +2 -1
  22. package/dist/es/api/modules/sepa/index.js +10 -51
  23. package/dist/es/api/modules/shopee-pay/index.js +8 -48
  24. package/dist/es/api/modules/threeDS/index.js +3 -0
  25. package/dist/es/api/modules/tng-wallet/index.js +8 -48
  26. package/dist/es/api/modules/wechat-pay/index.js +10 -51
  27. package/dist/es/api/modules/zalopay/index.js +16 -0
  28. package/dist/es/api/utils/index.js +59 -0
  29. package/dist/es/components/AddressField/index.js +37 -37
  30. package/dist/es/components/AliPay/index.js +143 -90
  31. package/dist/es/components/ApplePay/index.js +99 -67
  32. package/dist/es/components/Boost/index.js +66 -39
  33. package/dist/es/components/Card/index.js +90 -79
  34. package/dist/es/components/CardSelector/index.js +1 -1
  35. package/dist/es/components/DropIn/index.js +12 -4
  36. package/dist/es/components/EncryptedCard/index.js +1 -1
  37. package/dist/es/components/GooglePay/index.js +93 -60
  38. package/dist/es/components/GrabPay/index.js +66 -39
  39. package/dist/es/components/GuideCard/index.js +10 -7
  40. package/dist/es/components/LinePay/index.js +66 -39
  41. package/dist/es/components/MayBankQRPay/index.js +306 -273
  42. package/dist/es/components/NinePay/index.js +66 -39
  43. package/dist/es/components/SecuredFieldsProvider/index.js +3 -2
  44. package/dist/es/components/SecuredIframe/index.js +4 -2
  45. package/dist/es/components/Sepa/index.js +62 -39
  46. package/dist/es/components/ShopeePay/index.js +66 -39
  47. package/dist/es/components/SubmitButton/index.js +8 -7
  48. package/dist/es/components/TNGWallet/index.js +66 -39
  49. package/dist/es/components/WechatPay/index.js +146 -92
  50. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
  51. package/dist/es/components/index.js +1 -0
  52. package/dist/es/components/internal/Modal/Modal.js +1 -1
  53. package/dist/es/components/internal/Select/Select.js +19 -8
  54. package/dist/es/components/internal/Select/SelectMenuItem.js +12 -4
  55. package/dist/es/components/internal/icons/IconZalopay.js +47 -0
  56. package/dist/es/components/internal/icons/IconZalopayComplete.js +48 -0
  57. package/dist/es/components/wallets/GCash/GCash.js +68 -39
  58. package/dist/es/components/wallets/Paymaya/Paymaya.js +66 -39
  59. package/dist/es/components/wallets/Zalopay/Zalopay.js +386 -0
  60. package/dist/es/components/wallets/Zalopay/index.js +1 -0
  61. package/dist/es/components/wallets/Zalopay/type.js +1 -0
  62. package/dist/es/components/wallets/Zalopay/zalopay2.js +1 -0
  63. package/dist/es/config.js +5 -5
  64. package/dist/es/constant.js +8 -2
  65. package/dist/es/core/{Address.js → address.js} +8 -16
  66. package/dist/es/core/{PayKKaCheckout.js → checkout.js} +78 -27
  67. package/dist/es/core/query.js +3 -2
  68. package/dist/es/core/{Session.js → session.js} +37 -20
  69. package/dist/es/core.js +34 -38
  70. package/dist/es/hooks/usePayment.js +14 -0
  71. package/dist/es/i18n/locales/de-DE.js +3 -1
  72. package/dist/es/i18n/locales/en-GB.js +3 -1
  73. package/dist/es/i18n/locales/es-ES.js +3 -1
  74. package/dist/es/i18n/locales/fr-FR.js +3 -1
  75. package/dist/es/i18n/locales/ja-JP.js +3 -1
  76. package/dist/es/i18n/locales/ko-KR.js +3 -1
  77. package/dist/es/i18n/locales/nl-NL.js +3 -1
  78. package/dist/es/i18n/locales/pt-PT.js +3 -1
  79. package/dist/es/i18n/locales/ru-RU.js +3 -1
  80. package/dist/es/i18n/locales/zh-CN.js +3 -1
  81. package/dist/es/i18n/locales/zh-HK.js +3 -1
  82. package/dist/es/i18n/locales/zh-TW.js +3 -1
  83. package/dist/es/index.js +16 -4
  84. package/dist/es/style.css +1 -1
  85. package/dist/es/types/index.js +7 -0
  86. package/dist/es/utils/colors.js +5 -1
  87. package/dist/es/utils/payment.js +82 -0
  88. package/dist/es/utils/redirect.js +4 -4
  89. package/dist/es/utils/request-cache-manager.js +32 -0
  90. package/dist/style.css +1 -1
  91. package/dist/types/api/modules/address/index.d.ts +15 -6
  92. package/dist/types/api/modules/ali-pay/index.d.ts +3 -19
  93. package/dist/types/api/modules/apple-pay/index.d.ts +4 -14
  94. package/dist/types/api/modules/boost/index.d.ts +3 -23
  95. package/dist/types/api/modules/card/index.d.ts +3 -30
  96. package/dist/types/api/modules/checkout/index.d.ts +3 -3
  97. package/dist/types/api/modules/checkout/map.d.ts +3 -3
  98. package/dist/types/api/modules/checkout/type.d.ts +33 -4
  99. package/dist/types/api/modules/gcash/index.d.ts +3 -23
  100. package/dist/types/api/modules/google-pay/index.d.ts +3 -13
  101. package/dist/types/api/modules/grab-pay/index.d.ts +3 -23
  102. package/dist/types/api/modules/index.d.ts +1 -0
  103. package/dist/types/api/modules/line-pay/index.d.ts +3 -23
  104. package/dist/types/api/modules/map.d.ts +2 -2
  105. package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +3 -23
  106. package/dist/types/api/modules/nine-pay/index.d.ts +3 -23
  107. package/dist/types/api/modules/paymaya/index.d.ts +3 -23
  108. package/dist/types/api/modules/sepa/index.d.ts +3 -24
  109. package/dist/types/api/modules/shopee-pay/index.d.ts +3 -23
  110. package/dist/types/api/modules/tng-wallet/index.d.ts +3 -23
  111. package/dist/types/api/modules/type.d.ts +74 -21
  112. package/dist/types/api/modules/wechat-pay/index.d.ts +3 -20
  113. package/dist/types/api/modules/zalopay/index.d.ts +4 -0
  114. package/dist/types/api/utils/index.d.ts +48 -0
  115. package/dist/types/components/AddressField/type.d.ts +3 -9
  116. package/dist/types/components/AliPay/AliPay.d.ts +6 -2
  117. package/dist/types/components/AliPay/type.d.ts +15 -2
  118. package/dist/types/components/ApplePay/ApplePay.d.ts +6 -2
  119. package/dist/types/components/ApplePay/type.d.ts +10 -14
  120. package/dist/types/components/ApplePay/utils.d.ts +1 -1
  121. package/dist/types/components/Boost/Boost.d.ts +6 -2
  122. package/dist/types/components/Boost/type.d.ts +2 -24
  123. package/dist/types/components/Card/Card.d.ts +6 -2
  124. package/dist/types/components/Card/type.d.ts +3 -43
  125. package/dist/types/components/DropIn/DropIn.d.ts +6 -2
  126. package/dist/types/components/DropIn/type.d.ts +4 -10
  127. package/dist/types/components/GooglePay/GooglePay.d.ts +6 -2
  128. package/dist/types/components/GooglePay/createGooglePay.d.ts +2 -1
  129. package/dist/types/components/GooglePay/type.d.ts +10 -26
  130. package/dist/types/components/GrabPay/GrabPay.d.ts +6 -2
  131. package/dist/types/components/GrabPay/type.d.ts +3 -25
  132. package/dist/types/components/LinePay/LinePay.d.ts +6 -2
  133. package/dist/types/components/LinePay/type.d.ts +3 -25
  134. package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -2
  135. package/dist/types/components/MayBankQRPay/type.d.ts +3 -25
  136. package/dist/types/components/NinePay/NinePay.d.ts +6 -2
  137. package/dist/types/components/NinePay/type.d.ts +3 -25
  138. package/dist/types/components/Sepa/Sepa.d.ts +6 -2
  139. package/dist/types/components/Sepa/type.d.ts +3 -2
  140. package/dist/types/components/ShopeePay/ShopeePay.d.ts +6 -2
  141. package/dist/types/components/ShopeePay/type.d.ts +3 -25
  142. package/dist/types/components/TNGWallet/TNGWallet.d.ts +6 -2
  143. package/dist/types/components/TNGWallet/type.d.ts +3 -25
  144. package/dist/types/components/WechatPay/WechatPay.d.ts +6 -2
  145. package/dist/types/components/WechatPay/type.d.ts +15 -2
  146. package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
  147. package/dist/types/components/index.d.ts +1 -0
  148. package/dist/types/components/internal/icons/IconZalopay.d.ts +2 -0
  149. package/dist/types/components/internal/icons/IconZalopayComplete.d.ts +2 -0
  150. package/dist/types/components/internal/icons/index.d.ts +3 -0
  151. package/dist/types/components/wallets/GCash/GCash.d.ts +6 -2
  152. package/dist/types/components/wallets/GCash/type.d.ts +3 -35
  153. package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -2
  154. package/dist/types/components/wallets/Paymaya/type.d.ts +3 -25
  155. package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +10 -0
  156. package/dist/types/components/wallets/Zalopay/index.d.ts +2 -0
  157. package/dist/types/components/wallets/Zalopay/type.d.ts +39 -0
  158. package/dist/types/config.d.ts +2 -4
  159. package/dist/types/constant.d.ts +3 -1
  160. package/dist/types/core/{Address.d.ts → address.d.ts} +23 -24
  161. package/dist/types/core/{PayKKaCheckout.d.ts → checkout.d.ts} +5 -3
  162. package/dist/types/core/context.d.ts +3 -2
  163. package/dist/types/core/index.d.ts +2 -2
  164. package/dist/types/core/query.d.ts +2 -2
  165. package/dist/types/core/session.d.ts +33 -0
  166. package/dist/types/hooks/index.d.ts +1 -0
  167. package/dist/types/hooks/usePayment.d.ts +8 -0
  168. package/dist/types/i18n/locales/de-DE.d.ts +2 -0
  169. package/dist/types/i18n/locales/en-GB.d.ts +2 -0
  170. package/dist/types/i18n/locales/es-ES.d.ts +2 -0
  171. package/dist/types/i18n/locales/fr-FR.d.ts +2 -0
  172. package/dist/types/i18n/locales/ja-JP.d.ts +2 -0
  173. package/dist/types/i18n/locales/ko-KR.d.ts +2 -0
  174. package/dist/types/i18n/locales/nl-NL.d.ts +2 -0
  175. package/dist/types/i18n/locales/pt-PT.d.ts +2 -0
  176. package/dist/types/i18n/locales/ru-RU.d.ts +2 -0
  177. package/dist/types/i18n/locales/zh-CN.d.ts +2 -0
  178. package/dist/types/i18n/locales/zh-HK.d.ts +2 -0
  179. package/dist/types/i18n/locales/zh-TW.d.ts +2 -0
  180. package/dist/types/index.d.ts +2 -1
  181. package/dist/types/types/index.d.ts +70 -32
  182. package/dist/types/types/message.d.ts +1 -0
  183. package/dist/types/utils/card-brand/index.d.ts +3 -3
  184. package/dist/types/utils/colors.d.ts +1 -0
  185. package/dist/types/utils/index.d.ts +1 -0
  186. package/dist/types/utils/payment.d.ts +37 -0
  187. package/dist/types/utils/request-cache-manager.d.ts +12 -0
  188. package/package.json +67 -67
  189. package/dist/types/core/Session.d.ts +0 -16
@@ -1,15 +1,14 @@
1
1
  import { w, A, h, F, y, q, T, u, b } from "../../core.js";
2
2
  import { isTimeoutError } from "../../api/http.js";
3
- import { PaymentType, SessionMode, CardPaymentMethods, COMMON_CLASS_NAME, PaymentMethod } from "../../constant.js";
4
3
  import { intersection } from "../../utils/index.js";
5
- import { getBrowserParams } from "../../api/modules/get-browser-params.js";
4
+ import { defaultInputStyleConfig } from "../../types/index.js";
6
5
  import { getCardPayInfo, cardPay } from "../../api/modules/card/index.js";
6
+ import { getBrowserParams } from "../../api/modules/get-browser-params.js";
7
+ import { PaymentType, SessionMode, CardPaymentMethods, PaymentMethod, COMMON_CLASS_NAME } from "../../constant.js";
7
8
  import { CoreContext } from "../../core/context.js";
8
9
  import { PayKKaError } from "../../core/error.js";
9
- import { hidePaymentButton } from "../../config.js";
10
- import { defaultInputStyleConfig } from "../../types/index.js";
11
10
  import { WorldpayDDC } from "../../out/worldpay-ddc.js";
12
- import { createAddressCore } from "../../core/Address.js";
11
+ import { createPromise } from "../../utils/create-promise.js";
13
12
  import { useBEM } from "../../hooks/useBEM.js";
14
13
  import { usePayState } from "../../hooks/usePayState.js";
15
14
  import { useRetry } from "../../hooks/useRetry.js";
@@ -36,8 +35,8 @@ import { CombinedCardInfo } from "../CombinedCardInfo/index.js";
36
35
  import { cardBrandCodes } from "../../utils/card-brand/brands.js";
37
36
  import { findCardBrand } from "../../utils/card-brand/index.js";
38
37
  import { separateInputStyle } from "../../utils/style.js";
39
- import { createPromise } from "../../utils/create-promise.js";
40
38
  import { cssVarPrefix, normalizedClass, trimAll, formatAmount } from "../../utils/format.js";
39
+ import { formatPaymentResult } from "../../utils/payment.js";
41
40
  const { bem } = useBEM("card");
42
41
  const fieldClassNames = bem("field");
43
42
  const Card = w((props, ref) => {
@@ -53,9 +52,10 @@ const Card = w((props, ref) => {
53
52
  styles,
54
53
  enable3DSModal = true,
55
54
  isDropIn,
56
- core
55
+ core,
56
+ hidePaymentButton = false
57
57
  } = props;
58
- const addressState = createAddressCore();
58
+ const addressCore = core.getAddressCore();
59
59
  const emailState = createEmailCore();
60
60
  const { i18n, fraudDetection, sessionReady } = usePayState(session, core);
61
61
  const addressFieldRef = A(null);
@@ -70,13 +70,13 @@ const Card = w((props, ref) => {
70
70
  holderName: "",
71
71
  cardInfo: "",
72
72
  address: {
73
- country: "",
74
- province: "",
75
- city: "",
76
- area: "",
77
- postCode: "",
78
- address1: "",
79
- address2: ""
73
+ country: void 0,
74
+ province: void 0,
75
+ city: void 0,
76
+ area: void 0,
77
+ postCode: void 0,
78
+ address1: void 0,
79
+ address2: void 0
80
80
  }
81
81
  });
82
82
  const [validated, setValidated] = h(false);
@@ -99,15 +99,17 @@ const Card = w((props, ref) => {
99
99
  var _a2;
100
100
  if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
101
101
  return;
102
- setForm(Object.assign(form, { address: addressState.getAddressState() }));
103
- (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
102
+ const newForm = Object.assign(form, { address: addressCore.getAddressState() });
103
+ setForm(newForm);
104
+ (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
105
+ validateForm();
104
106
  },
105
107
  updateEmail: () => {
106
108
  var _a2;
107
109
  if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
108
110
  return;
109
- setForm(Object.assign(form, { email: emailState.email }));
110
- form.email = emailState.email;
111
+ const newForm = Object.assign(form, { email: emailState.email });
112
+ setForm(newForm);
111
113
  (_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
112
114
  validateForm();
113
115
  },
@@ -115,12 +117,6 @@ const Card = w((props, ref) => {
115
117
  hidePaymentButton && onSubmit();
116
118
  }
117
119
  }));
118
- const getPaymentSuccessData = () => {
119
- var _a2;
120
- return {
121
- returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
122
- };
123
- };
124
120
  const initFieldStatus = () => {
125
121
  const { field, sessionMode } = session.checkout;
126
122
  const { email, address, holderName } = field;
@@ -150,7 +146,7 @@ const Card = w((props, ref) => {
150
146
  if (!sessionReady) {
151
147
  return;
152
148
  }
153
- const { status, paymentMethod = [], bill = {}, sessionMode } = (session == null ? void 0 : session.checkout) || {};
149
+ const { status, supportMethods = [], bill = {}, sessionMode, country } = (session == null ? void 0 : session.checkout) || {};
154
150
  if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
155
151
  (_b2 = (_a2 = props.core.config).onInitError) == null ? void 0 : _b2.call(
156
152
  _a2,
@@ -158,18 +154,19 @@ const Card = w((props, ref) => {
158
154
  );
159
155
  return;
160
156
  }
161
- if (!intersection(paymentMethod, CardPaymentMethods).length) {
157
+ if (!intersection(supportMethods, CardPaymentMethods).length) {
162
158
  return;
163
159
  }
164
160
  initFieldStatus();
165
161
  initElementStyles();
166
162
  setSecurity(sessionMode !== SessionMode.HOSTED);
163
+ country && addressCore.setCountry(country);
167
164
  form.email = bill.email ?? "";
168
- setSupportedCardBrands(intersection(cardBrandCodes, paymentMethod || []));
165
+ form.address.country = country;
166
+ setSupportedCardBrands(intersection(cardBrandCodes, supportMethods || []));
169
167
  setIsCheckoutEnabled(true);
170
168
  if (status === "SUCCESS") {
171
- setSubmitButtonStatus("success");
172
- processOnSuccess();
169
+ processOnSuccess(session == null ? void 0 : session.checkout);
173
170
  }
174
171
  }, [sessionReady]);
175
172
  const onTimeout = q(
@@ -182,9 +179,13 @@ const Card = w((props, ref) => {
182
179
  },
183
180
  [i18n, props.onTimeout]
184
181
  );
185
- const processOnSuccess = () => {
186
- var _a2;
187
- (_a2 = props.onSuccess) == null ? void 0 : _a2.call(props, getPaymentSuccessData());
182
+ const processOnSuccess = (res) => {
183
+ var _a2, _b2;
184
+ setSubmitButtonStatus("success");
185
+ (_b2 = props.onSuccess) == null ? void 0 : _b2.call(props, formatPaymentResult({
186
+ ...res,
187
+ returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
188
+ }));
188
189
  };
189
190
  const processOnError = (error) => {
190
191
  var _a2;
@@ -231,7 +232,7 @@ const Card = w((props, ref) => {
231
232
  }
232
233
  (_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
233
234
  var _a3;
234
- (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
235
+ (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
235
236
  (_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
236
237
  if (errors) {
237
238
  setSubmitButtonStatus("unSubmit");
@@ -281,9 +282,13 @@ const Card = w((props, ref) => {
281
282
  },
282
283
  bill: (fieldStatus == null ? void 0 : fieldStatus.address.show) ? {
283
284
  email: form.email,
284
- ...form.address,
285
- province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
286
- city: addressState.getLabel(form.address.city, addressState.getCityOptions()) ?? form.address.city
285
+ addressLine1: form.address.address1,
286
+ addressLine2: form.address.address2,
287
+ postalCode: form.address.postCode,
288
+ country: form.address.country,
289
+ district: form.address.area,
290
+ state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
291
+ city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
287
292
  } : {
288
293
  email: form.email
289
294
  },
@@ -295,27 +300,29 @@ const Card = w((props, ref) => {
295
300
  };
296
301
  };
297
302
  async function pay(search = false, timeout) {
298
- var _a2, _b2, _c2, _d2;
303
+ var _a2, _b2, _c2, _d2, _e2, _f2;
299
304
  try {
300
- const paymentParams = await getPaymentParams();
301
- const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(
302
- _a2,
303
- "payment",
304
- paymentParams.payment.paymentMethod
305
- );
306
- if (!search && security) {
307
- (_c2 = SFPRef.current) == null ? void 0 : _c2.payment(paymentParams, extraParams);
308
- return { end: true };
309
- }
310
- const options = { locale: i18n.locale, timeout };
311
- let res = {};
305
+ const requestOptions = { locale: i18n.locale, timeout };
306
+ let res = null;
312
307
  if (search) {
308
+ const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", PaymentMethod.BANKCARD);
313
309
  res = await getCardPayInfo(
314
- { sessionId: session.sessionId, clientKey: session.clientKey },
315
- options
310
+ {
311
+ sessionId: session.sessionId,
312
+ clientKey: session.clientKey
313
+ },
314
+ extraParams,
315
+ requestOptions
316
316
  );
317
317
  } else {
318
- res = await cardPay(paymentParams, extraParams, options);
318
+ const paymentParams = await getPaymentParams();
319
+ const extraParams = (_d2 = (_c2 = core.config)._getExtraParams) == null ? void 0 : _d2.call(_c2, "payment", PaymentMethod.BANKCARD);
320
+ if (security) {
321
+ (_e2 = SFPRef.current) == null ? void 0 : _e2.payment(paymentParams, extraParams);
322
+ return { end: true };
323
+ } else {
324
+ res = await cardPay(paymentParams, extraParams, requestOptions);
325
+ }
319
326
  }
320
327
  return processAfterPayment(res, search);
321
328
  } catch (error) {
@@ -329,7 +336,7 @@ const Card = w((props, ref) => {
329
336
  } else {
330
337
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
331
338
  setErrorMsg(message);
332
- (_d2 = props.onError) == null ? void 0 : _d2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
339
+ (_f2 = props.onError) == null ? void 0 : _f2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
333
340
  setSubmitButtonStatus("unSubmit");
334
341
  stopReFetchCardPay3DSInfo();
335
342
  return { end: true };
@@ -359,32 +366,32 @@ const Card = w((props, ref) => {
359
366
  };
360
367
  const processAfterPayment = (res, search = false) => {
361
368
  var _a2, _b2;
362
- const { status, orderStatus, errorMessage, errorCode, threeDSUrl } = res;
369
+ const { status, orderStatus, errorMessage, errorCode, payInfo = {}, sessionId } = res;
370
+ const { threeDSUrl } = payInfo;
371
+ sessionId && (session.sessionId = sessionId);
363
372
  if (status === "PROCESSING") {
364
373
  if (!orderStatus) {
365
374
  setSubmitButtonStatus("unSubmit");
366
375
  } else if (orderStatus === "SUCCESS") {
367
- setSubmitButtonStatus("success");
368
- processOnSuccess();
376
+ processOnSuccess(res);
369
377
  } else if (orderStatus === "PROCESSING") {
370
378
  !search && startReFetchPayInfo();
371
379
  return { end: false };
372
380
  } else if (orderStatus === "FAILURE") {
373
- setErrorMsg(errorMessage);
381
+ errorMessage && setErrorMsg(errorMessage);
374
382
  setSubmitButtonStatus("unSubmit");
375
383
  processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
376
384
  } else if (orderStatus === "AUTHORIZED") {
377
385
  setSubmitButtonStatus("unSubmit");
378
386
  (_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
379
387
  } else if (orderStatus === "IN_THREED") {
380
- processThreeDS(threeDSUrl, false);
388
+ threeDSUrl && processThreeDS(threeDSUrl, false);
381
389
  } else if (orderStatus === "IN_PREVIOUS_THREED") {
382
- processThreeDS(threeDSUrl, true);
390
+ threeDSUrl && processThreeDS(threeDSUrl, true);
383
391
  }
384
392
  return { end: true };
385
393
  } else if (status === "SUCCESS") {
386
- setSubmitButtonStatus("success");
387
- processOnSuccess();
394
+ processOnSuccess(res);
388
395
  return { end: true };
389
396
  } else if (status === "EXPIRED") {
390
397
  setSubmitButtonStatus("unSubmit");
@@ -444,15 +451,17 @@ const Card = w((props, ref) => {
444
451
  }
445
452
  );
446
453
  async function checkThreeDS(search = false, timeout = 2e4) {
447
- var _a2, _b2, _c2;
454
+ var _a2, _b2, _c2, _d2, _e2;
448
455
  if (!session)
449
456
  return { end: true };
450
457
  try {
458
+ const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", PaymentMethod.BANKCARD);
451
459
  const res = await getCardPayInfo(
452
460
  {
453
461
  sessionId: session.sessionId,
454
462
  clientKey: session.clientKey
455
463
  },
464
+ extraParams,
456
465
  {
457
466
  locale: i18n.locale,
458
467
  timeout
@@ -463,12 +472,12 @@ const Card = w((props, ref) => {
463
472
  if (orderStatus === "PROCESSING") {
464
473
  startReFetchPayInfo();
465
474
  } else if (orderStatus === "FAILURE") {
466
- setErrorMsg(errorMessage);
475
+ errorMessage && setErrorMsg(errorMessage);
467
476
  setSubmitButtonStatus("unSubmit");
468
477
  processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
469
478
  } else if (orderStatus === "AUTHORIZED") {
470
479
  setSubmitButtonStatus("unSubmit");
471
- (_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
480
+ (_c2 = props.onAuthorized) == null ? void 0 : _c2.call(props);
472
481
  } else if (orderStatus === "IN_THREED") {
473
482
  setSubmitButtonStatus("loading");
474
483
  !search && startReFetchCardPay3DSInfo();
@@ -482,17 +491,15 @@ const Card = w((props, ref) => {
482
491
  stopReFetchCardPay3DSInfo();
483
492
  return { end: true };
484
493
  } else if (status === "SUCCESS") {
485
- setSubmitButtonStatus("success");
486
- processOnSuccess();
494
+ processOnSuccess(res);
487
495
  stopReFetchCardPay3DSInfo();
488
496
  return { end: true };
489
497
  } else if (status === "EXPIRED") {
490
498
  setSubmitButtonStatus("unSubmit");
491
- (_b2 = props.onExpired) == null ? void 0 : _b2.call(props);
499
+ (_d2 = props.onExpired) == null ? void 0 : _d2.call(props);
492
500
  stopReFetchCardPay3DSInfo();
493
501
  return { end: true };
494
502
  }
495
- processOnSuccess();
496
503
  setSubmitButtonStatus("unSubmit");
497
504
  stopReFetchCardPay3DSInfo();
498
505
  return { end: true };
@@ -507,7 +514,7 @@ const Card = w((props, ref) => {
507
514
  } else {
508
515
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
509
516
  setErrorMsg(message);
510
- (_c2 = props.onError) == null ? void 0 : _c2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
517
+ (_e2 = props.onError) == null ? void 0 : _e2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
511
518
  setSubmitButtonStatus("unSubmit");
512
519
  stopReFetchCardPay3DSInfo();
513
520
  return { end: true };
@@ -685,7 +692,7 @@ const Card = w((props, ref) => {
685
692
  ) }) });
686
693
  };
687
694
  const ErrorMessage = () => {
688
- return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
695
+ return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
689
696
  };
690
697
  const CardInfo = q(() => {
691
698
  var _a2, _b2, _c2, _d2;
@@ -695,7 +702,7 @@ const Card = w((props, ref) => {
695
702
  /* @__PURE__ */ u(
696
703
  CardNumberField,
697
704
  {
698
- supportedCardBrands: (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentMethod) == null ? void 0 : _b2.filter(Boolean),
705
+ supportedCardBrands: (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.supportMethods) == null ? void 0 : _b2.filter(Boolean),
699
706
  security,
700
707
  ref: cardNumberFieldRef,
701
708
  onBinValue: onBinValueChanged
@@ -707,7 +714,7 @@ const Card = w((props, ref) => {
707
714
  CardBrands,
708
715
  {
709
716
  className: bem("card-brands"),
710
- supportedCardBrands: (_d2 = (_c2 = session == null ? void 0 : session.checkout) == null ? void 0 : _c2.paymentMethod) == null ? void 0 : _d2.filter(Boolean)
717
+ supportedCardBrands: (_d2 = (_c2 = session == null ? void 0 : session.checkout) == null ? void 0 : _c2.supportMethods) == null ? void 0 : _d2.filter(Boolean)
711
718
  }
712
719
  )
713
720
  ] }),
@@ -747,9 +754,11 @@ const Card = w((props, ref) => {
747
754
  (fieldStatus == null ? void 0 : fieldStatus.holderName.show) && /* @__PURE__ */ u("div", { className: bem("holder-name"), children: /* @__PURE__ */ u(CardHolderNameField, { disabled: fieldStatus == null ? void 0 : fieldStatus.holderName.disabled }) }),
748
755
  Address(),
749
756
  ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentType) === PaymentType.RECURRING && RecurringTip(),
750
- isShowStoreCheckBox && storeCheckBox(),
751
- ErrorMessage(),
752
- !hidePaymentButton && Button()
757
+ /* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
758
+ isShowStoreCheckBox && storeCheckBox(),
759
+ ErrorMessage(),
760
+ !hidePaymentButton && Button()
761
+ ] })
753
762
  ] }) });
754
763
  };
755
764
  const fastPaymentCardForm = () => {
@@ -779,11 +788,13 @@ const Card = w((props, ref) => {
779
788
  )
780
789
  ] }),
781
790
  tokenAddressFilled && Address(),
782
- ErrorMessage(),
783
- !hidePaymentButton && Button()
791
+ /* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
792
+ ErrorMessage(),
793
+ !hidePaymentButton && Button()
794
+ ] })
784
795
  ] }) });
785
796
  };
786
- return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
797
+ return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n, core }, children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
787
798
  /* @__PURE__ */ u(
788
799
  SecuredFieldsProvider,
789
800
  {
@@ -1,9 +1,9 @@
1
1
  import { A, h, y, u } from "../../core.js";
2
2
  import { useBEM } from "../../hooks/useBEM.js";
3
3
  import { useI18n } from "../../hooks/useI18n.js";
4
- import "../../api/http.js";
5
4
  import { finCardBrandInfoByCode } from "../../utils/card-brand/index.js";
6
5
  import "../../utils/system-info/get-browser-info.js";
6
+ import "../../api/http.js";
7
7
  import "../internal/Form/type.js";
8
8
  import "../internal/Form/context.js";
9
9
  import { FormItem } from "../internal/Form/FormItem.js";
@@ -16,6 +16,7 @@ import { ShopeePay } from "../ShopeePay/index.js";
16
16
  import { GrabPay } from "../GrabPay/index.js";
17
17
  import { GCash } from "../wallets/GCash/GCash.js";
18
18
  import { Paymaya } from "../wallets/Paymaya/Paymaya.js";
19
+ import { Zalopay } from "../wallets/Zalopay/Zalopay.js";
19
20
  import { useBEM } from "../../hooks/useBEM.js";
20
21
  import { intersection } from "../../utils/index.js";
21
22
  import { PayKKaError } from "../../core/error.js";
@@ -32,6 +33,7 @@ import { IconTNGWallet } from "../internal/icons/IconTNGWallet.js";
32
33
  import { IconCard2 } from "../internal/icons/IconCard2.js";
33
34
  import { IconGCash } from "../internal/icons/IconGCash.js";
34
35
  import { IconPaymaya } from "../internal/icons/IconPaymaya.js";
36
+ import { IconZalopay } from "../internal/icons/IconZalopay.js";
35
37
  import { removeElementFromArray } from "../../utils/array.js";
36
38
  const dropInSupportedPaymentMethods = [
37
39
  ...CardPaymentMethods,
@@ -45,7 +47,8 @@ const dropInSupportedPaymentMethods = [
45
47
  PaymentMethod.TNG_WALLET,
46
48
  PaymentMethod.MAY_BANK_QR_PAY,
47
49
  PaymentMethod.GCASH,
48
- PaymentMethod.PAYMAYA
50
+ PaymentMethod.PAYMAYA,
51
+ PaymentMethod.ZALOPAY
49
52
  ];
50
53
  const PaymentComponentMap = {
51
54
  [PaymentCategory.CARD]: Card,
@@ -59,7 +62,8 @@ const PaymentComponentMap = {
59
62
  [PaymentCategory.SHOPEE_PAY]: ShopeePay,
60
63
  [PaymentCategory.GRAB_PAY]: GrabPay,
61
64
  [PaymentCategory.GCASH]: GCash,
62
- [PaymentCategory.PAYMAYA]: Paymaya
65
+ [PaymentCategory.PAYMAYA]: Paymaya,
66
+ [PaymentCategory.ZALOPAY]: Zalopay
63
67
  // [PaymentCategory.WECHAT_PAY]: WechatPay,
64
68
  // [PaymentCategory.ALI_PAY]: AliPay,
65
69
  // [PaymentCategory.SEPA_DEBIT]: Sepa
@@ -134,6 +138,10 @@ const paymentCategoryOptionMap = {
134
138
  [PaymentCategory.PAYMAYA]: {
135
139
  icon: IconPaymaya,
136
140
  nameKey: "dropIn.paymaya.label"
141
+ },
142
+ [PaymentCategory.ZALOPAY]: {
143
+ icon: IconZalopay,
144
+ nameKey: "dropIn.zalopay.label"
137
145
  }
138
146
  };
139
147
  const { bem } = useBEM("drop-in");
@@ -272,9 +280,9 @@ const DropIn = w((props, ref) => {
272
280
  );
273
281
  return;
274
282
  }
275
- const { paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
283
+ const { supportMethods = [] } = (session == null ? void 0 : session.checkout) || {};
276
284
  const enablePaymentMethods = intersection(
277
- paymentMethod,
285
+ supportMethods,
278
286
  dropInSupportedPaymentMethods
279
287
  );
280
288
  if (!enablePaymentMethods.length) {
@@ -9,6 +9,7 @@ import { useBEM } from "../../hooks/useBEM.js";
9
9
  import { useI18n } from "../../hooks/useI18n.js";
10
10
  import { defaultInputStyleConfig } from "../../types/index.js";
11
11
  import { intersection } from "../../utils/index.js";
12
+ import { createPromise } from "../../utils/create-promise.js";
12
13
  import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/index.js";
13
14
  import { CardNumberField } from "../CardNumberField/index.js";
14
15
  import { CardExpireDateField } from "../CardExpireDateField/index.js";
@@ -22,7 +23,6 @@ import { CombinedCardInfo } from "../CombinedCardInfo/index.js";
22
23
  import "../internal/Input/Input.js";
23
24
  import { inputWrapperClassName } from "../internal/Input/type.js";
24
25
  import { separateInputStyle, genComponentStyle, loadStyle } from "../../utils/style.js";
25
- import { createPromise } from "../../utils/create-promise.js";
26
26
  const ENCRYPTED_CARD_WRAPPER_ID = "encryptedCardWrapper";
27
27
  const ENCRYPTED_CARD_ITEM_ATTR = "data-eci";
28
28
  var EEncryptedCardType = /* @__PURE__ */ ((EEncryptedCardType2) => {