@paykka/card-checkout-ui 0.9.2 → 0.11.4

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 (108) hide show
  1. package/dist/card-checkout-ui.js +16 -16
  2. package/dist/card-checkout-ui.umd.cjs +16 -16
  3. package/dist/es/api/index.js +1 -2
  4. package/dist/es/api/modules/index.js +1 -2
  5. package/dist/es/api/modules/risk/index.js +13 -0
  6. package/dist/es/api/modules/threeDS/index.js +1 -0
  7. package/dist/es/components/AccordionItem/AccordionItem.js +1 -0
  8. package/dist/es/components/AccountNameField/index.js +1 -0
  9. package/dist/es/components/AddressField/index.js +1 -0
  10. package/dist/es/components/AliPay/index.js +1 -1
  11. package/dist/es/components/ApplePay/index.js +2 -2
  12. package/dist/es/components/Boost/index.js +3 -1
  13. package/dist/es/components/Card/index.js +29 -8
  14. package/dist/es/components/CardBrands/index.js +1 -0
  15. package/dist/es/components/CardExpireDateField/index.js +1 -0
  16. package/dist/es/components/CardHolderNameField/index.js +1 -0
  17. package/dist/es/components/CardIBANField/index.js +1 -0
  18. package/dist/es/components/CardNo/index.js +1 -0
  19. package/dist/es/components/CardNumberField/index.js +13 -2
  20. package/dist/es/components/CardSecurityCodeField/index.js +1 -0
  21. package/dist/es/components/CardSelector/index.js +1 -0
  22. package/dist/es/components/CombinedCardInfo/index.js +4 -0
  23. package/dist/es/components/DropIn/index.js +2 -1
  24. package/dist/es/components/EmailField/EmailField.js +14 -15
  25. package/dist/es/components/EncryptedCard/index.js +1 -0
  26. package/dist/es/components/GooglePay/index.js +2 -2
  27. package/dist/es/components/GrabPay/index.js +3 -1
  28. package/dist/es/components/GuideCard/index.js +1 -0
  29. package/dist/es/components/LinePay/index.js +3 -1
  30. package/dist/es/components/MayBankQRPay/index.js +3 -1
  31. package/dist/es/components/NinePay/index.js +3 -1
  32. package/dist/es/components/RecurringTip/index.js +1 -0
  33. package/dist/es/components/SecuredFieldsProvider/index.js +2 -1
  34. package/dist/es/components/SecuredIframe/index.js +54 -2
  35. package/dist/es/components/Sepa/index.js +1 -1
  36. package/dist/es/components/ShopeePay/index.js +3 -1
  37. package/dist/es/components/SubmitButton/index.js +1 -0
  38. package/dist/es/components/TNGWallet/index.js +3 -1
  39. package/dist/es/components/ThreeDS/index.js +1 -0
  40. package/dist/es/components/WechatPay/index.js +1 -1
  41. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +1 -0
  42. package/dist/es/components/business/QRCodeModal/index.js +1 -0
  43. package/dist/es/components/business/index.js +1 -0
  44. package/dist/es/components/index.js +1 -0
  45. package/dist/es/components/internal/Accordion/index.js +1 -0
  46. package/dist/es/components/internal/Button/Button.js +1 -0
  47. package/dist/es/components/internal/Button/index.js +1 -0
  48. package/dist/es/components/internal/CheckBox/CheckBox.js +1 -0
  49. package/dist/es/components/internal/CheckBox/index.js +1 -0
  50. package/dist/es/components/internal/Form/type.js +1 -0
  51. package/dist/es/components/internal/Info/Info.js +1 -0
  52. package/dist/es/components/internal/Info/index.js +1 -0
  53. package/dist/es/components/internal/Input/type.js +1 -0
  54. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +1 -0
  55. package/dist/es/components/internal/LoadingCheck/index.js +1 -0
  56. package/dist/es/components/internal/Modal/Modal.js +1 -0
  57. package/dist/es/components/internal/QRCode/QRCode.js +1 -0
  58. package/dist/es/components/internal/QRCode/index.js +1 -0
  59. package/dist/es/components/internal/Select/Select.js +11 -9
  60. package/dist/es/components/internal/Select/SelectMenu.js +1 -0
  61. package/dist/es/components/internal/Select/SelectMenuItem.js +1 -0
  62. package/dist/es/components/wallets/GCash/GCash.js +15 -3
  63. package/dist/es/components/wallets/Paymaya/Paymaya.js +3 -1
  64. package/dist/es/core/PayKKaCheckout.js +7 -2
  65. package/dist/es/core/index.js +1 -0
  66. package/dist/es/core/query.js +1 -2
  67. package/dist/es/hooks/index.js +1 -0
  68. package/dist/es/hooks/useI18n.js +1 -0
  69. package/dist/es/hooks/usePayState.js +7 -2
  70. package/dist/es/i18n/locales/index.js +2 -1
  71. package/dist/es/i18n/locales/nl-NL.js +88 -0
  72. package/dist/es/index.js +2 -0
  73. package/dist/es/out/fraud-detection.js +39 -13
  74. package/dist/es/out/worldpay-ddc.js +143 -0
  75. package/dist/es/types/event.js +15 -0
  76. package/dist/es/types/fraud-detection.js +1 -0
  77. package/dist/es/types/message.js +3 -0
  78. package/dist/es/utils/iframe.js +1 -1
  79. package/dist/es/utils/reg-exp.js +4 -0
  80. package/dist/types/api/modules/index.d.ts +2 -0
  81. package/dist/types/api/modules/risk/index.d.ts +8 -0
  82. package/dist/types/api/modules/threeDS/index.d.ts +3 -0
  83. package/dist/types/components/CardNumberField/type.d.ts +7 -1
  84. package/dist/types/components/CombinedCardInfo/type.d.ts +1 -0
  85. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -1
  86. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +1 -0
  87. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -1
  88. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +13 -3
  89. package/dist/types/components/internal/Select/Select.d.ts +1 -17
  90. package/dist/types/components/internal/Select/type.d.ts +26 -1
  91. package/dist/types/components/wallets/GCash/type.d.ts +5 -0
  92. package/dist/types/core/error.d.ts +12 -1
  93. package/dist/types/hooks/usePayState.d.ts +5 -2
  94. package/dist/types/i18n/locales/index.d.ts +2 -0
  95. package/dist/types/i18n/locales/nl-NL.d.ts +71 -0
  96. package/dist/types/index.d.ts +1 -0
  97. package/dist/types/out/fraud-detection.d.ts +5 -1
  98. package/dist/types/out/types.d.ts +4 -0
  99. package/dist/types/out/worldpay-ddc-iframe.d.ts +1 -0
  100. package/dist/types/out/worldpay-ddc.d.ts +37 -0
  101. package/dist/types/types/event.d.ts +26 -0
  102. package/dist/types/types/fraud-detection.d.ts +3 -1
  103. package/dist/types/types/index.d.ts +13 -1
  104. package/dist/types/types/message.d.ts +21 -2
  105. package/dist/types/utils/iframe.d.ts +1 -1
  106. package/dist/types/utils/index.d.ts +1 -0
  107. package/dist/types/utils/reg-exp.d.ts +1 -0
  108. package/package.json +3 -1
