@paykka/card-checkout-ui 0.14.0 → 0.15.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 (292) hide show
  1. package/README.md +1 -1
  2. package/dist/card-checkout-ui.js +20 -20
  3. package/dist/card-checkout-ui.umd.cjs +20 -20
  4. package/dist/es/api/http.js +1 -1
  5. package/dist/es/api/index.js +1 -1
  6. package/dist/es/api/modules/checkout/index.js +1 -3
  7. package/dist/es/api/modules/checkout/map.js +12 -4
  8. package/dist/es/api/modules/encrypted-card/index.js +3 -2
  9. package/dist/es/api/modules/get-browser-params.js +4 -5
  10. package/dist/es/api/modules/index.js +1 -1
  11. package/dist/es/api/modules/map.js +4 -1
  12. package/dist/es/components/AccordionItem/AccordionItem.js +1 -1
  13. package/dist/es/components/AccountNameField/index.js +1 -1
  14. package/dist/es/components/AddressField/index.js +1 -1
  15. package/dist/es/components/ApplePay/index.js +34 -21
  16. package/dist/es/components/CPFField/index.js +1 -1
  17. package/dist/es/components/Card/index.js +38 -30
  18. package/dist/es/components/CardBrands/index.js +1 -1
  19. package/dist/es/components/CardExpireDateField/index.js +1 -1
  20. package/dist/es/components/CardHolderNameField/index.js +1 -1
  21. package/dist/es/components/CardIBANField/index.js +1 -1
  22. package/dist/es/components/CardNo/index.js +1 -1
  23. package/dist/es/components/CardNumberField/index.js +1 -1
  24. package/dist/es/components/CardSecurityCodeField/index.js +1 -1
  25. package/dist/es/components/CardSelector/index.js +2 -2
  26. package/dist/es/components/CombinedCardInfo/index.js +1 -1
  27. package/dist/es/components/DropIn/index.js +117 -123
  28. package/dist/es/components/EmailField/EmailField.js +1 -1
  29. package/dist/es/components/EncryptedCard/index.js +5 -5
  30. package/dist/es/components/GooglePay/index.js +32 -29
  31. package/dist/es/components/GuideCard/index.js +2 -2
  32. package/dist/es/components/PaymentButton/index.js +22 -7
  33. package/dist/es/components/RecurringTip/index.js +1 -1
  34. package/dist/es/components/SecuredIframe/index.js +3 -4
  35. package/dist/es/components/Sepa/index.js +15 -7
  36. package/dist/es/components/SubmitButton/index.js +2 -2
  37. package/dist/es/components/ThreeDS/index.js +32 -20
  38. package/dist/es/components/Tip/index.js +1 -1
  39. package/dist/es/components/business/BlikCodeField/BlikCodeField.js +1 -1
  40. package/dist/es/components/business/BlikCodeField/index.js +1 -1
  41. package/dist/es/components/business/BlikConfirmModal/BlikConfirmModal.js +3 -3
  42. package/dist/es/components/business/BlikConfirmModal/index.js +2 -2
  43. package/dist/es/components/business/NameField/NameField.js +1 -1
  44. package/dist/es/components/business/NameField/index.js +1 -1
  45. package/dist/es/components/business/PhoneField/PhoneField.js +1 -1
  46. package/dist/es/components/business/PhoneField/index.js +1 -1
  47. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +2 -2
  48. package/dist/es/components/business/QRCodeModal/index.js +1 -1
  49. package/dist/es/components/business/Tooltip/Tooltip.js +1 -1
  50. package/dist/es/components/business/Tooltip/index.js +1 -1
  51. package/dist/es/components/business/index.js +2 -2
  52. package/dist/es/components/index.js +4 -4
  53. package/dist/es/components/internal/Accordion/index.js +1 -1
  54. package/dist/es/components/internal/Button/{Button.js → Button2.js} +2 -2
  55. package/dist/es/components/internal/Button/index.js +2 -2
  56. package/dist/es/components/internal/CheckBox/CheckBox.js +1 -1
  57. package/dist/es/components/internal/CheckBox/index.js +1 -1
  58. package/dist/es/components/internal/Form/type.js +1 -1
  59. package/dist/es/components/internal/Info/Info.js +1 -1
  60. package/dist/es/components/internal/Info/index.js +1 -1
  61. package/dist/es/components/internal/Input/type.js +1 -1
  62. package/dist/es/components/internal/Loading/Loading2.js +20 -0
  63. package/dist/es/{api/modules/line-pay → components/internal/Loading}/index.js +3 -2
  64. package/dist/es/components/internal/Loading/loading.js +1 -0
  65. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +1 -1
  66. package/dist/es/components/internal/LoadingCheck/index.js +1 -1
  67. package/dist/es/components/internal/Modal/Modal.js +1 -1
  68. package/dist/es/components/internal/QRCode/QRCode.js +1 -1
  69. package/dist/es/components/internal/QRCode/index.js +1 -1
  70. package/dist/es/components/internal/Select/Select.js +1 -1
  71. package/dist/es/components/internal/Select/SelectMenu.js +1 -1
  72. package/dist/es/components/internal/Select/SelectMenuItem.js +1 -1
  73. package/dist/es/components/internal/icons/IconAlipayPlus.js +116 -0
  74. package/dist/es/components/internal/icons/IconError.js +2 -2
  75. package/dist/es/components/internal/icons/IconSuccess.js +2 -2
  76. package/dist/es/components/internal/icons/IconWechatPayGlobal.js +45 -0
  77. package/dist/es/components/internal/icons/IconWechatPayGlobalComplete.js +107 -0
  78. package/dist/es/components/wallets/AliPay/AliPay.js +186 -0
  79. package/dist/es/components/wallets/AliPay/ali-pay.js +1 -0
  80. package/dist/es/components/wallets/AliPay/index.js +1 -0
  81. package/dist/es/components/wallets/AliPay/type.js +1 -0
  82. package/dist/es/components/wallets/Bancontact/Bancontact.js +7 -10
  83. package/dist/es/components/wallets/Blik/Blik.js +14 -11
  84. package/dist/es/components/wallets/Boost/Boost.js +6 -9
  85. package/dist/es/components/wallets/GCash/GCash.js +7 -10
  86. package/dist/es/components/wallets/GrabPay/GrabPay.js +7 -14
  87. package/dist/es/components/wallets/IDeal/IDeal.js +7 -10
  88. package/dist/es/components/wallets/LinePay/LinePay.js +6 -9
  89. package/dist/es/components/wallets/MayBankQRPay/MayBankQRPay.js +6 -9
  90. package/dist/es/components/wallets/NinePay/NinePay.js +6 -9
  91. package/dist/es/components/wallets/OVO/OVO.js +7 -10
  92. package/dist/es/components/wallets/OpayWallet/OpayWallet.js +6 -9
  93. package/dist/es/components/wallets/P24/P24.js +7 -10
  94. package/dist/es/components/wallets/PagaWallet/PagaWallet.js +6 -9
  95. package/dist/es/components/wallets/Paymaya/Paymaya.js +6 -9
  96. package/dist/es/components/wallets/PicPay/PicPay.js +54 -217
  97. package/dist/es/components/wallets/Pix/Pix.js +54 -217
  98. package/dist/es/components/wallets/ShopeePay/ShopeePay.js +6 -9
  99. package/dist/es/components/wallets/Skrill/Skrill.js +7 -10
  100. package/dist/es/components/wallets/TNGWallet/TNGWallet.js +6 -9
  101. package/dist/es/components/wallets/Trustly/Trustly.js +7 -10
  102. package/dist/es/components/wallets/Vietqr/Vietqr.js +14 -15
  103. package/dist/es/components/wallets/WechatPay/WechatPay.js +250 -0
  104. package/dist/es/components/wallets/WechatPay/index.js +1 -0
  105. package/dist/es/components/wallets/WechatPay/type.js +1 -0
  106. package/dist/es/components/wallets/WechatPay/util.js +47 -0
  107. package/dist/es/components/wallets/WechatPay/wechat-pay.js +1 -0
  108. package/dist/es/components/wallets/Zalopay/Zalopay.js +10 -13
  109. package/dist/es/components/wallets/index.js +2 -0
  110. package/dist/es/constant.js +7 -0
  111. package/dist/es/core/checkout.js +36 -9
  112. package/dist/es/core/create-child.js +5 -4
  113. package/dist/es/core/index.js +1 -1
  114. package/dist/es/core/logger.js +1 -1
  115. package/dist/es/core/payment.js +13 -0
  116. package/dist/es/core/preview.js +29 -0
  117. package/dist/es/core/query.js +12 -3
  118. package/dist/es/core/session.js +36 -6
  119. package/dist/es/core/theme.js +1 -1
  120. package/dist/es/hooks/index.js +1 -1
  121. package/dist/es/hooks/useBaseWallet.js +121 -52
  122. package/dist/es/hooks/useI18n.js +3 -3
  123. package/dist/es/i18n/locales/de-DE.js +7 -0
  124. package/dist/es/i18n/locales/en-GB.js +7 -0
  125. package/dist/es/i18n/locales/es-ES.js +7 -0
  126. package/dist/es/i18n/locales/fr-FR.js +7 -0
  127. package/dist/es/i18n/locales/ja-JP.js +7 -0
  128. package/dist/es/i18n/locales/ko-KR.js +7 -0
  129. package/dist/es/i18n/locales/nl-NL.js +7 -0
  130. package/dist/es/i18n/locales/pt-PT.js +7 -0
  131. package/dist/es/i18n/locales/ru-RU.js +7 -0
  132. package/dist/es/i18n/locales/zh-CN.js +7 -0
  133. package/dist/es/i18n/locales/zh-HK.js +7 -0
  134. package/dist/es/i18n/locales/zh-TW.js +7 -0
  135. package/dist/es/i18n/util.js +10 -10
  136. package/dist/es/index.js +7 -5
  137. package/dist/es/out/base-fraud-detection.js +1 -1
  138. package/dist/es/out/fraud-detection.js +59 -44
  139. package/dist/es/out/paykka-detection.js +5 -7
  140. package/dist/es/out/stripe-radar.js +1 -1
  141. package/dist/es/out/worldpay-ddc-manager.js +3 -0
  142. package/dist/es/out/worldpay-ddc.js +1 -1
  143. package/dist/es/style.css +1 -1
  144. package/dist/es/types/event.js +10 -1
  145. package/dist/es/types/index.js +7 -0
  146. package/dist/es/utils/array.js +19 -5
  147. package/dist/es/utils/business/amount.js +15 -0
  148. package/dist/es/utils/business/index.js +1 -0
  149. package/dist/es/utils/detect.js +8 -0
  150. package/dist/es/utils/index.js +7 -9
  151. package/dist/es/utils/location.js +8 -0
  152. package/dist/es/utils/number.js +19 -0
  153. package/dist/es/utils/redirect.js +2 -0
  154. package/dist/style.css +1 -1
  155. package/dist/types/api/modules/checkout/type.d.ts +1 -1
  156. package/dist/types/api/modules/index.d.ts +0 -17
  157. package/dist/types/api/modules/threeDS/index.d.ts +13 -5
  158. package/dist/types/components/ApplePay/type.d.ts +6 -2
  159. package/dist/types/components/Card/type.d.ts +2 -18
  160. package/dist/types/components/DropIn/layout.d.ts +33 -0
  161. package/dist/types/components/DropIn/type.d.ts +6 -6
  162. package/dist/types/components/GooglePay/createGooglePay.d.ts +1 -1
  163. package/dist/types/components/GooglePay/type.d.ts +6 -2
  164. package/dist/types/components/PaymentButton/type.d.ts +2 -0
  165. package/dist/types/components/Sepa/type.d.ts +3 -4
  166. package/dist/types/components/business/QRCodeModal/type.d.ts +12 -3
  167. package/dist/types/components/index.d.ts +0 -2
  168. package/dist/types/components/internal/Loading/Loading.d.ts +2 -1
  169. package/dist/types/components/internal/Loading/type.d.ts +8 -0
  170. package/dist/types/components/internal/ResultMessage/ResultMessage.d.ts +3 -0
  171. package/dist/types/components/internal/ResultMessage/index.d.ts +2 -0
  172. package/dist/types/components/internal/ResultMessage/type.d.ts +13 -0
  173. package/dist/types/components/internal/icons/IconAlipayPlus.d.ts +2 -0
  174. package/dist/types/components/internal/icons/IconError.d.ts +1 -1
  175. package/dist/types/components/internal/icons/IconSuccess.d.ts +1 -1
  176. package/dist/types/components/internal/icons/IconWechatPayGlobal.d.ts +2 -0
  177. package/dist/types/components/internal/icons/IconWechatPayGlobalComplete.d.ts +2 -0
  178. package/dist/types/components/internal/icons/index.d.ts +3 -0
  179. package/dist/types/components/{AliPay → wallets/AliPay}/AliPay.d.ts +9 -4
  180. package/dist/types/components/wallets/AliPay/type.d.ts +7 -0
  181. package/dist/types/components/wallets/Bancontact/type.d.ts +2 -24
  182. package/dist/types/components/wallets/Blik/type.d.ts +2 -24
  183. package/dist/types/components/wallets/Boost/type.d.ts +2 -24
  184. package/dist/types/components/wallets/GCash/type.d.ts +2 -24
  185. package/dist/types/components/wallets/GrabPay/type.d.ts +2 -12
  186. package/dist/types/components/wallets/IDeal/type.d.ts +2 -24
  187. package/dist/types/components/wallets/LinePay/type.d.ts +2 -24
  188. package/dist/types/components/wallets/MayBankQRPay/type.d.ts +2 -24
  189. package/dist/types/components/wallets/NinePay/type.d.ts +2 -24
  190. package/dist/types/components/wallets/OVO/type.d.ts +2 -24
  191. package/dist/types/components/wallets/OpayWallet/type.d.ts +2 -24
  192. package/dist/types/components/wallets/P24/type.d.ts +2 -24
  193. package/dist/types/components/wallets/PagaWallet/type.d.ts +2 -24
  194. package/dist/types/components/wallets/Paymaya/type.d.ts +2 -24
  195. package/dist/types/components/wallets/PicPay/type.d.ts +2 -24
  196. package/dist/types/components/wallets/Pix/type.d.ts +2 -24
  197. package/dist/types/components/wallets/ShopeePay/type.d.ts +2 -24
  198. package/dist/types/components/wallets/Skrill/type.d.ts +2 -12
  199. package/dist/types/components/wallets/TNGWallet/type.d.ts +2 -24
  200. package/dist/types/components/wallets/Trustly/type.d.ts +2 -16
  201. package/dist/types/components/wallets/Vietqr/type.d.ts +2 -24
  202. package/dist/types/components/wallets/WechatPay/WechatPay.d.ts +16 -0
  203. package/dist/types/components/wallets/WechatPay/type.d.ts +12 -0
  204. package/dist/types/components/wallets/WechatPay/util.d.ts +13 -0
  205. package/dist/types/components/wallets/Zalopay/type.d.ts +2 -24
  206. package/dist/types/components/wallets/index.d.ts +2 -0
  207. package/dist/types/components/wallets/type.d.ts +0 -14
  208. package/dist/types/constant.d.ts +8 -0
  209. package/dist/types/core/index.d.ts +1 -0
  210. package/dist/types/core/preview.d.ts +1 -0
  211. package/dist/types/core/session.d.ts +2 -2
  212. package/dist/types/hooks/index.d.ts +0 -1
  213. package/dist/types/hooks/useBaseWallet.d.ts +27 -5
  214. package/dist/types/hooks/useI18n.d.ts +1 -1
  215. package/dist/types/hooks/usePayState.d.ts +1 -4
  216. package/dist/types/i18n/I18n.d.ts +1 -0
  217. package/dist/types/i18n/locales/de-DE.d.ts +7 -0
  218. package/dist/types/i18n/locales/en-GB.d.ts +7 -0
  219. package/dist/types/i18n/locales/es-ES.d.ts +7 -0
  220. package/dist/types/i18n/locales/fr-FR.d.ts +7 -0
  221. package/dist/types/i18n/locales/ja-JP.d.ts +7 -0
  222. package/dist/types/i18n/locales/ko-KR.d.ts +7 -0
  223. package/dist/types/i18n/locales/nl-NL.d.ts +7 -0
  224. package/dist/types/i18n/locales/pt-PT.d.ts +7 -0
  225. package/dist/types/i18n/locales/ru-RU.d.ts +7 -0
  226. package/dist/types/i18n/locales/zh-CN.d.ts +7 -0
  227. package/dist/types/i18n/locales/zh-HK.d.ts +7 -0
  228. package/dist/types/i18n/locales/zh-TW.d.ts +7 -0
  229. package/dist/types/i18n/util.d.ts +8 -1
  230. package/dist/types/index.d.ts +2 -1
  231. package/dist/types/out/fraud-detection.d.ts +2 -5
  232. package/dist/types/out/types.d.ts +5 -6
  233. package/dist/types/out/worldpay-ddc-manager.d.ts +1 -0
  234. package/dist/types/types/event.d.ts +24 -2
  235. package/dist/types/types/index.d.ts +14 -0
  236. package/dist/types/types/message.d.ts +3 -1
  237. package/dist/types/types/payment.d.ts +26 -3
  238. package/dist/types/utils/app-payment.d.ts +1 -0
  239. package/dist/types/utils/array.d.ts +17 -0
  240. package/dist/types/utils/business/amount.d.ts +7 -0
  241. package/dist/types/utils/business/index.d.ts +1 -0
  242. package/dist/types/utils/detect.d.ts +3 -0
  243. package/dist/types/utils/index.d.ts +1 -6
  244. package/dist/types/utils/number.d.ts +4 -0
  245. package/dist/types/utils/redirect.d.ts +10 -0
  246. package/dist/types/utils/system-info/get-browser-info.d.ts +4 -0
  247. package/package.json +4 -2
  248. package/dist/es/api/modules/ali-pay/index.js +0 -16
  249. package/dist/es/api/modules/boost/index.js +0 -5
  250. package/dist/es/api/modules/gcash/index.js +0 -5
  251. package/dist/es/api/modules/grab-pay/index.js +0 -5
  252. package/dist/es/api/modules/may-bank-qr-pay/index.js +0 -5
  253. package/dist/es/api/modules/nine-pay/index.js +0 -5
  254. package/dist/es/api/modules/opay-wallet/index.js +0 -5
  255. package/dist/es/api/modules/paga-wallet/index.js +0 -5
  256. package/dist/es/api/modules/paymaya/index.js +0 -5
  257. package/dist/es/api/modules/pic-pay/index.js +0 -16
  258. package/dist/es/api/modules/pix/index.js +0 -16
  259. package/dist/es/api/modules/shopee-pay/index.js +0 -5
  260. package/dist/es/api/modules/tng-wallet/index.js +0 -5
  261. package/dist/es/api/modules/vietqr/index.js +0 -5
  262. package/dist/es/api/modules/wechat-pay/index.js +0 -16
  263. package/dist/es/api/modules/zalopay/index.js +0 -5
  264. package/dist/es/components/AliPay/index.js +0 -332
  265. package/dist/es/components/WechatPay/index.js +0 -340
  266. package/dist/es/hooks/usePayment.js +0 -1
  267. package/dist/types/api/modules/ali-pay/index.d.ts +0 -4
  268. package/dist/types/api/modules/boost/index.d.ts +0 -4
  269. package/dist/types/api/modules/gcash/index.d.ts +0 -4
  270. package/dist/types/api/modules/grab-pay/index.d.ts +0 -4
  271. package/dist/types/api/modules/line-pay/index.d.ts +0 -4
  272. package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +0 -4
  273. package/dist/types/api/modules/nine-pay/index.d.ts +0 -4
  274. package/dist/types/api/modules/opay-wallet/index.d.ts +0 -4
  275. package/dist/types/api/modules/paga-wallet/index.d.ts +0 -4
  276. package/dist/types/api/modules/paymaya/index.d.ts +0 -4
  277. package/dist/types/api/modules/pic-pay/index.d.ts +0 -4
  278. package/dist/types/api/modules/pix/index.d.ts +0 -4
  279. package/dist/types/api/modules/shopee-pay/index.d.ts +0 -4
  280. package/dist/types/api/modules/tng-wallet/index.d.ts +0 -4
  281. package/dist/types/api/modules/vietqr/index.d.ts +0 -4
  282. package/dist/types/api/modules/wechat-pay/index.d.ts +0 -4
  283. package/dist/types/api/modules/zalopay/index.d.ts +0 -4
  284. package/dist/types/components/AliPay/type.d.ts +0 -26
  285. package/dist/types/components/WechatPay/WechatPay.d.ts +0 -10
  286. package/dist/types/components/WechatPay/type.d.ts +0 -28
  287. package/dist/types/hooks/usePayment.d.ts +0 -8
  288. package/dist/types/hooks/useRetry.console-tests.d.ts +0 -41
  289. package/dist/types/utils/behavior-tracker.d.ts +0 -36
  290. /package/dist/es/components/internal/Button/{button2.js → button.js} +0 -0
  291. /package/dist/types/components/{AliPay → wallets/AliPay}/index.d.ts +0 -0
  292. /package/dist/types/components/{WechatPay → wallets/WechatPay}/index.d.ts +0 -0
