Skip to content

Commit 60e800d

Browse files
authored
Merge pull request #375 from 4site-interactive-studios/stripe-ach
Replace Plaid with Stripe Financial Connections component + fix issue with submit button not resetting when user cancels payment
2 parents 56771f2 + d8a02e6 commit 60e800d

19 files changed

Lines changed: 149 additions & 99 deletions

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- Tip: when debugging, `?debug=true` sets body `data-engrid-debug`, unlocking debug panels and conditional UI.
2727

2828
## When in Doubt
29-
- Search in `packages/scripts/src` before creating new utilities; most EN behaviours already exist (currency, remember-me, plaid, vgs).
29+
- Search in `packages/scripts/src` before creating new utilities; most EN behaviours already exist (currency, remember-me, stripe financial connections, vgs).
3030
- Do not hand-edit files under any `dist/` directory—run the relevant build instead.
3131
- Follow repo Prettier config (`.prettierrc.js`); formatting is enforced even though there are no automated tests.
32-
- Document new options by updating the interfaces in `packages/scripts/src/interfaces` and exposing them through `OptionsDefaults`.
32+
- Document new options by updating the interfaces in `packages/scripts/src/interfaces` and exposing them through `OptionsDefaults`.

packages/scripts/dist/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DonationAmount, DonationFrequency, EnForm, ProcessingFees, Country, } from "./events";
2-
import { AmountLabel, Loader, ProgressBar, UpsellLightbox, ENGrid, OptionsDefaults, setRecurrFreq, PageBackground, MediaAttribution, ApplePay, A11y, CapitalizeFields, Ecard, ClickToExpand, Advocacy, DataAttributes, LiveVariables, iFrame, InputPlaceholders, InputHasValueAndFocus, ShowHideRadioCheckboxes, AutoCountrySelect, SkipToMainContentLink, SrcDefer, NeverBounce, AutoYear, Autocomplete, RememberMe, TranslateFields, ShowIfAmount, EngridLogger, OtherAmount, MinMaxAmount, Ticker, DataReplace, DataHide, AddNameToMessage, ExpandRegionName, AppVersion, UrlToForm, RequiredIfVisible, TidyContact, DataLayer, LiveCurrency, Autosubmit, EventTickets, SwapAmounts, DebugPanel, DebugHiddenFields, FreshAddress, BrandingHtml, CountryDisable, PremiumGift, DigitalWallets, MobileCTA, LiveFrequency, UniversalOptIn, Plaid, GiveBySelect, UrlParamsToBodyAttrs, ExitIntentLightbox, SupporterHub, FastFormFill, SetAttr, ShowIfPresent, ENValidators, CustomCurrency, VGS, PostalCodeValidator, CountryRedirect, WelcomeBack, EcardToTarget, UsOnlyForm, ThankYouPageConditionalContent, EmbeddedEcard, CheckboxLabel, UpsellCheckbox, PostDonationEmbed, FrequencyUpsell, CustomPremium, PreferredPaymentMethod, } from ".";
2+
import { AmountLabel, Loader, ProgressBar, UpsellLightbox, ENGrid, OptionsDefaults, setRecurrFreq, PageBackground, MediaAttribution, ApplePay, A11y, CapitalizeFields, Ecard, ClickToExpand, Advocacy, DataAttributes, LiveVariables, iFrame, InputPlaceholders, InputHasValueAndFocus, ShowHideRadioCheckboxes, AutoCountrySelect, SkipToMainContentLink, SrcDefer, NeverBounce, AutoYear, Autocomplete, RememberMe, TranslateFields, ShowIfAmount, EngridLogger, OtherAmount, MinMaxAmount, Ticker, DataReplace, DataHide, AddNameToMessage, ExpandRegionName, AppVersion, UrlToForm, RequiredIfVisible, TidyContact, DataLayer, LiveCurrency, Autosubmit, EventTickets, SwapAmounts, DebugPanel, DebugHiddenFields, FreshAddress, BrandingHtml, CountryDisable, PremiumGift, DigitalWallets, MobileCTA, LiveFrequency, UniversalOptIn, StripeFinancialConnections, GiveBySelect, UrlParamsToBodyAttrs, ExitIntentLightbox, SupporterHub, FastFormFill, SetAttr, ShowIfPresent, ENValidators, CustomCurrency, VGS, PostalCodeValidator, CountryRedirect, WelcomeBack, EcardToTarget, UsOnlyForm, ThankYouPageConditionalContent, EmbeddedEcard, CheckboxLabel, UpsellCheckbox, PostDonationEmbed, FrequencyUpsell, CustomPremium, PreferredPaymentMethod, } from ".";
33
export class App extends ENGrid {
44
constructor(options) {
55
super();
@@ -262,9 +262,7 @@ export class App extends ENGrid {
262262
new LiveFrequency();
263263
// Universal Opt In
264264
new UniversalOptIn();
265-
// Plaid
266-
if (this.options.Plaid)
267-
new Plaid();
265+
new StripeFinancialConnections();
268266
//Exit Intent Lightbox
269267
new ExitIntentLightbox();
270268
new UrlParamsToBodyAttrs();

packages/scripts/dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export * from "./digital-wallets";
6363
export * from "./mobile-cta";
6464
export * from "./live-frequency";
6565
export * from "./universal-opt-in";
66-
export * from "./plaid";
66+
export * from "./stripe-financial-connections";
6767
export * from "./give-by-select";
6868
export * from "./url-params-to-body-attrs";
6969
export * from "./exit-intent-lightbox";

packages/scripts/dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export * from "./digital-wallets";
6363
export * from "./mobile-cta";
6464
export * from "./live-frequency";
6565
export * from "./universal-opt-in";
66-
export * from "./plaid";
66+
export * from "./stripe-financial-connections";
6767
export * from "./give-by-select";
6868
export * from "./url-params-to-body-attrs";
6969
export * from "./exit-intent-lightbox";

packages/scripts/dist/interfaces/options.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export interface Options {
8282
}[];
8383
PageLayouts?: string[];
8484
CountryDisable?: string[];
85-
Plaid?: boolean;
8685
Placeholders?: false | {
8786
[key: string]: string;
8887
};

packages/scripts/dist/interfaces/options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const OptionsDefaults = {
3131
TidyContact: false,
3232
RegionLongFormat: "",
3333
CountryDisable: [],
34-
Plaid: false,
3534
Placeholders: false,
3635
ENValidators: false,
3736
MobileCTA: false,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* This component improves EN's implementation of Stripe Financial Connections.
3+
* Enhancements:
4+
* - When the modal is closed, it re-enables the submit button.
5+
*/
6+
export declare class StripeFinancialConnections {
7+
private stripeModalOpen;
8+
private logger;
9+
constructor();
10+
isStripeModalNode(node: Node): boolean;
11+
isStripeModalNodeWIthIframe(node: Node): boolean;
12+
onStripeModalOpen(): void;
13+
onStripeModalClose(): void;
14+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* This component improves EN's implementation of Stripe Financial Connections.
3+
* Enhancements:
4+
* - When the modal is closed, it re-enables the submit button.
5+
*/
6+
import { ENGrid, EngridLogger } from ".";
7+
export class StripeFinancialConnections {
8+
constructor() {
9+
this.stripeModalOpen = false;
10+
this.logger = new EngridLogger("Stripe Financial Connections", "black", "pink", "🏛️");
11+
const observer = new MutationObserver((mutations) => {
12+
mutations.forEach((mutation) => {
13+
mutation.addedNodes.forEach((node) => {
14+
if (!this.stripeModalOpen && this.isStripeModalNodeWIthIframe(node)) {
15+
this.logger.log("Stripe Financial Connections modal opened.");
16+
this.onStripeModalOpen();
17+
}
18+
});
19+
mutation.removedNodes.forEach((node) => {
20+
if (this.stripeModalOpen && this.isStripeModalNode(node)) {
21+
this.logger.log("Stripe Financial Connections modal closed.");
22+
this.onStripeModalClose();
23+
}
24+
});
25+
});
26+
});
27+
observer.observe(document.body, {
28+
childList: true,
29+
subtree: true,
30+
});
31+
}
32+
isStripeModalNode(node) {
33+
return (node instanceof HTMLElement &&
34+
node.hasAttribute("data-react-aria-top-layer"));
35+
}
36+
isStripeModalNodeWIthIframe(node) {
37+
return !!(this.isStripeModalNode(node) &&
38+
node instanceof HTMLElement &&
39+
node.querySelector('iframe[src*="js.stripe.com"]'));
40+
}
41+
onStripeModalOpen() {
42+
this.stripeModalOpen = true;
43+
}
44+
onStripeModalClose() {
45+
this.stripeModalOpen = false;
46+
ENGrid.enableSubmit();
47+
}
48+
}

packages/scripts/dist/supporter-hub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class SupporterHub {
3434
}
3535
});
3636
});
37-
// Start observing the Link ID #plaid-link-button
37+
// Start observing the Link ID
3838
observer.observe(form, {
3939
childList: true,
4040
subtree: true,

packages/scripts/src/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import {
6464
MobileCTA,
6565
LiveFrequency,
6666
UniversalOptIn,
67-
Plaid,
67+
StripeFinancialConnections,
6868
GiveBySelect,
6969
UrlParamsToBodyAttrs,
7070
ExitIntentLightbox,
@@ -433,8 +433,7 @@ export class App extends ENGrid {
433433
// Universal Opt In
434434
new UniversalOptIn();
435435

436-
// Plaid
437-
if (this.options.Plaid) new Plaid();
436+
new StripeFinancialConnections();
438437

439438
//Exit Intent Lightbox
440439
new ExitIntentLightbox();

0 commit comments

Comments
 (0)