@paykka/card-checkout-ui 0.11.6 → 0.13.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 (217) hide show
  1. package/dist/card-checkout-ui.js +19 -19
  2. package/dist/card-checkout-ui.umd.cjs +19 -19
  3. package/dist/es/_commonjsHelpers.js +82 -1
  4. package/dist/es/api/index.js +1 -0
  5. package/dist/es/api/modules/address/index.js +9 -9
  6. package/dist/es/api/modules/ali-pay/index.js +10 -49
  7. package/dist/es/api/modules/apple-pay/index.js +13 -59
  8. package/dist/es/api/modules/boost/index.js +8 -48
  9. package/dist/es/api/modules/card/index.js +10 -54
  10. package/dist/es/api/modules/checkout/index.js +11 -9
  11. package/dist/es/api/modules/checkout/map.js +25 -18
  12. package/dist/es/api/modules/encrypted-card/index.js +3 -2
  13. package/dist/es/api/modules/gcash/index.js +8 -48
  14. package/dist/es/api/modules/get-browser-params.js +4 -1
  15. package/dist/es/api/modules/google-pay/index.js +10 -56
  16. package/dist/es/api/modules/grab-pay/index.js +8 -48
  17. package/dist/es/api/modules/index.js +1 -0
  18. package/dist/es/api/modules/line-pay/index.js +8 -48
  19. package/dist/es/api/modules/map.js +17 -11
  20. package/dist/es/api/modules/may-bank-qr-pay/index.js +8 -48
  21. package/dist/es/api/modules/nine-pay/index.js +8 -48
  22. package/dist/es/api/modules/paymaya/index.js +8 -48
  23. package/dist/es/api/modules/risk/index.js +2 -1
  24. package/dist/es/api/modules/sepa/index.js +10 -51
  25. package/dist/es/api/modules/shopee-pay/index.js +8 -48
  26. package/dist/es/api/modules/threeDS/index.js +3 -0
  27. package/dist/es/api/modules/tng-wallet/index.js +8 -48
  28. package/dist/es/api/modules/wechat-pay/index.js +10 -51
  29. package/dist/es/api/modules/zalopay/index.js +16 -0
  30. package/dist/es/api/utils/index.js +59 -0
  31. package/dist/es/components/AddressField/index.js +37 -37
  32. package/dist/es/components/AliPay/index.js +158 -111
  33. package/dist/es/components/ApplePay/index.js +99 -67
  34. package/dist/es/components/Boost/index.js +91 -70
  35. package/dist/es/components/Card/index.js +114 -107
  36. package/dist/es/components/CardSelector/index.js +1 -1
  37. package/dist/es/components/DropIn/index.js +12 -4
  38. package/dist/es/components/EncryptedCard/index.js +6 -2
  39. package/dist/es/components/GooglePay/index.js +94 -60
  40. package/dist/es/components/GrabPay/index.js +91 -70
  41. package/dist/es/components/GuideCard/index.js +10 -7
  42. package/dist/es/components/LinePay/index.js +91 -70
  43. package/dist/es/components/MayBankQRPay/index.js +302 -275
  44. package/dist/es/components/NinePay/index.js +91 -70
  45. package/dist/es/components/SecuredFieldsProvider/index.js +26 -9
  46. package/dist/es/components/SecuredIframe/index.js +40 -61
  47. package/dist/es/components/Sepa/index.js +72 -53
  48. package/dist/es/components/ShopeePay/index.js +91 -70
  49. package/dist/es/components/SubmitButton/index.js +8 -7
  50. package/dist/es/components/TNGWallet/index.js +91 -70
  51. package/dist/es/components/ThreeDS/index.js +32 -7
  52. package/dist/es/components/WechatPay/index.js +151 -102
  53. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
  54. package/dist/es/components/index.js +1 -0
  55. package/dist/es/components/internal/Form/FormItem.js +1 -1
  56. package/dist/es/components/internal/Form/util.js +1 -1
  57. package/dist/es/components/internal/Modal/Modal.js +1 -1
  58. package/dist/es/components/internal/Select/Select.js +19 -8
  59. package/dist/es/components/internal/Select/SelectMenu.js +2 -2
  60. package/dist/es/components/internal/Select/SelectMenuItem.js +12 -4
  61. package/dist/es/components/internal/icons/IconError.js +7 -4
  62. package/dist/es/components/internal/icons/IconZalopay.js +47 -0
  63. package/dist/es/components/internal/icons/IconZalopayComplete.js +48 -0
  64. package/dist/es/components/wallets/GCash/GCash.js +80 -56
  65. package/dist/es/components/wallets/Paymaya/Paymaya.js +91 -70
  66. package/dist/es/components/wallets/Zalopay/Zalopay.js +381 -0
  67. package/dist/es/components/wallets/Zalopay/index.js +1 -0
  68. package/dist/es/components/wallets/Zalopay/type.js +1 -0
  69. package/dist/es/components/wallets/Zalopay/zalopay2.js +1 -0
  70. package/dist/es/config.js +5 -5
  71. package/dist/es/constant.js +8 -2
  72. package/dist/es/core/{Address.js → address.js} +8 -16
  73. package/dist/es/core/{PayKKaCheckout.js → checkout.js} +101 -27
  74. package/dist/es/core/create.js +1 -1
  75. package/dist/es/core/query.js +3 -2
  76. package/dist/es/core/{Session.js → session.js} +28 -32
  77. package/dist/es/core/theme.js +65 -0
  78. package/dist/es/core.js +0 -4
  79. package/dist/es/hooks/usePayment.js +14 -0
  80. package/dist/es/i18n/locales/de-DE.js +3 -1
  81. package/dist/es/i18n/locales/en-GB.js +3 -1
  82. package/dist/es/i18n/locales/es-ES.js +3 -1
  83. package/dist/es/i18n/locales/fr-FR.js +3 -1
  84. package/dist/es/i18n/locales/ja-JP.js +3 -1
  85. package/dist/es/i18n/locales/ko-KR.js +3 -1
  86. package/dist/es/i18n/locales/nl-NL.js +3 -1
  87. package/dist/es/i18n/locales/pt-PT.js +3 -1
  88. package/dist/es/i18n/locales/ru-RU.js +3 -1
  89. package/dist/es/i18n/locales/zh-CN.js +3 -1
  90. package/dist/es/i18n/locales/zh-HK.js +3 -1
  91. package/dist/es/i18n/locales/zh-TW.js +3 -1
  92. package/dist/es/index.js +21 -7
  93. package/dist/es/style.css +1 -1
  94. package/dist/es/types/index.js +7 -0
  95. package/dist/es/utils/colors.js +5 -1
  96. package/dist/es/utils/format.js +0 -5
  97. package/dist/es/utils/object.js +31 -1
  98. package/dist/es/utils/payment.js +82 -0
  99. package/dist/es/utils/redirect.js +4 -4
  100. package/dist/es/utils/string.js +10 -0
  101. package/dist/es/utils/system-info/is-ua-webview.js +14 -12
  102. package/dist/es/utils/theme.js +7 -0
  103. package/dist/style.css +1 -1
  104. package/dist/types/api/modules/address/index.d.ts +15 -6
  105. package/dist/types/api/modules/ali-pay/index.d.ts +3 -19
  106. package/dist/types/api/modules/apple-pay/index.d.ts +4 -14
  107. package/dist/types/api/modules/boost/index.d.ts +3 -23
  108. package/dist/types/api/modules/card/index.d.ts +3 -30
  109. package/dist/types/api/modules/checkout/index.d.ts +3 -3
  110. package/dist/types/api/modules/checkout/map.d.ts +3 -3
  111. package/dist/types/api/modules/checkout/type.d.ts +33 -4
  112. package/dist/types/api/modules/gcash/index.d.ts +3 -23
  113. package/dist/types/api/modules/get-browser-params.d.ts +1 -0
  114. package/dist/types/api/modules/google-pay/index.d.ts +3 -13
  115. package/dist/types/api/modules/grab-pay/index.d.ts +3 -23
  116. package/dist/types/api/modules/index.d.ts +1 -0
  117. package/dist/types/api/modules/line-pay/index.d.ts +3 -23
  118. package/dist/types/api/modules/map.d.ts +2 -2
  119. package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +3 -23
  120. package/dist/types/api/modules/nine-pay/index.d.ts +3 -23
  121. package/dist/types/api/modules/paymaya/index.d.ts +3 -23
  122. package/dist/types/api/modules/sepa/index.d.ts +3 -24
  123. package/dist/types/api/modules/shopee-pay/index.d.ts +3 -23
  124. package/dist/types/api/modules/tng-wallet/index.d.ts +3 -23
  125. package/dist/types/api/modules/type.d.ts +74 -21
  126. package/dist/types/api/modules/wechat-pay/index.d.ts +3 -20
  127. package/dist/types/api/modules/zalopay/index.d.ts +4 -0
  128. package/dist/types/api/utils/index.d.ts +48 -0
  129. package/dist/types/components/AddressField/type.d.ts +3 -9
  130. package/dist/types/components/AliPay/AliPay.d.ts +6 -2
  131. package/dist/types/components/AliPay/type.d.ts +15 -2
  132. package/dist/types/components/ApplePay/ApplePay.d.ts +6 -2
  133. package/dist/types/components/ApplePay/type.d.ts +10 -14
  134. package/dist/types/components/ApplePay/utils.d.ts +1 -1
  135. package/dist/types/components/Boost/Boost.d.ts +6 -2
  136. package/dist/types/components/Boost/type.d.ts +2 -24
  137. package/dist/types/components/Card/Card.d.ts +6 -2
  138. package/dist/types/components/Card/type.d.ts +3 -43
  139. package/dist/types/components/DropIn/DropIn.d.ts +6 -2
  140. package/dist/types/components/DropIn/type.d.ts +4 -10
  141. package/dist/types/components/GooglePay/GooglePay.d.ts +6 -2
  142. package/dist/types/components/GooglePay/createGooglePay.d.ts +2 -1
  143. package/dist/types/components/GooglePay/type.d.ts +10 -26
  144. package/dist/types/components/GrabPay/GrabPay.d.ts +6 -2
  145. package/dist/types/components/GrabPay/type.d.ts +3 -25
  146. package/dist/types/components/LinePay/LinePay.d.ts +6 -2
  147. package/dist/types/components/LinePay/type.d.ts +3 -25
  148. package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -2
  149. package/dist/types/components/MayBankQRPay/type.d.ts +3 -25
  150. package/dist/types/components/NinePay/NinePay.d.ts +6 -2
  151. package/dist/types/components/NinePay/type.d.ts +3 -25
  152. package/dist/types/components/SecuredFieldsProvider/type.d.ts +5 -0
  153. package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +3 -1
  154. package/dist/types/components/Sepa/Sepa.d.ts +6 -2
  155. package/dist/types/components/Sepa/type.d.ts +3 -2
  156. package/dist/types/components/ShopeePay/ShopeePay.d.ts +6 -2
  157. package/dist/types/components/ShopeePay/type.d.ts +3 -25
  158. package/dist/types/components/TNGWallet/TNGWallet.d.ts +6 -2
  159. package/dist/types/components/TNGWallet/type.d.ts +3 -25
  160. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +2 -0
  161. package/dist/types/components/WechatPay/WechatPay.d.ts +6 -2
  162. package/dist/types/components/WechatPay/type.d.ts +15 -2
  163. package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
  164. package/dist/types/components/index.d.ts +1 -0
  165. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  166. package/dist/types/components/internal/Select/SelectMenu.d.ts +1 -1
  167. package/dist/types/components/internal/icons/IconZalopay.d.ts +2 -0
  168. package/dist/types/components/internal/icons/IconZalopayComplete.d.ts +2 -0
  169. package/dist/types/components/internal/icons/index.d.ts +3 -0
  170. package/dist/types/components/wallets/GCash/GCash.d.ts +6 -2
  171. package/dist/types/components/wallets/GCash/type.d.ts +3 -35
  172. package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -2
  173. package/dist/types/components/wallets/Paymaya/type.d.ts +3 -25
  174. package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +10 -0
  175. package/dist/types/components/wallets/Zalopay/index.d.ts +2 -0
  176. package/dist/types/components/wallets/Zalopay/type.d.ts +39 -0
  177. package/dist/types/config.d.ts +2 -4
  178. package/dist/types/constant.d.ts +3 -1
  179. package/dist/types/core/{Address.d.ts → address.d.ts} +23 -24
  180. package/dist/types/core/{PayKKaCheckout.d.ts → checkout.d.ts} +9 -3
  181. package/dist/types/core/context.d.ts +3 -2
  182. package/dist/types/core/index.d.ts +3 -2
  183. package/dist/types/core/query.d.ts +2 -2
  184. package/dist/types/core/session.d.ts +23 -0
  185. package/dist/types/core/theme.d.ts +7 -0
  186. package/dist/types/hooks/index.d.ts +1 -0
  187. package/dist/types/hooks/usePayment.d.ts +8 -0
  188. package/dist/types/i18n/locales/de-DE.d.ts +2 -0
  189. package/dist/types/i18n/locales/en-GB.d.ts +2 -0
  190. package/dist/types/i18n/locales/es-ES.d.ts +2 -0
  191. package/dist/types/i18n/locales/fr-FR.d.ts +2 -0
  192. package/dist/types/i18n/locales/ja-JP.d.ts +2 -0
  193. package/dist/types/i18n/locales/ko-KR.d.ts +2 -0
  194. package/dist/types/i18n/locales/nl-NL.d.ts +2 -0
  195. package/dist/types/i18n/locales/pt-PT.d.ts +2 -0
  196. package/dist/types/i18n/locales/ru-RU.d.ts +2 -0
  197. package/dist/types/i18n/locales/zh-CN.d.ts +2 -0
  198. package/dist/types/i18n/locales/zh-HK.d.ts +2 -0
  199. package/dist/types/i18n/locales/zh-TW.d.ts +2 -0
  200. package/dist/types/index.d.ts +2 -1
  201. package/dist/types/types/index.d.ts +70 -32
  202. package/dist/types/types/message.d.ts +30 -25
  203. package/dist/types/utils/card-brand/index.d.ts +3 -3
  204. package/dist/types/utils/colors.d.ts +1 -0
  205. package/dist/types/utils/index.d.ts +4 -2
  206. package/dist/types/utils/object.d.ts +7 -0
  207. package/dist/types/utils/payment.d.ts +37 -0
  208. package/dist/types/utils/string.d.ts +1 -0
  209. package/dist/types/utils/style.d.ts +1 -1
  210. package/dist/types/utils/system-info/is-ua-webview.d.ts +1 -1
  211. package/dist/types/utils/theme.d.ts +4 -0
  212. package/package.json +3 -3
  213. package/dist/es/utils/deep-freeze.js +0 -13
  214. package/dist/es/utils/obj.js +0 -22
  215. package/dist/types/core/Session.d.ts +0 -16
  216. package/dist/types/utils/deep-freeze.d.ts +0 -1
  217. package/dist/types/utils/obj.d.ts +0 -6