@@ -0,0 +1,250 @@
1
+ import { w, F, A, h, y, T, u, b } from "../../../core.js";
2
+ import "./wechat-pay.js";
3
+ import { PaymentMethod, PayEnv, PaymentCategory, COMMON_CLASS_NAME, PaymentType } from "../../../constant.js";
4
+ import { CoreContext } from "../../../core/context.js";
5
+ import "../../../utils/card-brand/brands.js";
6
+ import "../../../utils/system-info/get-browser-info.js";
7
+ import { normalizedClass } from "../../../utils/format.js";
8
+ import { WechatPayEventType } from "../../../types/event.js";
9
+ import { getPayEnv } from "../../../utils/detect.js";
10
+ import "../../../out/fraud-detection.js";
11
+ import { useBEM } from "../../../hooks/useBEM.js";
12
+ import { usePayState } from "../../../hooks/usePayState.js";
13
+ import { useBaseWallet } from "../../../hooks/useBaseWallet.js";
14
+ import { DEFAULT_ADDRESS, AddressField } from "../../AddressField/index.js";
15
+ import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
16
+ import "../../internal/Form/type.js";
17
+ import "../../internal/Form/context.js";
18
+ import "../../internal/Form/FormItem.js";
19
+ import { Form } from "../../internal/Form/Form.js";
20
+ import { Info } from "../../internal/Info/Info.js";
21
+ import { RecurringTip } from "../../RecurringTip/index.js";
22
+ import { calcAmountWithFee } from "../../../utils/business/amount.js";
23
+ import { PaymentButton } from "../../PaymentButton/index.js";
24
+ import { GuideCard } from "../../GuideCard/index.js";
25
+ import { QRCodeModal } from "../../business/QRCodeModal/QRCodeModal.js";
26
+ import "../../internal/Input/Input.js";
27
+ import "../../internal/Input/type.js";
28
+ import "../../internal/Select/Select.js";
29
+ import "../../business/PhoneField/config.js";
30
+ import "../../business/PhoneField/phone-field.js";
31
+ import { IconWechatPayGlobalComplete } from "../../internal/icons/IconWechatPayGlobalComplete.js";
32
+ import "../../business/Tooltip/tooltip2.js";
33
+ import "../../business/BlikCodeField/blik-code-field.js";
34
+ import "../../internal/Button/button.js";
35
+ import "../../internal/Modal/Modal.js";
36
+ import "../../business/BlikConfirmModal/blik-confirm-modal.js";
37
+ import "../../internal/LoadingCheck/loading-check.js";
38
+ import { launchWechatPay, WechatPayResult } from "./util.js";
39
+ const { bem } = useBEM("wechat-pay");
40
+ const fieldClassNames = bem("field");
41
+ const CURR_PAYMENT_METHOD = PaymentMethod.WECHAT_PAY;
42
+ const WechatPay = w((props, ref) => {
43
+ var _a, _b;
44
+ const { session, core, hidePaymentButton = false, showGuideCard = true } = props;
45
+ F(ref, () => ({
46
+ stopRetry: () => stopRetry(),
47
+ startRetry: (timeout) => startRetry(timeout),
48
+ updateAddress: () => {
49
+ var _a2;
50
+ if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
51
+ return;
52
+ const address = addressCore.getAddressState();
53
+ form.address = address;
54
+ setForm(form);
55
+ (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(address);
56
+ validateFormSilently();
57
+ },
58
+ updateEmail: () => {
59
+ var _a2;
60
+ if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
61
+ return;
62
+ form.email = emailState.email;
63
+ setForm(form);
64
+ (_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
65
+ validateFormSilently();
66
+ },
67
+ payment: () => {
68
+ hidePaymentButton && onSubmit();
69
+ }
70
+ }));
71
+ const {
72
+ isEnabled,
73
+ fieldStatus,
74
+ paymentButtonStatus,
75
+ setPaymentButtonStatus,
76
+ errorMessage,
77
+ setErrorMessage,
78
+ payment,
79
+ startRetry,
80
+ stopRetry,
81
+ showQRCodeModal,
82
+ qrCodeInfo,
83
+ processCloseQRCodeModal,
84
+ getPaymentMethodContext
85
+ } = useBaseWallet(CURR_PAYMENT_METHOD, props, {
86
+ retryTimeout: 2 * 60 * 1e3,
87
+ supportQRCodeModal: true,
88
+ getFormData: () => form,
89
+ getExtraPaymentParams: async () => {
90
+ var _a2;
91
+ return {
92
+ channelUserId: getPayEnv() === PayEnv.WX_WEB ? await ((_a2 = props.onGetOpenId) == null ? void 0 : _a2.call(props)) : void 0
93
+ };
94
+ },
95
+ onProcessing: getPayEnv() === PayEnv.WX_WEB ? async (res) => {
96
+ var _a2, _b2, _c, _d, _e, _f, _g, _h;
97
+ if (!res.payInfo)
98
+ return true;
99
+ console.log("微信支付开始", res.payInfo);
100
+ (_b2 = (_a2 = core.config).onEvent) == null ? void 0 : _b2.call(_a2, WechatPayEventType.WECHAT_PAY_START);
101
+ try {
102
+ await launchWechatPay(res.payInfo);
103
+ console.log("微信支付box回调成功");
104
+ (_d = (_c = core.config).onEvent) == null ? void 0 : _d.call(_c, WechatPayEventType.WECHAT_PAY_SUCCESS);
105
+ return true;
106
+ } catch (error) {
107
+ console.log("微信支付box回调失败", error);
108
+ const message = error instanceof Error ? error.message : String(error);
109
+ console.log("微信支付box回调失败消息", message);
110
+ if (message === WechatPayResult.CANCEL) {
111
+ console.log("微信支付box回调取消");
112
+ (_f = (_e = core.config).onEvent) == null ? void 0 : _f.call(_e, WechatPayEventType.WECHAT_PAY_CANCELLED);
113
+ return false;
114
+ } else {
115
+ console.log("微信支付box回调失败,发送失败事件");
116
+ (_h = (_g = core.config).onEvent) == null ? void 0 : _h.call(_g, WechatPayEventType.WECHAT_PAY_FAILURE, { message });
117
+ throw error;
118
+ }
119
+ }
120
+ } : void 0
121
+ });
122
+ const { i18n, sessionReady, disabled } = usePayState(session, props.core);
123
+ const formRef = A(null);
124
+ const [form, setForm] = h({
125
+ email: "",
126
+ address: { ...DEFAULT_ADDRESS }
127
+ });
128
+ const [validated, setValidated] = h(false);
129
+ const addressFieldRef = A(null);
130
+ const emailFieldRef = A(null);
131
+ const addressCore = core.getAddressCore();
132
+ const emailState = createEmailCore();
133
+ const validateFormSilently = () => {
134
+ var _a2;
135
+ (_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => setValidated(true)).catch(() => setValidated(false));
136
+ };
137
+ y(() => {
138
+ validateFormSilently();
139
+ }, [form]);
140
+ y(() => {
141
+ if (!sessionReady)
142
+ return;
143
+ const { bill = {}, country } = (session == null ? void 0 : session.checkout) || {};
144
+ country && addressCore.setCountry(country);
145
+ form.email = bill.email ?? "";
146
+ form.address.country = country;
147
+ }, [sessionReady]);
148
+ const onSubmit = async () => {
149
+ var _a2;
150
+ setErrorMessage("");
151
+ (_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
152
+ var _a3;
153
+ (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
154
+ const submitResult = await ((_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors, getPaymentMethodContext()));
155
+ if (submitResult === false)
156
+ return;
157
+ if (errors) {
158
+ setPaymentButtonStatus("unSubmit");
159
+ return;
160
+ }
161
+ setPaymentButtonStatus("loading");
162
+ await payment();
163
+ });
164
+ };
165
+ const totalAmount = T(() => {
166
+ var _a2, _b2, _c;
167
+ const { channelParams = {} } = (session == null ? void 0 : session.checkout) ?? {};
168
+ const amount = (_b2 = (_a2 = core == null ? void 0 : core.payment) == null ? void 0 : _a2.amount.value) == null ? void 0 : _b2.amount;
169
+ return {
170
+ ...(_c = core == null ? void 0 : core.payment) == null ? void 0 : _c.amount.value,
171
+ amount: amount ? calcAmountWithFee(amount, channelParams.wechatPay) : 0
172
+ };
173
+ }, [(_a = core == null ? void 0 : core.payment) == null ? void 0 : _a.amount.value]);
174
+ const Button = () => {
175
+ return /* @__PURE__ */ u(
176
+ PaymentButton,
177
+ {
178
+ className: bem("button"),
179
+ status: paymentButtonStatus,
180
+ disabled,
181
+ verified: validated,
182
+ onClick: onSubmit,
183
+ amount: totalAmount.amount
184
+ }
185
+ );
186
+ };
187
+ const setFormRef = (dom) => {
188
+ formRef.current = dom;
189
+ dom && validateFormSilently();
190
+ };
191
+ const Email = () => {
192
+ return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
193
+ EmailField,
194
+ {
195
+ ref: emailFieldRef,
196
+ value: form.email,
197
+ disabled: (fieldStatus == null ? void 0 : fieldStatus.email.disabled) || disabled
198
+ }
199
+ ) }) });
200
+ };
201
+ const Address = () => {
202
+ return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
203
+ AddressField,
204
+ {
205
+ ref: addressFieldRef,
206
+ value: form.address,
207
+ disabled,
208
+ onChange: (value) => setForm(Object.assign(form, { address: value }))
209
+ }
210
+ ) }) });
211
+ };
212
+ return /* @__PURE__ */ u(
213
+ CoreContext.Provider,
214
+ {
215
+ value: {
216
+ i18n,
217
+ session,
218
+ core
219
+ },
220
+ children: isEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
221
+ showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.WECHAT_PAY }),
222
+ /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
223
+ Email(),
224
+ Address(),
225
+ ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.paymentType) === PaymentType.RECURRING && RecurringTip(),
226
+ /* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
227
+ !!errorMessage && /* @__PURE__ */ u(Info, { content: errorMessage }),
228
+ !hidePaymentButton && Button()
229
+ ] })
230
+ ] }) }),
231
+ showQRCodeModal && /* @__PURE__ */ u(
232
+ QRCodeModal,
233
+ {
234
+ title: i18n.get("qrCode.scanWechatPayGlobal"),
235
+ qrCode: qrCodeInfo.qrCode,
236
+ icon: /* @__PURE__ */ u(IconWechatPayGlobalComplete, { size: 22 }),
237
+ amount: totalAmount,
238
+ expiredTime: qrCodeInfo.expiredTime,
239
+ bgColor: "#07C160",
240
+ textColor: "#FFFFFF",
241
+ onClose: processCloseQRCodeModal
242
+ }
243
+ )
244
+ ] })
245
+ }
246
+ );
247
+ });
248
+ export {
249
+ WechatPay
250
+ };
@@ -0,0 +1 @@
1
+ import "./WechatPay.js";
@@ -0,0 +1,47 @@
1
+ var WechatPayResult = /* @__PURE__ */ ((WechatPayResult2) => {
2
+ WechatPayResult2["SUCCESS"] = "get_brand_wcpay_request:ok";
3
+ WechatPayResult2["CANCEL"] = "get_brand_wcpay_request:cancel";
4
+ WechatPayResult2["FAIL"] = "get_brand_wcpay_request:fail";
5
+ return WechatPayResult2;
6
+ })(WechatPayResult || {});
7
+ const UNKNOWN_WECHAT_PAY_RESULT = "unknown wechat pay result";
8
+ const isWechatBridgeReady = () => {
9
+ if (typeof WeixinJSBridge !== "undefined") {
10
+ console.log("WeixinJSBridge已加载,无需重复加载");
11
+ return Promise.resolve();
12
+ }
13
+ console.log("WeixinJSBridge没加载");
14
+ return new Promise((resolve) => {
15
+ console.log("监听WeixinJSBridge加载完毕");
16
+ document.addEventListener("WeixinJSBridgeReady", () => resolve(), { once: true });
17
+ });
18
+ };
19
+ const callWechatPayBox = (config) => {
20
+ return new Promise((resolve, reject) => {
21
+ console.log("调用微信支付box");
22
+ try {
23
+ WeixinJSBridge.invoke("getBrandWCPayRequest", config, (res) => {
24
+ console.log("微信支付box回调", res);
25
+ if (res.err_msg === "get_brand_wcpay_request:ok") {
26
+ console.log("微信支付box回调成功");
27
+ resolve();
28
+ return;
29
+ }
30
+ console.log("微信支付box回调失败", res.err_msg);
31
+ reject(new Error(res.err_msg ?? UNKNOWN_WECHAT_PAY_RESULT));
32
+ });
33
+ } catch (error) {
34
+ console.log("调用微信支付box报错", error);
35
+ reject(error);
36
+ }
37
+ });
38
+ };
39
+ const launchWechatPay = async (config) => {
40
+ console.log("启动微信支付");
41
+ await isWechatBridgeReady();
42
+ return callWechatPayBox(config);
43
+ };
44
+ export {
45
+ WechatPayResult,
46
+ launchWechatPay
47
+ };
@@ -3,9 +3,9 @@ import { useBEM } from "../../../hooks/useBEM.js";
3
3
  import { CoreContext } from "../../../core/context.js";
