@4site/engrid-scripts 0.23.0 → 0.23.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.
@@ -8,6 +8,13 @@ export class DataAttributes {
8
8
  this.setDataAttributes();
9
9
  }
10
10
  setDataAttributes() {
11
+ // Apple Pay Availability
12
+ if (window.hasOwnProperty("ApplePaySession")) {
13
+ ENGrid.setBodyData("apple-pay-available", "true");
14
+ }
15
+ else {
16
+ ENGrid.setBodyData("apple-pay-available", "false");
17
+ }
11
18
  // Add the Page Type as a Data Attribute on the Body Tag
12
19
  if (ENGrid.checkNested(window, "pageJson", "pageType")) {
13
20
  ENGrid.setBodyData("page-type", window.pageJson.pageType);
@@ -1,5 +1,4 @@
1
1
  export declare class DigitalWallets {
2
- private static isApplePayAvailable;
3
2
  constructor();
4
3
  private addStripeDigitalWallets;
5
4
  private addPaypalTouchDigitalWallets;
@@ -87,8 +87,17 @@ export class DigitalWallets {
87
87
  }
88
88
  addStripeDigitalWallets() {
89
89
  this.addOptionToPaymentTypeField("stripedigitalwallet", "GooglePay / ApplePay");
90
- ENGrid.setBodyData("payment-type-option-apple-pay", DigitalWallets.isApplePayAvailable.toString());
91
- ENGrid.setBodyData("payment-type-option-google-pay", !DigitalWallets.isApplePayAvailable.toString());
90
+ // ENGrid.setBodyData(
91
+ // "payment-type-option-apple-pay",
92
+ // DigitalWallets.isApplePayAvailable.toString()
93
+ // );
94
+ // ENGrid.setBodyData(
95
+ // "payment-type-option-google-pay",
96
+ // !DigitalWallets.isApplePayAvailable.toString()
97
+ // );
98
+ // TODO: Change to trustworthy detection of Google Pay & Apple Pay availability
99
+ ENGrid.setBodyData("payment-type-option-apple-pay", "true");
100
+ ENGrid.setBodyData("payment-type-option-google-pay", "true");
92
101
  ENGrid.setBodyData("payment-type-option-stripedigitalwallet", "true");
93
102
  }
94
103
  addPaypalTouchDigitalWallets() {
@@ -144,4 +153,3 @@ export class DigitalWallets {
144
153
  observer.observe(node, { childList: true, subtree: true });
145
154
  }
146
155
  }
147
- DigitalWallets.isApplePayAvailable = !!window.hasOwnProperty("ApplePaySession");
@@ -26,11 +26,15 @@ export class PreferredPaymentMethod {
26
26
  this.logger.log("Not a donation page. Skipping preferred payment selection.");
27
27
  return false;
28
28
  }
29
+ // If there's a "payment" URL parameter, we can proceed
30
+ if (ENGrid.getUrlParameter("payment")) {
31
+ return true;
32
+ }
29
33
  if (!this.getGiveBySelectInputs().length) {
30
34
  this.logger.log("No give-by-select inputs found. Skipping.");
31
35
  return false;
32
36
  }
33
- const config = ENGrid.getOption("PreferredPaymentMethod");
37
+ const config = ENGrid.getOption("PreferredPaymentMethod") || false;
34
38
  if (config === false) {
35
39
  this.logger.log("PreferredPaymentMethod option disabled.");
36
40
  return false;
@@ -38,7 +42,7 @@ export class PreferredPaymentMethod {
38
42
  return true;
39
43
  }
40
44
  resolveConfig() {
41
- const option = ENGrid.getOption("PreferredPaymentMethod");
45
+ const option = ENGrid.getOption("PreferredPaymentMethod") || false;
42
46
  if (option && typeof option === "object") {
43
47
  const preferredPaymentMethodField = option.preferredPaymentMethodField || "";
44
48
  const defaultPaymentMethod = Array.isArray(option.defaultPaymentMethod)
@@ -212,14 +216,8 @@ export class PreferredPaymentMethod {
212
216
  this.logger.log(`Payment method "${method}" is not available to select.`);
213
217
  return;
214
218
  }
215
- const label = this.findLabelForInput(input);
216
- if (label) {
217
- label.click();
218
- }
219
- else {
220
- input.checked = true;
221
- input.dispatchEvent(new Event("change", { bubbles: true, cancelable: true }));
222
- }
219
+ input.checked = true;
220
+ input.dispatchEvent(new Event("change", { bubbles: true, cancelable: true }));
223
221
  ENGrid.setPaymentType(method);
224
222
  this.syncPreferredField(input.value);
225
223
  this.selectionFinalized = true;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AppVersion = "0.23.0";
1
+ export declare const AppVersion = "0.23.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const AppVersion = "0.23.0";
1
+ export const AppVersion = "0.23.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4site/engrid-scripts",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "description": "Scripts for the ENGRID Project",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "strongly-typed-events": "^2.0.9"
26
26
  },
27
27
  "homepage": "https://github.com/4site-interactive-studios/engrid#readme",
28
- "gitHead": "78e80f4a337ab108967c9c5467b95d74e307d93b",
28
+ "gitHead": "7f5ab2b32142ec7a5885fea3354370a4bad06cce",
29
29
  "devDependencies": {
30
30
  "nodemon": "^2.0.20"
31
31
  }