@payment-kit-js/vanilla 0.5.2 → 0.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * PaymentKit.js v0.5.2
2
+ * PaymentKit.js v0.5.4
3
3
  * https://paymentkit.com
4
4
  *
5
5
  * @license MIT
@@ -42,7 +42,7 @@ var PaymentKit = (() => {
42
42
  });
43
43
 
44
44
  // package.json
45
- var version = "0.5.2";
45
+ var version = "0.5.4";
46
46
 
47
47
  // src/analytics/mock-adapter.ts
48
48
  var MockAnalyticsAdapter = class {
@@ -6872,6 +6872,27 @@ var PaymentKit = (() => {
6872
6872
  validations: ["required", "validCardSecurityCode"],
6873
6873
  css: fieldCss
6874
6874
  });
6875
+ for (const selector of [mountPoints.pan, mountPoints.exp, mountPoints.cvc]) {
6876
+ const container = document.querySelector(selector);
6877
+ if (!container) continue;
6878
+ const styleIframe = (iframe) => {
6879
+ iframe.style.width = "100%";
6880
+ iframe.style.height = "100%";
6881
+ };
6882
+ const existing = container.querySelector("iframe");
6883
+ if (existing) {
6884
+ styleIframe(existing);
6885
+ } else {
6886
+ const observer = new MutationObserver((_2, obs) => {
6887
+ const iframe = container.querySelector("iframe");
6888
+ if (iframe) {
6889
+ styleIframe(iframe);
6890
+ obs.disconnect();
6891
+ }
6892
+ });
6893
+ observer.observe(container, { childList: true, subtree: true });
6894
+ }
6895
+ }
6875
6896
  if (onFocusChangeCallbacks) {
6876
6897
  const fieldMap = [
6877
6898
  [panField, "card_pan"],
@@ -6920,6 +6941,8 @@ var PaymentKit = (() => {
6920
6941
  let cleanupVgs;
6921
6942
  let cleanupDirect;
6922
6943
  let cancelled = false;
6944
+ if (!states.vgsMountSelectors) states.vgsMountSelectors = {};
6945
+ states.vgsMountSelectors[type] = parentSelector;
6923
6946
  const doMount = () => {
6924
6947
  if (cancelled) return;
6925
6948
  const isVgsMode = states.cardTokenizationMode === "vgs";
@@ -6957,10 +6980,10 @@ var PaymentKit = (() => {
6957
6980
  const css = style ? Object.fromEntries(
6958
6981
  Object.entries(style).map(([k2, v2]) => [k2.replace(/([A-Z])/g, "-$1").toLowerCase(), v2])
6959
6982
  ) : void 0;
6960
- const expSelector = parentSelector.replace(/card[-_]pan/, (m2) => m2.replace("pan", "exp"));
6961
- const cvcSelector = parentSelector.replace(/card[-_]pan/, (m2) => m2.replace("pan", "cvc"));
6962
- if (expSelector === parentSelector || cvcSelector === parentSelector) {
6963
- const msg = `[PaymentKit] Failed to derive exp/cvc selectors from "${parentSelector}". Expected a selector containing "card-pan" or "card_pan".`;
6983
+ const expSelector = states.vgsMountSelectors?.card_exp;
6984
+ const cvcSelector = states.vgsMountSelectors?.card_cvc;
6985
+ if (!expSelector || !cvcSelector) {
6986
+ const msg = `[PaymentKit] VGS mode requires all three card fields to be mounted. Missing: ${!expSelector ? "card_exp" : ""}${!expSelector && !cvcSelector ? ", " : ""}${!cvcSelector ? "card_cvc" : ""}`;
6964
6987
  console.error(msg);
6965
6988
  onLoaded?.();
6966
6989
  return;