@@ -1,2 +1,2 @@
1
- import { type RequestOptions, type QueryCheckoutParams, type CheckoutRes } from '../api';
2
- export declare const querySession: ({ sessionId, clientKey }: QueryCheckoutParams, options?: RequestOptions) => Promise<CheckoutRes>;
1
+ import { type RequestOptions, type CheckoutInitParams, type CheckoutRes } from '../api';
2
+ export declare const querySession: (params: CheckoutInitParams, extraParams?: Recordable, options?: RequestOptions) => Promise<CheckoutRes>;
@@ -0,0 +1,23 @@
1
+ import { type CheckoutRes } from '../api';
2
+ export interface SessionParams {
3
+ /**
4
+ * 会话 ID
5
+ * Hosted、Component、Drop-in 必填
6
+ */
7
+ sessionId?: string;
8
+ /**
9
+ * 客户端密钥
10
+ * Component、Drop-in 必填
11
+ */
12
+ clientKey?: string;
13
+ }
14
+ export declare class Session {
15
+ #private;
16
+ sessionId?: string;
17
+ readonly clientKey?: string;
18
+ checkout?: CheckoutRes;
19
+ theme: import("@preact/signals").Signal<Recordable<any>>;
20
+ extraParams: Recordable;
21
+ constructor(params: SessionParams, extraParams?: Recordable);
22
+ ready(): import("../utils").CreatePromiseReturn<boolean>;
23
+ }
@@ -0,0 +1,7 @@
1
+ import type { CheckoutTheme } from '../api';
2
+ export declare class PayKKaTheme {
3
+ #private;
4
+ constructor(checkoutId: string);
5
+ init(theme?: CheckoutTheme): void;
6
+ get className(): string;
7
+ }
@@ -3,3 +3,4 @@ export * from './useI18n';
3
3
  export * from './usePayState';
