@paykka/card-checkout-ui 0.8.0 → 0.9.2

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 (247) hide show
  1. package/dist/card-checkout-ui.js +20 -13
  2. package/dist/card-checkout-ui.umd.cjs +20 -13
  3. package/dist/es/_commonjsHelpers.js +1 -0
  4. package/dist/es/api/http.js +19 -21
  5. package/dist/es/api/index.js +1 -0
  6. package/dist/es/api/modules/ali-pay/index.js +19 -11
  7. package/dist/es/api/modules/apple-pay/index.js +10 -26
  8. package/dist/es/api/modules/boost/index.js +56 -0
  9. package/dist/es/api/modules/card/index.js +17 -11
  10. package/dist/es/api/modules/checkout/index.js +6 -6
  11. package/dist/es/api/modules/checkout/map.js +23 -6
  12. package/dist/es/api/modules/gcash/index.js +56 -0
  13. package/dist/es/api/modules/get-browser-params.js +2 -2
  14. package/dist/es/api/modules/google-pay/index.js +10 -26
  15. package/dist/es/api/modules/grab-pay/index.js +56 -0
  16. package/dist/es/api/modules/index.js +1 -0
  17. package/dist/es/api/modules/line-pay/index.js +56 -0
  18. package/dist/es/api/modules/may-bank-qr-pay/index.js +56 -0
  19. package/dist/es/api/modules/nine-pay/index.js +56 -0
  20. package/dist/es/api/modules/paymaya/index.js +56 -0
  21. package/dist/es/api/modules/sepa/index.js +19 -11
  22. package/dist/es/api/modules/shopee-pay/index.js +56 -0
  23. package/dist/es/api/modules/tng-wallet/index.js +56 -0
  24. package/dist/es/api/modules/wechat-pay/index.js +18 -31
  25. package/dist/es/components/AccordionItem/AccordionItem.js +36 -0
  26. package/dist/es/components/AliPay/index.js +27 -39
  27. package/dist/es/components/ApplePay/index.js +16 -37
  28. package/dist/es/components/Boost/index.js +322 -0
  29. package/dist/es/components/Card/index.js +52 -41
  30. package/dist/es/components/CardBrands/index.js +2 -2
  31. package/dist/es/components/CardNumberField/index.js +113 -106
  32. package/dist/es/components/DropIn/index.js +204 -49
  33. package/dist/es/components/GooglePay/index.js +5 -4
  34. package/dist/es/components/GrabPay/index.js +322 -0
  35. package/dist/es/components/GuideCard/index.js +43 -0
  36. package/dist/es/components/LinePay/index.js +322 -0
  37. package/dist/es/components/MayBankQRPay/index.js +322 -0
  38. package/dist/es/components/NinePay/index.js +322 -0
  39. package/dist/es/components/SecuredIframe/index.js +3 -2
  40. package/dist/es/components/Sepa/index.js +6 -9
  41. package/dist/es/components/ShopeePay/index.js +322 -0
  42. package/dist/es/components/SubmitButton/index.js +6 -20
  43. package/dist/es/components/TNGWallet/index.js +322 -0
  44. package/dist/es/components/WechatPay/index.js +30 -49
  45. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +41 -0
  46. package/dist/es/components/business/QRCodeModal/index.js +6 -0
  47. package/dist/es/components/business/QRCodeModal/qr-code-modal.js +1 -0
  48. package/dist/es/components/business/QRCodeModal/type.js +1 -0
  49. package/dist/es/components/business/index.js +6 -0
  50. package/dist/es/components/index.js +9 -0
  51. package/dist/es/components/internal/Accordion/Accordion.js +14 -0
  52. package/dist/es/components/internal/Accordion/accordion2.js +1 -0
  53. package/dist/es/components/internal/Accordion/accordionTransition.js +26 -0
  54. package/dist/es/components/internal/Accordion/index.js +7 -0
  55. package/dist/es/components/internal/Accordion/type.js +10 -0
  56. package/dist/es/components/internal/Modal/Modal.js +17 -3
  57. package/dist/es/components/internal/Modal/index.js +1 -0
  58. package/dist/es/components/internal/Modal/type.js +1 -0
  59. package/dist/es/components/internal/QRCode/QRCode.js +31 -0
  60. package/dist/es/components/internal/QRCode/index.js +4 -0
  61. package/dist/es/components/internal/QRCode/type.js +1 -0
  62. package/dist/es/components/internal/icons/IconBoost.js +63 -0
  63. package/dist/es/components/internal/icons/IconCard.js +1 -40
  64. package/dist/es/components/internal/icons/IconCard2.js +60 -0
  65. package/dist/es/components/internal/icons/IconGCash.js +196 -0
  66. package/dist/es/components/internal/icons/IconGcashComplete.js +184 -0
  67. package/dist/es/components/internal/icons/IconGrabPay.js +59 -0
  68. package/dist/es/components/internal/icons/IconLinePay.js +99 -0
  69. package/dist/es/components/internal/icons/IconMayBankQRPay.js +69 -0
  70. package/dist/es/components/internal/icons/IconNinePay.js +255 -0
  71. package/dist/es/components/internal/icons/IconPaymaya.js +114 -0
  72. package/dist/es/components/internal/icons/IconRedirect.js +58 -0
  73. package/dist/es/components/internal/icons/IconScan.js +102 -0
  74. package/dist/es/components/internal/icons/IconShopeePay.js +108 -0
  75. package/dist/es/components/internal/icons/IconTNGWallet.js +119 -0
  76. package/dist/es/components/internal/icons/IconUnionPay.js +65 -0
  77. package/dist/es/components/wallets/GCash/GCash.js +356 -0
  78. package/dist/es/components/wallets/GCash/g-cash.js +1 -0
  79. package/dist/es/components/wallets/GCash/index.js +1 -0
  80. package/dist/es/components/wallets/GCash/type.js +1 -0
  81. package/dist/es/components/wallets/Paymaya/Paymaya.js +323 -0
  82. package/dist/es/components/wallets/Paymaya/index.js +1 -0
  83. package/dist/es/components/wallets/Paymaya/paymaya2.js +1 -0
  84. package/dist/es/components/wallets/Paymaya/type.js +1 -0
  85. package/dist/es/config.js +12 -12
  86. package/dist/es/constant.js +84 -4
  87. package/dist/es/core/PayKKaCheckout.js +28 -3
  88. package/dist/es/core/Session.js +24 -23
  89. package/dist/es/core/error.js +7 -0
  90. package/dist/es/core/query.js +3 -2
  91. package/dist/es/core.js +2082 -70
  92. package/dist/es/hooks/usePayState.js +0 -3
  93. package/dist/es/i18n/I18n.js +8 -2
  94. package/dist/es/i18n/locales/de-DE.js +16 -1
  95. package/dist/es/i18n/locales/en-GB.js +16 -1
  96. package/dist/es/i18n/locales/es-ES.js +16 -1
  97. package/dist/es/i18n/locales/fr-FR.js +16 -1
  98. package/dist/es/i18n/locales/ja-JP.js +16 -1
  99. package/dist/es/i18n/locales/ko-KR.js +16 -1
  100. package/dist/es/i18n/locales/pt-PT.js +16 -1
  101. package/dist/es/i18n/locales/ru-RU.js +16 -1
  102. package/dist/es/i18n/locales/zh-CN.js +16 -1
  103. package/dist/es/i18n/locales/zh-HK.js +16 -1
  104. package/dist/es/i18n/locales/zh-TW.js +16 -1
  105. package/dist/es/i18n/util.js +12 -3
  106. package/dist/es/index.js +20 -0
  107. package/dist/es/style.css +1 -1192
  108. package/dist/es/types/index.js +1 -0
  109. package/dist/es/utils/array.js +9 -0
  110. package/dist/es/utils/card-brand/brands.js +11 -1
  111. package/dist/es/utils/card-brand/index.js +4 -3
  112. package/dist/es/utils/card-brand/luhn.js +25 -0
  113. package/dist/es/utils/date.js +25 -0
  114. package/dist/es/utils/detect.js +6 -0
  115. package/dist/es/utils/format.js +28 -12
  116. package/dist/es/utils/index.js +9 -1
  117. package/dist/es/utils/location.js +37 -0
  118. package/dist/es/utils/object.js +14 -0
  119. package/dist/es/utils/redirect.js +32 -0
  120. package/dist/es/utils/system-info/get-browser-info.js +4 -4
  121. package/dist/es/utils/system-info/get-system-info.js +11 -7
  122. package/dist/es/utils/system-info/index.js +4 -4
  123. package/dist/style.css +1 -1
  124. package/dist/types/api/http.d.ts +4 -10
  125. package/dist/types/api/modules/ali-pay/index.d.ts +2 -1
  126. package/dist/types/api/modules/apple-pay/index.d.ts +2 -1
  127. package/dist/types/api/modules/boost/index.d.ts +24 -0
  128. package/dist/types/api/modules/card/index.d.ts +1 -1
  129. package/dist/types/api/modules/checkout/index.d.ts +2 -2
  130. package/dist/types/api/modules/checkout/type.d.ts +9 -0
  131. package/dist/types/api/modules/gcash/index.d.ts +24 -0
  132. package/dist/types/api/modules/get-browser-params.d.ts +2 -2
  133. package/dist/types/api/modules/google-pay/index.d.ts +2 -1
  134. package/dist/types/api/modules/grab-pay/index.d.ts +24 -0
  135. package/dist/types/api/modules/index.d.ts +9 -0
  136. package/dist/types/api/modules/line-pay/index.d.ts +24 -0
  137. package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +24 -0
  138. package/dist/types/api/modules/nine-pay/index.d.ts +24 -0
  139. package/dist/types/api/modules/paymaya/index.d.ts +24 -0
  140. package/dist/types/api/modules/sepa/index.d.ts +2 -1
  141. package/dist/types/api/modules/shopee-pay/index.d.ts +24 -0
  142. package/dist/types/api/modules/tng-wallet/index.d.ts +24 -0
  143. package/dist/types/api/modules/wechat-pay/index.d.ts +2 -1
  144. package/dist/types/components/Boost/Boost.d.ts +7 -0
  145. package/dist/types/components/Boost/index.d.ts +2 -0
  146. package/dist/types/components/Boost/type.d.ts +61 -0
  147. package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +1 -1
  148. package/dist/types/components/DropIn/config.d.ts +7 -0
  149. package/dist/types/components/DropIn/type.d.ts +11 -3
  150. package/dist/types/components/GrabPay/GrabPay.d.ts +7 -0
  151. package/dist/types/components/GrabPay/index.d.ts +2 -0
  152. package/dist/types/components/GrabPay/type.d.ts +61 -0
  153. package/dist/types/components/GuideCard/GuideCard.d.ts +3 -0
  154. package/dist/types/components/GuideCard/index.d.ts +2 -0
  155. package/dist/types/components/GuideCard/type.d.ts +4 -0
  156. package/dist/types/components/LinePay/LinePay.d.ts +7 -0
  157. package/dist/types/components/LinePay/index.d.ts +2 -0
  158. package/dist/types/components/LinePay/type.d.ts +61 -0
  159. package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -0
  160. package/dist/types/components/MayBankQRPay/index.d.ts +2 -0
  161. package/dist/types/components/MayBankQRPay/type.d.ts +61 -0
  162. package/dist/types/components/NinePay/NinePay.d.ts +6 -0
  163. package/dist/types/components/NinePay/index.d.ts +2 -0
  164. package/dist/types/components/NinePay/type.d.ts +61 -0
  165. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +1 -1
  166. package/dist/types/components/ShopeePay/ShopeePay.d.ts +7 -0
  167. package/dist/types/components/ShopeePay/index.d.ts +2 -0
  168. package/dist/types/components/ShopeePay/type.d.ts +61 -0
  169. package/dist/types/components/SubmitButton/SubmitButton.d.ts +1 -1
  170. package/dist/types/components/TNGWallet/TNGWallet.d.ts +7 -0
  171. package/dist/types/components/TNGWallet/index.d.ts +2 -0
  172. package/dist/types/components/TNGWallet/type.d.ts +61 -0
  173. package/dist/types/components/business/QRCodeModal/QRCodeModal.d.ts +3 -0
  174. package/dist/types/components/business/QRCodeModal/index.d.ts +2 -0
  175. package/dist/types/components/business/QRCodeModal/type.d.ts +18 -0
  176. package/dist/types/components/business/index.d.ts +1 -0
  177. package/dist/types/components/index.d.ts +9 -0
  178. package/dist/types/components/internal/Accordion/Accordion.d.ts +3 -0
  179. package/dist/types/components/internal/Accordion/accordionTransition.d.ts +8 -0
  180. package/dist/types/components/internal/Accordion/components/AccordionItem/AccordionItem.d.ts +3 -0
  181. package/dist/types/components/internal/Accordion/components/AccordionItem/index.d.ts +2 -0
  182. package/dist/types/components/internal/Accordion/components/AccordionItem/type.d.ts +18 -0
  183. package/dist/types/components/internal/Accordion/index.d.ts +3 -0
  184. package/dist/types/components/internal/Accordion/type.d.ts +18 -0
  185. package/dist/types/components/internal/Modal/type.d.ts +2 -0
  186. package/dist/types/components/internal/QRCode/QRCode.d.ts +2 -0
  187. package/dist/types/components/internal/QRCode/index.d.ts +2 -0
  188. package/dist/types/components/internal/QRCode/type.d.ts +9 -0
  189. package/dist/types/components/internal/icons/IconBoost.d.ts +2 -0
  190. package/dist/types/components/internal/icons/IconCard2.d.ts +2 -0
  191. package/dist/types/components/internal/icons/IconGCash.d.ts +2 -0
  192. package/dist/types/components/internal/icons/IconGcashComplete.d.ts +2 -0
  193. package/dist/types/components/internal/icons/IconGrabPay.d.ts +2 -0
  194. package/dist/types/components/internal/icons/IconLinePay.d.ts +2 -0
  195. package/dist/types/components/internal/icons/IconMayBankQRPay.d.ts +2 -0
  196. package/dist/types/components/internal/icons/IconNinePay.d.ts +2 -0
  197. package/dist/types/components/internal/icons/IconPaymaya.d.ts +2 -0
  198. package/dist/types/components/internal/icons/IconRedirect.d.ts +2 -0
  199. package/dist/types/components/internal/icons/IconScan.d.ts +2 -0
  200. package/dist/types/components/internal/icons/IconShopeePay.d.ts +2 -0
  201. package/dist/types/components/internal/icons/IconTNGWallet.d.ts +2 -0
  202. package/dist/types/components/internal/icons/IconUnionPay.d.ts +2 -0
  203. package/dist/types/components/internal/icons/index.d.ts +13 -0
  204. package/dist/types/components/wallets/GCash/GCash.d.ts +6 -0
  205. package/dist/types/components/wallets/GCash/index.d.ts +2 -0
  206. package/dist/types/components/wallets/GCash/type.d.ts +66 -0
  207. package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -0
  208. package/dist/types/components/wallets/Paymaya/index.d.ts +2 -0
  209. package/dist/types/components/wallets/Paymaya/type.d.ts +61 -0
  210. package/dist/types/config.d.ts +9 -9
  211. package/dist/types/constant.d.ts +28 -3
  212. package/dist/types/core/PayKKaCheckout.d.ts +10 -0
  213. package/dist/types/core/Session.d.ts +2 -0
  214. package/dist/types/core/error.d.ts +3 -1
  215. package/dist/types/core/query.d.ts +2 -2
  216. package/dist/types/hooks/usePayState.d.ts +0 -3
  217. package/dist/types/i18n/I18n.d.ts +1 -1
  218. package/dist/types/i18n/locales/de-DE.d.ts +13 -0
  219. package/dist/types/i18n/locales/en-GB.d.ts +13 -0
  220. package/dist/types/i18n/locales/es-ES.d.ts +13 -0
  221. package/dist/types/i18n/locales/fr-FR.d.ts +13 -0
  222. package/dist/types/i18n/locales/ja-JP.d.ts +13 -0
  223. package/dist/types/i18n/locales/ko-KR.d.ts +13 -0
  224. package/dist/types/i18n/locales/pt-PT.d.ts +13 -0
  225. package/dist/types/i18n/locales/ru-RU.d.ts +13 -0
  226. package/dist/types/i18n/locales/zh-CN.d.ts +13 -0
  227. package/dist/types/i18n/locales/zh-HK.d.ts +13 -0
  228. package/dist/types/i18n/locales/zh-TW.d.ts +13 -0
  229. package/dist/types/i18n/util.d.ts +5 -0
  230. package/dist/types/index.d.ts +1 -1
  231. package/dist/types/types/index.d.ts +10 -3
  232. package/dist/types/types/message.d.ts +1 -0
  233. package/dist/types/utils/array.d.ts +1 -0
  234. package/dist/types/utils/card-brand/brands.d.ts +4 -3
  235. package/dist/types/utils/card-brand/index.d.ts +9 -6
  236. package/dist/types/utils/card-brand/luhn.d.ts +9 -0
  237. package/dist/types/utils/date.d.ts +9 -0
  238. package/dist/types/utils/detect.d.ts +1 -0
  239. package/dist/types/utils/format.d.ts +7 -1
  240. package/dist/types/utils/index.d.ts +7 -0
  241. package/dist/types/utils/location.d.ts +7 -0
  242. package/dist/types/utils/object.d.ts +1 -0
  243. package/dist/types/utils/redirect.d.ts +5 -0
  244. package/dist/types/utils/system-info/get-browser-info.d.ts +1 -1
  245. package/dist/types/utils/system-info/get-system-info.d.ts +3 -2
  246. package/dist/types/utils/system-info/index.d.ts +3 -3
  247. package/package.json +4 -2
