@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
@@ -3,17 +3,16 @@ 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 { cssVarPrefix, normalizedClass, formatAmount } from "../../../utils/format.js";
6
+ import { normalizedClass, formatAmount } from "../../../utils/format.js";
7
7
  import { redirectToPayment } from "../../../utils/redirect.js";
8
+ import { formatPaymentResult } from "../../../utils/payment.js";
8
9
  import { isTimeoutError } from "../../../api/http.js";
9
- import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../../constant.js";
10
10
  import { getBrowserParams } from "../../../api/modules/get-browser-params.js";
11
+ import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../../constant.js";
11
12
  import { getPaymayaPayInfo, paymayaPay } from "../../../api/modules/paymaya/index.js";
12
13
  import { PayKKaError } from "../../../core/error.js";
13
- import { hidePaymentButton } from "../../../config.js";
14
14
  import { usePayState } from "../../../hooks/usePayState.js";
15
15
  import { useRetry } from "../../../hooks/useRetry.js";
16
- import { createAddressCore } from "../../../core/Address.js";
17
16
  import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
18
17
  import { SubmitButton } from "../../SubmitButton/index.js";
19
18
  import { GuideCard } from "../../GuideCard/index.js";
@@ -27,7 +26,6 @@ import "./paymaya2.js";
27
26
  const { bem } = useBEM("paymaya");
28
27
  const fieldClassNames = bem("field");