4
4
  export * from './useRetry';
5
5
  export * from './useBreakpoints';
6
+ export * from './usePayment';
@@ -0,0 +1,8 @@
1
+ import type { SubmitButtonStatus } from '../components';
2
+ /** 支付状态管理 */
3
+ export declare const usePaymentStatus: () => {
4
+ paymentButtonStatus: SubmitButtonStatus;
5
+ setPaymentButtonStatus: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<SubmitButtonStatus>>;
6
+ errorMsg: string;
7
+ setErrorMsg: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<string>>;
8
+ };
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'dropIn.ninePay.label': string;
13
13
  'dropIn.gcash.label': string;
14
14
  'dropIn.paymaya.label': string;
15
+ 'dropIn.zalopay.label': string;
15
16
  'card.cardNumber.label': string;
16
17
  'card.cardNumber.incomplete': string;
17
18
  'card.cardNumber.invalid': string;
@@ -67,5 +68,6 @@ declare const _default: {
67
68
  'threeDS.returnToCheckout': string;
68
69
  'qrCode.expired': string;
69
70
  'qrCode.scanByGcash': string;
71
+ 'qrCode.scanByZalopay': string;
70
72
  };
71
73
  export default _default;
@@ -1,6 +1,7 @@
1
1
  export * from './components';
