@internetarchive/donation-form 0.5.7-alpha.2 → 0.5.8-alpha.3

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.
@@ -91,10 +91,10 @@ export class PaymentClients {
91
91
  generator: () => __awaiter(this, void 0, void 0, function* () {
92
92
  yield this.lazyLoader.loadScript({
93
93
  src: 'https://www.paypalobjects.com/api/checkout.js',
94
- attributes: [
95
- { key: 'data-version-4', value: '' },
96
- { key: 'log-level', value: 'warn' },
97
- ],
94
+ attributes: {
95
+ 'data-version-4': '',
96
+ 'log-level': 'warn',
97
+ },
98
98
  });
99
99
  return window.paypal;
100
100
  }),
@@ -110,7 +110,7 @@ export class PaymentClients {
110
110
  const extension = this.environment === HostingEnvironment.Production ? 'min.js' : 'js';
111
111
  const scriptWithSuffix = `${scriptName}.${extension}`;
112
112
  const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptWithSuffix}`;
113
- return this.lazyLoader.loadScript({ src: url });
113
+ yield this.lazyLoader.loadScript({ src: url });
114
114
  });
115
115
  }
116
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"payment-clients.js","sourceRoot":"","sources":["../../../src/braintree-manager/payment-clients.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAiB5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAiGzB,YAAY,UAAsC,EAAE,WAA+B;QAhGnF,oBAAe,GAAG,IAAI,iBAAiB,CAAmB;YACxD,SAAS,EAAE,GAAoC,EAAE;gBAC/C,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;gBACzC,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YACjC,CAAC,CAAA;SACF,CAAC,CAAC;QAEH,kBAAa,GAAG,IAAI,iBAAiB,CAA0B;YAC7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EAAE,EAAE,EAAE;wBACpC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;qBACpC;iBACF,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC,MAAM,CAAC;YACvB,CAAC,CAAA;SACF,CAAC,CAAC;QAeK,qBAAgB,GAAG,QAAQ,CAAC;QAE5B,gBAAW,GAAuB,kBAAkB,CAAC,WAAW,CAAC;QAdvE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,8DAA8D;IAChD,mBAAmB,CAAC,UAAkB;;YAClD,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,KAAK,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;YACvF,MAAM,gBAAgB,GAAG,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;YACtD,MAAM,GAAG,GAAG,uCAAuC,IAAI,CAAC,gBAAgB,OAAO,gBAAgB,EAAE,CAAC;YAClG,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAClD,CAAC;KAAA;CAOF","sourcesContent":["import { LazyLoaderServiceInterface } from '@internetarchive/lazy-loader-service';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { HostingEnvironment } from './braintree-interfaces';\n\nexport interface PaymentClientsInterface {\n braintreeClient: PromisedSingleton<braintree.Client>;\n dataCollector: PromisedSingleton<braintree.DataCollector>;\n hostedFields: PromisedSingleton<braintree.HostedFields>;\n venmo: PromisedSingleton<braintree.Venmo>;\n payPal: PromisedSingleton<braintree.PayPalCheckout>;\n applePay: PromisedSingleton<braintree.ApplePay>;\n googlePayBraintreeClient: PromisedSingleton<braintree.GooglePayment>;\n\n googlePaymentsClient: PromisedSingleton<google.payments.api.PaymentsClient>;\n recaptchaLibrary: PromisedSingleton<ReCaptchaV2.ReCaptcha>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n paypalLibrary: PromisedSingleton<any>;\n}\n\n/**\n * The PaymentClients class is responsible for loading and passing around\n * all of the payment libraries. Internally it uses the LazyLoaderService to lazy load\n * the javascript clients.\n *\n * For instance, it carries around the braintree and paypal libraries, as well as the specific\n * payment-provider clients for each of the providers. This allows us to pass around typed\n * objects instead of the untyped libraries we get from the providers.\n *\n * @export\n * @class PaymentClients\n * @implements {PaymentClientsInterface}\n */\nexport class PaymentClients implements PaymentClientsInterface {\n braintreeClient = new PromisedSingleton<braintree.Client>({\n generator: async (): Promise<braintree.Client> => {\n await this.loadBraintreeScript('client');\n return window.braintree.client;\n },\n });\n\n dataCollector = new PromisedSingleton<braintree.DataCollector>({\n generator: async (): Promise<braintree.DataCollector> => {\n await this.loadBraintreeScript('data-collector');\n return window.braintree.dataCollector;\n },\n });\n\n hostedFields = new PromisedSingleton<braintree.HostedFields>({\n generator: async (): Promise<braintree.HostedFields> => {\n await this.loadBraintreeScript('hosted-fields');\n return window.braintree.hostedFields;\n },\n });\n\n venmo = new PromisedSingleton<braintree.Venmo>({\n generator: async (): Promise<braintree.Venmo> => {\n await this.loadBraintreeScript('venmo');\n return window.braintree.venmo;\n },\n });\n\n payPal = new PromisedSingleton<braintree.PayPalCheckout>({\n generator: async (): Promise<braintree.PayPalCheckout> => {\n await this.loadBraintreeScript('paypal-checkout');\n return window.braintree.paypalCheckout;\n },\n });\n\n applePay = new PromisedSingleton<braintree.ApplePay>({\n generator: async (): Promise<braintree.ApplePay> => {\n await this.loadBraintreeScript('apple-pay');\n return window.braintree.applePay;\n },\n });\n\n googlePayBraintreeClient = new PromisedSingleton<braintree.GooglePayment>({\n generator: async (): Promise<braintree.GooglePayment> => {\n await this.loadBraintreeScript('google-payment');\n return window.braintree.googlePayment;\n },\n });\n\n googlePaymentsClient = new PromisedSingleton<google.payments.api.PaymentsClient>({\n generator: async (): Promise<google.payments.api.PaymentsClient> => {\n await this.lazyLoader.loadScript({ src: 'https://pay.google.com/gp/p/js/pay.js' });\n return new google.payments.api.PaymentsClient({\n environment: this.environment === HostingEnvironment.Development ? 'TEST' : 'PRODUCTION',\n });\n },\n });\n\n recaptchaLibrary = new PromisedSingleton<ReCaptchaV2.ReCaptcha>({\n generator: (): Promise<ReCaptchaV2.ReCaptcha> =>\n new Promise(resolve => {\n // The loader for the recaptcha library is relying on an onload callback from the recaptcha\n // library because even when the library has loaded, it is still not ready\n // As recommended by Recaptcha, we attach a callback to the window object before starting\n // the load and remove it once the load is complete and resolve the promise.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).donationFormGrecaptchaLoadedCallback = (): void => {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delete (window as any).donationFormGrecaptchaLoadedCallback;\n }, 10);\n resolve(window.grecaptcha);\n };\n\n this.lazyLoader.loadScript({\n src:\n 'https://www.google.com/recaptcha/api.js?onload=donationFormGrecaptchaLoadedCallback&render=explicit',\n });\n }),\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n paypalLibrary = new PromisedSingleton<any>({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n generator: async (): Promise<any> => {\n await this.lazyLoader.loadScript({\n src: 'https://www.paypalobjects.com/api/checkout.js',\n attributes: [\n { key: 'data-version-4', value: '' },\n { key: 'log-level', value: 'warn' },\n ],\n });\n return window.paypal;\n },\n });\n\n constructor(lazyLoader: LazyLoaderServiceInterface, environment: HostingEnvironment) {\n this.lazyLoader = lazyLoader;\n this.environment = environment;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private async loadBraintreeScript(scriptName: string): Promise<any> {\n const extension = this.environment === HostingEnvironment.Production ? 'min.js' : 'js';\n const scriptWithSuffix = `${scriptName}.${extension}`;\n const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptWithSuffix}`;\n return this.lazyLoader.loadScript({ src: url });\n }\n\n private braintreeVersion = '3.62.2';\n\n private environment: HostingEnvironment = HostingEnvironment.Development;\n\n private lazyLoader: LazyLoaderServiceInterface;\n}\n"]}
1
+ {"version":3,"file":"payment-clients.js","sourceRoot":"","sources":["../../../src/braintree-manager/payment-clients.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAiB5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAiGzB,YAAY,UAAsC,EAAE,WAA+B;QAhGnF,oBAAe,GAAG,IAAI,iBAAiB,CAAmB;YACxD,SAAS,EAAE,GAAoC,EAAE;gBAC/C,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;gBACzC,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YACjC,CAAC,CAAA;SACF,CAAC,CAAC;QAEH,kBAAa,GAAG,IAAI,iBAAiB,CAA0B;YAC7D,SAAS,EAAE,GAA2C,EAAE;gBACtD,MAAM,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;gBACjD,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC;YACxC,CAAC,CAAA;SACF,CAAC,CAAC;QAEH,iBAAY,GAAG,IAAI,iBAAiB,CAAyB;YAC3D,SAAS,EAAE,GAA0C,EAAE;gBACrD,MAAM,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;gBAChD,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,CAAC,CAAA;SACF,CAAC,CAAC;QAEH,UAAK,GAAG,IAAI,iBAAiB,CAAkB;YAC7C,SAAS,EAAE,GAAmC,EAAE;gBAC9C,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBACxC,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;YAChC,CAAC,CAAA;SACF,CAAC,CAAC;QAEH,WAAM,G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UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACjD,CAAC;KAAA;CAOF","sourcesContent":["import { LazyLoaderServiceInterface } from '@internetarchive/lazy-loader-service';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { HostingEnvironment } from './braintree-interfaces';\n\nexport interface PaymentClientsInterface {\n braintreeClient: PromisedSingleton<braintree.Client>;\n dataCollector: PromisedSingleton<braintree.DataCollector>;\n hostedFields: PromisedSingleton<braintree.HostedFields>;\n venmo: PromisedSingleton<braintree.Venmo>;\n payPal: PromisedSingleton<braintree.PayPalCheckout>;\n applePay: PromisedSingleton<braintree.ApplePay>;\n googlePayBraintreeClient: PromisedSingleton<braintree.GooglePayment>;\n\n googlePaymentsClient: PromisedSingleton<google.payments.api.PaymentsClient>;\n recaptchaLibrary: PromisedSingleton<ReCaptchaV2.ReCaptcha>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n paypalLibrary: PromisedSingleton<any>;\n}\n\n/**\n * The PaymentClients class is responsible for loading and passing around\n * all of the payment libraries. Internally it uses the LazyLoaderService to lazy load\n * the javascript clients.\n *\n * For instance, it carries around the braintree and paypal libraries, as well as the specific\n * payment-provider clients for each of the providers. This allows us to pass around typed\n * objects instead of the untyped libraries we get from the providers.\n *\n * @export\n * @class PaymentClients\n * @implements {PaymentClientsInterface}\n */\nexport class PaymentClients implements PaymentClientsInterface {\n braintreeClient = new PromisedSingleton<braintree.Client>({\n generator: async (): Promise<braintree.Client> => {\n await this.loadBraintreeScript('client');\n return window.braintree.client;\n },\n });\n\n dataCollector = new PromisedSingleton<braintree.DataCollector>({\n generator: async (): Promise<braintree.DataCollector> => {\n await this.loadBraintreeScript('data-collector');\n return window.braintree.dataCollector;\n },\n });\n\n hostedFields = new PromisedSingleton<braintree.HostedFields>({\n generator: async (): Promise<braintree.HostedFields> => {\n await this.loadBraintreeScript('hosted-fields');\n return window.braintree.hostedFields;\n },\n });\n\n venmo = new PromisedSingleton<braintree.Venmo>({\n generator: async (): Promise<braintree.Venmo> => {\n await this.loadBraintreeScript('venmo');\n return window.braintree.venmo;\n },\n });\n\n payPal = new PromisedSingleton<braintree.PayPalCheckout>({\n generator: async (): Promise<braintree.PayPalCheckout> => {\n await this.loadBraintreeScript('paypal-checkout');\n return window.braintree.paypalCheckout;\n },\n });\n\n applePay = new PromisedSingleton<braintree.ApplePay>({\n generator: async (): Promise<braintree.ApplePay> => {\n await this.loadBraintreeScript('apple-pay');\n return window.braintree.applePay;\n },\n });\n\n googlePayBraintreeClient = new PromisedSingleton<braintree.GooglePayment>({\n generator: async (): Promise<braintree.GooglePayment> => {\n await this.loadBraintreeScript('google-payment');\n return window.braintree.googlePayment;\n },\n });\n\n googlePaymentsClient = new PromisedSingleton<google.payments.api.PaymentsClient>({\n generator: async (): Promise<google.payments.api.PaymentsClient> => {\n await this.lazyLoader.loadScript({ src: 'https://pay.google.com/gp/p/js/pay.js' });\n return new google.payments.api.PaymentsClient({\n environment: this.environment === HostingEnvironment.Development ? 'TEST' : 'PRODUCTION',\n });\n },\n });\n\n recaptchaLibrary = new PromisedSingleton<ReCaptchaV2.ReCaptcha>({\n generator: (): Promise<ReCaptchaV2.ReCaptcha> =>\n new Promise(resolve => {\n // The loader for the recaptcha library is relying on an onload callback from the recaptcha\n // library because even when the library has loaded, it is still not ready\n // As recommended by Recaptcha, we attach a callback to the window object before starting\n // the load and remove it once the load is complete and resolve the promise.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).donationFormGrecaptchaLoadedCallback = (): void => {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delete (window as any).donationFormGrecaptchaLoadedCallback;\n }, 10);\n resolve(window.grecaptcha);\n };\n\n this.lazyLoader.loadScript({\n src:\n 'https://www.google.com/recaptcha/api.js?onload=donationFormGrecaptchaLoadedCallback&render=explicit',\n });\n }),\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n paypalLibrary = new PromisedSingleton<any>({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n generator: async (): Promise<any> => {\n await this.lazyLoader.loadScript({\n src: 'https://www.paypalobjects.com/api/checkout.js',\n attributes: {\n 'data-version-4': '',\n 'log-level': 'warn',\n },\n });\n return window.paypal;\n },\n });\n\n constructor(lazyLoader: LazyLoaderServiceInterface, environment: HostingEnvironment) {\n this.lazyLoader = lazyLoader;\n this.environment = environment;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private async loadBraintreeScript(scriptName: string): Promise<void> {\n const extension = this.environment === HostingEnvironment.Production ? 'min.js' : 'js';\n const scriptWithSuffix = `${scriptName}.${extension}`;\n const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptWithSuffix}`;\n await this.lazyLoader.loadScript({ src: url });\n }\n\n private braintreeVersion = '3.62.2';\n\n private environment: HostingEnvironment = HostingEnvironment.Development;\n\n private lazyLoader: LazyLoaderServiceInterface;\n}\n"]}
@@ -63,7 +63,8 @@ let DonationFormController = class DonationFormController extends LitElement {
63
63
  changedProperties.has('recaptchaElement')) {
64
64
  this.setupPaymentFlowHandlers();
65
65
  }
66
- if (changedProperties.has('environment') && this.environment && !this.paymentClients) {
66
+ if ((changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&
67
+ this.environment) {
67
68
  this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);
68
69
  }
69
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,EAAE,cAAc,EAA2B,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AEtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAiB;AAEhB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAAqD;AAEpD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsC;AAErC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAAgC;AAE/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAoD;AAEnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAA0C;AAGrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAC6C;AAEhD;IAAvB,KAAK,CAAC,eAAe,CAAC;4DAAqC;AAE5B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;oEAAiD;AAEvD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;iEAA8C;AAEtC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;4EAAyD;AAErD;IAAlC,KAAK,CAAC,0BAA0B,CAAC;qEAAgD;AAE3D;IAAtB,KAAK,CAAC,cAAc,CAAC;2DAAmC;AA1D9C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CAgelC;SAheY,sBAAsB","sourcesContent":["import { LitElement, html, PropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card';\nimport calendarImg from '@internetarchive/icon-calendar';\nimport lockImg from '@internetarchive/icon-lock';\nimport { AnalyticsHandlerInterface } from './@types/analytics-handler';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsHandlerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLInputElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLInputElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLInputElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (changedProperties.has('environment') && this.environment && !this.paymentClients) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider);\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} name Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(name: string, label?: string): void {\n this.analyticsHandler?.send_event(this.analyticsCategory, name, label);\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM, it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n </style>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,EAAE,cAAc,EAA2B,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAMzE,OAAO,EACL,mBAAmB,GAEpB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAA6B,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AACxH,OAAO,EAEL,oBAAoB,GACrB,MAAM,0EAA0E,CAAC;AAElF,OAAO,8BAA8B,CAAC;AAEtC,OAAO,2CAA2C,CAAC;AAEnD,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAC9D,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAEjD,OAAO,EACL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACL,mBAAmB,EAEnB,YAAY,EACZ,sBAA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,EAAE,CAAC;mEAAoD;AAEnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAA0C;AAGrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAC6C;AAEhD;IAAvB,KAAK,CAAC,eAAe,CAAC;4DAAqC;AAE5B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;oEAAiD;AAEvD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;iEAA8C;AAEtC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;4EAAyD;AAErD;IAAlC,KAAK,CAAC,0BAA0B,CAAC;qEAAgD;AAE3D;IAAtB,KAAK,CAAC,cAAc,CAAC;2DAAmC;AA1D9C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CAmelC;SAneY,sBAAsB","sourcesContent":["import { LitElement, html, PropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card';\nimport calendarImg from '@internetarchive/icon-calendar';\nimport lockImg from '@internetarchive/icon-lock';\nimport { AnalyticsHandlerInterface } from './@types/analytics-handler';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsHandlerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLInputElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLInputElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLInputElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (\n (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&\n this.environment\n ) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider);\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} name Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(name: string, label?: string): void {\n this.analyticsHandler?.send_event(this.analyticsCategory, name, label);\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM, it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n </style>\n `;\n }\n}\n"]}
@@ -1,15 +1,15 @@
1
- import { LazyLoaderServiceInterface, BundleType } from '@internetarchive/lazy-loader-service';
1
+ import { LazyLoaderServiceEvents, LazyLoaderServiceInterface, BundleType } from '@internetarchive/lazy-loader-service';
2
+ import { Unsubscribe } from 'nanoevents';
2
3
  export declare class MockLazyLoader implements LazyLoaderServiceInterface {
4
+ private emitter;
5
+ on<E extends keyof LazyLoaderServiceEvents>(event: E, callback: LazyLoaderServiceEvents[E]): Unsubscribe;
3
6
  loadBundle(bundle: {
4
7
  module?: string | undefined;
5
8
  nomodule?: string | undefined;
6
- }): Promise<Event | undefined>;
9
+ }): Promise<void>;
7
10
  loadScript(options: {
8
11
  src: string;
9
12
  bundleType?: BundleType | undefined;
10
- attributes?: {
11
- key: string;
12
- value: any;
13
- }[] | undefined;
14
- }): Promise<Event>;
13
+ attributes?: Record<string, string> | undefined;
14
+ }): Promise<void>;
15
15
  }
@@ -1,13 +1,33 @@
1
1
  import { __awaiter } from "tslib";
2
+ import { createNanoEvents } from 'nanoevents';
2
3
  export class MockLazyLoader {
4
+ constructor() {
5
+ this.emitter = createNanoEvents();
6
+ // async loadBundle(bundle: {
7
+ // module?: string | undefined;
8
+ // nomodule?: string | undefined;
9
+ // }): Promise<Event | undefined> {
10
+ // return new Event('done');
11
+ // }
12
+ // async loadScript(options: {
13
+ // src: string;
14
+ // bundleType?: BundleType | undefined;
15
+ // attributes?: { key: string; value: any }[] | undefined;
16
+ // }): Promise<Event> {
17
+ // return new Event('done');
18
+ // }
19
+ }
20
+ on(event, callback) {
21
+ return this.emitter.on(event, callback);
22
+ }
3
23
  loadBundle(bundle) {
4
24
  return __awaiter(this, void 0, void 0, function* () {
5
- return new Event('done');
25
+ return;
6
26
  });
7
27
  }
8
28
  loadScript(options) {
9
29
  return __awaiter(this, void 0, void 0, function* () {
10
- return new Event('done');
30
+ return;
11
31
  });
12
32
  }
13
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mock-lazy-loader.js","sourceRoot":"","sources":["../../../test/mocks/mock-lazy-loader.ts"],"names":[],"mappings":";AAIA,MAAM,OAAO,cAAc;IACnB,UAAU,CAAC,MAGhB;;YACC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;KAAA;IACK,UAAU,CAAC,OAIhB;;YACC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;KAAA;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { LazyLoaderServiceInterface, BundleType } from '@internetarchive/lazy-loader-service';\n\nexport class MockLazyLoader implements LazyLoaderServiceInterface {\n async loadBundle(bundle: {\n module?: string | undefined;\n nomodule?: string | undefined;\n }): Promise<Event | undefined> {\n return new Event('done');\n }\n async loadScript(options: {\n src: string;\n bundleType?: BundleType | undefined;\n attributes?: { key: string; value: any }[] | undefined;\n }): Promise<Event> {\n return new Event('done');\n }\n}\n"]}
1
+ {"version":3,"file":"mock-lazy-loader.js","sourceRoot":"","sources":["../../../test/mocks/mock-lazy-loader.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,cAAc;IAA3B;QACU,YAAO,GAAG,gBAAgB,EAA2B,CAAC;QAuB9D,6BAA6B;QAC7B,iCAAiC;QACjC,mCAAmC;QACnC,mCAAmC;QACnC,8BAA8B;QAC9B,IAAI;QACJ,8BAA8B;QAC9B,iBAAiB;QACjB,yCAAyC;QACzC,4DAA4D;QAC5D,uBAAuB;QACvB,8BAA8B;QAC9B,IAAI;IACN,CAAC;IAlCC,EAAE,CACA,KAAQ,EACR,QAAoC;QAEpC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEK,UAAU,CAAC,MAGhB;;YACC,OAAO;QACT,CAAC;KAAA;IAEK,UAAU,CAAC,OAIhB;;YACC,OAAO;QACT,CAAC;KAAA;CAcF","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n LazyLoaderServiceEvents,\n LazyLoaderServiceInterface,\n BundleType,\n} from '@internetarchive/lazy-loader-service';\nimport { createNanoEvents, Unsubscribe } from 'nanoevents';\n\nexport class MockLazyLoader implements LazyLoaderServiceInterface {\n private emitter = createNanoEvents<LazyLoaderServiceEvents>();\n\n on<E extends keyof LazyLoaderServiceEvents>(\n event: E,\n callback: LazyLoaderServiceEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n async loadBundle(bundle: {\n module?: string | undefined;\n nomodule?: string | undefined;\n }): Promise<void> {\n return;\n }\n\n async loadScript(options: {\n src: string;\n bundleType?: BundleType | undefined;\n attributes?: Record<string, string> | undefined;\n }): Promise<void> {\n return;\n }\n // async loadBundle(bundle: {\n // module?: string | undefined;\n // nomodule?: string | undefined;\n // }): Promise<Event | undefined> {\n // return new Event('done');\n // }\n // async loadScript(options: {\n // src: string;\n // bundleType?: BundleType | undefined;\n // attributes?: { key: string; value: any }[] | undefined;\n // }): Promise<Event> {\n // return new Event('done');\n // }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/donation-form",
3
- "version": "0.5.7-alpha.2",
3
+ "version": "0.5.8-alpha.3",
4
4
  "description": "The Internet Archive Donation Form",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "dist/index.js",
@@ -32,18 +32,18 @@
32
32
  "@internetarchive/donation-form-data-models": "^0.3.2",
33
33
  "@internetarchive/donation-form-edit-donation": "^0.3.11",
34
34
  "@internetarchive/donation-form-section": "^0.3.3",
35
- "@internetarchive/icon-applepay": "1.3.2-alpha.0",
36
- "@internetarchive/icon-calendar": "1.3.2-alpha.0",
37
- "@internetarchive/icon-credit-card": "1.3.2-alpha.0",
38
- "@internetarchive/icon-email": "1.3.2-alpha.0",
39
- "@internetarchive/icon-googlepay": "1.3.2-alpha.0",
40
- "@internetarchive/icon-locale-pin": "1.3.2-alpha.0",
41
- "@internetarchive/icon-lock": "1.3.2-alpha.0",
42
- "@internetarchive/icon-paypal": "1.3.2-alpha.0",
43
- "@internetarchive/icon-user": "1.3.2-alpha.0",
44
- "@internetarchive/icon-venmo": "1.3.2-alpha.0",
45
- "@internetarchive/lazy-loader-service": "^0.1.0",
46
- "@internetarchive/modal-manager": "0.2.1-alpha.0",
35
+ "@internetarchive/icon-applepay": "^1.3.2",
36
+ "@internetarchive/icon-calendar": "^1.3.2",
37
+ "@internetarchive/icon-credit-card": "^1.3.2",
38
+ "@internetarchive/icon-email": "^1.3.2",
39
+ "@internetarchive/icon-googlepay": "^1.3.2",
40
+ "@internetarchive/icon-locale-pin": "^1.3.2",
41
+ "@internetarchive/icon-lock": "^1.3.2",
42
+ "@internetarchive/icon-paypal": "^1.3.2",
43
+ "@internetarchive/icon-user": "^1.3.2",
44
+ "@internetarchive/icon-venmo": "^1.3.2",
45
+ "@internetarchive/lazy-loader-service": "0.2.0-alpha.2",
46
+ "@internetarchive/modal-manager": "^0.2.1",
47
47
  "@internetarchive/promised-singleton": "^0.2.1",
48
48
  "currency.js": "^2.0.2",
49
49
  "lit": "^2.0.2",
@@ -118,10 +118,10 @@ export class PaymentClients implements PaymentClientsInterface {
118
118
  generator: async (): Promise<any> => {
119
119
  await this.lazyLoader.loadScript({
120
120
  src: 'https://www.paypalobjects.com/api/checkout.js',
121
- attributes: [
122
- { key: 'data-version-4', value: '' },
123
- { key: 'log-level', value: 'warn' },
124
- ],
121
+ attributes: {
122
+ 'data-version-4': '',
123
+ 'log-level': 'warn',
124
+ },
125
125
  });
126
126
  return window.paypal;
127
127
  },
@@ -133,11 +133,11 @@ export class PaymentClients implements PaymentClientsInterface {
133
133
  }
134
134
 
135
135
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
- private async loadBraintreeScript(scriptName: string): Promise<any> {
136
+ private async loadBraintreeScript(scriptName: string): Promise<void> {
137
137
  const extension = this.environment === HostingEnvironment.Production ? 'min.js' : 'js';
138
138
  const scriptWithSuffix = `${scriptName}.${extension}`;
139
139
  const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptWithSuffix}`;
140
- return this.lazyLoader.loadScript({ src: url });
140
+ await this.lazyLoader.loadScript({ src: url });
141
141
  }
142
142
 
143
143
  private braintreeVersion = '3.62.2';
@@ -156,7 +156,10 @@ export class DonationFormController extends LitElement {
156
156
  this.setupPaymentFlowHandlers();
157
157
  }
158
158
 
159
- if (changedProperties.has('environment') && this.environment && !this.paymentClients) {
159
+ if (
160
+ (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&
161
+ this.environment
162
+ ) {
160
163
  this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);
161
164
  }
162
165
  }