@internetarchive/donation-form 0.5.15-a4 → 0.5.15-a5

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.
@@ -38,7 +38,7 @@ export class BraintreeEndpointManager {
38
38
  }
39
39
  const service = encodeURI(response.paymentProvider);
40
40
  submitFormWith({
41
- action: `https://www-jasonb.archive.org/services/donate.php?service=${service}`,
41
+ action: `https://ia-petabox.archive.org/services/donate.php?service=${service}`,
42
42
  fields: payload,
43
43
  });
44
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"braintree-endpoint-manager.js","sourceRoot":"","sources":["../../demo/braintree-endpoint-manager.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAUnC,MAAM,OAAO,wBAAwB;IAC7B,UAAU,CAAC,OAAwB;;YACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,mFAAmF,EACnF;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,MAAM,EAAE,kBAAkB;iBAC3B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,CACF,CAAC;YACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAED,kBAAkB,CAAC,OAGlB;QACC,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;QACzC,MAAM,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAErD,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEhD,MAAM,OAAO,GAA0C;YACrD,MAAM,EAAE,GAAG,aAAa,EAAE;YAC1B,WAAW,EAAE,QAAQ,CAAC,cAAc;YACpC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY;YAClE,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS;YACvC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ;YACrC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK;SAC/B,CAAC;QAEF,IAAI,cAAc,EAAE;YAClB,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC;YAC3C,MAAM,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;YACrD,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;YACnD,OAAO,CAAC,eAAe,CAAC,GAAG,GAAG,mBAAmB,EAAE,CAAC;YACpD,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC;SAC9C;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEpD,cAAc,CAAC;YACb,MAAM,EAAE,8DAA8D,OAAO,EAAE;YAC/E,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\nimport { submitFormWith } from './submit-form-with';\nimport currency from 'currency.js';\n\nimport {\n SuccessResponse,\n DonationRequest,\n DonationResponse,\n} from '@internetarchive/donation-form-data-models';\n\nimport { BraintreeEndpointManagerInterface } from '../index';\n\nexport class BraintreeEndpointManager implements BraintreeEndpointManagerInterface {\n async submitData(request: DonationRequest): Promise<DonationResponse> {\n const response = await fetch(\n 'https://ia-petabox.archive.org/services/donations/braintree-charge.php?debug=true',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n body: JSON.stringify(request),\n },\n );\n const json = await response.json();\n return json;\n }\n\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n const response = options.successResponse;\n const upsellResponse = options.upsellSuccessResponse;\n\n const displayAmount = currency(response.amount);\n\n const payload: { [key: string]: string | undefined } = {\n amount: `${displayAmount}`,\n 'charge-id': response.transaction_id,\n 'donation-type': upsellResponse ? 'upsell' : response.donationType,\n first_name: response.customer.firstName,\n last_name: response.customer.lastName,\n email: response.customer.email,\n };\n\n if (upsellResponse) {\n const upsellAmount = upsellResponse.amount;\n const upsellChargeId = upsellResponse.transaction_id;\n const displayUpsellAmount = currency(upsellAmount);\n payload['upsell-amount'] = `${displayUpsellAmount}`;\n payload['upsell-charge-id'] = upsellChargeId;\n }\n\n const service = encodeURI(response.paymentProvider);\n\n submitFormWith({\n action: `https://www-jasonb.archive.org/services/donate.php?service=${service}`,\n fields: payload,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"braintree-endpoint-manager.js","sourceRoot":"","sources":["../../demo/braintree-endpoint-manager.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAUnC,MAAM,OAAO,wBAAwB;IAC7B,UAAU,CAAC,OAAwB;;YACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,mFAAmF,EACnF;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,MAAM,EAAE,kBAAkB;iBAC3B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,CACF,CAAC;YACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAED,kBAAkB,CAAC,OAGlB;QACC,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;QACzC,MAAM,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAErD,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEhD,MAAM,OAAO,GAA0C;YACrD,MAAM,EAAE,GAAG,aAAa,EAAE;YAC1B,WAAW,EAAE,QAAQ,CAAC,cAAc;YACpC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY;YAClE,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS;YACvC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ;YACrC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK;SAC/B,CAAC;QAEF,IAAI,cAAc,EAAE;YAClB,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC;YAC3C,MAAM,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;YACrD,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;YACnD,OAAO,CAAC,eAAe,CAAC,GAAG,GAAG,mBAAmB,EAAE,CAAC;YACpD,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC;SAC9C;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEpD,cAAc,CAAC;YACb,MAAM,EAAE,8DAA8D,OAAO,EAAE;YAC/E,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\nimport { submitFormWith } from './submit-form-with';\nimport currency from 'currency.js';\n\nimport {\n SuccessResponse,\n DonationRequest,\n DonationResponse,\n} from '@internetarchive/donation-form-data-models';\n\nimport { BraintreeEndpointManagerInterface } from '../index';\n\nexport class BraintreeEndpointManager implements BraintreeEndpointManagerInterface {\n async submitData(request: DonationRequest): Promise<DonationResponse> {\n const response = await fetch(\n 'https://ia-petabox.archive.org/services/donations/braintree-charge.php?debug=true',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n body: JSON.stringify(request),\n },\n );\n const json = await response.json();\n return json;\n }\n\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n const response = options.successResponse;\n const upsellResponse = options.upsellSuccessResponse;\n\n const displayAmount = currency(response.amount);\n\n const payload: { [key: string]: string | undefined } = {\n amount: `${displayAmount}`,\n 'charge-id': response.transaction_id,\n 'donation-type': upsellResponse ? 'upsell' : response.donationType,\n first_name: response.customer.firstName,\n last_name: response.customer.lastName,\n email: response.customer.email,\n };\n\n if (upsellResponse) {\n const upsellAmount = upsellResponse.amount;\n const upsellChargeId = upsellResponse.transaction_id;\n const displayUpsellAmount = currency(upsellAmount);\n payload['upsell-amount'] = `${displayUpsellAmount}`;\n payload['upsell-charge-id'] = upsellChargeId;\n }\n\n const service = encodeURI(response.paymentProvider);\n\n submitFormWith({\n action: `https://ia-petabox.archive.org/services/donate.php?service=${service}`,\n fields: payload,\n });\n }\n}\n"]}
@@ -40,14 +40,12 @@ let DonationFormController = class DonationFormController extends LitElement {
40
40
  var _a, _b, _c;
41
41
  if (changedProperties.has('referrer') && this.referrer) {
42
42
  (_a = this.braintreeManager) === null || _a === void 0 ? void 0 : _a.setReferrer(this.referrer);
43
- this.logDonationFlowEvent('referrer', this.referrer);
44
43
  }
45
44
  if (changedProperties.has('loggedInUser') && this.loggedInUser) {
46
45
  (_b = this.braintreeManager) === null || _b === void 0 ? void 0 : _b.setLoggedInUser(this.loggedInUser);
47
46
  }
48
47
  if (changedProperties.has('origin') && this.origin) {
49
48
  (_c = this.braintreeManager) === null || _c === void 0 ? void 0 : _c.setOrigin(this.origin);
50
- this.logDonationFlowEvent('origin', this.origin);
51
49
  }
52
50
  if (changedProperties.has('paymentClients') ||
53
51
  changedProperties.has('braintreeAuthToken') ||
@@ -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,EAA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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;oEAA+C;AAErD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;iEAA4C;AAEpC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;4EAAuD;AAEnD;IAAlC,KAAK,CAAC,0BAA0B,CAAC;qEAAgD;AAE3D;IAAtB,KAAK,CAAC,cAAc,CAAC;2DAAmC;AA1D9C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CA4iBlC;SA5iBY,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 { DonationControllerEventLoggerInterface } from './@types/analytics-handler';\nimport { AnalyticsManagerInterface, AnalyticsEvent } from '@internetarchive/analytics-manager';\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?: AnalyticsManagerInterface;\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!: HTMLDivElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLDivElement;\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 this.logDonationFlowEvent('referrer', 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 this.logDonationFlowEvent('origin', 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 showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\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 this.braintreeManager.on('paymentProvidersHostedFieldsRetry', (retryNumber: number) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n });\n this.dispatchEvent(event);\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsFailed', (error: unknown) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n });\n this.dispatchEvent(event);\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 resources: {\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n } as DonationControllerEventLoggerInterface,\n }\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 @paymentFlowConfirmed=${this.paymentFlowConfirmed}\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 paymentFlowConfirmed(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowConfirmed', providerNoSpaces);\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} action Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: this.analyticsCategory } as AnalyticsEvent;\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /**\n * Logs `DonationFlow` Event category into no sample bucket\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\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 {\n color: var(--donateFormTextColor, #333);\n background-color: var(--donateFormBgColor, transparent);\n\n --formSectionContentBackgroundColor: var(--donateFormBgColor, transparent);\n\n --editFormBadgeBgColor: var(--donateFormBadgeBgColor, #333);\n --formSectionBadgeBackgroundColor: var(--donateFormBadgeBgColor, #333);\n\n --editFormBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n --formSectionBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n\n --paymentButtonFontColor: var(--donateFormPaymentOptionTextColor);\n --paymentButtonColor: var(--donateFormPaymentOptionBgColor);\n\n --paymentButtonSelectedColor: var(--donateFormSelectedOptionBgColor);\n --paymentButtonSelectedFontColor: var(--donateFormSelectedOptionTextColor);\n }\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\n .donation-form-controller-container div[slot=\"braintree-hosted-fields\"] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
1
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,IAAI,EAAE,MAAM,EAAE,CAAC;iEAC6C;AAEhD;IAAvB,KAAK,CAAC,eAAe,CAAC;4DAAqC;AAE5B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;oEAA+C;AAErD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;iEAA4C;AAEpC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;4EAAuD;AAEnD;IAAlC,KAAK,CAAC,0BAA0B,CAAC;qEAAgD;AAE3D;IAAtB,KAAK,CAAC,cAAc,CAAC;2DAAmC;AA1D9C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CA0iBlC;SA1iBY,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 { DonationControllerEventLoggerInterface } from './@types/analytics-handler';\nimport { AnalyticsManagerInterface, AnalyticsEvent } from '@internetarchive/analytics-manager';\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?: AnalyticsManagerInterface;\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!: HTMLDivElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLDivElement;\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 showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\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 this.braintreeManager.on('paymentProvidersHostedFieldsRetry', (retryNumber: number) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n });\n this.dispatchEvent(event);\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsFailed', (error: unknown) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n });\n this.dispatchEvent(event);\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 resources: {\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n } as DonationControllerEventLoggerInterface,\n }\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 @paymentFlowConfirmed=${this.paymentFlowConfirmed}\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 paymentFlowConfirmed(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowConfirmed', providerNoSpaces);\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} action Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: this.analyticsCategory } as AnalyticsEvent;\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /**\n * Logs `DonationFlow` Event category into no sample bucket\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\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 {\n color: var(--donateFormTextColor, #333);\n background-color: var(--donateFormBgColor, transparent);\n\n --formSectionContentBackgroundColor: var(--donateFormBgColor, transparent);\n\n --editFormBadgeBgColor: var(--donateFormBadgeBgColor, #333);\n --formSectionBadgeBackgroundColor: var(--donateFormBadgeBgColor, #333);\n\n --editFormBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n --formSectionBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n\n --paymentButtonFontColor: var(--donateFormPaymentOptionTextColor);\n --paymentButtonColor: var(--donateFormPaymentOptionBgColor);\n\n --paymentButtonSelectedColor: var(--donateFormSelectedOptionBgColor);\n --paymentButtonSelectedFontColor: var(--donateFormSelectedOptionTextColor);\n }\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\n .donation-form-controller-container div[slot=\"braintree-hosted-fields\"] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
@@ -5,5 +5,4 @@ export declare class MockAnalyticHandler implements AnalyticsHandlerInterface {
5
5
  callLabel?: string;
6
6
  callAdditionalEventParams?: object;
7
7
  send_event(category: string, action: string, label?: string, additionalEventParams?: object): void;
8
- send_event_no_sampling(category: string, action: string, label?: string, additionalEventParams?: object): void;
9
8
  }
@@ -6,12 +6,5 @@ export class MockAnalyticHandler {
6
6
  this.callLabel = label;
7
7
  this.callAdditionalEventParams = additionalEventParams;
8
8
  }
9
- // eslint-disable-next-line @typescript-eslint/camelcase
10
- send_event_no_sampling(category, action, label, additionalEventParams) {
11
- this.callCategory = category;
12
- this.callAction = action;
13
- this.callLabel = label;
14
- this.callAdditionalEventParams = additionalEventParams;
15
- }
16
9
  }
17
10
  //# sourceMappingURL=mock-analytics-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-analytics-handler.js","sourceRoot":"","sources":["../../../test/mocks/mock-analytics-handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAM9B,wDAAwD;IACxD,UAAU,CACR,QAAgB,EAChB,MAAc,EACd,KAAc,EACd,qBAA8B;QAE9B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;IACzD,CAAC;IAED,wDAAwD;IACxD,sBAAsB,CACpB,QAAgB,EAChB,MAAc,EACd,KAAc,EACd,qBAA8B;QAE9B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { AnalyticsHandlerInterface } from '../../src/@types/analytics-handler';\n\nexport class MockAnalyticHandler implements AnalyticsHandlerInterface {\n callCategory?: string;\n callAction?: string;\n callLabel?: string;\n callAdditionalEventParams?: object;\n\n // eslint-disable-next-line @typescript-eslint/camelcase\n send_event(\n category: string,\n action: string,\n label?: string,\n additionalEventParams?: object,\n ): void {\n this.callCategory = category;\n this.callAction = action;\n this.callLabel = label;\n this.callAdditionalEventParams = additionalEventParams;\n }\n\n // eslint-disable-next-line @typescript-eslint/camelcase\n send_event_no_sampling(\n category: string,\n action: string,\n label?: string,\n additionalEventParams?: object,\n ): void {\n this.callCategory = category;\n this.callAction = action;\n this.callLabel = label;\n this.callAdditionalEventParams = additionalEventParams;\n }\n}\n"]}
1
+ {"version":3,"file":"mock-analytics-handler.js","sourceRoot":"","sources":["../../../test/mocks/mock-analytics-handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAM9B,wDAAwD;IACxD,UAAU,CACR,QAAgB,EAChB,MAAc,EACd,KAAc,EACd,qBAA8B;QAE9B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,yBAAyB,GAAG,qBAAqB,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { AnalyticsHandlerInterface } from '../../src/@types/analytics-handler';\n\nexport class MockAnalyticHandler implements AnalyticsHandlerInterface {\n callCategory?: string;\n callAction?: string;\n callLabel?: string;\n callAdditionalEventParams?: object;\n\n // eslint-disable-next-line @typescript-eslint/camelcase\n send_event(\n category: string,\n action: string,\n label?: string,\n additionalEventParams?: object,\n ): void {\n this.callCategory = category;\n this.callAction = action;\n this.callLabel = label;\n this.callAdditionalEventParams = additionalEventParams;\n }\n}\n"]}
@@ -28,7 +28,7 @@ describe('Donation Flow Modal Manager', () => {
28
28
  const manager = new DonationFlowModalManager({
29
29
  braintreeManager: mockBraintreeManager,
30
30
  modalManager: mockModalManager,
31
- analytics
31
+ analytics,
32
32
  });
33
33
  manager.closeModal();
34
34
  expect(mockModalManager.closeCalled).to.be.true;
@@ -58,7 +58,7 @@ describe('Donation Flow Modal Manager', () => {
58
58
  const manager = new DonationFlowModalManager({
59
59
  braintreeManager: mockBraintreeManager,
60
60
  modalManager: mockModalManager,
61
- analytics
61
+ analytics,
62
62
  });
63
63
  manager.showProcessingModal();
64
64
  const modalOptions = mockModalManager.showModalOptions;
@@ -78,7 +78,7 @@ describe('Donation Flow Modal Manager', () => {
78
78
  const manager = new DonationFlowModalManager({
79
79
  braintreeManager: mockBraintreeManager,
80
80
  modalManager: mockModalManager,
81
- analytics
81
+ analytics,
82
82
  });
83
83
  manager.showErrorModal({ message: 'foo-error' });
84
84
  const modalOptions = mockModalManager.showModalOptions;
@@ -103,7 +103,7 @@ describe('Donation Flow Modal Manager', () => {
103
103
  analytics: {
104
104
  logEvent,
105
105
  logDonationFlowEvent,
106
- }
106
+ },
107
107
  });
108
108
  manager.showThankYouModal({
109
109
  successResponse: mockSuccessResponse,
@@ -131,7 +131,7 @@ describe('Donation Flow Modal Manager', () => {
131
131
  analytics: {
132
132
  logEvent,
133
133
  logDonationFlowEvent,
134
- }
134
+ },
135
135
  });
136
136
  const successResponse = mockSuccessResponse;
137
137
  successResponse.paymentProvider = PaymentProvider.GooglePay;
@@ -152,7 +152,7 @@ describe('Donation Flow Modal Manager', () => {
152
152
  const manager = new DonationFlowModalManager({
153
153
  braintreeManager: mockBraintreeManager,
154
154
  modalManager: mockModalManager,
155
- analytics
155
+ analytics,
156
156
  });
157
157
  manager.showConfirmationStepModal({
158
158
  donationType: DonationType.Upsell,
@@ -175,7 +175,7 @@ describe('Donation Flow Modal Manager', () => {
175
175
  const manager = new DonationFlowModalManager({
176
176
  braintreeManager: mockBraintreeManager,
177
177
  modalManager: mockModalManager,
178
- analytics
178
+ analytics,
179
179
  });
180
180
  const result = yield manager.startDonationSubmissionFlow({
181
181
  nonce: 'foo',
@@ -1 +1 @@
1
- {"version":3,"file":"donation-flow-modal-manager.test.js","sourceRoot":"","sources":["../../../../test/tests/flow-handlers/donation-flow-modal-manager.test.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAA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BAClB,YAAY,EAAE,UAAU;gBACxB,kBAAkB,EAAE,KAAK;gBACzB,eAAe,EAAE,aAAa;gBAC9B,cAAc,EAAE,KAAK;aACtB;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\nimport { html, fixture, expect } from '@open-wc/testing';\nimport { DonationFlowModalManager } from '../../../src/payment-flow-handlers/donation-flow-modal-manager';\nimport { MockModalManager } from '../../mocks/mock-modal-manager';\nimport '../../mocks/mock-modal-manager';\nimport { MockBraintreeManager } from '../../mocks/mock-braintree-manager';\nimport { mockSuccessResponse } from '../../mocks/models/mock-success-response';\nimport {\n PaymentProvider,\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\nimport { mockBillingInfo } from '../../mocks/models/mock-billing-info';\nimport { mockCustomerInfo } from '../../mocks/models/mock-customer-info';\nimport { DonationControllerEventLoggerInterface } from '../../../src/@types/analytics-handler';\nimport sinon from 'sinon';\n\nlet analytics: DonationControllerEventLoggerInterface;\n\ndescribe('Donation Flow Modal Manager', () => {\n beforeEach(() => {\n analytics = {\n logEvent: sinon.fake(),\n logDonationFlowEvent: sinon.fake(),\n };\n });\n afterEach(() => {\n sinon.restore();\n });\n it('can close the modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics\n });\n manager.closeModal();\n expect(mockModalManager.closeCalled).to.be.true;\n });\n\n it('can calculate the proper default upsell amount', async () => {\n let amount = DonationFlowModalManager.getDefaultUpsellAmount(1);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10.01);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25.01);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100.01);\n expect(amount).to.equal(50);\n });\n\n it('can show the processing modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics\n });\n manager.showProcessingModal();\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#497fbf');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.processingImageMode).to.equal('processing');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.false;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Processing...');\n });\n\n it('can show the error modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics\n });\n manager.showErrorModal({ message: 'foo-error' });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#691916');\n expect(modalOptions?.config.showProcessingIndicator).to.be.false;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.headline?.strings[0]).to.contain(\n \"There's been a problem completing your donation.\",\n );\n expect(modalOptions?.config.message?.values[0]).to.equal('foo-error');\n });\n\n it('shows the thank you modal and calls `donationSuccessful` to take user to thank you page', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n }\n });\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.processingImageMode).to.equal('complete');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Thank You!');\n const response = mockBraintreeManager.donationSuccessfulOptions?.successResponse;\n expect(response).to.deep.equal(mockSuccessResponse);\n });\n\n it('donation submitted analytics gets sent when drawing thank you modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n }\n });\n const successResponse = mockSuccessResponse;\n successResponse.paymentProvider = PaymentProvider.GooglePay;\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n\n // fires analytics\n expect(logDonationFlowEvent.callCount).to.equal(1);\n expect(logDonationFlowEvent.args[0][0]).to.equal(`Donated-GooglePay`);\n expect(logDonationFlowEvent.args[0][1]).to.equal(DonationType.OneTime);\n });\n\n it('can show the confirmation modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics\n });\n manager.showConfirmationStepModal({\n donationType: DonationType.Upsell,\n amount: 8,\n currencyType: 'USD',\n cancelDonationCB: () => console.log('donation cancelled'),\n confirmDonationCB: () => console.log('donation confirmed'),\n });\n\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config?.title?.values).to.contain('Confirm monthly donation');\n });\n\n it('can start the donation submission flow', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics\n });\n const result = await manager.startDonationSubmissionFlow({\n nonce: 'foo',\n paymentProvider: PaymentProvider.CreditCard,\n donationInfo: new DonationPaymentInfo({\n donationType: DonationType.OneTime,\n amount: 5,\n coverFees: false,\n }),\n billingInfo: mockBillingInfo,\n customerInfo: mockCustomerInfo,\n });\n\n expect(result).to.deep.equal({\n success: true,\n value: {\n amount: 5,\n billing: {\n countryCodeAlpha2: 'US',\n extendedAddress: 'Apt 123',\n locality: 'San Francisco',\n postalCode: '12345',\n region: 'CA',\n streetAddress: '123 Fake St',\n },\n customer: {\n email: 'foo@bar.com',\n firstName: 'Fooey',\n lastName: 'McBarrison',\n },\n customer_id: 'bar',\n donationType: 'one-time',\n paymentMethodNonce: 'foo',\n paymentProvider: 'Credit Card',\n transaction_id: 'foo',\n },\n });\n });\n});\n"]}
1
+ {"version":3,"file":"donation-flow-modal-manager.test.js","sourceRoot":"","sources":["../../../../test/tests/flow-handlers/donation-flow-modal-manager.test.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA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C9B,cAAc,EAAE,KAAK;aACtB;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\nimport { html, fixture, expect } from '@open-wc/testing';\nimport { DonationFlowModalManager } from '../../../src/payment-flow-handlers/donation-flow-modal-manager';\nimport { MockModalManager } from '../../mocks/mock-modal-manager';\nimport '../../mocks/mock-modal-manager';\nimport { MockBraintreeManager } from '../../mocks/mock-braintree-manager';\nimport { mockSuccessResponse } from '../../mocks/models/mock-success-response';\nimport {\n PaymentProvider,\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\nimport { mockBillingInfo } from '../../mocks/models/mock-billing-info';\nimport { mockCustomerInfo } from '../../mocks/models/mock-customer-info';\nimport { DonationControllerEventLoggerInterface } from '../../../src/@types/analytics-handler';\nimport sinon from 'sinon';\n\nlet analytics: DonationControllerEventLoggerInterface;\n\ndescribe('Donation Flow Modal Manager', () => {\n beforeEach(() => {\n analytics = {\n logEvent: sinon.fake(),\n logDonationFlowEvent: sinon.fake(),\n };\n });\n afterEach(() => {\n sinon.restore();\n });\n it('can close the modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.closeModal();\n expect(mockModalManager.closeCalled).to.be.true;\n });\n\n it('can calculate the proper default upsell amount', async () => {\n let amount = DonationFlowModalManager.getDefaultUpsellAmount(1);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10.01);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25.01);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100.01);\n expect(amount).to.equal(50);\n });\n\n it('can show the processing modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showProcessingModal();\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#497fbf');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.processingImageMode).to.equal('processing');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.false;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Processing...');\n });\n\n it('can show the error modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showErrorModal({ message: 'foo-error' });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#691916');\n expect(modalOptions?.config.showProcessingIndicator).to.be.false;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.headline?.strings[0]).to.contain(\n \"There's been a problem completing your donation.\",\n );\n expect(modalOptions?.config.message?.values[0]).to.equal('foo-error');\n });\n\n it('shows the thank you modal and calls `donationSuccessful` to take user to thank you page', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.processingImageMode).to.equal('complete');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Thank You!');\n const response = mockBraintreeManager.donationSuccessfulOptions?.successResponse;\n expect(response).to.deep.equal(mockSuccessResponse);\n });\n\n it('donation submitted analytics gets sent when drawing thank you modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n const successResponse = mockSuccessResponse;\n successResponse.paymentProvider = PaymentProvider.GooglePay;\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n\n // fires analytics\n expect(logDonationFlowEvent.callCount).to.equal(1);\n expect(logDonationFlowEvent.args[0][0]).to.equal(`Donated-GooglePay`);\n expect(logDonationFlowEvent.args[0][1]).to.equal(DonationType.OneTime);\n });\n\n it('can show the confirmation modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showConfirmationStepModal({\n donationType: DonationType.Upsell,\n amount: 8,\n currencyType: 'USD',\n cancelDonationCB: () => console.log('donation cancelled'),\n confirmDonationCB: () => console.log('donation confirmed'),\n });\n\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config?.title?.values).to.contain('Confirm monthly donation');\n });\n\n it('can start the donation submission flow', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n const result = await manager.startDonationSubmissionFlow({\n nonce: 'foo',\n paymentProvider: PaymentProvider.CreditCard,\n donationInfo: new DonationPaymentInfo({\n donationType: DonationType.OneTime,\n amount: 5,\n coverFees: false,\n }),\n billingInfo: mockBillingInfo,\n customerInfo: mockCustomerInfo,\n });\n\n expect(result).to.deep.equal({\n success: true,\n value: {\n amount: 5,\n billing: {\n countryCodeAlpha2: 'US',\n extendedAddress: 'Apt 123',\n locality: 'San Francisco',\n postalCode: '12345',\n region: 'CA',\n streetAddress: '123 Fake St',\n },\n customer: {\n email: 'foo@bar.com',\n firstName: 'Fooey',\n lastName: 'McBarrison',\n },\n customer_id: 'bar',\n donationType: 'one-time',\n paymentMethodNonce: 'foo',\n paymentProvider: 'Credit Card',\n transaction_id: 'foo',\n },\n });\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/donation-form",
3
- "version": "0.5.15-a4",
3
+ "version": "0.5.15-a5",
4
4
  "description": "The Internet Archive Donation Form",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "dist/index.js",
@@ -124,7 +124,6 @@ export class DonationFormController extends LitElement {
124
124
  updated(changedProperties: PropertyValues): void {
125
125
  if (changedProperties.has('referrer') && this.referrer) {
126
126
  this.braintreeManager?.setReferrer(this.referrer);
127
- this.logDonationFlowEvent('referrer', this.referrer);
128
127
  }
129
128
 
130
129
  if (changedProperties.has('loggedInUser') && this.loggedInUser) {
@@ -133,7 +132,6 @@ export class DonationFormController extends LitElement {
133
132
 
134
133
  if (changedProperties.has('origin') && this.origin) {
135
134
  this.braintreeManager?.setOrigin(this.origin);
136
- this.logDonationFlowEvent('origin', this.origin);
137
135
  }
138
136
 
139
137
  if (