4
4
  import "../../../utils/card-brand/brands.js";
5
5
  import "../../../utils/system-info/get-browser-info.js";
6
- import { normalizedClass, formatAmount } from "../../../utils/format.js";
6
+ import { normalizedClass } from "../../../utils/format.js";
7
7
  import { PaymentMethod, PaymentCategory, COMMON_CLASS_NAME } from "../../../constant.js";
8
- import "../../../out/worldpay-jsc-origin.js";
8
+ import "../../../out/fraud-detection.js";
9
9
  import { usePayState } from "../../../hooks/usePayState.js";
10
10
  import { useBaseWallet } from "../../../hooks/useBaseWallet.js";
11
11
  import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
@@ -25,7 +25,7 @@ import "../../business/PhoneField/phone-field.js";
25
25
  import { IconZalopayComplete } from "../../internal/icons/IconZalopayComplete.js";
26
26
  import "../../business/Tooltip/tooltip2.js";
27
27
  import "../../business/BlikCodeField/blik-code-field.js";
28
- import "../../internal/Button/button2.js";
28
+ import "../../internal/Button/button.js";
29
29
  import "../../internal/Modal/Modal.js";
30
30
  import "../../business/BlikConfirmModal/blik-confirm-modal.js";
31
31
  import "../../internal/LoadingCheck/loading-check.js";