@@ -0,0 +1,88 @@
1
+ const nlNL = {
2
+ // guide card
3
+ "guideCard.redirectDescription": "Na het indienen wordt u doorgestuurd naar de pagina van de betalingsmethode provider om de volgende stappen veilig te voltooien.",
4
+ "guideCard.scanQRCode": "Na het indienen van de bestelling, gebruik {method} om de QR-code te scannen.",
5
+ // Drop In
6
+ "dropIn.card.label": "Bankkaart",
7
+ "dropIn.otherPaymentMethod": "Andere betaalmethode",
8
+ "dropIn.boost.label": "Boost",
9
+ "dropIn.TNGWallet.label": "Touch 'n Go eWallet",
10
+ "dropIn.shopeePay.label": "ShopeePay",
11
+ "dropIn.mayBankQRPay.label": "Maybank QRPay",
12
+ "dropIn.grabPay.label": "GrabPay",
13
+ "dropIn.linePay.label": "LinePay",
14
+ "dropIn.ninePay.label": "9Pay",
15
+ "dropIn.gcash.label": "GCash",
16
+ "dropIn.paymaya.label": "Paymaya",
17
+ // card number
18
+ "card.cardNumber.label": "Kaartnummer",
19
+ "card.cardNumber.incomplete": "Uw kaartnummer is onvolledig",
20
+ "card.cardNumber.invalid": "Uw kaartnummer is ongeldig",
21
+ "card.cardNumber.placeholder": "1234 5678 9012 3456",
22
+ // card expire date
23
+ "card.cardExpireDate.label": "Vervaldatum",
24
+ "card.cardExpireDate.placeholder": "MM/JJ",
25
+ "card.cardExpireDate.incomplete": "Uw kaart vervaldatum is onvolledig",
26
+ "card.cardExpireDate.expired": "Uw kaart is verlopen",
27
+ // card security code
28
+ "card.cardSecurityCode.label": "CVC/CVV",
29
+ "card.cardSecurityCode.placeholder": "123",
30
+ "card.cardSecurityCode.incomplete": "Uw kaart beveiligingscode is onvolledig",
31
+ // card holder name
32
+ "card.cardHolderName.label": "Kaarthouder naam",
33
+ "card.cardHolderName.placeholder": "Volledige naam op kaart",
34
+ "card.cardHolderName.incomplete": "Uw naam is onvolledig",
35
+ // card selector
36
+ "card.cardSelector.change": "Wijzigen",
37
+ "card.cardSelector.useOtherCard": "Andere kaart gebruiken",
38
+ "card.storeInfo": "Sla mijn kaartgegevens op voor toekomstig gebruik",
39
+ // card info
40
+ "card.info.label": "Kaartinformatie",
41
+ // common
42
+ "common.pay": "Nu kopen",
43
+ "common.payProcessing": "Verwerken...",
44
+ "common.paySuccess": "Betaling succesvol",
45
+ "common.payTimeout": "Verbinding verbroken",
46
+ "common.pay3DSIncomplete": "3DS Authenticatie onvolledig",
47
+ "common.queryTimeout": "Query time-out. Vernieuw de pagina of betaal opnieuw",
48
+ "common.generateQrCode": "QR-code genereren",
49
+ "common.recurringTip": "Door voor deze bestelling te betalen, machtigt u de handelaar om in de toekomst automatisch uw bankkaart te belasten volgens de voorwaarden.",
50
+ "common.noData": "Geen gegevens",
51
+ "common.netError": "Netwerkfout",
52
+ "common.unknownError": "Onbekende fout",
53
+ "common.cancel": "Annuleren",
54
+ "common.confirm": "Bevestigen",
55
+ // common email
56
+ "common.email.label": "E-mail",
57
+ "common.email.incomplete": "Voer uw e-mailadres in",
58
+ "common.email.incorrect": "Incorrect e-mailadres",
59
+ // common account name
60
+ "common.accountName.label": "Accountnaam",
61
+ "common.accountName.placeholder": "Volledige naam op het account",
62
+ "common.accountName.incomplete": "Uw naam is onvolledig",
63
+ // address
64
+ "address.label": "Factuuradres",
65
+ "address.country": "Land/Regio",
66
+ "address.address1": "Regel 1",
67
+ "address.address2": "Regel 2",
68
+ "address.city": "Stad",
69
+ "address.postCode": "Postcode",
70
+ "address.province": "Staat/Provincie",
71
+ "address.area": "District/Graafschap",
72
+ // sepa
73
+ "sepa.iban.label": "IBAN",
74
+ "sepa.iban.placeholder": "NL00 BANK 0000 0000 00",
75
+ "sepa.iban.invalid": "Uw ingevoerde IBAN is ongeldig",
76
+ // threeDS
77
+ "threeDS.paymentIncomplete": "Uw laatste betaling is onvolledig, ",
78
+ "threeDS.completeFirst": "voltooi eerst de verwerking.",
79
+ "threeDS.authenticationSuccessful": "Authenticatie succesvol,",
80
+ "threeDS.authenticationFailed": "Authenticatie mislukt,",
81
+ "threeDS.returnToCheckout": "binnenkort terugkeren.",
82
+ // qrCode
83
+ "qrCode.expired": "De QR-code is verlopen.",
84
+ "qrCode.scanByGcash": "Scan QR-code met GCash"
85
+ };
86
+ export {
87
+ nlNL as default
88
+ };
package/dist/es/index.js CHANGED
@@ -39,6 +39,7 @@ import { setApiUrl, setCDNUrl, setCheckoutConfig, setCustomLocale, setCustomReqH
39
39
  import "./utils/card-brand/brands.js";
40
40
  import { getFingerprint } from "./utils/system-info/finger-print.js";
41
41
  import "./utils/system-info/get-browser-info.js";
42
+ import { PaymentMethod } from "./constant.js";
42
43
  import { redirectToPayment } from "./utils/redirect.js";
43
44
  export {
44
45
  AliPay,
@@ -72,6 +73,7 @@ export {
72
73
  PayKKaError,
73
74
  Paymaya,
74
75
  PaymentComponentMap,
76
+ PaymentMethod,
75
77
  SecuredIframe,
76
78
  Sepa,
77
79
  Session,
@@ -5,6 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { ECollMode } from "../types/fraud-detection.js";
8
+ import { FraudDetectionEventType } from "../types/event.js";
9
+ import { WorldpayDDC } from "./worldpay-ddc.js";
8
10
  var define_import_meta_env_default = { VITE_API_URL: "https://checkout.aq.paykka.com", VITE_CDN_ORIGIN: "https://checkout.aq.paykka.com", VITE_CDN_DIR: "/cp", BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false };
9
11
  const stripeKeyMap = {
10
12
  eu: "pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq",
@@ -13,19 +15,22 @@ const stripeKeyMap = {
13
15
  };
14
16
  const DEFAULT_ENV = "eu";
15
17
  let instance = null;
16
- function getFraudDetectionInstance(env, mode) {
18
+ function getFraudDetectionInstance(env, mode, options) {
17
19
  if (!instance) {
18
- instance = new FraudDetection(env, mode);
20
+ instance = new FraudDetection(env, mode, options);
19
21
  }
20
22
  return instance;
21
23
  }
22
24
  class FraudDetection {
23
- constructor(env = DEFAULT_ENV, mode = [ECollMode.SR]) {
25
+ constructor(env = DEFAULT_ENV, mode = [ECollMode.SR, ECollMode.WP], options) {
26
+ __publicField(this, "options");
24
27
  __publicField(this, "collResultMap", {
25
- [ECollMode.SR]: { s: "" }
28
+ [ECollMode.SR]: "",
29
+ [ECollMode.WP]: ""
26
30
  });
27
31
  __publicField(this, "collMap", {
28
- [ECollMode.SR]: () => this.stripeRadarColl()
32
+ [ECollMode.SR]: () => this.stripeRadarColl(),
33
+ [ECollMode.WP]: () => this.worldpayDDCColl()
29
34
  });
30
35
  __publicField(this, "p");
31
36
  __publicField(this, "realMode", []);
@@ -33,6 +38,7 @@ class FraudDetection {
33
38
  [ECollMode.SR]: ""
34
39
  });
35
40
  this.realMode = mode;
41
+ this.options = options;
36
42
  if (mode.includes(ECollMode.SR)) {
37
43
  if (typeof env === "string") {
38
44
  this.keyMap[ECollMode.SR] = stripeKeyMap[env];
@@ -41,8 +47,19 @@ class FraudDetection {
41
47
  }
42
48
  }
43
49
  }
50
+ // TODO: 待废弃
44
51
  get fraudDetectionID() {
45
- return this.transferRes();
52
+ return this.formatFraudDetectionId({
53
+ s: this.collResultMap[ECollMode.SR]
54
+ });
55
+ }
56
+ async getFraudDetectionId(options) {
57
+ return this.formatFraudDetectionId({
58
+ // stripe radar session id
59
+ s: this.collResultMap[ECollMode.SR],
60
+ // worldpay ddc fraud detection id
61
+ w: await this.worldpayDDCColl().getFraudDetectionId((options == null ? void 0 : options.bin) || "")
62
+ });
46
63
  }
47
64
  /** 创建获取 radar session id 的 promise,缓存单例 */
48
65
  async createFraudDetection() {
@@ -59,40 +76,49 @@ class FraudDetection {
59
76
  }
60
77
  await this.p;
61
78
  }
62
- /** 获取 stripe 返回的 radar session id,组件直接调,有没有返回值都直接调,传给后端 */
63
- transferRes() {
79
+ formatFraudDetectionId(data) {
80
+ var _a, _b;
64
81
  try {
65
- const s = JSON.stringify(this.collResultMap[ECollMode.SR]);
82
+ const s = JSON.stringify(data);
66
83
  return btoa(s);
67
84
  } catch (error) {
68
- console.log("[PayKKa Fraud Detection SDK]:", error);
85
+ console.error("[PayKKa Fraud Detection SDK]:", error);
86
+ (_b = (_a = this.options) == null ? void 0 : _a.onEvent) == null ? void 0 : _b.call(_a, FraudDetectionEventType.FRAUD_DETECTION_TRANSFORM_ERROR);
69
87
  return "";
70
88
  }
71
89
  }
72
90
  stripeRadarColl() {
73
91
  return new Promise((resolve, reject) => {
92
+ const { onEvent } = this.options || {};
93
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.STRIPE_RADAR_START);
74
94
  const script = document.createElement("script");
75
95
  script.type = "text/javascript";
76
96
  script.src = "https://js.stripe.com/v3/";
77
97
  script.async = true;
98
+ script.crossOrigin = "";
78
99
  script.onload = async () => {
79
100
  const stripe = window.Stripe(this.keyMap[ECollMode.SR]);
80
101
  const { radarSession, error } = await stripe.createRadarSession();
81
102
  if (error) {
82
103
  console.error(error);
104
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.STRIPE_RADAR_ERROR);
83
105
  reject(error);
84
106
  } else {
85
- this.collResultMap[ECollMode.SR].s = radarSession == null ? void 0 : radarSession.id;
107
+ this.collResultMap[ECollMode.SR] = radarSession == null ? void 0 : radarSession.id;
108
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.STRIPE_RADAR_SUCCESS);
86
109
  resolve(radarSession);
87
110
  }
88
111
  };
89
- script.onerror = function() {
112
+ script.onerror = () => {
113
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.STRIPE_RADAR_LOAD_ERROR);
90
114
  reject();
91
115
  };
92
- script.crossOrigin = "";
93
116
  document.getElementsByTagName("head")[0].appendChild(script);
94
117
  });
95
118
  }
119
+ worldpayDDCColl() {
120
+ return new WorldpayDDC(this.options);
121
+ }
96
122
  }
97
123
  export {
98
124
  getFraudDetectionInstance
@@ -0,0 +1,143 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { getRiskAuthorization } from "../api/modules/risk/index.js";
8
+ import { cdnOrigin, cdnUrl } from "../config.js";
9
+ import { MessageAction } from "../types/message.js";
10
+ import { FraudDetectionEventType } from "../types/event.js";
11
+ import "../utils/card-brand/brands.js";
12
+ import "../utils/system-info/get-browser-info.js";
13
+ import { postMessageToIframe } from "../utils/iframe.js";
14
+ const DDC_ORIGIN = "https://centinelapistag.cardinalcommerce.com";
15
+ const DDC_TIMEOUT = 1e4;
16
+ const _WorldpayDDC = class _WorldpayDDC {
17
+ constructor(options) {
18
+ __publicField(this, "iframe", null);
19
+ __publicField(this, "jwt", null);
20
+ __publicField(this, "listener", null);
21
+ __publicField(this, "timer", null);
22
+ __publicField(this, "fraudDetectionId", null);
23
+ __publicField(this, "p");
24
+ __publicField(this, "options");
25
+ if (_WorldpayDDC.instance) {
26
+ return _WorldpayDDC.instance;
27
+ }
28
+ this.options = options;
29
+ _WorldpayDDC.instance = this;
30
+ }
31
+ /**
32
+ * 获取 fraudDetectionId,每次支付的时候都要调用
33
+ * @param bin 最好是完整卡号,至少得是 6 位卡 bin
34
+ */
35
+ async getFraudDetectionId(bin) {
36
+ if (this.fraudDetectionId) {
37
+ return this.fraudDetectionId;
38
+ }
39
+ if (this.p) {
40
+ return this.p;
41
+ }
42
+ this.iframe = null;
43
+ if (this.timer) {
44
+ clearTimeout(this.timer);
45
+ }
46
+ this.p = this.requestFraudDetectionId(bin);
47
+ return this.p;
48
+ }
49
+ async requestFraudDetectionId(bin) {
50
+ const { onEvent } = this.options || {};
51
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.WORLDPAY_DDC_START);
52
+ try {
53
+ await Promise.all([this.getJWT(), this.initIframe()]);
54
+ this.sendJWTAndBin(bin);
55
+ return new Promise((resolve) => {
56
+ this.timer && clearTimeout(this.timer);
57
+ this.timer = setTimeout(() => {
58
+ this.clearListener();
59
+ console.error("worldpay ddc get id timeout");
60
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.WORLDPAY_DDC_TIMEOUT);
61
+ resolve("");
62
+ }, DDC_TIMEOUT);
63
+ this.listenFraudDetectionId((fraudDetectionId) => {
64
+ this.timer && clearTimeout(this.timer);
65
+ this.fraudDetectionId = fraudDetectionId;
66
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.WORLDPAY_DDC_SUCCESS);
67
+ resolve(fraudDetectionId);
68
+ });
69
+ });
70
+ } catch (error) {
71
+ console.error(error);
72
+ onEvent == null ? void 0 : onEvent(FraudDetectionEventType.WORLDPAY_DDC_ERROR);
73
+ return "";
74
+ }
75
+ }
76
+ sendJWTAndBin(bin) {
77
+ const message = {
78
+ action: MessageAction.DDC_JWT_BIN,
79
+ jwt: this.jwt || "",
80
+ bin
81
+ };
82
+ postMessageToIframe(message, this.iframe.contentWindow, cdnOrigin);
83
+ }
84
+ /**
85
+ * 监听 worldpay 返回的 fraudDetectionId
86
+ * 由于可能会多次调用,所以需要先移除之前的监听
87
+ * 如果 worldpay 一直没有返回信息,则 10s 后清除监听,并返回空字符串
88
+ */
89
+ listenFraudDetectionId(cb) {
90
+ if (this.listener) {
91
+ this.clearListener();
92
+ }
93
+ this.listener = (event) => {
94
+ var _a;
95
+ if (event.origin === DDC_ORIGIN) {
96
+ const data = JSON.parse(event.data);
97
+ console.warn("worldpay ddc data", data);
98
+ if (data) {
99
+ const fraudDetectionId = data.SessionId || ((_a = data.Payload) == null ? void 0 : _a.SessionId);
100
+ cb(fraudDetectionId);
101
+ }
102
+ }
103
+ };
104
+ window.addEventListener("message", this.listener);
105
+ }
106
+ clearListener() {
107
+ this.listener && window.removeEventListener("message", this.listener);
108
+ this.timer && clearTimeout(this.timer);
109
+ this.listener = null;
110
+ this.timer = null;
111
+ }
112
+ getJWT() {
113
+ if (this.jwt) {
114
+ return this.jwt;
115
+ }
116
+ return getRiskAuthorization({ channel: "WORLD_PAY" }).then((res) => {
117
+ this.jwt = res.authCode;
118
+ return this.jwt;
119
+ });
120
+ }
121
+ initIframe() {
122
+ if (this.iframe) {
123
+ return;
124
+ }
125
+ const iframe = document.createElement("iframe");
126
+ iframe.src = `${cdnUrl}/worldpay-ddc.html`;
127
+ iframe.style.display = "none";
128
+ iframe.width = "1";
129
+ iframe.height = "1";
130
+ document.body.appendChild(iframe);
131
+ this.iframe = iframe;
132
+ return new Promise((resolve) => {
133
+ iframe.onload = () => {
134
+ resolve();
135
+ };
136
+ });
137
+ }
138
+ };
139
+ __publicField(_WorldpayDDC, "instance", null);
140
+ let WorldpayDDC = _WorldpayDDC;
141
+ export {
142
+ WorldpayDDC
143
+ };
@@ -0,0 +1,15 @@
1
+ var FraudDetectionEventType = /* @__PURE__ */ ((FraudDetectionEventType2) => {
2
+ FraudDetectionEventType2["FRAUD_DETECTION_TRANSFORM_ERROR"] = "fraudDetection:transFormError";
3
+ FraudDetectionEventType2["STRIPE_RADAR_ERROR"] = "stripeRadar:error";
4
+ FraudDetectionEventType2["STRIPE_RADAR_LOAD_ERROR"] = "stripeRadar:loadError";
5
+ FraudDetectionEventType2["STRIPE_RADAR_START"] = "stripeRadar:start";
6
+ FraudDetectionEventType2["STRIPE_RADAR_SUCCESS"] = "stripeRadar:success";
7
+ FraudDetectionEventType2["WORLDPAY_DDC_START"] = "worldpayDDC:start";
8
+ FraudDetectionEventType2["WORLDPAY_DDC_ERROR"] = "worldpayDDC:error";
9
+ FraudDetectionEventType2["WORLDPAY_DDC_TIMEOUT"] = "worldpayDDC:timeout";
10
+ FraudDetectionEventType2["WORLDPAY_DDC_SUCCESS"] = "worldpayDDC:success";
11
+ return FraudDetectionEventType2;
12
+ })(FraudDetectionEventType || {});
13
+ export {
14
+ FraudDetectionEventType
15
+ };
@@ -1,5 +1,6 @@
1
1
  var ECollMode = /* @__PURE__ */ ((ECollMode2) => {
2
2
  ECollMode2["SR"] = "SR";
3
+ ECollMode2["WP"] = "WP";
3
4
  return ECollMode2;
4
5
  })(ECollMode || {});
5
6
  export {
@@ -21,6 +21,9 @@ var MessageAction = /* @__PURE__ */ ((MessageAction2) => {
21
21
  MessageAction2["CHECK_THREE_DS"] = "checkThreeDS";
22
22
  MessageAction2["THREE_DS_STATUS_INIT"] = "threeDSStatusInit";
23
23
  MessageAction2["THREE_DS_STATUS_CONFIG"] = "threeDSStatusConfig";
24
+ MessageAction2["DEBUG_MODE"] = "debugMode";
25
+ MessageAction2["DDC_RESULT"] = "ddcResult";
26
+ MessageAction2["DDC_JWT_BIN"] = "ddcJwtBin";
24
27
  return MessageAction2;
25
28
  })(MessageAction || {});
26
29
  export {
@@ -14,7 +14,7 @@ const postMessageToIframe = (data, iframe, targetOrigin = "*") => {
14
14
  if (!iframe) {
15
15
  return;
16
16
  }
17
- const dataStr = JSON.stringify(data);
17
+ const dataStr = typeof data === "string" ? data : JSON.stringify(data);
18
18
  iframe == null ? void 0 : iframe.postMessage(dataStr, { targetOrigin });
19
19
  };
20
20
  export {
@@ -0,0 +1,4 @@
1
+ const EMAIL_REG = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
2
+ export {
3
+ EMAIL_REG
4
+ };
@@ -17,3 +17,5 @@ export * from './paymaya';
17
17
  export * from './map';
18
18
  export * from './type';
19
19
  export * from './get-browser-params';
20
+ export * from './threeDS';
21
+ export * from './risk';
@@ -0,0 +1,8 @@
1
+ import { type RequestOptions } from '../../http';
2
+ export declare const getRiskAuthorization: (params: {
3
+ channel: string;
4
+ }, options?: RequestOptions) => Promise<{
5
+ authCode: any;
6
+ channel: any;
7
+ expireTime: any;
8
+ }>;
@@ -0,0 +1,3 @@
1
+ import { type RequestOptions } from '../../http';
2
+ /** 通知后端服务商 3ds 页面已加载 */
3
+ export declare const noticeThreeDSLoaded: (sessionId: string, options?: RequestOptions) => Promise<any>;
@@ -2,15 +2,21 @@ import type { CardBrand } from '../../types';
2
2
  import type { FormItemProps, FormValidationStatus } from '../internal/Form';
3
3
  import type { InputProps } from '../internal/Input';
4
4
  export interface CardNumberFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
5
+ /** 支持的卡品牌 */
5
6
  supportedCardBrands?: string[];
6
- security: boolean;
7
+ /** 是否显示标签 */
7
8
  showLabel?: boolean;
9
+ /** 是否使用安全模式(iframe) */
10
+ security: boolean;
11
+ /** 卡 bin 改变回调 */
12
+ onBinValue?: (binValue: string) => void;
8
13
  }
9
14
  export interface CardNumberFieldRef {
10
15
  focus: () => void;
11
16
  blur: () => void;
12
17
  resetValidation: (status: FormValidationStatus, errorTip?: string) => void;
13
18
  binValueChanged: (binValue: string) => void;
19
+ binValue: () => string;
14
20
  brandChanged: (brand?: CardBrand) => void;
15
21
  getCardBrand: () => Recordable;
16
22
  }
@@ -11,6 +11,7 @@ export interface CombinedCardInfoRef {
11
11
  blur: () => void;
12
12
  resetValidation: (status: FormValidationStatus, errorTip?: string) => void;
13
13
  binValueChanged: (binValue: string) => void;
14
+ binValue: () => string;
14
15
  brandChanged: (brand?: CardBrand) => void;
15
16
  getCardBrand: () => Recordable;
16
17
  }
@@ -12,7 +12,7 @@ export interface SecuredFieldsProviderProps extends SecuredFieldsCallback {
12
12
  style?: InputStylesConfig;
13
13
  }
14
14
  export interface SecuredFieldsProviderRef {
15
- payment: (formData: any) => void;
15
+ payment: (formData: Recordable, extraParams?: Recordable) => void;
16
16
  encryptCard: (encryptInfo: EncryptCardMessage) => void;
17
17
  reload: () => void;
18
18
  validate: () => void;
@@ -1,2 +1,3 @@
1
1
  import type { ThreeDSIframeProps } from './type';
2
+ import './three-ds-iframe.scss';
2
3
  export declare const ThreeDSIframe: (props: ThreeDSIframeProps) => import("preact").JSX.Element;
@@ -1 +1 @@
1
- export {};
1
+ import './three-ds-iframe.scss';
@@ -1,5 +1,15 @@
1
+ export interface ThreeDSFormConfig {
2
+ action: string | null;
3
+ dataList: Array<{
4
+ name: string;
5
+ value: string | null;
6
+ }>;
7
+ }
1
8
  export interface ThreeDSIframeProps {
2
- uniqueId: string;
3
- signature: string;
4
- action: string;
9
+ config: ThreeDSFormConfig;
10
+ sessionId?: string;
11
+ }
12
+ export declare enum ThreeDSChannel {
13
+ ECP = "ECP",
14
+ WORLDPAY = "WORLD_PAY"
5
15
  }
@@ -1,20 +1,4 @@
1
- import { type ReactNode } from 'preact/compat';
2
- import type { CustomAttributes } from '../../../types';
3
- import type { SelectOption, SelectRef } from './type';
4
- interface SelectProps extends CustomAttributes<HTMLInputElement, 'onBlur' | 'onFocus' | 'placeholder'> {
5
- value?: string | number;
6
- status?: 'error' | 'success';
7
- placeholder?: string;
8
- rightIcon?: ReactNode;
9
- options: SelectOption[];
10
- onSelect: (value: string | number, option: SelectOption) => void;
11
- inputClassName?: string;
12
- noDataTip: string;
13
- renderLabel?: (option: SelectOption) => ReactNode;
14
- action?: ReactNode;
15
- filterable?: boolean;
16
- }
1
+ import type { SelectProps, SelectRef } from './type';
17
2
  export declare const Select: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<SelectProps> & {
18
3
  ref?: import("preact").Ref<SelectRef> | undefined;
19
4
  }>;
20
- export {};
@@ -1,4 +1,5 @@
1
- import type { ReactNode } from "preact/compat";
1
+ import type { ReactNode } from 'preact/compat';
2
+ import type { CustomAttributes } from '../../../types';
2
3
  export interface BaseSelectOption<V = string | number, L = string | ((option: BaseSelectOption<V>, selected: boolean) => ReactNode)> {
3
4
  label: L;
4
5
  value: V;
@@ -8,3 +9,27 @@ export type SelectOption = BaseSelectOption<string | number>;
8
9
  export interface SelectRef {
9
10
  blur: () => void;
10
11
  }
12
+ export interface SelectProps extends CustomAttributes<HTMLInputElement, 'onBlur' | 'onFocus' | 'placeholder'> {
13
+ /** 选中值 */
14
+ value?: string | number;
15
+ /** 校验状态 */
16
+ status?: 'error' | 'success';
17
+ /** 占位符 */
18
+ placeholder?: string;
19
+ /** 右侧图标 */
20
+ rightIcon?: ReactNode;
21
+ /** 选项列表 */
22
+ options: SelectOption[];
23
+ /** 选中回调 */
24
+ onSelect: (value: string | number, option: SelectOption) => void;
25
+ /** 输入框样式 */
26
+ inputClassName?: string;
27
+ /** 没有数据时的提示 */
28
+ noDataTip?: string;
29
+ /** 渲染选项 */
30
+ renderLabel?: (option: SelectOption) => ReactNode;
31
+ /** 操作按钮 */
32
+ action?: ReactNode;
33
+ /** 是否可过滤 */
34
+ filterable?: boolean;
35
+ }
@@ -51,6 +51,11 @@ export interface GCashProps {
51
51
  * 是否展示二维码弹窗
52
52
  */
53
53
  enableQRCodeModal?: boolean;
54
+ /**
55
+ * @internal
56
+ * 用户关闭支付弹窗时触发
57
+ */
58
+ onCloseModal?: () => void;
54
59
  }
55
60
  export interface GCashRef {
56
61
  /** 停止轮询支付结果 */
@@ -1,3 +1,14 @@
1
+ /** 前端错误信息枚举,为了防止与后端 code 冲突做的区分 */
2
+ export declare enum EPayKKaErrorMessage {
3
+ /** worldpay ddc 错误 */
4
+ DDC_ERROR = "DDC_ERROR",
5
+ /** worldpay ddc 超时 */
6
+ DDC_TIMEOUT = "DDC_TIMEOUT",
7
+ /** 欺诈检测数据转换错误 */
8
+ FRAUD_DETECTION_ID_FORMAT_ERROR = "FRAUD_DETECTION_ID_FORMAT_ERROR",
9
+ /** stripe radar 错误 */
10
+ STRIPE_RADAR_ERROR = "STRIPE_RADAR_ERROR"
11
+ }
1
12
  export declare enum EPayKKaError {
2
13
  /** 普通错误,基本是前端错误 */
3
14
  ERROR = "ERROR",
@@ -11,7 +22,7 @@ export declare class PayKKaError extends Error {
11
22
  type: keyof typeof EPayKKaError;
12
23
  /** 错误代码 */
13
24
  code?: string;
14
- constructor(type: keyof typeof EPayKKaError, message?: string, info?: {
25
+ constructor(type: keyof typeof EPayKKaError, message?: string | EPayKKaErrorMessage, info?: {
15
26
  code?: string;
16
27
  cause?: any;
17
28
  });
@@ -1,5 +1,5 @@
1
- import type { Session } from '../core';
2
- export declare function usePayState(session: Session): {
1
+ import type { PayKKaCheckout, Session } from '../core';
2
+ export declare function usePayState(session: Session, core?: PayKKaCheckout): {
3
3
  validated: boolean;
4
4
  setValidated: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<boolean>>;
5
5
  errorMsg: string;
@@ -7,6 +7,9 @@ export declare function usePayState(session: Session): {
7
7
  i18n: import("../i18n").I18n;
8
8
  fraudDetection: {
9
9
  fraudDetectionID: string;
10
+ getFraudDetectionId: (options?: {
11
+ bin?: string | undefined;
12
+ } | undefined) => Promise<string>;
10
13
  createFraudDetection: () => Promise<void>;
11
14
  } | null;
12
15
  sessionReady: boolean;
@@ -14,6 +14,8 @@ export declare enum LocaleKey {
14
14
  jaJP = "ja-JP",
15
15
  /** 韩语(韩国) */
16
16
  koKR = "ko-KR",
17
+ /** 荷兰语(荷兰) */
18
+ nlNL = "nl-NL",
17
19
  /** 葡萄牙语(葡萄牙) */
18
20
  ptPT = "pt-PT",
19
21
  /** 俄语(俄罗斯) */