@@ -11,118 +11,125 @@ import "../internal/Input/type.js";
11
11
  import { EFieldType } from "../SecuredFieldsProvider/index.js";
12
12
  import { getSupportedCardBrands, getSupportedCardBrandsLengths, finCardBrandInfoByCode, findCardBrandInfo } from "../../utils/card-brand/index.js";
13
13
  import { trimAll, limitedToNumber } from "../../utils/format.js";
14
- const CardNumberField = w((props, ref) => {
15
- const { supportedCardBrands = [], className, security, showLabel } = props;
16
- const inputRef = A(null);
17
- const formItemRef = A(null);
18
- F(ref, () => ({
19
- input: inputRef.current,
20
- focus: () => {
21
- var _a;
22
- (_a = inputRef.current) == null ? void 0 : _a.focus();
23
- },
24
- blur: () => {
25
- var _a;
26
- (_a = inputRef.current) == null ? void 0 : _a.blur();
27
- },
28
- resetValidation: (status, errorTip) => {
29
- var _a;
30
- (_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
31
- },
32
- binValueChanged: (binValue) => {
33
- setValue(binValue);
34
- },
35
- brandChanged: (brand) => {
36
- if (brand) {
37
- const brandInfo = finCardBrandInfoByCode(brand);
38
- setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
39
- } else {
40
- setBrandIcon(void 0);
41
- }
42
- },
43
- getCardBrand: () => findCardBrandInfo(trimAll(value), brands) || {}
44
- }));
45
- const { i18n } = useI18n();
46
- const [value, setValue] = h("");
47
- const [validationStatus, setValidationStatus] = h("");
48
- const brands = getSupportedCardBrands(supportedCardBrands);
49
- const brandLengths = getSupportedCardBrandsLengths(brands);
50
- const [brandIcon, setBrandIcon] = h(void 0);
51
- y(() => {
52
- setBrandIcon(value ? () => {
53
- var _a;
54
- return (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
55
- } : void 0);
56
- }, [value]);
57
- const rule = {
58
- trigger: ["blur", "submit"],
59
- validator(value2) {
60
- if (security) {
61
- const result = formItemRef.current.getValidateResult();
62
- if (result.status === "error") {
63
- throw new Error(result.errors[0].message);
64
- } else if (result.status === "success") {
65
- return true;
14
+ const CardNumberField = w(
15
+ (props, ref) => {
16
+ const { supportedCardBrands = [], className, security, showLabel } = props;
17
+ const inputRef = A(null);
18
+ const formItemRef = A(null);
19
+ F(ref, () => ({
20
+ input: inputRef.current,
21
+ focus: () => {
22
+ var _a;
23
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
24
+ },
25
+ blur: () => {
26
+ var _a;
27
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
28
+ },
29
+ resetValidation: (status, errorTip) => {
30
+ var _a;
31
+ (_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
32
+ },
33
+ binValueChanged: (binValue) => {
34
+ setValue(binValue);
35
+ },
36
+ brandChanged: (brand2) => {
37
+ if (brand2) {
38
+ const brandInfo = finCardBrandInfoByCode(brand2);
39
+ setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
40
+ setBrand(brandInfo == null ? void 0 : brandInfo.code);
41
+ } else {
42
+ setBrandIcon(void 0);
43
+ setBrand(void 0);
66
44
  }
45
+ },
46
+ getCardBrand: () => {
47
+ return findCardBrandInfo(trimAll(value), brands) || { code: brand };
67
48
  }
68
- value2 = trimAll(value2 ?? "");
69
- if (!brandLengths.includes(value2.length)) {
70
- throw new Error(i18n.get("card.cardNumber.incomplete"));
49
+ }));
50
+ const { i18n } = useI18n();
51
+ const [value, setValue] = h("");
52
+ const [validationStatus, setValidationStatus] = h("");
53
+ const brands = getSupportedCardBrands(supportedCardBrands);
54
+ const brandLengths = getSupportedCardBrandsLengths(brands);
55
+ const [brandIcon, setBrandIcon] = h(void 0);
56
+ const [brand, setBrand] = h(void 0);
57
+ y(() => {
58
+ setBrandIcon(value ? () => {
59
+ var _a;
60
+ return (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
61
+ } : void 0);
62
+ }, [value]);
63
+ const rule = {
64
+ trigger: ["blur", "submit"],
65
+ validator(value2) {
66
+ if (security) {
67
+ const result = formItemRef.current.getValidateResult();
68
+ if (result.status === "error") {
69
+ throw new Error(result.errors[0].message);
70
+ } else if (result.status === "success") {
71
+ return true;
72
+ }
73
+ }
74
+ value2 = trimAll(value2 ?? "");
75
+ if (!brandLengths.includes(value2.length)) {
76
+ throw new Error(i18n.get("card.cardNumber.incomplete"));
77
+ }
78
+ const cardBrand = findCardBrandInfo(value2, brands);
79
+ if (!cardBrand) {
80
+ throw new Error(i18n.get("card.cardNumber.invalid"));
81
+ }
82
+ return true;
71
83
  }
72
- const cardBrand = findCardBrandInfo(value2, brands);
73
- if (!cardBrand) {
74
- throw new Error(i18n.get("card.cardNumber.invalid"));
84
+ };
85
+ function onInput(event) {
86
+ var _a;
87
+ const { currentTarget, inputType } = event;
88
+ const selectionStart = currentTarget.selectionStart;
89
+ let val = limitedToNumber(currentTarget.value);
90
+ val = val.replace(/(\d{4})(?=\d)/g, "$1 ");
91
+ let pos = selectionStart;
92
+ if (pos % 5 === 0) {
93
+ pos = clamp(selectionStart + (inputType === "insertText" ? 1 : -1), 0);
75
94
  }
76
- return true;
77
- }
78
- };
79
- function onInput(event) {
80
- var _a;
81
- const { currentTarget, inputType } = event;
82
- const selectionStart = currentTarget.selectionStart;
83
- let val = limitedToNumber(currentTarget.value);
84
- val = val.replace(/(\d{4})(?=\d)/g, "$1 ");
85
- let pos = selectionStart;
86
- if (pos % 5 === 0) {
87
- pos = clamp(selectionStart + (inputType === "insertText" ? 1 : -1), 0);
95
+ setValue(currentTarget.value = val);
96
+ currentTarget.setSelectionRange(pos, pos);
97
+ (_a = props.onInput) == null ? void 0 : _a.call(props, event);
88
98
  }
89
- setValue(currentTarget.value = val);
90
- currentTarget.setSelectionRange(pos, pos);
91
- (_a = props.onInput) == null ? void 0 : _a.call(props, event);
99
+ const RightIcon = () => {
100
+ if (validationStatus !== "error") {
101
+ const Icon = brandIcon ?? IconCardNo;
102
+ return /* @__PURE__ */ u(Icon, { size: 32 });
103
+ }
104
+ };
105
+ return /* @__PURE__ */ u(
106
+ FormItem,
107
+ {
108
+ label: i18n.get("card.cardNumber.label"),
109
+ showLabel,
110
+ path: "number",
111
+ ref: formItemRef,
112
+ rule,
113
+ onValidationStatusChange: setValidationStatus,
114
+ className,
115
+ children: /* @__PURE__ */ u(
116
+ Input,
117
+ {
118
+ type: "text",
119
+ inputmode: "numeric",
120
+ ref: inputRef,
121
+ maxLength: 23,
122
+ value,
123
+ onInput,
124
+ rightIcon: RightIcon(),
125
+ placeholder: i18n.get("card.cardNumber.placeholder"),
126
+ children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CARD_NUMBER })
127
+ }
128
+ )
129
+ }
130
+ );
92
131
  }
93
- const RightIcon = () => {
94
- if (validationStatus !== "error") {
95
- const Icon = brandIcon ?? IconCardNo;
96
- return /* @__PURE__ */ u(Icon, { size: 32 });
97
- }
98
- };
99
- return /* @__PURE__ */ u(
100
- FormItem,
101
- {
102
- label: i18n.get("card.cardNumber.label"),
103
- showLabel,
104
- path: "number",
105
- ref: formItemRef,
106
- rule,
107
- onValidationStatusChange: setValidationStatus,
108
- className,
109
- children: /* @__PURE__ */ u(
110
- Input,
111
- {
112
- type: "text",
113
- inputmode: "numeric",
114
- ref: inputRef,
115
- maxLength: 23,
116
- value,
117
- onInput,
118
- rightIcon: RightIcon(),
119
- placeholder: i18n.get("card.cardNumber.placeholder"),
120
- children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CARD_NUMBER })
121
- }
122
- )
123
- }
124
- );
125
- });
132
+ );
126
133
  export {
127
134
  CardNumberField
128
135
  };
@@ -2,24 +2,63 @@ import { u, w, h, A, F, y, b } from "../../core.js";
2
2
  import "../../utils/card-brand/brands.js";
3
3
  import "../../utils/system-info/get-browser-info.js";
4
4
  import { CoreContext } from "../../core/context.js";
5
- import { CardPaymentMethods, PaymentMethod, PaymentCategory, SessionMode } from "../../constant.js";
5
+ import { CardPaymentMethods, PaymentMethod, PaymentCategory, SessionMode, PaymentMethod2CategoryMap } from "../../constant.js";
6
6
  import { Card } from "../Card/index.js";
7
7
  import { ApplePay } from "../ApplePay/index.js";
8
8
  import { GooglePay } from "../GooglePay/index.js";
9
+ import { Boost } from "../Boost/index.js";
10
+ import { NinePay } from "../NinePay/index.js";
11
+ import { LinePay } from "../LinePay/index.js";
12
+ import { TNGWallet } from "../TNGWallet/index.js";
13
+ import { MayBankQRPay } from "../MayBankQRPay/index.js";
14
+ import { ShopeePay } from "../ShopeePay/index.js";
15
+ import { GrabPay } from "../GrabPay/index.js";
16
+ import { GCash } from "../wallets/GCash/GCash.js";
17
+ import { Paymaya } from "../wallets/Paymaya/Paymaya.js";
9
18
  import { useBEM } from "../../hooks/useBEM.js";
10
19
  import { intersection } from "../../utils/index.js";
11
20
  import { PayKKaError } from "../../core/error.js";
12
21
  import { usePayState } from "../../hooks/usePayState.js";
13
- import { IconCard } from "../internal/icons/IconCard.js";
22
+ import { Accordion } from "../internal/Accordion/Accordion.js";
23
+ import { AccordionItem } from "../AccordionItem/AccordionItem.js";
24
+ import { IconLinePay } from "../internal/icons/IconLinePay.js";
25
+ import { IconBoost } from "../internal/icons/IconBoost.js";
26
+ import { IconGrabPay } from "../internal/icons/IconGrabPay.js";
27
+ import { IconNinePay } from "../internal/icons/IconNinePay.js";
28
+ import { IconMayBankQRPay } from "../internal/icons/IconMayBankQRPay.js";
29
+ import { IconShopeePay } from "../internal/icons/IconShopeePay.js";
30
+ import { IconTNGWallet } from "../internal/icons/IconTNGWallet.js";
31
+ import { IconCard2 } from "../internal/icons/IconCard2.js";
32
+ import { IconGCash } from "../internal/icons/IconGCash.js";
33
+ import { IconPaymaya } from "../internal/icons/IconPaymaya.js";
34
+ import { removeElementFromArray } from "../../utils/array.js";
14
35
  const dropInSupportedPaymentMethods = [
15
36
  ...CardPaymentMethods,
16
37
  PaymentMethod.GOOGLE_PAY,
17
- PaymentMethod.APPLE_PAY
38
+ PaymentMethod.APPLE_PAY,
39
+ PaymentMethod.BOOST,
40
+ PaymentMethod.GRAB_PAY,
41
+ PaymentMethod.LINE_PAY,
42
+ PaymentMethod.NINE_PAY,
43
+ PaymentMethod.SHOPEE_PAY,
44
+ PaymentMethod.TNG_WALLET,
45
+ PaymentMethod.MAY_BANK_QR_PAY,
46
+ PaymentMethod.GCASH,
47
+ PaymentMethod.PAYMAYA
18
48
  ];
19
49
  const PaymentComponentMap = {
20
50
  [PaymentCategory.CARD]: Card,
21
51
  [PaymentCategory.APPLE_PAY]: ApplePay,
22
- [PaymentCategory.GOOGLE_PAY]: GooglePay
52
+ [PaymentCategory.GOOGLE_PAY]: GooglePay,
53
+ [PaymentCategory.BOOST]: Boost,
54
+ [PaymentCategory.NINE_PAY]: NinePay,
55
+ [PaymentCategory.LINE_PAY]: LinePay,
56
+ [PaymentCategory.TNG_WALLET]: TNGWallet,
57
+ [PaymentCategory.MAY_BANK_QR_PAY]: MayBankQRPay,
58
+ [PaymentCategory.SHOPEE_PAY]: ShopeePay,
59
+ [PaymentCategory.GRAB_PAY]: GrabPay,
60
+ [PaymentCategory.GCASH]: GCash,
61
+ [PaymentCategory.PAYMAYA]: Paymaya
23
62
  // [PaymentCategory.WECHAT_PAY]: WechatPay,
24
63
  // [PaymentCategory.ALI_PAY]: AliPay,
25
64
  // [PaymentCategory.SEPA_DEBIT]: Sepa
@@ -54,14 +93,61 @@ const PaymentTabs = (props) => {
54
93
  }
55
94
  )) });
56
95
  };
96
+ const paymentCategoryOptionMap = {
97
+ [PaymentCategory.CARD]: {
98
+ icon: IconCard2,
99
+ nameKey: "dropIn.card.label"
100
+ },
101
+ [PaymentCategory.LINE_PAY]: {
102
+ icon: IconLinePay,
103
+ nameKey: "dropIn.linePay.label"
104
+ },
105
+ [PaymentCategory.BOOST]: {
106
+ icon: IconBoost,
107
+ nameKey: "dropIn.boost.label"
108
+ },
109
+ [PaymentCategory.GRAB_PAY]: {
110
+ icon: IconGrabPay,
111
+ nameKey: "dropIn.grabPay.label"
112
+ },
113
+ [PaymentCategory.NINE_PAY]: {
114
+ icon: IconNinePay,
115
+ nameKey: "dropIn.ninePay.label"
116
+ },
117
+ [PaymentCategory.MAY_BANK_QR_PAY]: {
118
+ icon: IconMayBankQRPay,
119
+ nameKey: "dropIn.mayBankQRPay.label"
120
+ },
121
+ [PaymentCategory.SHOPEE_PAY]: {
122
+ icon: IconShopeePay,
123
+ nameKey: "dropIn.shopeePay.label"
124
+ },
125
+ [PaymentCategory.TNG_WALLET]: {
126
+ icon: IconTNGWallet,
127
+ nameKey: "dropIn.TNGWallet.label"
128
+ },
129
+ [PaymentCategory.GCASH]: {
130
+ icon: IconGCash,
131
+ nameKey: "dropIn.gcash.label"
132
+ },
133
+ [PaymentCategory.PAYMAYA]: {
134
+ icon: IconPaymaya,
135
+ nameKey: "dropIn.paymaya.label"
136
+ }
137
+ };
57
138
  const { bem } = useBEM("drop-in");
58
139
  const DropIn = w((props, ref) => {
59
- const { paymentMethods: paymentMethodsConfig, layout = "tabs", session } = props;
140
+ const {
141
+ paymentMethods: paymentMethodsConfig,
142
+ layout = "accordion",
143
+ session,
144
+ core,
145
+ enableAccordionTransition = true
146
+ } = props;
60
147
  const { i18n, sessionReady } = usePayState(session);
61
148
  const [paymentCategoryOptions, setPaymentCategoryOptions] = h([]);
62
- const [activePaymentCategory, setActivePaymentCategory] = h(
63
- null
64
- );
149
+ const [activePaymentCategory, setActivePaymentCategory] = h();
150
+ const [enablePaymentMethod, setEnablePaymentMethod] = h();
65
151
  const [headerPaymentCategories, setHeaderPaymentCategories] = h(
66
152
  []
67
153
  );
@@ -78,14 +164,24 @@ const DropIn = w((props, ref) => {
78
164
  }
79
165
  }));
80
166
  y(() => {
167
+ var _a, _b;
81
168
  if (!activePaymentCategory) {
82
169
  return;
83
170
  }
84
- if (componentInstMap.current[activePaymentCategory]) {
85
- return;
171
+ const currCompInst = componentInstMap.current[activePaymentCategory];
172
+ if (currCompInst) {
173
+ const ref2 = currCompInst.ref;
174
+ (_a = ref2.updateAddress) == null ? void 0 : _a.call(ref2);
175
+ (_b = ref2.updateEmail) == null ? void 0 : _b.call(ref2);
86
176
  }
87
- renderComponent(activePaymentCategory);
88
177
  }, [activePaymentCategory]);
178
+ y(() => {
179
+ if (paymentCategories == null ? void 0 : paymentCategories.length) {
180
+ paymentCategories.forEach((category) => {
181
+ renderComponent(category);
182
+ });
183
+ }
184
+ }, [paymentCategories]);
89
185
  y(() => {
90
186
  if (headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) {
91
187
  renderComponent(PaymentCategory.APPLE_PAY);
@@ -113,32 +209,46 @@ const DropIn = w((props, ref) => {
113
209
  }
114
210
  };
115
211
  const initPaymentCategories = (enablePaymentMethods) => {
212
+ const cpyEnablePaymentMethods = [...enablePaymentMethods];
116
213
  const paymentCategoryOptions2 = [];
117
214
  const paymentCategories2 = [];
118
215
  const headerPaymentCategories2 = [];
119
- if (enablePaymentMethods.includes(PaymentMethod.APPLE_PAY)) {
120
- if (layout === "tabs") {
121
- headerPaymentCategories2.push(PaymentCategory.APPLE_PAY);
122
- } else {
123
- paymentCategories2.push(PaymentCategory.APPLE_PAY);
124
- }
216
+ if (cpyEnablePaymentMethods.includes(PaymentMethod.APPLE_PAY)) {
217
+ headerPaymentCategories2.push(PaymentCategory.APPLE_PAY);
218
+ removeElementFromArray(cpyEnablePaymentMethods, PaymentMethod.APPLE_PAY);
125
219
  }
126
- if (enablePaymentMethods.includes(PaymentMethod.GOOGLE_PAY)) {
127
- if (layout === "tabs") {
128
- headerPaymentCategories2.push(PaymentCategory.GOOGLE_PAY);
129
- } else {
130
- paymentCategories2.push(PaymentCategory.APPLE_PAY);
131
- }
220
+ if (cpyEnablePaymentMethods.includes(PaymentMethod.GOOGLE_PAY)) {
221
+ headerPaymentCategories2.push(PaymentCategory.GOOGLE_PAY);
222
+ removeElementFromArray(cpyEnablePaymentMethods, PaymentMethod.GOOGLE_PAY);
132
223
  }
133
- const isCardEnable = !!intersection(enablePaymentMethods, CardPaymentMethods).length;
224
+ const isCardEnable = !!intersection(cpyEnablePaymentMethods, CardPaymentMethods).length;
134
225
  if (isCardEnable) {
135
226
  paymentCategories2.push(PaymentCategory.CARD);
136
227
  paymentCategoryOptions2.push({
137
228
  type: PaymentCategory.CARD,
138
- name: i18n.get("dropIn.card.label"),
139
- icon: /* @__PURE__ */ u(IconCard, { size: 16 })
229
+ icon: () => {
230
+ const Icon = paymentCategoryOptionMap[PaymentCategory.CARD].icon;
231
+ return Icon ? /* @__PURE__ */ u(Icon, { size: 24 }) : null;
232
+ },
233
+ name: i18n.get(paymentCategoryOptionMap[PaymentCategory.CARD].nameKey)
140
234
  });
141
235
  }
236
+ cpyEnablePaymentMethods.forEach((method) => {
237
+ if (cpyEnablePaymentMethods.includes(method)) {
238
+ const type = PaymentMethod2CategoryMap[method];
239
+ if (type) {
240
+ paymentCategories2.push(type);
241
+ paymentCategoryOptions2.push({
242
+ type,
243
+ icon: () => {
244
+ const Icon = paymentCategoryOptionMap[type].icon;
245
+ return Icon ? /* @__PURE__ */ u(Icon, { size: 24 }) : null;
246
+ },
247
+ name: i18n.get(paymentCategoryOptionMap[type].nameKey)
248
+ });
249
+ }
250
+ }
251
+ });
142
252
  if (paymentCategoryOptions2.length) {
143
253
  setPaymentCategoryOptions(paymentCategoryOptions2);
144
254
  setActivePaymentCategory(paymentCategoryOptions2[0].type);
@@ -157,7 +267,7 @@ const DropIn = w((props, ref) => {
157
267
  if (((_a = session.checkout) == null ? void 0 : _a.sessionMode) === SessionMode.COMPONENT) {
158
268
  (_c = (_b = props.core.config).onInitError) == null ? void 0 : _c.call(
159
269
  _b,
160
- new PayKKaError("ERROR", "Please send the correct mode when creating the checkout")
270
+ new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
161
271
  );
162
272
  return;
163
273
  }
@@ -170,38 +280,83 @@ const DropIn = w((props, ref) => {
170
280
  return;
171
281
  }
172
282
  initPaymentCategories(enablePaymentMethods);
283
+ if (core.processingPaymentMethod) {
284
+ const category = PaymentMethod2CategoryMap[core.processingPaymentMethod];
285
+ category && setActivePaymentCategory(category);
286
+ core.enablePaymentMethod.value = core.processingPaymentMethod;
287
+ }
173
288
  }, [sessionReady, i18n.ready.value]);
174
- return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: i18n.ready.value && /* @__PURE__ */ u("div", { className: bem(), children: layout === "accordion" ? /* @__PURE__ */ u(b, {}) : /* @__PURE__ */ u(b, { children: [
175
- headerPaymentCategories == null ? void 0 : headerPaymentCategories.map((category) => /* @__PURE__ */ u(
289
+ y(() => {
290
+ if (core.enablePaymentMethod.value) {
291
+ setEnablePaymentMethod(
292
+ PaymentMethod2CategoryMap[core.enablePaymentMethod.value]
293
+ );
294
+ } else {
295
+ setEnablePaymentMethod(void 0);
296
+ }
297
+ }, [core.enablePaymentMethod.value]);
298
+ const HeaderField = () => {
299
+ return /* @__PURE__ */ u(b, { children: headerPaymentCategories == null ? void 0 : headerPaymentCategories.map((category) => /* @__PURE__ */ u(
176
300
  "div",
177
301
  {
178
302
  className: bem("header-payment"),
179
303
  ref: (el) => componentMountRefMap.current[category] = el
180
304
  }
181
- )),
182
- !!paymentCategoryOptions.length && activePaymentCategory && /* @__PURE__ */ u(b, { children: [
183
- !!(headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) && /* @__PURE__ */ u("div", { className: bem("other"), children: [
184
- /* @__PURE__ */ u("div", { className: bem("other-line") }),
185
- /* @__PURE__ */ u("div", { className: bem("other-text"), children: i18n.get("dropIn.otherPaymentMethod") }),
186
- /* @__PURE__ */ u("div", { className: bem("other-line") })
187
- ] }),
188
- /* @__PURE__ */ u("div", { className: bem("tabs-wrapper"), children: /* @__PURE__ */ u(
189
- PaymentTabs,
305
+ )) });
306
+ };
307
+ const OtherLine = () => {
308
+ return /* @__PURE__ */ u(b, { children: !!(headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) && /* @__PURE__ */ u("div", { className: bem("other"), children: [
309
+ /* @__PURE__ */ u("div", { className: bem("other-line") }),
310
+ /* @__PURE__ */ u("div", { className: bem("other-text"), children: i18n.get("dropIn.otherPaymentMethod") }),
311
+ /* @__PURE__ */ u("div", { className: bem("other-line") })
312
+ ] }) });
313
+ };
314
+ return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: i18n.ready.value && /* @__PURE__ */ u("div", { className: bem(), children: [
315
+ HeaderField(),
316
+ !!paymentCategoryOptions.length && /* @__PURE__ */ u(b, { children: [
317
+ OtherLine(),
318
+ layout === "accordion" ? /* @__PURE__ */ u(b, { children: /* @__PURE__ */ u("div", { className: bem("accordion-wrapper"), children: /* @__PURE__ */ u(
319
+ Accordion,
190
320
  {
191
321
  value: activePaymentCategory,
192
- tabs: paymentCategoryOptions,
193
- onChange: (item) => handlePaymentCategoryChange(item)
194
- }
195
- ) }),
196
- paymentCategories == null ? void 0 : paymentCategories.map((category) => /* @__PURE__ */ u(
197
- "div",
198
- {
199
- style: { display: category === activePaymentCategory ? "block" : "none" },
200
- ref: (el) => componentMountRefMap.current[category] = el
322
+ enableTransition: enableAccordionTransition,
323
+ onChange: (item) => handlePaymentCategoryChange(item),
324
+ children: paymentCategoryOptions.map((item) => /* @__PURE__ */ u(
325
+ AccordionItem,
326
+ {
327
+ title: item.name,
328
+ value: item.type,
329
+ header: /* @__PURE__ */ u("div", { className: bem("accordion-icon"), children: item.icon() }),
330
+ disabled: !!enablePaymentMethod && enablePaymentMethod !== item.type,
331
+ children: /* @__PURE__ */ u(
332
+ "div",
333
+ {
334
+ style: "padding: 0 2px",
335
+ ref: (el) => componentMountRefMap.current[item.type] = el
336
+ }
337
+ )
338
+ }
339
+ ))
201
340
  }
202
- ))
341
+ ) }) }) : /* @__PURE__ */ u(b, { children: [
342
+ /* @__PURE__ */ u("div", { className: bem("tabs-wrapper"), children: /* @__PURE__ */ u(
343
+ PaymentTabs,
344
+ {
345
+ value: activePaymentCategory,
346
+ tabs: paymentCategoryOptions,
347
+ onChange: (item) => handlePaymentCategoryChange(item)
348
+ }
349
+ ) }),
350
+ paymentCategories == null ? void 0 : paymentCategories.map((category) => /* @__PURE__ */ u(
351
+ "div",
352
+ {
353
+ style: { display: category === activePaymentCategory ? "block" : "none" },
354
+ ref: (el) => componentMountRefMap.current[category] = el
355
+ }
356
+ ))
357
+ ] })
203
358
  ] })
204
- ] }) }) });
359
+ ] }) });
205
360
  });
206
361
  export {
207
362
  DropIn,
@@ -1,13 +1,13 @@
1
1
  import { w, F, h, q, y, A, u, b } from "../../core.js";
2
2
  import { isTimeoutError } from "../../api/http.js";
3
3
  import { SessionMode, PaymentMethod } from "../../constant.js";
4
+ import "../../utils/card-brand/brands.js";
5
+ import "../../utils/system-info/get-browser-info.js";
6
+ import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
4
7
  import { getBrowserParams } from "../../api/modules/get-browser-params.js";
5
8
  import { getGooglePayInfo, googlePay } from "../../api/modules/google-pay/index.js";
6
9
  import { useBEM } from "../../hooks/useBEM.js";
7
10
  import "../../core/context.js";
8
- import "../../utils/card-brand/brands.js";
9
- import "../../utils/system-info/get-browser-info.js";
10
- import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
11
11
  import { PayKKaError } from "../../core/error.js";
12
12
  import { usePayState } from "../../hooks/usePayState.js";
13
13
  import { useRetry } from "../../hooks/useRetry.js";
@@ -206,7 +206,7 @@ const GooglePay = w((props, ref) => {
206
206
  if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
207
207
  (_b = (_a2 = props.core.config).onInitError) == null ? void 0 : _b.call(
208
208
  _a2,
209
- new PayKKaError("ERROR", "Please send the correct mode when creating the checkout")
209
+ new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
210
210
  );
211
211
  return;
212
212
  }
@@ -293,6 +293,7 @@ const GooglePay = w((props, ref) => {
293
293
  fraudDetectionId: fraudDetection == null ? void 0 : fraudDetection.fraudDetectionID
294
294
  })
295
295
  },
296
+ props.core,
296
297
  { locale: i18n.locale }
297
298
  );
298
299
  }());