@paykka/card-checkout-ui 0.7.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 (266) hide show
  1. package/dist/card-checkout-ui.js +27 -20
  2. package/dist/card-checkout-ui.umd.cjs +27 -20
  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 +29 -1
  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 +58 -60
  27. package/dist/es/components/ApplePay/index.js +29 -43
  28. package/dist/es/components/Boost/index.js +322 -0
  29. package/dist/es/components/Card/index.js +89 -75
  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 +365 -0
  33. package/dist/es/components/GooglePay/index.js +15 -7
  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 +8 -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 +51 -61
  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 +10 -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 +3 -0
  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 +94 -4
  87. package/dist/es/core/PayKKaCheckout.js +38 -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 +3 -4
  93. package/dist/es/i18n/I18n.js +8 -2
  94. package/dist/es/i18n/locales/de-DE.js +19 -1
  95. package/dist/es/i18n/locales/en-GB.js +19 -1
  96. package/dist/es/i18n/locales/es-ES.js +19 -1
  97. package/dist/es/i18n/locales/fr-FR.js +19 -1
  98. package/dist/es/i18n/locales/ja-JP.js +19 -1
  99. package/dist/es/i18n/locales/ko-KR.js +19 -1
  100. package/dist/es/i18n/locales/pt-PT.js +19 -1
  101. package/dist/es/i18n/locales/ru-RU.js +19 -1
  102. package/dist/es/i18n/locales/zh-CN.js +19 -1
  103. package/dist/es/i18n/locales/zh-HK.js +19 -1
  104. package/dist/es/i18n/locales/zh-TW.js +19 -1
  105. package/dist/es/i18n/util.js +20 -0
  106. package/dist/es/index.js +24 -0
  107. package/dist/es/style.css +1 -1096
  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/map.d.ts +2 -1
  131. package/dist/types/api/modules/checkout/type.d.ts +20 -2
  132. package/dist/types/api/modules/gcash/index.d.ts +24 -0
  133. package/dist/types/api/modules/get-browser-params.d.ts +2 -2
  134. package/dist/types/api/modules/google-pay/index.d.ts +2 -1
  135. package/dist/types/api/modules/grab-pay/index.d.ts +24 -0
  136. package/dist/types/api/modules/index.d.ts +9 -0
  137. package/dist/types/api/modules/line-pay/index.d.ts +24 -0
  138. package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +24 -0
  139. package/dist/types/api/modules/nine-pay/index.d.ts +24 -0
  140. package/dist/types/api/modules/paymaya/index.d.ts +24 -0
  141. package/dist/types/api/modules/sepa/index.d.ts +2 -1
  142. package/dist/types/api/modules/shopee-pay/index.d.ts +24 -0
  143. package/dist/types/api/modules/tng-wallet/index.d.ts +24 -0
  144. package/dist/types/api/modules/wechat-pay/index.d.ts +2 -1
  145. package/dist/types/components/AliPay/AliPay.d.ts +2 -1
  146. package/dist/types/components/AliPay/type.d.ts +1 -2
  147. package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
  148. package/dist/types/components/ApplePay/type.d.ts +9 -6
  149. package/dist/types/components/Boost/Boost.d.ts +7 -0
  150. package/dist/types/components/Boost/index.d.ts +2 -0
  151. package/dist/types/components/Boost/type.d.ts +61 -0
  152. package/dist/types/components/Card/Card.d.ts +2 -1
  153. package/dist/types/components/Card/type.d.ts +2 -2
  154. package/dist/types/components/DropIn/DropIn.d.ts +6 -0
  155. package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
  156. package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
  157. package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
  158. package/dist/types/components/DropIn/config.d.ts +7 -0
  159. package/dist/types/components/DropIn/index.d.ts +2 -0
  160. package/dist/types/components/DropIn/type.d.ts +57 -0
  161. package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
  162. package/dist/types/components/GooglePay/type.d.ts +20 -9
  163. package/dist/types/components/GrabPay/GrabPay.d.ts +7 -0
  164. package/dist/types/components/GrabPay/index.d.ts +2 -0
  165. package/dist/types/components/GrabPay/type.d.ts +61 -0
  166. package/dist/types/components/GuideCard/GuideCard.d.ts +3 -0
  167. package/dist/types/components/GuideCard/index.d.ts +2 -0
  168. package/dist/types/components/GuideCard/type.d.ts +4 -0
  169. package/dist/types/components/LinePay/LinePay.d.ts +7 -0
  170. package/dist/types/components/LinePay/index.d.ts +2 -0
  171. package/dist/types/components/LinePay/type.d.ts +61 -0
  172. package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -0
  173. package/dist/types/components/MayBankQRPay/index.d.ts +2 -0
  174. package/dist/types/components/MayBankQRPay/type.d.ts +61 -0
  175. package/dist/types/components/NinePay/NinePay.d.ts +6 -0
  176. package/dist/types/components/NinePay/index.d.ts +2 -0
  177. package/dist/types/components/NinePay/type.d.ts +61 -0
  178. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +1 -1
  179. package/dist/types/components/Sepa/Sepa.d.ts +2 -1
  180. package/dist/types/components/Sepa/type.d.ts +1 -2
  181. package/dist/types/components/ShopeePay/ShopeePay.d.ts +7 -0
  182. package/dist/types/components/ShopeePay/index.d.ts +2 -0
  183. package/dist/types/components/ShopeePay/type.d.ts +61 -0
  184. package/dist/types/components/SubmitButton/SubmitButton.d.ts +1 -1
  185. package/dist/types/components/TNGWallet/TNGWallet.d.ts +7 -0
  186. package/dist/types/components/TNGWallet/index.d.ts +2 -0
  187. package/dist/types/components/TNGWallet/type.d.ts +61 -0
  188. package/dist/types/components/WechatPay/WechatPay.d.ts +2 -1
  189. package/dist/types/components/WechatPay/type.d.ts +1 -2
  190. package/dist/types/components/business/QRCodeModal/QRCodeModal.d.ts +3 -0
  191. package/dist/types/components/business/QRCodeModal/index.d.ts +2 -0
  192. package/dist/types/components/business/QRCodeModal/type.d.ts +18 -0
  193. package/dist/types/components/business/index.d.ts +1 -0
  194. package/dist/types/components/index.d.ts +10 -0
  195. package/dist/types/components/internal/Accordion/Accordion.d.ts +3 -0
  196. package/dist/types/components/internal/Accordion/accordionTransition.d.ts +8 -0
  197. package/dist/types/components/internal/Accordion/components/AccordionItem/AccordionItem.d.ts +3 -0
  198. package/dist/types/components/internal/Accordion/components/AccordionItem/index.d.ts +2 -0
  199. package/dist/types/components/internal/Accordion/components/AccordionItem/type.d.ts +18 -0
  200. package/dist/types/components/internal/Accordion/index.d.ts +3 -0
  201. package/dist/types/components/internal/Accordion/type.d.ts +18 -0
  202. package/dist/types/components/internal/Modal/index.d.ts +2 -0
  203. package/dist/types/components/internal/Modal/type.d.ts +3 -1
  204. package/dist/types/components/internal/QRCode/QRCode.d.ts +2 -0
  205. package/dist/types/components/internal/QRCode/index.d.ts +2 -0
  206. package/dist/types/components/internal/QRCode/type.d.ts +9 -0
  207. package/dist/types/components/internal/icons/IconBoost.d.ts +2 -0
  208. package/dist/types/components/internal/icons/IconCard.d.ts +2 -0
  209. package/dist/types/components/internal/icons/IconCard2.d.ts +2 -0
  210. package/dist/types/components/internal/icons/IconGCash.d.ts +2 -0
  211. package/dist/types/components/internal/icons/IconGcashComplete.d.ts +2 -0
  212. package/dist/types/components/internal/icons/IconGrabPay.d.ts +2 -0
  213. package/dist/types/components/internal/icons/IconLinePay.d.ts +2 -0
  214. package/dist/types/components/internal/icons/IconMayBankQRPay.d.ts +2 -0
  215. package/dist/types/components/internal/icons/IconNinePay.d.ts +2 -0
  216. package/dist/types/components/internal/icons/IconPaymaya.d.ts +2 -0
  217. package/dist/types/components/internal/icons/IconRedirect.d.ts +2 -0
  218. package/dist/types/components/internal/icons/IconScan.d.ts +2 -0
  219. package/dist/types/components/internal/icons/IconShopeePay.d.ts +2 -0
  220. package/dist/types/components/internal/icons/IconTNGWallet.d.ts +2 -0
  221. package/dist/types/components/internal/icons/IconUnionPay.d.ts +2 -0
  222. package/dist/types/components/internal/icons/index.d.ts +14 -0
  223. package/dist/types/components/wallets/GCash/GCash.d.ts +6 -0
  224. package/dist/types/components/wallets/GCash/index.d.ts +2 -0
  225. package/dist/types/components/wallets/GCash/type.d.ts +66 -0
  226. package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -0
  227. package/dist/types/components/wallets/Paymaya/index.d.ts +2 -0
  228. package/dist/types/components/wallets/Paymaya/type.d.ts +61 -0
  229. package/dist/types/config.d.ts +9 -9
  230. package/dist/types/constant.d.ts +38 -2
  231. package/dist/types/core/PayKKaCheckout.d.ts +11 -0
  232. package/dist/types/core/Session.d.ts +2 -0
  233. package/dist/types/core/error.d.ts +3 -1
  234. package/dist/types/core/query.d.ts +2 -2
  235. package/dist/types/hooks/usePayState.d.ts +0 -3
  236. package/dist/types/i18n/I18n.d.ts +1 -1
  237. package/dist/types/i18n/locales/de-DE.d.ts +15 -0
  238. package/dist/types/i18n/locales/en-GB.d.ts +15 -0
  239. package/dist/types/i18n/locales/es-ES.d.ts +15 -0
  240. package/dist/types/i18n/locales/fr-FR.d.ts +15 -0
  241. package/dist/types/i18n/locales/ja-JP.d.ts +15 -0
  242. package/dist/types/i18n/locales/ko-KR.d.ts +15 -0
  243. package/dist/types/i18n/locales/pt-PT.d.ts +15 -0
  244. package/dist/types/i18n/locales/ru-RU.d.ts +15 -0
  245. package/dist/types/i18n/locales/zh-CN.d.ts +15 -0
  246. package/dist/types/i18n/locales/zh-HK.d.ts +15 -0
  247. package/dist/types/i18n/locales/zh-TW.d.ts +15 -0
  248. package/dist/types/i18n/util.d.ts +10 -0
  249. package/dist/types/index.d.ts +1 -1
  250. package/dist/types/types/index.d.ts +34 -7
  251. package/dist/types/types/message.d.ts +1 -0
  252. package/dist/types/utils/array.d.ts +1 -0
  253. package/dist/types/utils/card-brand/brands.d.ts +4 -3
  254. package/dist/types/utils/card-brand/index.d.ts +9 -6
  255. package/dist/types/utils/card-brand/luhn.d.ts +9 -0
  256. package/dist/types/utils/date.d.ts +9 -0
  257. package/dist/types/utils/detect.d.ts +1 -0
  258. package/dist/types/utils/format.d.ts +7 -1
  259. package/dist/types/utils/index.d.ts +7 -0
  260. package/dist/types/utils/location.d.ts +7 -0
  261. package/dist/types/utils/object.d.ts +1 -0
  262. package/dist/types/utils/redirect.d.ts +5 -0
  263. package/dist/types/utils/system-info/get-browser-info.d.ts +1 -1
  264. package/dist/types/utils/system-info/get-system-info.d.ts +3 -2
  265. package/dist/types/utils/system-info/index.d.ts +3 -3
  266. package/package.json +65 -63