29
28
  const Paymaya = w((props, ref) => {
30
- var _a, _b, _c, _d, _e, _f;
31
29
  const {
32
30
  session,
33
31
  showEmail = false,
@@ -35,7 +33,8 @@ const Paymaya = w((props, ref) => {
35
33
  core,
36
34
  redirectMode = "auto",
37
35
  autoQuery = true,
38
- showGuideCard = true
36
+ showGuideCard = true,
37
+ hidePaymentButton = false
39
38
  } = props;
40
39
  F(ref, () => ({
41
40
  stopRetry: () => {
@@ -47,26 +46,28 @@ const Paymaya = w((props, ref) => {
47
46
  startReFetchPayInfo({ timeout });
48
47
  },
49
48
  updateAddress: () => {
50
- var _a2;
49
+ var _a;
51
50
  if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
52
51
  return;
53
- setForm(Object.assign(form, { address: addressState.getAddressState() }));
54
- (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
52
+ const newForm = Object.assign(form, { address: addressCore.getAddressState() });
53
+ setForm(newForm);
54
+ (_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
55
+ validateForm();
55
56
  },
56
57
  updateEmail: () => {
57
- var _a2;
58
+ var _a;
58
59
  if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
59
60
  return;
60
- setForm(Object.assign(form, { email: emailState.email }));
61
- form.email = emailState.email;
62
- (_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
61
+ const newForm = Object.assign(form, { email: emailState.email });
62
+ setForm(newForm);
63
+ (_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
63
64
  validateForm();
64
65
  },
65
66
  payment: () => {
66
67
  hidePaymentButton && onSubmit();
67
68
  }
68
69
  }));
69
- const addressState = createAddressCore();
70
+ const addressCore = core.getAddressCore();
70
71
  const emailState = createEmailCore();
71
72
  const addressFieldRef = A(null);
72
73
  const emailFieldRef = A(null);
@@ -77,13 +78,13 @@ const Paymaya = w((props, ref) => {
77
78
  const [form, setForm] = h({
78
79
  email: "",
79
80
  address: {
80
- country: "",
81
- province: "",
82
- city: "",
83
- area: "",
84
- postCode: "",
85
- address1: "",
86
- address2: ""
81
+ country: void 0,
82
+ province: void 0,
83
+ city: void 0,
84
+ area: void 0,
85
+ postCode: void 0,
86
+ address1: void 0,
87
+ address2: void 0
87
88
  }
88
89
  });
89
90
  const [validated, setValidated] = h(false);
@@ -101,33 +102,43 @@ const Paymaya = w((props, ref) => {
101
102
  }
102
103
  setFieldStatus({ ...field });
103
104
  };
105
+ const processOnSuccess = (res) => {
106
+ var _a, _b;
107
+ setSubmitButtonStatus("success");
108
+ (_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
109
+ ...res,
110
+ returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
111
+ }));
112
+ };
104
113
  y(() => {
105
114
  if (!sessionReady) {
106
115
  return;
107
116
  }
108
- const { bill = {}, paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
109
- if (!paymentMethod.includes(PaymentMethod.PAYMAYA)) {
117
+ const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
118
+ if (!supportMethods.includes(PaymentMethod.PAYMAYA)) {
110
119
  return;
111
120
  }
112
121
  initFieldStatus();
113
122
  setIsCheckoutEnabled(true);
123
+ country && addressCore.setCountry(country);
114
124
  form.email = bill.email ?? "";
125
+ form.address.country = country;
115
126
  if (autoQuery && core.processingPaymentMethod === PaymentMethod.PAYMAYA) {
116
127
  setSubmitButtonStatus("loading");
117
128
  startReFetchPayInfo();
118
129
  }
119
130
  }, [sessionReady]);
120
131
  const processOnError = (error) => {
121
- var _a2;
122
- (_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
132
+ var _a;
133
+ (_a = props.onError) == null ? void 0 : _a.call(props, error);
123
134
  core.resetEnablePaymentMethod();
124
135
  };
125
136
  const onTimeout = q(
126
137
  (message) => {
127
- var _a2;
138
+ var _a;
128
139
  setErrorMsg(message || i18n.get("common.payTimeout"));
129
140
  setSubmitButtonStatus("unSubmit");
130
- (_a2 = props.onTimeout) == null ? void 0 : _a2.call(props);
141
+ (_a = props.onTimeout) == null ? void 0 : _a.call(props);
131
142
  core.resetEnablePaymentMethod();
132
143
  },
133
144
  [i18n, props.onTimeout]
@@ -145,34 +156,49 @@ const Paymaya = w((props, ref) => {
145
156
  },
146
157
  bill: {
147
158
  email: form.email,
148
- ...form.address,
149
- province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
150
- city: addressState.getLabel(form.address.city, addressState.getCityOptions()) ?? form.address.city
159
+ addressLine1: form.address.address1,
160
+ addressLine2: form.address.address2,
161
+ postalCode: form.address.postCode,
162
+ country: form.address.country,
163
+ district: form.address.area,
164
+ state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
165
+ city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
151
166
  },
152
167
  browser: await getBrowserParams()
153
168
  };
154
169
  };
155
170
  const pay = async (search = false, timeout) => {
156
- var _a2, _b2, _c2, _d2, _e2;
171
+ var _a, _b, _c, _d, _e, _f, _g;
157
172
  try {
158
- const paymentParams = await getPaymentParams();
159
173
  const requestOptions = { locale: i18n.locale, timeout };
160
- const res = search ? await getPaymayaPayInfo(
161
- { sessionId: session.sessionId, clientKey: session.clientKey },
162
- requestOptions
163
- ) : await paymayaPay(paymentParams, props.core, requestOptions);
164
- !search && ((_a2 = props.onSubmitResponse) == null ? void 0 : _a2.call(props, res));
165
- const { status, orderStatus, errorMessage, errorCode, payInfo } = res;
174
+ let res = null;
175
+ if (search) {
176
+ const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.PAYMAYA);
177
+ res = await getPaymayaPayInfo(
178
+ {
179
+ sessionId: session.sessionId,
180
+ clientKey: session.clientKey,
181
+ paymentMethod: PaymentMethod.PAYMAYA
182
+ },
183
+ extraParams,
184
+ requestOptions
185
+ );
186
+ } else {
187
+ const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.PAYMAYA);
188
+ res = await paymayaPay(await getPaymentParams(), extraParams, requestOptions);
189
+ }
190
+ !search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
191
+ const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
192
+ sessionId && (session.sessionId = sessionId);
166
193
  if (status === "PROCESSING") {
167
194
  if (!orderStatus) {
168
195
  setSubmitButtonStatus("unSubmit");
169
196
  return { end: true };
170
197
  } else if (orderStatus === "SUCCESS") {
171
- setSubmitButtonStatus("success");
172
- (_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
198
+ processOnSuccess(res);
173
199
  return { end: true };
174
200
  } else if (orderStatus === "FAILURE") {
175
- setErrorMsg(errorMessage);
201
+ errorMessage && setErrorMsg(errorMessage);
176
202
  setSubmitButtonStatus("unSubmit");
177
203
  processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
178
204
  return { end: true };
@@ -188,17 +214,16 @@ const Paymaya = w((props, ref) => {
188
214
  return { end: false };
189
215
  } else if (orderStatus === "CANCELED") {
190
216
  setSubmitButtonStatus("unSubmit");
191
- (_c2 = props.onTimeout) == null ? void 0 : _c2.call(props);
217
+ (_f = props.onTimeout) == null ? void 0 : _f.call(props);
192
218
  core.resetEnablePaymentMethod();
193
219
  return { end: true };
194
220
  }
195
221
  } else if (status === "SUCCESS") {
196
- setSubmitButtonStatus("success");
197
- (_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
222
+ processOnSuccess(res);
198
223
  return { end: true };
199
224
  } else if (status === "EXPIRED") {
200
225
  setSubmitButtonStatus("unSubmit");
201
- (_e2 = props.onExpired) == null ? void 0 : _e2.call(props);
226
+ (_g = props.onExpired) == null ? void 0 : _g.call(props);
202
227
  return { end: true };
203
228
  }
204
229
  setSubmitButtonStatus("unSubmit");
@@ -213,7 +238,7 @@ const Paymaya = w((props, ref) => {
213
238
  }
214
239
  } else {
215
240
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
216
- setErrorMsg(message);
241
+ message && setErrorMsg(message);
217
242
  processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
218
243
  setSubmitButtonStatus("unSubmit");
219
244
  return { end: true };
@@ -221,8 +246,8 @@ const Paymaya = w((props, ref) => {
221
246
  }
222
247
  };
223
248
  const validateForm = () => {
224
- var _a2;
225
- (_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
249
+ var _a;
250
+ (_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
226
251
  setValidated(true);
227
252
  }).catch(() => {
228
253
  setValidated(false);
@@ -232,12 +257,12 @@ const Paymaya = w((props, ref) => {
232
257
  validateForm();
233
258
  }, [form]);
234
259
  const onSubmit = async () => {
235
- var _a2;
260
+ var _a;
236
261
  setErrorMsg("");
237
- (_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
238
- var _a3;
239
- (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
240
- (_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
262
+ (_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
263
+ var _a2;
264
+ (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
265
+ (_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
241
266
  if (errors) {
242
267
  setSubmitButtonStatus("unSubmit");
243
268
  return;
@@ -252,8 +277,8 @@ const Paymaya = w((props, ref) => {
252
277
  dom && validateForm();
253
278
  };
254
279
  const Button = () => {
255
- var _a2;
256
- const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
280
+ var _a;
281
+ const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
257
282
  const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
258
283
  const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
259
284
  return /* @__PURE__ */ u(
@@ -279,24 +304,17 @@ const Paymaya = w((props, ref) => {
279
304
  }
280
305
  ) }) });
281
306
  };
282
- const formStyle = {
283
- [cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
284
- [cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
285
- [cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
286
- [cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
287
- [cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
288
- };
289
307
  const ErrorMessage = () => {
290
- return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
308
+ return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
291
309
  };
292
310
  const Address = () => {
293
- var _a2, _b2;
311
+ var _a, _b;
294
312
  return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
295
313
  AddressField,
296
314
  {
297
315
  ref: addressFieldRef,
298
316
  value: form.address,
299
- country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.bill.country),
317
+ country: ((_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
300
318
  onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
301
319
  }
302
320
  ) }) });
@@ -306,15 +324,18 @@ const Paymaya = w((props, ref) => {
306
324
  {
307
325
  value: {
308
326
  i18n,
309
- session
327
+ session,
328
+ core
310
329
  },
311
- children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
330
+ children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
312
331
  showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.PAYMAYA }),
313
- /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
332
+ /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
314
333
  Email(),
315
334
  Address(),
316
- ErrorMessage(),
317
- !hidePaymentButton && Button()
335
+ /* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
336
+ ErrorMessage(),
337
+ !hidePaymentButton && Button()
338
+ ] })
318
339
  ] }) })
319
340
  ] })
320
341
  }