@@ -123,7 +123,9 @@ const Zalopay = w((props, ref) => {
123
123
  (_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
124
124
  var _a3;
125
125
  (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
126
- (_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors, getPaymentMethodContext());
126
+ const submitResult = await ((_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors, getPaymentMethodContext()));
127
+ if (submitResult === false)
128
+ return;
127
129
  if (errors) {
128
130
  setPaymentButtonStatus("unSubmit");
129
131
  return;
@@ -136,20 +138,15 @@ const Zalopay = w((props, ref) => {
136
138
  formRef.current = dom;
137
139
  dom && validateFormSilently();
138
140
  };
139
- const WalletButton = () => {
140
- var _a2;
141
- const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
142
- const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
143
- const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
141
+ const Button = () => {
144
142
  return /* @__PURE__ */ u(
145
143
  PaymentButton,
146
144
  {
147
145
  className: bem("button"),
148
- disabled,
149
146
  status: paymentButtonStatus,
150
- onClick: onSubmit,
147
+ disabled,
151
148
  verified: validated,
152
- children: text
149
+ onClick: onSubmit
153
150
  }
154
151
  );
155
152
  };
@@ -192,7 +189,7 @@ const Zalopay = w((props, ref) => {
192
189
  Address(),
193
190
  /* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
194
191
  ErrorMessage(),
195
- !hidePaymentButton && WalletButton()
192
+ !hidePaymentButton && Button()
196
193
  ] })
197
194
  ] }) }),
198
195
  showQRCodeModal && /* @__PURE__ */ u(
@@ -20,3 +20,5 @@ import "./IDeal/IDeal.js";
20
20
  import "./Skrill/Skrill.js";
21
21
  import "./P24/P24.js";
22
22
  import "./Trustly/Trustly.js";
23
+ import "./AliPay/AliPay.js";
24
+ import "./WechatPay/WechatPay.js";
@@ -225,12 +225,19 @@ var ChannelCode = /* @__PURE__ */ ((ChannelCode2) => {
225
225
  ChannelCode2["PAYKKA"] = "PAYKKA";
226
226
  return ChannelCode2;
227
227
  })(ChannelCode || {});
228
+ var PayEnv = /* @__PURE__ */ ((PayEnv2) => {
229
+ PayEnv2["WX_WEB"] = "WX_WEB";
230
+ PayEnv2["ALI_WEB"] = "ALI_WEB";
231
+ PayEnv2["WEB"] = "WEB";
232
+ return PayEnv2;
233
+ })(PayEnv || {});
228
234
  export {
229
235
  COMMON_CLASS_NAME,
230
236
  CardPaymentMethods,
231
237
  ChannelCode,
232
238
  EAddressType,
233
239
  PREFIX,
240
+ PayEnv,
234
241
  PaymentCategory,
235
242
  PaymentMethod,
236
243
  PaymentMethod2CategoryMap,
@@ -27,17 +27,17 @@ import { Session } from "./session.js";
27
27
  import { setApiPrefix, setApiUrl, setCDNUrl, setFraudDetectionEnv, fraudDetectionEnv, setCustomLocale } from "../config.js";
28
28
  import { PayKKaError } from "./error.js";
29
29
  import { apiEnv, cdnEnv } from "./environment.js";
30
+ import "../out/fraud-detection.js";
30
31
  import { isEmptyObject } from "../utils/is.js";
31
32
  import "../utils/card-brand/brands.js";
32
33
  import "../utils/system-info/get-browser-info.js";
33
34
  import { deepMerge } from "../utils/object.js";
34
35
  import { genShortId } from "../utils/string.js";
35
- import "./context.js";
36
36
  import { AddressCore } from "./address.js";
37
37
  import { PayKKaTheme } from "./theme.js";
38
38
  import { PayKKaLogger } from "./logger.js";
39
39
  import { PayKKaPayment } from "./payment.js";
40
- import "../out/worldpay-jsc-origin.js";
40
+ import { genPreviewData } from "./preview.js";
41
41
  const DEFAULT_CHECKOUT_CONFIG = {
42
42
  enableInitValidation: true,
43
43
  apiPrefix: "/session",
@@ -92,7 +92,7 @@ class PayKKaCheckout {
92
92
  onSuccess,
93
93
  _checkoutConfig = {}
94
94
  } = __privateGet(this, _config);
95
- const { enableInitValidation } = _checkoutConfig;
95
+ const { enableInitValidation, preview, previewOptions } = _checkoutConfig;
96
96
  if (enableInitValidation) {
97
97
  if (!sessionId) {
98
98
  onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "SessionId is required"));
@@ -100,7 +100,12 @@ class PayKKaCheckout {
100
100
  }
101
101
  }
102
102
  const extraParams = (_b = (_a = __privateGet(this, _config))._getExtraParams) == null ? void 0 : _b.call(_a, "info");
103
- __privateSet(this, _session, new Session({ sessionId, clientKey }, extraParams));
103
+ __privateSet(this, _session, new Session({
104
+ sessionId,
105
+ clientKey,
106
+ // 预览模式下,不请求任何接口,直接返回预览数据
107
+ initialCheckout: preview ? genPreviewData(previewOptions || {}) : void 0
108
+ }, extraParams));
104
109
  return __privateGet(this, _session).ready().then(() => {
105
110
  var _a2, _b2, _c, _d, _e;
106
111
  if (isEmptyObject((_a2 = __privateGet(this, _session)) == null ? void 0 : _a2.checkout)) {
@@ -142,8 +147,13 @@ class PayKKaCheckout {
142
147
  __privateGet(this, _theme).init((_a = __privateGet(this, _session).checkout) == null ? void 0 : _a.theme);
143
148
  }
144
149
  initOtherData() {
150
+ var _a;
145
151
  __privateSet(this, _payment, new PayKKaPayment(__privateGet(this, _session)));
146
152
  __privateGet(this, _payment).init();
153
+ const amount = (_a = __privateGet(this, _session).checkout) == null ? void 0 : _a.transAmount;
154
+ if (amount) {
155
+ __privateGet(this, _payment).setAmount(amount);
156
+ }
147
157
  }
148
158
  async initLogger() {
149
159
  const { reportLogger = true, env, onEvent } = __privateGet(this, _config);
@@ -202,12 +212,13 @@ class PayKKaCheckout {
202
212
  };
203
213
  const componentInst = create(component, {
204
214
  ...combinedProps,
205
- onSubmit: (formValidateError, context) => {
215
+ onSubmit: async (formValidateError, context) => {
206
216
  var _a2, _b, _c;
207
- if (!formValidateError) {
208
- (_b = (_a2 = this.config).onEvent) == null ? void 0 : _b.call(_a2, PaymentEventType.PAYMENT_START, context);
217
+ const submitResult = await ((_a2 = combinedProps.onSubmit) == null ? void 0 : _a2.call(combinedProps, formValidateError, context));
218
+ if (!formValidateError && submitResult !== false) {
219
+ (_c = (_b = this.config).onEvent) == null ? void 0 : _c.call(_b, PaymentEventType.PAYMENT_START, context);
209
220
  }
210
- (_c = combinedProps.onSubmit) == null ? void 0 : _c.call(combinedProps, formValidateError, context);
221
+ return submitResult;
211
222
  },
212
223
  onExpired: (context) => {
213
224
  var _a2, _b, _c;
@@ -240,7 +251,11 @@ class PayKKaCheckout {
240
251
  },
241
252
  onSubmitResponse: (payRes, context) => {
242
253
  var _a2, _b, _c;
243
- (_b = (_a2 = this.config).onEvent) == null ? void 0 : _b.call(_a2, PaymentEventType.PAYMENT_RESPONSE, context);
254
+ (_b = (_a2 = this.config).onEvent) == null ? void 0 : _b.call(_a2, PaymentEventType.PAYMENT_RESPONSE, {
255
+ ...context,
256
+ orderId: payRes.orderId,
257
+ sessionId: payRes.sessionId
258
+ });
244
259
  (_c = combinedProps.onSubmitResponse) == null ? void 0 : _c.call(combinedProps, payRes, context);
245
260
  }
246
261
  });
@@ -268,6 +283,18 @@ class PayKKaCheckout {
268
283
  get payment() {
269
284
  return __privateGet(this, _payment);
270
285
  }
286
+ /**
287
+ * 更新收银台 session,用于无初始 sessionId 的场景(如 QRCode)
288
+ * 触发 onSessionIdUpdate 回调
289
+ * @internal
290
+ */
291
+ async updateSessionId(params) {
292
+ var _a, _b;
293
+ const newSessionId = await __privateGet(this, _session).updateSessionId(params);
294
+ if (newSessionId) {
295
+ (_b = (_a = __privateGet(this, _config)._checkoutConfig) == null ? void 0 : _a.onSessionIdUpdate) == null ? void 0 : _b.call(_a, newSessionId);
296
+ }
297
+ }
271
298
  }
272
299
  _id = new WeakMap();
273
300
  _config = new WeakMap();
@@ -24,17 +24,18 @@ const createCheckoutChild = (core, component, dropInProps, childProps) => {
24
24
  };
25
25
  const wrappedProps = {
26
26
  ...combinedProps,
27
- onSubmit: (error, context) => {
27
+ onSubmit: async (error, context) => {
28
28
  var _a, _b, _c;
29
29
  console.log("dropin内部代理onSubmit", dropInProps == null ? void 0 : dropInProps.onSubmit, onSubmit);
30
- if (childProps == null ? void 0 : childProps.onSubmit) {
30
+ const submitResult = await ((_a = combinedProps == null ? void 0 : combinedProps.onSubmit) == null ? void 0 : _a.call(combinedProps, error, context));
31
+ if ((childProps == null ? void 0 : childProps.onSubmit) && submitResult !== false) {
31
32
  if (!error) {
32
- (_b = (_a = core.config).onEvent) == null ? void 0 : _b.call(_a, PaymentEventType.PAYMENT_START, {
33
+ (_c = (_b = core.config).onEvent) == null ? void 0 : _c.call(_b, PaymentEventType.PAYMENT_START, {
33
34
  paymentMethod: context.paymentMethod
34
35
  });
35
36
  }
36
37
  }
37
- (_c = combinedProps == null ? void 0 : combinedProps.onSubmit) == null ? void 0 : _c.call(combinedProps, error, context);
38
+ return submitResult;
38
39
  },
39
40
  onSuccess: (data, context) => {
40
41
  var _a;
@@ -2,4 +2,4 @@ import "./context.js";
2
2
  import "../core.js";
3
3
  import "../utils/card-brand/brands.js";
4
4
  import "../utils/system-info/get-browser-info.js";
5
- import "../out/worldpay-jsc-origin.js";
5
+ import "../out/fraud-detection.js";
@@ -34,7 +34,7 @@ class PayKKaLogger {
34
34
  (_b = window.JlFeLogger) == null ? void 0 : _b.init({
35
35
  pid: options.pid || COMPONENT_PID,
36
36
  env: loggerEnvInfo.env,
37
- release: "0.14.0",
37
+ release: "0.15.1",
38
38
  imgUrl: loggerEnvInfo.imgUrl,
39
39
  postUrl: loggerEnvInfo.postUrl,
40
40
  beforeSend: this.beforeSendEvent
@@ -36,6 +36,11 @@ class PayKKaPayment {
36
36
  * 当 currPaymentMethod 不为 null,就表示当前处于支付或查询状态,所有支付方式表单、按钮禁用,也无法切换支付方式
37
37
  */
38
38
  __publicField(this, "currPaymentMethod", d(null));
39
+ /**
40
+ * 当前支付金额,QRCode 需要用到
41
+ * @internal
42
+ */
43
+ __publicField(this, "amount", d(null));
39
44
  __privateAdd(this, _session, void 0);
40
45
  __privateSet(this, _session, session);
41
46
  }
@@ -58,6 +63,14 @@ class PayKKaPayment {
58
63
  resetCurrPaymentMethod() {
59
64
  this.currPaymentMethod.value = null;
60
65
  }
66
+ /**
67
+ * 设置交易金额,目前用于 PaymentLink 预览场景
68
+ * @param amount 交易金额
69
+ * @internal
70
+ */
71
+ setAmount(amount) {
72
+ this.amount.value = amount;
73
+ }
61
74
  }
62
75
  _session = new WeakMap();
63
76
  export {
@@ -0,0 +1,29 @@
1
+ const genPreviewData = (options) => {
2
+ return {
3
+ merchantId: "preview-merchant-id",
4
+ sessionId: "preview-session-id",
5
+ status: "PROCESSING",
6
+ bill: {},
7
+ goods: [],
8
+ // 所有表单项都要展示
9
+ field: {
10
+ holderName: {
11
+ show: true,
12
+ required: true
13
+ },
14
+ email: {
15
+ show: true,
16
+ required: true,
17
+ disabled: false
18
+ },
19
+ address: {
20
+ show: true,
21
+ required: true
22
+ }
23
+ },
24
+ ...options
25
+ };
26
+ };
27
+ export {
28
+ genPreviewData
29
+ };
@@ -1,12 +1,21 @@
1
+ import { http } from "../api/http.js";
2
+ import { apiPrefix } from "../config.js";
1
3
  import "../utils/card-brand/brands.js";
2
4
  import "../utils/system-info/get-browser-info.js";
3
- import "../core.js";
4
- import "./context.js";
5
- import "../out/worldpay-jsc-origin.js";
6
5
  import { onceGetCheckoutInfo } from "../api/modules/checkout/index.js";
7
6
  const querySession = async (params, extraParams = {}, options) => {
8
7
  return onceGetCheckoutInfo(params, extraParams, options);
9
8
  };
9
+ const createSessionId = async (params, options) => {
10
+ return http.post(
11
+ `${apiPrefix}/session`,
12
+ {
13
+ ...params
14
+ },
15
+ options
16
+ ).then((res) => res.session_id);
17
+ };
10
18
  export {
19
+ createSessionId,
11
20
  querySession
12
21
  };