@@ -0,0 +1 @@
1
+
@@ -1,29 +1,33 @@
1
1
  import { apiUrl, customReqHeaders } from "../config.js";
2
- import "../utils/card-brand/brands.js";
3
- import { getBrowserInfo } from "../utils/system-info/get-browser-info.js";
2
+ import "../core/context.js";
3
+ import "../core.js";
4
+ import { safeStringify } from "../utils/index.js";
4
5
  import { getFetch } from "./fetch.js";
5
- async function request(method, url, params, { timeout = 2e4, headers, locale } = {}) {
6
+ import { PayKKaError, EPayKKaError } from "../core/error.js";
7
+ import { getBrowserInfo } from "../utils/system-info/get-browser-info.js";
8
+ const request = async (method, url, params, { timeout = 2e4, headers, locale } = {}) => {
6
9
  const abortController = new AbortController();
7
10
  const timer = setTimeout(() => {
8
11
  abortController.abort();
9
12
  }, timeout);
10
13
  try {
11
14
  const fetch = getFetch();
15
+ const isPost = method === "post";
12
16
  const resp = await fetch(`${apiUrl}/bk${url}`, {
17
+ method,
13
18
  mode: "cors",
14
19
  cache: "default",
15
20
  credentials: "same-origin",
16
21
  headers: {
17
22
  Accept: "application/json, text/plain, */*",
18
- "Content-Type": method === "post" ? "application/json" : "text/plain",
23
+ "Content-Type": isPost ? "application/json" : "text/plain",
19
24
  "Accept-Language": locale ?? getBrowserInfo().language,
20
25
  ...customReqHeaders,
21
26
  ...headers
22
27
  },
23
28
  redirect: "follow",
24
29
  referrerPolicy: "no-referrer-when-downgrade",
25
- method,
26
- body: method === "post" && params ? JSON.stringify(params) : void 0,
30
+ body: isPost && params ? safeStringify(params) : void 0,
27
31
  signal: abortController.signal
28
32
  });
29
33
  clearTimeout(timer);
@@ -48,30 +52,24 @@ async function request(method, url, params, { timeout = 2e4, headers, locale } =
48
52
  return res.data;
49
53
  } catch (error) {
50
54
  if (error.name === "AbortError") {
51
- throw new TimeoutError("timeout");
55
+ throw new PayKKaError(EPayKKaError.TIMEOUT);
52
56
  }
53
57
  throw error.code ? error : { i18nKey: "common.unknownError" };
54
58
  }
55
- }
56
- function get(url, params, options) {
59
+ };
60
+ const get = (url, params, options) => {
57
61
  return request("get", url, params, options);
58
- }
59
- function post(url, params, options) {
62
+ };
63
+ const post = (url, params, options) => {
60
64
  return request("post", url, params, options);
61
- }
65
+ };
62
66
  const http = {
63
67
  get,
64
68
  post
65
69
  };
66
- class TimeoutError extends Error {
67
- constructor(message) {
68
- super(message);
69
- this.name = "TimeoutError";
70
- }
71
- }
72
- function isTimeoutError(error) {
73
- return error instanceof TimeoutError;
74
- }
70
+ const isTimeoutError = (error) => {
71
+ return error instanceof PayKKaError && error.type === EPayKKaError.TIMEOUT;
72
+ };
75
73
  export {
76
74
  http,
77
75
  isTimeoutError
@@ -1,3 +1,4 @@
1
1
  import "../utils/card-brand/brands.js";
2
2
  import "../utils/system-info/get-browser-info.js";
3
3
  import "../core.js";
4
+ import "../core/context.js";
@@ -1,4 +1,7 @@
1
1
  import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
2
5
  import { http } from "../../http.js";
3
6
  import { getBrowserParams } from "../get-browser-params.js";
4
7
  import { payResMap } from "../map.js";
@@ -6,25 +9,30 @@ async function aliPay({
6
9
  sessionId,
7
10
  clientKey,
8
11
  bill
9
- }, options) {
12
+ }, core, options) {
13
+ const { _getExtraParams } = core.config;
14
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", PaymentMethod.ALI_PAY);
15
+ const params = deepMerge({
16
+ bill: {
17
+ email: bill.email,
18
+ country: bill.country,
19
+ state: bill.province,
20
+ city: bill.city,
21
+ postal_code: bill.postCode,
22
+ address_line1: bill.address1,
23
+ address_line2: bill.address2,
24
+ county: bill.area
25
+ }
26
+ }, extraParams || {});
10
27
  return http.post(
11
28
  "/session/payments",
12
29
  {
30
+ ...params,
13
31
  session_id: sessionId,
14
32
  client_key: clientKey,
15
33
  payment: {
16
34
  payment_method: PaymentMethod.ALI_PAY
17
35
  },
18
- bill: {
19
- email: bill.email,
20
- country: bill.country,
21
- state: bill.province,
22
- city: bill.city,
23
- postal_code: bill.postCode,
24
- address_line1: bill.address1,
25
- address_line2: bill.address2,
26
- county: bill.area
27
- },
28
36
  browser: await getBrowserParams()
29
37
  },
30
38
  options
@@ -1,4 +1,7 @@
1
1
  import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
2
5
  import { http } from "../../http.js";
3
6
  import { payResMap } from "../map.js";
4
7
  async function getMerchantSession(options) {
@@ -10,15 +13,10 @@ async function applePay({
10
13
  token,
11
14
  bill,
12
15
  browser
13
- }, options) {
14
- console.log("apple pay payments params", {
15
- session_id: sessionId,
16
- client_key: clientKey,
17
- payment: {
18
- payment_method: PaymentMethod.APPLE_PAY,
19
- token_data: token
20
- },
21
- browser,
16
+ }, core, options) {
17
+ const { _getExtraParams } = core.config;
18
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", PaymentMethod.APPLE_PAY);
19
+ const params = deepMerge({
22
20
  bill: {
23
21
  first_name: bill == null ? void 0 : bill.firstName,
24
22
  middle_name: bill == null ? void 0 : bill.middleName,
@@ -34,32 +32,18 @@ async function applePay({
34
32
  phone_number: bill == null ? void 0 : bill.phoneNumber,
35
33
  descriptor: bill == null ? void 0 : bill.descriptor
36
34
  }
37
- });
35
+ }, extraParams || {});
38
36
  return http.post(
39
37
  "/session/payments",
40
38
  {
39
+ ...params,
41
40
  session_id: sessionId,
42
41
  client_key: clientKey,
43
42
  payment: {
44
43
  payment_method: PaymentMethod.APPLE_PAY,
45
44
  token_data: token
46
45
  },
47
- browser,
48
- bill: {
49
- first_name: bill == null ? void 0 : bill.firstName,
50
- middle_name: bill == null ? void 0 : bill.middleName,
51
- last_name: bill == null ? void 0 : bill.lastName,
52
- address_line1: bill == null ? void 0 : bill.addressLine1,
53
- address_line2: bill == null ? void 0 : bill.addressLine2,
54
- country: bill == null ? void 0 : bill.country,
55
- state: bill == null ? void 0 : bill.state,
56
- city: bill == null ? void 0 : bill.city,
57
- email: bill == null ? void 0 : bill.email,
58
- postal_code: bill == null ? void 0 : bill.postalCode,
59
- area_code: bill == null ? void 0 : bill.areaCode,
60
- phone_number: bill == null ? void 0 : bill.phoneNumber,
61
- descriptor: bill == null ? void 0 : bill.descriptor
62
- }
46
+ browser
63
47
  },
64
48
  options
65
49
  ).then(payResMap);
@@ -0,0 +1,56 @@
1
+ import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
5
+ import { http } from "../../http.js";
6
+ import { payResMap } from "../map.js";
7
+ const boostPay = async ({
8
+ sessionId,
9
+ clientKey,
10
+ payment,
11
+ bill,
12
+ browser
13
+ }, core, options) => {
14
+ const { _getExtraParams } = core.config;
15
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
16
+ const params = deepMerge({
17
+ bill: {
18
+ email: bill.email,
19
+ country: bill.country,
20
+ state: bill.province,
21
+ city: bill.city,
22
+ postal_code: bill.postCode,
23
+ address_line1: bill.address1,
24
+ address_line2: bill.address2,
25
+ county: bill.area
26
+ }
27
+ }, extraParams || {});
28
+ return http.post(
29
+ "/session/payments",
30
+ {
31
+ ...params,
32
+ session_id: sessionId,
33
+ client_key: clientKey,
34
+ payment: {
35
+ payment_method: payment.paymentMethod
36
+ },
37
+ browser
38
+ },
39
+ options
40
+ ).then(payResMap);
41
+ };
42
+ const getBoostPayInfo = async ({ sessionId, clientKey }, options) => {
43
+ return http.post(
44
+ "/session/payments/query",
45
+ {
46
+ session_id: sessionId,
47
+ client_key: clientKey,
48
+ payment_method: PaymentMethod.BOOST
49
+ },
50
+ options
51
+ ).then(payResMap);
52
+ };
53
+ export {
54
+ boostPay,
55
+ getBoostPayInfo
56
+ };
@@ -1,3 +1,6 @@
1
+ import "../../../utils/card-brand/brands.js";
2
+ import "../../../utils/system-info/get-browser-info.js";
3
+ import { deepMerge } from "../../../utils/object.js";
1
4
  import { http } from "../../http.js";
2
5
  import { payResMap } from "../map.js";
3
6
  async function cardPay({
@@ -6,10 +9,23 @@ async function cardPay({
6
9
  payment,
7
10
  bill,
8
11
  browser
9
- }, options) {
12
+ }, extraParams, options) {
13
+ const params = deepMerge({
14
+ bill: {
15
+ email: bill.email,
16
+ country: bill.country,
17
+ state: bill.province,
18
+ city: bill.city,
19
+ postal_code: bill.postCode,
20
+ address_line1: bill.address1,
21
+ address_line2: bill.address2,
22
+ county: bill.area
23
+ }
24
+ }, extraParams || {});
10
25
  return http.post(
11
26
  "/session/payments",
12
27
  {
28
+ ...params,
13
29
  session_id: sessionId,
14
30
  client_key: clientKey,
15
31
  payment: {
@@ -23,16 +39,6 @@ async function cardPay({
23
39
  token_usage: payment.tokenUsage,
24
40
  token: payment.token
25
41
  },
26
- bill: {
27
- email: bill.email,
28
- country: bill.country,
29
- state: bill.province,
30
- city: bill.city,
31
- postal_code: bill.postCode,
32
- address_line1: bill.address1,
33
- address_line2: bill.address2,
34
- county: bill.area
35
- },
36
42
  browser
37
43
  },
38
44
  options
@@ -1,7 +1,7 @@
1
1
  import { http } from "../../http.js";
2
2
  import { getBrowserParams } from "../get-browser-params.js";
3
3
  import { checkoutMap } from "./map.js";
4
- async function queryCheckout({ sessionId, clientKey }, options) {
4
+ const queryCheckout = async ({ sessionId, clientKey }, options) => {
5
5
  return http.post(
6
6
  "/session/info",
7
7
  {
@@ -11,19 +11,19 @@ async function queryCheckout({ sessionId, clientKey }, options) {
11
11
  },
12
12
  options
13
13
  );
14
- }
15
- async function getCheckoutInfo({ sessionId, clientKey }, options) {
14
+ };
15
+ const getCheckoutInfo = async ({ sessionId, clientKey }, options) => {
16
16
  const checkoutInfo = await queryCheckout({ sessionId, clientKey }, options);
17
17
  return checkoutMap({ ...checkoutInfo, ...checkoutInfo == null ? void 0 : checkoutInfo.support_methods });
18
- }
18
+ };
19
19
  let getCheckoutInfoIns;
20
- async function onceGetCheckoutInfo({ sessionId, clientKey }, options) {
20
+ const onceGetCheckoutInfo = async ({ sessionId, clientKey }, options) => {
21
21
  if (!getCheckoutInfoIns) {
22
22
  return getCheckoutInfoIns = getCheckoutInfo({ sessionId, clientKey }, options);
23
23
  } else {
24
24
  return getCheckoutInfoIns;
25
25
  }
26
- }
26
+ };
27
27
  export {
28
28
  onceGetCheckoutInfo
29
29
  };
@@ -20,6 +20,22 @@ function formatPaymentMethodInfo(paymentMethods = []) {
20
20
  environment: configuration == null ? void 0 : configuration.environment,
21
21
  googlePayMerchantId: configuration == null ? void 0 : configuration.merchant_id
22
22
  };
23
+ } else if (value === PaymentMethod.WECHAT_PAY) {
24
+ channelParams.wechatPay = {
25
+ neededToCompute: configuration == null ? void 0 : configuration.needed_to_compute,
26
+ fee: amountMap(configuration == null ? void 0 : configuration.fee),
27
+ totalAmount: amountMap(configuration == null ? void 0 : configuration.total_amount),
28
+ percentageFee: configuration == null ? void 0 : configuration.percentage_fee,
29
+ transactionFee: configuration == null ? void 0 : configuration.transaction_fee
30
+ };
31
+ } else if (value === PaymentMethod.ALI_PAY) {
32
+ channelParams.aliPay = {
33
+ neededToCompute: configuration == null ? void 0 : configuration.needed_to_compute,
34
+ fee: amountMap(configuration == null ? void 0 : configuration.fee),
35
+ totalAmount: amountMap(configuration == null ? void 0 : configuration.total_amount),
36
+ percentageFee: configuration == null ? void 0 : configuration.percentage_fee,
37
+ transactionFee: configuration == null ? void 0 : configuration.transaction_fee
38
+ };
23
39
  }
24
40
  if (value === PaymentMethod.BANKCARD) {
25
41
  paymentMethod.push(...configuration.allowed_card_networks || []);
@@ -32,6 +48,15 @@ function formatPaymentMethodInfo(paymentMethods = []) {
32
48
  channelParams
33
49
  };
34
50
  }
51
+ function formatAmountBreakdown(info = {}) {
52
+ return {
53
+ goodsTax: amountMap(info.goods_tax),
54
+ shippingAmount: amountMap(info.shipping_amount),
55
+ shippingTax: amountMap(info.shipping_tax),
56
+ discount: amountMap(info.discount),
57
+ other: amountMap(info.other)
58
+ };
59
+ }
35
60
  function checkoutMap(res = {}) {
36
61
  var _a, _b, _c;
37
62
  const { theme, bill, payment_methods, field } = res;
@@ -47,6 +72,7 @@ function checkoutMap(res = {}) {
47
72
  sessionMode,
48
73
  merchantName: (_a = res.theme) == null ? void 0 : _a.merchant_name,
49
74
  returnUrl: res.return_url,
75
+ cancelUrl: res.cancel_url,
50
76
  locale: res.locale,
51
77
  paymentType: res.payment_type,
52
78
  goods: res.goods ? res.goods : [],
@@ -79,13 +105,15 @@ function checkoutMap(res = {}) {
79
105
  },
80
106
  email: {
81
107
  show: !!(field == null ? void 0 : field.bill_email_display),
82
- required: !!(field == null ? void 0 : field.bill_email_required)
108
+ required: !!(field == null ? void 0 : field.bill_email_required),
109
+ disabled: !!(field == null ? void 0 : field.bill_email_disabled)
83
110
  },
84
111
  address: {
85
112
  show: !!(field == null ? void 0 : field.bill_address_display),
86
113
  required: !!(field == null ? void 0 : field.bill_address_required)
87
114
  }
88
115
  },
116
+ amountBreakdown: formatAmountBreakdown(res.amount_breakdown),
89
117
  ...paymentMethodsInfo
90
118
  };
91
119
  }
@@ -0,0 +1,56 @@
1
+ import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
5
+ import { http } from "../../http.js";
6
+ import { payResMap } from "../map.js";
7
+ const gcashPay = async ({
8
+ sessionId,
9
+ clientKey,
10
+ payment,
11
+ bill,
12
+ browser
13
+ }, core, options) => {
14
+ const { _getExtraParams } = core.config;
15
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
16
+ const params = deepMerge({
17
+ bill: {
18
+ email: bill.email,
19
+ country: bill.country,
20
+ state: bill.province,
21
+ city: bill.city,
22
+ postal_code: bill.postCode,
23
+ address_line1: bill.address1,
24
+ address_line2: bill.address2,
25
+ county: bill.area
26
+ }
27
+ }, extraParams || {});
28
+ return http.post(
29
+ "/session/payments",
30
+ {
31
+ ...params,
32
+ session_id: sessionId,
33
+ client_key: clientKey,
34
+ payment: {
35
+ payment_method: payment.paymentMethod
36
+ },
37
+ browser
38
+ },
39
+ options
40
+ ).then(payResMap);
41
+ };
42
+ const getGcashPayInfo = async ({ sessionId, clientKey }, options) => {
43
+ return http.post(
44
+ "/session/payments/query",
45
+ {
46
+ session_id: sessionId,
47
+ client_key: clientKey,
48
+ payment_method: PaymentMethod.GCASH
49
+ },
50
+ options
51
+ ).then(payResMap);
52
+ };
53
+ export {
54
+ gcashPay,
55
+ getGcashPayInfo
56
+ };
@@ -1,7 +1,7 @@
1
1
  import "../../utils/card-brand/brands.js";
2
2
  import { getBrowser } from "../../utils/system-info/index.js";
3
3
  import { isUaWebview } from "../../utils/system-info/is-ua-webview.js";
4
- async function getBrowserParams(params = {}) {
4
+ const getBrowserParams = async (params = {}) => {
5
5
  const { fraudDetectionId } = params;
6
6
  const browser = await getBrowser();
7
7
  let terminalType = "WEB";
@@ -32,7 +32,7 @@ async function getBrowserParams(params = {}) {
32
32
  terminal_type: terminalType,
33
33
  fraud_detection_id: fraudDetectionId
34
34
  };
35
- }
35
+ };
36
36
  export {
37
37
  getBrowserParams
38
38
  };
@@ -1,4 +1,7 @@
1
1
  import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
2
5
  import { http } from "../../http.js";
3
6
  import { payResMap } from "../map.js";
4
7
  async function googlePay({
@@ -7,15 +10,10 @@ async function googlePay({
7
10
  token,
8
11
  bill,
9
12
  browser
10
- }, options) {
11
- console.log("google pay payments params", {
12
- session_id: sessionId,
13
- client_key: clientKey,
14
- payment: {
15
- payment_method: PaymentMethod.GOOGLE_PAY,
16
- token_data: token
17
- },
18
- browser,
13
+ }, core, options) {
14
+ const { _getExtraParams } = core.config;
15
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", PaymentMethod.GOOGLE_PAY);
16
+ const params = deepMerge({
19
17
  bill: {
20
18
  first_name: bill == null ? void 0 : bill.firstName,
21
19
  middle_name: bill == null ? void 0 : bill.middleName,
@@ -31,32 +29,18 @@ async function googlePay({
31
29
  phone_number: bill == null ? void 0 : bill.phoneNumber,
32
30
  descriptor: bill == null ? void 0 : bill.descriptor
33
31
  }
34
- });
32
+ }, extraParams || {});
35
33
  return http.post(
36
34
  "/session/payments",
37
35
  {
36
+ ...params,
38
37
  session_id: sessionId,
39
38
  client_key: clientKey,
40
39
  payment: {
41
40
  payment_method: PaymentMethod.GOOGLE_PAY,
42
41
  token_data: token
43
42
  },
44
- browser,
45
- bill: {
46
- first_name: bill == null ? void 0 : bill.firstName,
47
- middle_name: bill == null ? void 0 : bill.middleName,
48
- last_name: bill == null ? void 0 : bill.lastName,
49
- address_line1: bill == null ? void 0 : bill.addressLine1,
50
- address_line2: bill == null ? void 0 : bill.addressLine2,
51
- country: bill == null ? void 0 : bill.country,
52
- state: bill == null ? void 0 : bill.state,
53
- city: bill == null ? void 0 : bill.city,
54
- email: bill == null ? void 0 : bill.email,
55
- postal_code: bill == null ? void 0 : bill.postalCode,
56
- area_code: bill == null ? void 0 : bill.areaCode,
57
- phone_number: bill == null ? void 0 : bill.phoneNumber,
58
- descriptor: bill == null ? void 0 : bill.descriptor
59
- }
43
+ browser
60
44
  },
61
45
  options
62
46
  ).then(payResMap);
@@ -0,0 +1,56 @@
1
+ import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
5
+ import { http } from "../../http.js";
6
+ import { payResMap } from "../map.js";
7
+ const grabPay = async ({
8
+ sessionId,
9
+ clientKey,
10
+ payment,
11
+ bill,
12
+ browser
13
+ }, core, options) => {
14
+ const { _getExtraParams } = core.config;
15
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
16
+ const params = deepMerge({
17
+ bill: {
18
+ email: bill.email,
19
+ country: bill.country,
20
+ state: bill.province,
21
+ city: bill.city,
22
+ postal_code: bill.postCode,
23
+ address_line1: bill.address1,
24
+ address_line2: bill.address2,
25
+ county: bill.area
26
+ }
27
+ }, extraParams || {});
28
+ return http.post(
29
+ "/session/payments",
30
+ {
31
+ ...params,
32
+ session_id: sessionId,
33
+ client_key: clientKey,
34
+ payment: {
35
+ payment_method: payment.paymentMethod
36
+ },
37
+ browser
38
+ },
39
+ options
40
+ ).then(payResMap);
41
+ };
42
+ const getGrabPayInfo = async ({ sessionId, clientKey }, options) => {
43
+ return http.post(
44
+ "/session/payments/query",
45
+ {
46
+ session_id: sessionId,
47
+ client_key: clientKey,
48
+ payment_method: PaymentMethod.GRAB_PAY
49
+ },
50
+ options
51
+ ).then(payResMap);
52
+ };
53
+ export {
54
+ getGrabPayInfo,
55
+ grabPay
56
+ };
@@ -1,3 +1,4 @@
1
1
  import "../../utils/card-brand/brands.js";
2
2
  import "../../utils/system-info/get-browser-info.js";
3
3
  import "../../core.js";
4
+ import "../../core/context.js";
@@ -0,0 +1,56 @@
1
+ import { PaymentMethod } from "../../../constant.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
4
+ import { deepMerge } from "../../../utils/object.js";
5
+ import { http } from "../../http.js";
6
+ import { payResMap } from "../map.js";
7
+ const linePay = async ({
8
+ sessionId,
9
+ clientKey,
10
+ payment,
11
+ bill,
12
+ browser
13
+ }, core, options) => {
14
+ const { _getExtraParams } = core.config;
15
+ const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
16
+ const params = deepMerge({
17
+ bill: {
18
+ email: bill.email,
19
+ country: bill.country,
20
+ state: bill.province,
21
+ city: bill.city,
22
+ postal_code: bill.postCode,
23
+ address_line1: bill.address1,
24
+ address_line2: bill.address2,
25
+ county: bill.area
26
+ }
27
+ }, extraParams || {});
28
+ return http.post(
29
+ "/session/payments",
30
+ {
31
+ ...params,
32
+ session_id: sessionId,
33
+ client_key: clientKey,
34
+ payment: {
35
+ payment_method: payment.paymentMethod
36
+ },
37
+ browser
38
+ },
39
+ options
40
+ ).then(payResMap);
41
+ };
42
+ const getLinePayInfo = async ({ sessionId, clientKey }, options) => {
43
+ return http.post(
44
+ "/session/payments/query",
45
+ {
46
+ session_id: sessionId,
47
+ client_key: clientKey,
48
+ payment_method: PaymentMethod.LINE_PAY
49
+ },
50
+ options
51
+ ).then(payResMap);
52
+ };
53
+ export {
54
+ getLinePayInfo,
55
+ linePay
56
+ };