2
2
  export { type ComponentInst, create, querySession, Session, PayKKaCheckout, PayKKaError } from './core';
3
3
  export { I18n, LocaleKey } from './i18n';
4
- export { setApiUrl, setCDNUrl, setFraudDetectionEnv, setCustomReqHeaders, setCustomLocale, setCheckoutConfig } from './config';
4
+ export { setApiUrl, setCDNUrl, setFraudDetectionEnv, setCustomReqHeaders, setCustomLocale } from './config';
5
5
  export { getFingerprint, redirectToPayment } from './utils';
6
6
  export { PaymentMethod } from './constant';
7
+ export * from './types';
@@ -1,27 +1,29 @@
1
1
  import type { HTMLAttributes } from 'preact/compat';
2
2
  import type { LocaleKeyType } from '../i18n';
3
- import type { PayKKaCheckout, PayKKaError, Session } from '../core';
3
+ import type { PayKKaError } from '../core';
4
4
  import type { FraudDetectionEnv } from './fraud-detection';
5
5
  import type { FormValidateError } from '../components/internal/Form';
6
6
  import type { PaymentMethod } from '../constant';
7
- import type { EventType } from './event';
7
+ import type { Amount, OrderStatus, SessionStatus } from '../api';
8
8
  export * from './fraud-detection';
