@economist/web-apple-pay 0.1.3-beta.10 → 0.1.3-beta.12

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.
package/dist/index.js CHANGED
@@ -942,8 +942,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
942
942
  () => this.close()
943
943
  );
944
944
  }
945
- open() {
946
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
945
+ open(recaptchaTokensPromise) {
946
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
947
947
  this.#triggerElement = document.activeElement;
948
948
  document.body.appendChild(this);
949
949
  this.#keyHandler = (event) => {
@@ -1169,7 +1169,6 @@ var validateAppleMerchant = (data) => {
1169
1169
  });
1170
1170
  };
1171
1171
  var performPurchase = (data) => {
1172
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
1173
1172
  return apiFetch("/v1/wallet/purchase", {
1174
1173
  method: "POST",
1175
1174
  body: JSON.stringify(data),
@@ -1572,7 +1571,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1572
1571
  sessionData,
1573
1572
  config.supportedBillingCountries
1574
1573
  );
1575
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
1576
1574
  const result = await performPurchase({
1577
1575
  applePayToken: event.payment.token,
1578
1576
  skuId: config.skuId,
@@ -1927,6 +1925,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1927
1925
  #returnUrl = "";
1928
1926
  #supportedBillingCountries = [];
1929
1927
  #entryPoint = "";
1928
+ #recaptchaTokensPromise = null;
1930
1929
  // ─── Public API ─────────────────────────────────────────────────────────────
1931
1930
  get offer() {
1932
1931
  return this.#offer;
@@ -1991,6 +1990,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1991
1990
  this.#paymentOptions = null;
1992
1991
  this.#returnUrl = "";
1993
1992
  this.#supportedBillingCountries = [];
1993
+ this.#recaptchaTokensPromise = null;
1994
1994
  this.querySelector(SEL_CONTAINER)?.remove();
1995
1995
  }
1996
1996
  // ─── Render pipeline ────────────────────────────────────────────────────────
@@ -2105,6 +2105,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2105
2105
  if (button) {
2106
2106
  button.classList.remove("wap-loading");
2107
2107
  this.#updateDisabledState();
2108
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2108
2109
  trackExpressWalletImpression(this.#offer.sku_id, {
2109
2110
  entryPoint: this.#entryPoint,
2110
2111
  country: this.#country
@@ -2139,11 +2140,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2139
2140
  if (this.#sessionData?.loggedIn) {
2140
2141
  modal.dataset.loggedIn = "true";
2141
2142
  }
2142
- const { skuId, country } = { skuId: this.#offer.sku_id, country: this.#country };
2143
+ const skuId = this.#offer.sku_id;
2144
+ const country = this.#country;
2143
2145
  modal.onConfirm = (recaptchaTokens) => {
2144
2146
  this.#initiateApplePay(skuId, country, recaptchaTokens);
2147
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2145
2148
  };
2146
- modal.open();
2149
+ modal.open(this.#recaptchaTokensPromise);
2147
2150
  }
2148
2151
  async #fetchSession() {
2149
2152
  try {
@@ -937,8 +937,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
937
937
  () => this.close()
938
938
  );
939
939
  }
940
- open() {
941
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
940
+ open(recaptchaTokensPromise) {
941
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
942
942
  this.#triggerElement = document.activeElement;
943
943
  document.body.appendChild(this);
944
944
  this.#keyHandler = (event) => {
@@ -1164,7 +1164,6 @@ var validateAppleMerchant = (data) => {
1164
1164
  });
1165
1165
  };
1166
1166
  var performPurchase = (data) => {
1167
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
1168
1167
  return apiFetch("/v1/wallet/purchase", {
1169
1168
  method: "POST",
1170
1169
  body: JSON.stringify(data),
@@ -1567,7 +1566,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1567
1566
  sessionData,
1568
1567
  config.supportedBillingCountries
1569
1568
  );
1570
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
1571
1569
  const result = await performPurchase({
1572
1570
  applePayToken: event.payment.token,
1573
1571
  skuId: config.skuId,
@@ -1922,6 +1920,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1922
1920
  #returnUrl = "";
1923
1921
  #supportedBillingCountries = [];
1924
1922
  #entryPoint = "";
1923
+ #recaptchaTokensPromise = null;
1925
1924
  // ─── Public API ─────────────────────────────────────────────────────────────
1926
1925
  get offer() {
1927
1926
  return this.#offer;
@@ -1986,6 +1985,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1986
1985
  this.#paymentOptions = null;
1987
1986
  this.#returnUrl = "";
1988
1987
  this.#supportedBillingCountries = [];
1988
+ this.#recaptchaTokensPromise = null;
1989
1989
  this.querySelector(SEL_CONTAINER)?.remove();
1990
1990
  }
1991
1991
  // ─── Render pipeline ────────────────────────────────────────────────────────
@@ -2100,6 +2100,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2100
2100
  if (button) {
2101
2101
  button.classList.remove("wap-loading");
2102
2102
  this.#updateDisabledState();
2103
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2103
2104
  trackExpressWalletImpression(this.#offer.sku_id, {
2104
2105
  entryPoint: this.#entryPoint,
2105
2106
  country: this.#country
@@ -2134,11 +2135,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2134
2135
  if (this.#sessionData?.loggedIn) {
2135
2136
  modal.dataset.loggedIn = "true";
2136
2137
  }
2137
- const { skuId, country } = { skuId: this.#offer.sku_id, country: this.#country };
2138
+ const skuId = this.#offer.sku_id;
2139
+ const country = this.#country;
2138
2140
  modal.onConfirm = (recaptchaTokens) => {
2139
2141
  this.#initiateApplePay(skuId, country, recaptchaTokens);
2142
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2140
2143
  };
2141
- modal.open();
2144
+ modal.open(this.#recaptchaTokensPromise);
2142
2145
  }
2143
2146
  async #fetchSession() {
2144
2147
  try {
@@ -945,8 +945,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
945
945
  () => this.close()
946
946
  );
947
947
  }
948
- open() {
949
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
948
+ open(recaptchaTokensPromise) {
949
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
950
950
  this.#triggerElement = document.activeElement;
951
951
  document.body.appendChild(this);
952
952
  this.#keyHandler = (event) => {
@@ -1172,7 +1172,6 @@ var validateAppleMerchant = (data) => {
1172
1172
  });
1173
1173
  };
1174
1174
  var performPurchase = (data) => {
1175
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
1176
1175
  return apiFetch("/v1/wallet/purchase", {
1177
1176
  method: "POST",
1178
1177
  body: JSON.stringify(data),
@@ -1575,7 +1574,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1575
1574
  sessionData,
1576
1575
  config.supportedBillingCountries
1577
1576
  );
1578
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
1579
1577
  const result = await performPurchase({
1580
1578
  applePayToken: event.payment.token,
1581
1579
  skuId: config.skuId,
@@ -1930,6 +1928,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1930
1928
  #returnUrl = "";
1931
1929
  #supportedBillingCountries = [];
1932
1930
  #entryPoint = "";
1931
+ #recaptchaTokensPromise = null;
1933
1932
  // ─── Public API ─────────────────────────────────────────────────────────────
1934
1933
  get offer() {
1935
1934
  return this.#offer;
@@ -1994,6 +1993,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1994
1993
  this.#paymentOptions = null;
1995
1994
  this.#returnUrl = "";
1996
1995
  this.#supportedBillingCountries = [];
1996
+ this.#recaptchaTokensPromise = null;
1997
1997
  this.querySelector(SEL_CONTAINER)?.remove();
1998
1998
  }
1999
1999
  // ─── Render pipeline ────────────────────────────────────────────────────────
@@ -2108,6 +2108,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2108
2108
  if (button) {
2109
2109
  button.classList.remove("wap-loading");
2110
2110
  this.#updateDisabledState();
2111
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2111
2112
  trackExpressWalletImpression(this.#offer.sku_id, {
2112
2113
  entryPoint: this.#entryPoint,
2113
2114
  country: this.#country
@@ -2142,11 +2143,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2142
2143
  if (this.#sessionData?.loggedIn) {
2143
2144
  modal.dataset.loggedIn = "true";
2144
2145
  }
2145
- const { skuId, country } = { skuId: this.#offer.sku_id, country: this.#country };
2146
+ const skuId = this.#offer.sku_id;
2147
+ const country = this.#country;
2146
2148
  modal.onConfirm = (recaptchaTokens) => {
2147
2149
  this.#initiateApplePay(skuId, country, recaptchaTokens);
2150
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2148
2151
  };
2149
- modal.open();
2152
+ modal.open(this.#recaptchaTokensPromise);
2150
2153
  }
2151
2154
  async #fetchSession() {
2152
2155
  try {
@@ -21,7 +21,7 @@ export declare class ApplePayModal extends HTMLElement {
21
21
  get country(): string;
22
22
  set country(value: string);
23
23
  connectedCallback(): void;
24
- open(): void;
24
+ open(recaptchaTokensPromise?: Promise<RecaptchaTokens> | null): void;
25
25
  close(): void;
26
26
  }
27
27
  export {};
@@ -937,8 +937,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
937
937
  () => this.close()
938
938
  );
939
939
  }
940
- open() {
941
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
940
+ open(recaptchaTokensPromise) {
941
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
942
942
  this.#triggerElement = document.activeElement;
943
943
  document.body.appendChild(this);
944
944
  this.#keyHandler = (event) => {
@@ -937,8 +937,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
937
937
  () => this.close()
938
938
  );
939
939
  }
940
- open() {
941
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
940
+ open(recaptchaTokensPromise) {
941
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
942
942
  this.#triggerElement = document.activeElement;
943
943
  document.body.appendChild(this);
944
944
  this.#keyHandler = (event) => {
@@ -1164,7 +1164,6 @@ var validateAppleMerchant = (data) => {
1164
1164
  });
1165
1165
  };
1166
1166
  var performPurchase = (data) => {
1167
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
1168
1167
  return apiFetch("/v1/wallet/purchase", {
1169
1168
  method: "POST",
1170
1169
  body: JSON.stringify(data),
@@ -1567,7 +1566,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1567
1566
  sessionData,
1568
1567
  config.supportedBillingCountries
1569
1568
  );
1570
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
1571
1569
  const result = await performPurchase({
1572
1570
  applePayToken: event.payment.token,
1573
1571
  skuId: config.skuId,
@@ -1922,6 +1920,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1922
1920
  #returnUrl = "";
1923
1921
  #supportedBillingCountries = [];
1924
1922
  #entryPoint = "";
1923
+ #recaptchaTokensPromise = null;
1925
1924
  // ─── Public API ─────────────────────────────────────────────────────────────
1926
1925
  get offer() {
1927
1926
  return this.#offer;
@@ -1986,6 +1985,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1986
1985
  this.#paymentOptions = null;
1987
1986
  this.#returnUrl = "";
1988
1987
  this.#supportedBillingCountries = [];
1988
+ this.#recaptchaTokensPromise = null;
1989
1989
  this.querySelector(SEL_CONTAINER)?.remove();
1990
1990
  }
1991
1991
  // ─── Render pipeline ────────────────────────────────────────────────────────
@@ -2100,6 +2100,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2100
2100
  if (button) {
2101
2101
  button.classList.remove("wap-loading");
2102
2102
  this.#updateDisabledState();
2103
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2103
2104
  trackExpressWalletImpression(this.#offer.sku_id, {
2104
2105
  entryPoint: this.#entryPoint,
2105
2106
  country: this.#country
@@ -2134,11 +2135,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2134
2135
  if (this.#sessionData?.loggedIn) {
2135
2136
  modal.dataset.loggedIn = "true";
2136
2137
  }
2137
- const { skuId, country } = { skuId: this.#offer.sku_id, country: this.#country };
2138
+ const skuId = this.#offer.sku_id;
2139
+ const country = this.#country;
2138
2140
  modal.onConfirm = (recaptchaTokens) => {
2139
2141
  this.#initiateApplePay(skuId, country, recaptchaTokens);
2142
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2140
2143
  };
2141
- modal.open();
2144
+ modal.open(this.#recaptchaTokensPromise);
2142
2145
  }
2143
2146
  async #fetchSession() {
2144
2147
  try {
@@ -69,7 +69,6 @@ var validateAppleMerchant = (data) => {
69
69
  });
70
70
  };
71
71
  var performPurchase = (data) => {
72
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
73
72
  return apiFetch("/v1/wallet/purchase", {
74
73
  method: "POST",
75
74
  body: JSON.stringify(data),
@@ -55,7 +55,6 @@ var apiFetch = async (path, options = {}) => {
55
55
  return response.json();
56
56
  };
57
57
  var performPurchase = (data) => {
58
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
59
58
  return apiFetch("/v1/wallet/purchase", {
60
59
  method: "POST",
61
60
  body: JSON.stringify(data),
@@ -336,7 +335,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
336
335
  sessionData,
337
336
  config.supportedBillingCountries
338
337
  );
339
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
340
338
  const result = await performPurchase({
341
339
  applePayToken: event.payment.token,
342
340
  skuId: config.skuId,
package/dist/src/index.js CHANGED
@@ -942,8 +942,8 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
942
942
  () => this.close()
943
943
  );
944
944
  }
945
- open() {
946
- this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
945
+ open(recaptchaTokensPromise) {
946
+ this.#recaptchaTokensPromise = recaptchaTokensPromise ?? getPurchaseRecaptchaTokens();
947
947
  this.#triggerElement = document.activeElement;
948
948
  document.body.appendChild(this);
949
949
  this.#keyHandler = (event) => {
@@ -1169,7 +1169,6 @@ var validateAppleMerchant = (data) => {
1169
1169
  });
1170
1170
  };
1171
1171
  var performPurchase = (data) => {
1172
- console.log("[web-apple-pay] performPurchase request", JSON.stringify(data, null, 2));
1173
1172
  return apiFetch("/v1/wallet/purchase", {
1174
1173
  method: "POST",
1175
1174
  body: JSON.stringify(data),
@@ -1572,7 +1571,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1572
1571
  sessionData,
1573
1572
  config.supportedBillingCountries
1574
1573
  );
1575
- console.log("[web-apple-pay] performPurchase currency", { skuId, currency: config.currency });
1576
1574
  const result = await performPurchase({
1577
1575
  applePayToken: event.payment.token,
1578
1576
  skuId: config.skuId,
@@ -1927,6 +1925,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1927
1925
  #returnUrl = "";
1928
1926
  #supportedBillingCountries = [];
1929
1927
  #entryPoint = "";
1928
+ #recaptchaTokensPromise = null;
1930
1929
  // ─── Public API ─────────────────────────────────────────────────────────────
1931
1930
  get offer() {
1932
1931
  return this.#offer;
@@ -1991,6 +1990,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
1991
1990
  this.#paymentOptions = null;
1992
1991
  this.#returnUrl = "";
1993
1992
  this.#supportedBillingCountries = [];
1993
+ this.#recaptchaTokensPromise = null;
1994
1994
  this.querySelector(SEL_CONTAINER)?.remove();
1995
1995
  }
1996
1996
  // ─── Render pipeline ────────────────────────────────────────────────────────
@@ -2105,6 +2105,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2105
2105
  if (button) {
2106
2106
  button.classList.remove("wap-loading");
2107
2107
  this.#updateDisabledState();
2108
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2108
2109
  trackExpressWalletImpression(this.#offer.sku_id, {
2109
2110
  entryPoint: this.#entryPoint,
2110
2111
  country: this.#country
@@ -2139,11 +2140,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2139
2140
  if (this.#sessionData?.loggedIn) {
2140
2141
  modal.dataset.loggedIn = "true";
2141
2142
  }
2142
- const { skuId, country } = { skuId: this.#offer.sku_id, country: this.#country };
2143
+ const skuId = this.#offer.sku_id;
2144
+ const country = this.#country;
2143
2145
  modal.onConfirm = (recaptchaTokens) => {
2144
2146
  this.#initiateApplePay(skuId, country, recaptchaTokens);
2147
+ this.#recaptchaTokensPromise = getPurchaseRecaptchaTokens();
2145
2148
  };
2146
- modal.open();
2149
+ modal.open(this.#recaptchaTokensPromise);
2147
2150
  }
2148
2151
  async #fetchSession() {
2149
2152
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@economist/web-apple-pay",
3
3
  "description": "Web component package for Apple Pay checkout UI",
4
- "version": "0.1.3-beta.10",
4
+ "version": "0.1.3-beta.12",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",