9
9
  export * from './message';
10
10
  export * from './event';
11
11
  export type CustomAttributes<T extends EventTarget, K extends keyof HTMLAttributes<T> = 'style' | 'className'> = Pick<HTMLAttributes<T>, K>;
12
12
  /** 收银台初始化参数 */
13
- export interface PayKKaInitConfiguration {
14
- sessionId: string;
13
+ export interface PayKKaInitConfiguration extends PayKKaCommonConfig {
14
+ sessionId?: string;
15
15
  /** 环境配置,必传! */
16
16
  env: PayKKaEnvType;
17
17
  /** 嵌入式收银台必传,需要商户进行配置 */
18
18
  clientKey?: string;
19
19
  /** 国际化语言 */
20
20
  locale?: LocaleKeyType;
21
- /** 是否隐藏支付按钮 */
22
- hidePaymentButton?: boolean;
23
21
  /** 定义 3DS 所需配置 */
24
22
  threeDSFrame?: ThreeDSFrameConfig;
23
+ /**
24
+ * TODO: 很多时候用户需要的不仅仅是支付方式,而是支付成功后的数据,比如订单号、支付方式等,所以需要换成一个统一的回调
25
+ * 参考 adyen onPaymentCompleted 回调 https://docs.adyen.com/online-payments/build-your-integration/sessions-flow/?platform=Web&integration=Components&version=6.17.0#create-the-component
26
+ */
25
27
  /** 收银台已经获取到可用支付方式时调用 */
26
28
  onPaymentMethodsReady?: (methods: PaymentMethod[]) => void;
27
29
  /** 收银台创建时报错触发 */
@@ -33,44 +35,42 @@ export interface PayKKaInitConfiguration {
33
35
  /** 提交表单时触发 */
34
36
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
35
37
  /** 支付成功后触发 */
36
- onSuccess?: (data: PaymentSuccessData) => void;
38
+ onSuccess?: (data: PaymentInfo) => void;
37
39
  /** 支付失败时触发 */
38
40
  onError?: (error: PayKKaError) => void;
39
41
  /** 支付超时时触发 */
40
42
  onTimeout?: () => void;
41
43
  /** 收银台已过期时触发 */
42
44
  onExpired?: () => void;
45
+ }
46
+ export interface PayKKaCheckoutConfig {
43
47
  /**
44
- * @internal
45
- * 各种发生在收银台生命周期中的事件
46
- */
47
- onEvent?: (type: EventType, data?: any) => void;
48
- /**
49
- * @internal
50
- * 欺诈检测错误回调
48
+ * 是否启用初始化验证
49
+ * 收银台内置对 sessionId 等参数进行校验,但不同收银台校验规则不同,需要自行校验
50
+ * @defaultValue true
51
51
  */
52
- onFraudDetectionError?: (error: PayKKaError) => void;
52
+ enableInitValidation?: boolean;
53
53
  /**
54
- * @internal
55
- * 环境配置,优先级大于 env 参数
54
+ * API 地址前缀,不同收银台的 API 地址前缀不同
55
+ * @defaultValue /session
56
56
  */
57
- _envConfig?: PayKKaEnvConfig;
57
+ apiPrefix?: string;
58
58
  /**
59
- * @internal
60
- * 根据请求类型和请求方式额外传递的参数回调
59
+ * 地址模式,不同收银台的地址模式不同
60
+ * address: 地址模式,需要展示国家、省市区等所有地址输入框
61
+ * country: 国家模式,只需要展示国家选择框
62
+ * @defaultValue 'address'
61
63
  */
62
- _getExtraParams?: (type: 'info' | 'query' | 'payment', paymentMethod: PaymentMethod) => Recordable;
64
+ addressMode?: AddressMode;
65
+ }
66
+ export type AddressMode = 'address' | 'country';
67
+ /** 公共配置属性 */
68
+ export interface PayKKaCommonConfig {
69
+ /** 是否隐藏支付按钮,默认 false */
70
+ hidePaymentButton?: boolean;
63
71
  }
64
72
  /** 收银台创建组件时自动传入的内部属性 */
65
- export type CoreProps = {
66
- session: Session;
67
- /** 收银台实例 */
68
- core: PayKKaCheckout;
69
- /** 定义 3DS 所需配置 */
70
- threeDSFrame?: ThreeDSFrameConfig;
71
- /** 组件是否通过 DropIn 创建 */
72
- isDropIn?: boolean;
73
- };
73
+ export type CoreProps = PayKKaCommonConfig & {};
74
74
  export interface ThreeDSFrameConfig {
75
75
  /** 3DS 页面宽度 */
76
76
  modalWidth?: number | string;
@@ -91,9 +91,47 @@ export interface PayKKaEnvConfig {
91
91
  fraudDetection?: FraudDetectionEnv;
92
92
  }
93
93
  export type PayKKaEnvType = `${EPayKKaEnv}`;
94
- export type PaymentSuccessData = {
94
+ export interface BasePaymentInfo {
95
+ /** 会话 ID */
96
+ sessionId?: string;
97
+ /** 商户 ID */
98
+ merchantId?: string;
99
+ /** 支付成功跳转的链接(由商户配置) */
95
100
  returnUrl?: string;
96
- };
101
+ /** 订单 ID */
102
+ orderId?: string;
103
+ /** 错误码 */
104
+ errorCode?: string;
105
+ /** 错误信息 */
106
+ errorMessage?: string;
107
+ /** 交易金额 */
108
+ transAmount?: Amount;
109
+ /** 收银台状态 */
110
+ status?: SessionStatus;
111
+ /** 订单状态 */
112
+ orderStatus?: OrderStatus;
113
+ /** 支付方式 */
114
+ paymentMethod?: PaymentMethod;
115
+ /** 支付完成时间 */
116
+ finishTime?: string;
117
+ /** 原始响应信息,一些业务字段,组件用不到,但外部会用到,可以从这里获取 */
118
+ rawResponse?: Recordable;
119
+ /** 支付信息 */
120
+ payInfo?: {
121
+ /** 三方认证 URL */
122
+ threeDSUrl?: string;
123
+ /** 支付 URL */
124
+ paymentUrl?: string;
125
+ /** 支付过期时间 */
126
+ paymentExpiredAt?: string;
127
+ /** 其他支付信息 */
128
+ [key: string]: any;
129
+ };
130
+ }
131
+ export interface PaymentInfo extends BasePaymentInfo {
132
+ /** 支付成功跳转的链接(由商户配置) */
133
+ returnUrl?: string;
134
+ }
97
135
  export declare enum CardBrandCode {
98
136
  VISA = "VISA",
99
137
  MASTER_CARD = "MASTER_CARD",
@@ -84,8 +84,8 @@ type MessageMapping = {
84
84
  [MessageAction.AUTHORIZED]: AuthorizedMessage;
85
85
  [MessageAction.BRAND]: BrandMessage;
86
86
  [MessageAction.ACTIVATED]: ActivatedMessage;
87
- [MessageAction.HIDDEN_IFRAME_READY]: {};
88
- [MessageAction.VALIDATE]: {};
87
+ [MessageAction.HIDDEN_IFRAME_READY]: {} extends BaseMessage ? {} : BaseMessage;
88
+ [MessageAction.VALIDATE]: {} extends BaseMessage ? {} : BaseMessage;
89
89
  [MessageAction.VALIDATED]: ValidatedMessage;
90
90
  [MessageAction.SET_CONFIG]: SetConfigMessage;
91
91
  [MessageAction.CHECK_THREE_DS]: CheckThreeDSMessage;
@@ -95,92 +95,97 @@ type MessageMapping = {
95
95
  [MessageAction.DDC_RESULT]: DDCResultMessage;
96
96
  [MessageAction.DDC_JWT_BIN]: DDCJwtBinMessage;
97
97
  };
98
- export interface InitMessage {
98
+ export interface BaseMessage {
99
+ /** 收银台 id */
100
+ checkoutId: string;
101
+ }
102
+ export interface InitMessage extends BaseMessage {
99
103
  config?: FieldIframeConfig;
100
- /** 是否隐藏,如不隐藏则为表单iframe */
104
+ /** 是否隐藏,如不隐藏则为表单 iframe */
101
105
  hidden: boolean;
102
106
  apiUrl?: string;
103
107
  cdnUrl?: string;
108
+ apiPrefix?: string;
104
109
  }
105
- export interface FocusMessage {
110
+ export interface FocusMessage extends BaseMessage {
106
111
  focus: boolean;
107
112
  fieldType: EFieldType;
108
113
  }
109
- export interface InvalidMessage {
114
+ export interface InvalidMessage extends BaseMessage {
110
115
  errorTip: string;
111
116
  fieldType: EFieldType;
112
117
  }
113
- export interface ValidMessage {
118
+ export interface ValidMessage extends BaseMessage {
114
119
  fieldType: EFieldType;
115
120
  }
116
- export interface BinValueMessage {
121
+ export interface BinValueMessage extends BaseMessage {
117
122
  binValue: string;
118
123
  fieldType: EFieldType;
119
124
  brand?: CardBrand;
120
125
  }
121
- export interface ValidWithValueMessage {
126
+ export interface ValidWithValueMessage extends BaseMessage {
122
127
  value: string;
123
128
  fieldType: EFieldType;
124
129
  }
125
- export interface PaymentMessage {
130
+ export interface PaymentMessage extends BaseMessage {
126
131
  formData: any;
127
132
  locale: string;
128
133
  extraParams?: Recordable;
129
134
  }
130
- export interface AfterPaymentMessage {
135
+ export interface AfterPaymentMessage extends BaseMessage {
131
136
  response: PayRes;
132
137
  }
133
- export interface PaymentErrorMessage {
138
+ export interface PaymentErrorMessage extends BaseMessage {
134
139
  error: {
135
140
  message: string;
136
141
  code: string;
137
142
  };
138
143
  }
139
- export interface ValidStatusChangedMessage {
144
+ export interface ValidStatusChangedMessage extends BaseMessage {
140
145
  status: FormValidationStatus;
141
146
  errorTip?: string;
142
147
  fieldType: EFieldType;
143
148
  }
144
- export interface PaymentTimeoutMessage {
149
+ export interface PaymentTimeoutMessage extends BaseMessage {
145
150
  message?: string;
146
151
  }
147
- export interface CardEncryptedMessage {
152
+ export interface CardEncryptedMessage extends BaseMessage {
148
153
  encryptedInfo: EncryptCardRes;
149
154
  }
150
- export interface CardEncryptionFailedMessage {
155
+ export interface CardEncryptionFailedMessage extends BaseMessage {
151
156
  error: {
152
157
  message: string;
153
158
  code: string;
154
159
  };
155
160
  }
156
- export interface AuthorizedMessage {
161
+ export interface AuthorizedMessage extends BaseMessage {
157
162
  success: boolean;
158
163
  }
159
- export interface BrandMessage {
164
+ export interface BrandMessage extends BaseMessage {
160
165
  brand?: CardBrand;
161
166
  fieldType: EFieldType;
162
167
  }
163
- export interface EncryptCardMessage {
168
+ export interface EncryptCardMessage extends BaseMessage {
164
169
  merchantId: string;
165
170
  clientKey: string;
166
171
  }
167
- export interface ActivatedMessage {
172
+ export interface ActivatedMessage extends BaseMessage {
168
173
  fieldType: EFieldType;
169
174
  }
170
- export interface ValidatedMessage {
175
+ export interface ValidatedMessage extends BaseMessage {
171
176
  status: FormValidationStatus;
172
177
  fieldType: EFieldType;
173
178
  }
174
- export interface SetConfigMessage {
179
+ export interface SetConfigMessage extends BaseMessage {
175
180
  style?: InputStylesConfig;
176
181
  }
177
- export interface CheckThreeDSMessage {
182
+ export interface CheckThreeDSMessage extends BaseMessage {
178
183
  status: string;
179
184
  }
180
- export interface ThreeDSStatusConfigMessage {
185
+ export interface ThreeDSStatusConfigMessage extends BaseMessage {
181
186
  locale?: LocaleKeyType;
182
187
  }
183
- export interface DDCResultMessage {
188
+ export interface DDCResultMessage extends BaseMessage {
184
189
  sessionId: string;
185
190
  }
186
191
  export interface DDCJwtBinMessage {
@@ -5,7 +5,7 @@ export declare function findCardBrand(number: string, brands?: CardBrandConfig[]
5
5
  export declare function findCardBrandInfo(number: string, brands?: CardBrandConfig[]): {
6
6
  icon: typeof import("../../components/internal/icons").IconVisa | typeof import("../../components/internal/icons").IconMasterCard | typeof import("../../components/internal/icons").IconJcb | typeof import("../../components/internal/icons").IconAmex | typeof import("../../components/internal/icons").IconDiscover | typeof import("../../components/internal/icons").IconDinnersClub | typeof import("../../components/internal/icons").IconUnionPay;
7
7
  name: string;
8
- code: import("../../types").CardBrandCode;
8
+ code: import("../..").CardBrandCode;
9
9
  pattern?: RegExp | undefined;
10
10
  validator?: ((cardNumber: string) => boolean) | undefined;
11
11
  lengths: number[];
@@ -14,7 +14,7 @@ export declare function findCardBrandInfo(number: string, brands?: CardBrandConf
14
14
  export declare function getCardBrandInfo(brand: CardBrandConfig): {
15
15
  icon: typeof import("../../components/internal/icons").IconVisa | typeof import("../../components/internal/icons").IconMasterCard | typeof import("../../components/internal/icons").IconJcb | typeof import("../../components/internal/icons").IconAmex | typeof import("../../components/internal/icons").IconDiscover | typeof import("../../components/internal/icons").IconDinnersClub | typeof import("../../components/internal/icons").IconUnionPay;
16
16
  name: string;
17
- code: import("../../types").CardBrandCode;
17
+ code: import("../..").CardBrandCode;
18
18
  pattern?: RegExp | undefined;
19
19
  validator?: ((cardNumber: string) => boolean) | undefined;
20
20
  lengths: number[];
@@ -24,7 +24,7 @@ export type CardBrandInfo = ReturnType<typeof getCardBrandInfo>;
24
24
  export declare function finCardBrandInfoByCode(code: string): {
25
25
  icon: typeof import("../../components/internal/icons").IconVisa | typeof import("../../components/internal/icons").IconMasterCard | typeof import("../../components/internal/icons").IconJcb | typeof import("../../components/internal/icons").IconAmex | typeof import("../../components/internal/icons").IconDiscover | typeof import("../../components/internal/icons").IconDinnersClub | typeof import("../../components/internal/icons").IconUnionPay;
26
26
  name: string;
27
- code: import("../../types").CardBrandCode;
27
+ code: import("../..").CardBrandCode;
28
28
  pattern?: RegExp | undefined;
29
29
  validator?: ((cardNumber: string) => boolean) | undefined;
30
30
  lengths: number[];
@@ -2,5 +2,6 @@ interface Opts {
2
2
  theme?: 'dark' | 'default';
3
3
  backgroundColor?: string;
4
4
  }
5
+ export declare const DEFAULT_THEME: Opts;
5
6
  export declare function generateColors(color: string, opts?: Opts): string[];
6
7
  export {};
@@ -3,10 +3,8 @@ export * from './system-info';
3
3
  export * from './bem';
4
4
  export * from './colors';
5
5
  export * from './create-promise';
6
- export * from './deep-freeze';
7
6
  export * from './format';
8
7
  export * from './is';
9
- export * from './obj';
10
8
  export * from './style';
11
9
  export * from './iframe';
12
10
  export * from './location';
@@ -16,6 +14,10 @@ export * from './detect';
16
14
  export * from './date';
17
15
  export * from './object';
18
16
  export * from './reg-exp';
17
+ export * from './payment';
18
+ export * from './theme';
19
+ export * from './string';
20
+ export * from './load';
19
21
  export declare function getIf<T>(value: T, condition: boolean): T | undefined;
20
22
  /**
21
23
  * 将一个数值限制在指定的范围内
@@ -1 +1,8 @@
1
+ import type { O as TO, S as TS } from 'ts-toolbelt';
2
+ type ObjectPath = Numeric[] | string;
3
+ type ObjectPathToArray<T extends ObjectPath> = T extends string ? TS.Split<T, '.'> : T;
4
+ type GetObjectValue<T extends Recordable, Path extends ObjectPath, UndefinedValue> = TO.Path<T, ObjectPathToArray<Path>> extends infer T ? T extends undefined ? UndefinedValue : T : never;
5
+ export declare function set<T extends Recordable, Path extends ObjectPath, Value extends GetObjectValue<T, Path, any>>(obj: T, path: Path, value: Value): void;
1
6
  export declare const deepMerge: <T extends Recordable<any>, U extends Recordable<any>>(target: T, source: U) => T & U;
7
+ export declare function deepFreeze<T extends Recordable>(obj: T): DeepReadonly<T>;
8
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 支付流程处理
3
+ */
4
+ import type { CheckoutRes, PayRes } from '../api';
5
+ import type { PaymentInfo } from '../types';
6
+ export interface PaymentCallbackConfig {
7
+ /** 订单处理中,定时查询订单 */
8
+ onProcessing?: () => void;
9
+ /** 订单已授权,提示用户,跳转商户页面 */
10
+ onAuthorized?: () => void;
11
+ /** 订单需要3DS认证,跳转3DS认证页面 */
12
+ onInThreeDS?: () => void;
13
+ /** 上一次3DS认证未完成,跳转3DS认证页面 */
14
+ onInPreviousThreeDS?: () => void;
15
+ /** 订单取消,导致查询超时 */
16
+ onCanceled?: () => void;
17
+ /** 订单成功,支付成功 */
18
+ onSuccess?: () => void;
19
+ /** 订单失败,支付失败 */
20
+ onFailure?: () => void;
21
+ /** 订单过期,支付过期 */
22
+ onExpired?: () => void;
23
+ /** 不属于其他任何状态,兜底逻辑 */
24
+ onDefault?: () => void;
25
+ }
26
+ /**
27
+ * 处理支付状态的判断
28
+ * 每个支付方式都要走类似的判断,所以封装成工具函数便于维护
29
+ * @param res 支付结果
30
+ * @param config 支付回调
31
+ */
32
+ export declare const processPaymentStatus: (res: PayRes, config: PaymentCallbackConfig) => void;
33
+ /**
34
+ * 格式化支付结果
35
+ * @param res
36
+ */
37
+ export declare const formatPaymentResult: (res?: PayRes | CheckoutRes) => PaymentInfo;
@@ -0,0 +1 @@
1
+ export declare const genShortId: (length?: number) => string;
@@ -13,7 +13,7 @@ export declare const generateClassNameMap: (selector?: string) => {
13
13
  invalid: string;
14
14
  };
15
15
  /** 动态加载样式 */
16
- export declare const loadStyle: (styleStr: string, extraOptions?: Partial<HTMLScriptElement>) => void;
16
+ export declare const loadStyle: (styleStr: string, extraOptions?: Partial<HTMLStyleElement>) => void;
17
17
  /** 创建 placeholder 样式 */
18
18
  export declare const createPlaceholderStyle: (selector: string, style?: Recordable) => string;
19
19
  /** 将可以直接应用到 iframe 中的 input 样式剥离出来 */