@internetarchive/donation-form 0.5.15-a3 → 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.
- package/dist/demo/braintree-endpoint-manager.js +1 -1
- package/dist/demo/braintree-endpoint-manager.js.map +1 -1
- package/dist/src/donation-form-controller.d.ts +2 -2
- package/dist/src/donation-form-controller.js +4 -6
- package/dist/src/donation-form-controller.js.map +1 -1
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js +2 -2
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js.map +1 -1
- package/dist/src/payment-flow-handlers/payment-flow-handlers.d.ts +1 -1
- package/dist/src/payment-flow-handlers/payment-flow-handlers.js.map +1 -1
- package/dist/test/mocks/mock-analytics-handler.d.ts +0 -1
- package/dist/test/mocks/mock-analytics-handler.js +0 -7
- package/dist/test/mocks/mock-analytics-handler.js.map +1 -1
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +15 -15
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js.map +1 -1
- package/package.json +1 -1
- package/src/@types/analytics-handler/index.d.ts +1 -1
- package/src/donation-form-controller.ts +4 -6
- package/src/payment-flow-handlers/donation-flow-modal-manager.ts +2 -2
- package/src/payment-flow-handlers/payment-flow-handlers.ts +2 -2
|
@@ -38,7 +38,7 @@ export class BraintreeEndpointManager {
|
|
|
38
38
|
}
|
|
39
39
|
const service = encodeURI(response.paymentProvider);
|
|
40
40
|
submitFormWith({
|
|
41
|
-
action: `https://
|
|
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,C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AO,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://
|
|
1
|
+
{"version":3,"file":"braintree-endpoint-manager.js","sourceRoot":"","sources":["../../demo/braintree-endpoint-manager.ts"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AC;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"]}
|
|
@@ -93,12 +93,12 @@ export declare class DonationFormController extends LitElement {
|
|
|
93
93
|
*/
|
|
94
94
|
private logEvent;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Logs `DonationFlow` Event category into no sample bucket
|
|
97
97
|
*
|
|
98
98
|
* @param {string} action Name of event
|
|
99
99
|
* @param {string} label Event label, optional
|
|
100
100
|
*/
|
|
101
|
-
private
|
|
101
|
+
private logDonationFlowEvent;
|
|
102
102
|
/**
|
|
103
103
|
* This is not the normal LitElement styles block.
|
|
104
104
|
*
|
|
@@ -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.logEventNoSampling('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.logEventNoSampling('origin', this.origin);
|
|
51
49
|
}
|
|
52
50
|
if (changedProperties.has('paymentClients') ||
|
|
53
51
|
changedProperties.has('braintreeAuthToken') ||
|
|
@@ -202,7 +200,7 @@ let DonationFormController = class DonationFormController extends LitElement {
|
|
|
202
200
|
resources: {
|
|
203
201
|
analytics: {
|
|
204
202
|
logEvent: this.logEvent.bind(this),
|
|
205
|
-
|
|
203
|
+
logDonationFlowEvent: this.logDonationFlowEvent.bind(this),
|
|
206
204
|
},
|
|
207
205
|
}
|
|
208
206
|
});
|
|
@@ -386,14 +384,14 @@ let DonationFormController = class DonationFormController extends LitElement {
|
|
|
386
384
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent(analyticEvent);
|
|
387
385
|
}
|
|
388
386
|
/**
|
|
389
|
-
*
|
|
387
|
+
* Logs `DonationFlow` Event category into no sample bucket
|
|
390
388
|
*
|
|
391
389
|
* @param {string} action Name of event
|
|
392
390
|
* @param {string} label Event label, optional
|
|
393
391
|
*/
|
|
394
|
-
|
|
392
|
+
logDonationFlowEvent(action, label) {
|
|
395
393
|
var _a;
|
|
396
|
-
const analyticEvent = { action, label, category:
|
|
394
|
+
const analyticEvent = { action, label, category: 'DonationFlow' };
|
|
397
395
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEventNoSampling(analyticEvent);
|
|
398
396
|
}
|
|
399
397
|
/**
|
|
@@ -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,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,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AC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAuB;AAEtB;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;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.logEventNoSampling('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.logEventNoSampling('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 logEventNoSampling: this.logEventNoSampling.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 * Log an event in no sample bucket\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logEventNoSampling(action: string, label?: string): void {\n const analyticEvent = { action, label, category: this.analyticsCategory } 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
|
+
{"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,8EA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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;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"]}
|
|
@@ -55,7 +55,7 @@ export class DonationFlowModalManager {
|
|
|
55
55
|
action += `-upsell`;
|
|
56
56
|
}
|
|
57
57
|
const label = options.successResponse.donationType;
|
|
58
|
-
this.analytics.
|
|
58
|
+
this.analytics.logDonationFlowEvent(action, label);
|
|
59
59
|
// post donation
|
|
60
60
|
this.braintreeManager.donationSuccessful(options);
|
|
61
61
|
}
|
|
@@ -206,7 +206,7 @@ export class DonationFlowModalManager {
|
|
|
206
206
|
const selectedPayment = options.successResponse.paymentProvider.replace(/\s+/g, '');
|
|
207
207
|
const action = `Donated-${selectedPayment}-upsell`;
|
|
208
208
|
const label = options.successResponse.donationType;
|
|
209
|
-
this.analytics.
|
|
209
|
+
this.analytics.logDonationFlowEvent(action, label);
|
|
210
210
|
this.braintreeManager.donationSuccessful(options);
|
|
211
211
|
}
|
|
212
212
|
static getDefaultUpsellAmount(oneTimeAmount) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-flow-modal-manager.js","sourceRoot":"","sources":["../../../src/payment-flow-handlers/donation-fl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,KAAK,YAAY,CAAC,OAAO;gBACvB,IAAI,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACtD,MAAM;YACR,qEAAqE;YACrE,6DAA6D;YAC7D,KAAK,YAAY,CAAC,MAAM;gBACtB,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;CACF","sourcesContent":["import { html } from 'lit';\nimport { ModalConfig, ModalManagerInterface } from '@internetarchive/modal-manager';\nimport { UpsellModalCTAMode } from '../modals/upsell-modal-content';\nimport '../modals/confirm-donation-modal-content';\nimport { BraintreeManagerInterface } from '../braintree-manager/braintree-interfaces';\nimport {\n SuccessResponse,\n ErrorResponse,\n DonationPaymentInfo,\n DonationType,\n PaymentProvider,\n BillingInfo,\n CustomerInfo,\n DonationResponse,\n} from '@internetarchive/donation-form-data-models';\nimport '../modals/error-modal-content';\nimport { DonationControllerEventLoggerInterface } from '../@types/analytics-handler';\n\nenum ModalHeaderColor {\n Blue = '#497fbf',\n Green = '#55A183',\n Red = '#691916',\n}\n\n/**\n * The DonationFlowModalManager is responsible for most of the high-level modal flows.\n *\n * Each of the payment providers has slightly different interactions, ie the PayPal button,\n * ApplePay popup, Venmo launching the app, etc. The modal flow is the same for all of them\n * so this class gets called by the individual payment flow handlers to take the user\n * through the modal flow.\n *\n * @export\n * @interface DonationFlowModalManagerInterface\n */\nexport interface DonationFlowModalManagerInterface {\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void>;\n /**\n * Close the modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n closeModal(): void;\n\n /**\n * Show the processing modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n showProcessingModal(): void;\n\n /**\n * Show the Thank You modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n showThankYouModal(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void;\n\n /**\n * Show the Error modal\n *\n * @param {{\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @memberof DonationFlowModalManagerInterface\n */\n showErrorModal(options: { message: string; userClosedModalCallback?: () => void }): void;\n\n /**\n * Show the upsell modal\n *\n * @param {{\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @returns {Promise<void>}\n * @memberof DonationFlowModalManagerInterface\n */\n showUpsellModal(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\n /**\n * Start the donation submission flow. This kicks off the \"main\" modal flow once the\n * user authorizes the donation through their payment provider, which provides\n * us the with the nonce used to complete the donation.\n *\n * @param {{\n * nonce: string;\n * paymentProvider: PaymentProvider;\n * donationInfo: DonationPaymentInfo;\n * billingInfo: BillingInfo;\n * customerInfo: CustomerInfo;\n * upsellOnetimeTransactionId?: string;\n * customerId?: string;\n * recaptchaToken?: string;\n * bin?: string; // first 6 digits of CC\n * binName?: string; // credit card bank name\n * }} options\n * @returns {(Promise<DonationResponse | undefined>)}\n * @memberof DonationFlowModalManagerInterface\n */\n startDonationSubmissionFlow(options: {\n nonce: string;\n paymentProvider: PaymentProvider;\n donationInfo: DonationPaymentInfo;\n billingInfo: BillingInfo;\n customerInfo: CustomerInfo;\n upsellOnetimeTransactionId?: string;\n customerId?: string;\n recaptchaToken?: string;\n bin?: string; // first 6 digits of CC\n binName?: string; // credit card bank name\n }): Promise<DonationResponse | undefined>;\n\n /**\n * Handle a successful donation response. This encapsulates the logic for the type of\n * donation that was made.\n * ie. If it was a one-time donation, show the upsell, if it was monthly do not.\n *\n * @param {DonationPaymentInfo} donationInfo\n * @param {SuccessResponse} response\n * @memberof DonationFlowModalManagerInterface\n */\n handleSuccessfulDonationResponse(\n donationInfo: DonationPaymentInfo,\n response: SuccessResponse,\n ): void;\n}\n\nexport class DonationFlowModalManager implements DonationFlowModalManagerInterface {\n private braintreeManager: BraintreeManagerInterface;\n\n private modalManager: ModalManagerInterface;\n\n private analytics: DonationControllerEventLoggerInterface;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n analytics: DonationControllerEventLoggerInterface;\n }) {\n this.modalManager = options.modalManager;\n this.braintreeManager = options.braintreeManager;\n this.analytics = options.analytics;\n }\n\n /** @inheritdoc */\n closeModal(): void {\n this.modalManager.closeModal();\n }\n\n /** @inheritdoc */\n showProcessingModal(): void {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Blue,\n showProcessingIndicator: true,\n closeOnBackdropClick: false,\n showCloseButton: false,\n processingImageMode: 'processing',\n title: html`\n Processing...\n `,\n });\n this.modalManager.showModal({ config: modalConfig });\n }\n\n /** @inheritdoc */\n showThankYouModal(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n const modalConfig = new ModalConfig({\n showProcessingIndicator: true,\n processingImageMode: 'complete',\n headerColor: ModalHeaderColor.Green,\n title: html`\n Thank You!\n `,\n });\n this.modalManager.showModal({\n config: modalConfig,\n });\n\n // post analytic\n const selectedPayment = options.successResponse.paymentProvider.replace(/\\s+/g, '');\n let action = `Donated-${selectedPayment}`;\n if (options.upsellSuccessResponse) {\n action += `-upsell`;\n }\n const label = options.successResponse.donationType;\n this.analytics.logEventNoSampling(action, label);\n\n // post donation\n this.braintreeManager.donationSuccessful(options);\n }\n\n /** @inheritdoc */\n showErrorModal(options: { message: string; userClosedModalCallback?: () => void }): void {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Red,\n title: html`\n Processing error\n `,\n headline: html`\n There's been a problem completing your donation.\n `,\n message: html`\n ${options?.message}\n `,\n });\n\n this.modalManager.showModal({\n config: modalConfig,\n userClosedModalCallback: options?.userClosedModalCallback,\n customModalContent: html`\n <donation-form-error-modal-content></donation-form-error-modal-content>\n `,\n });\n }\n\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void> {\n const confirmDonation = (): void => {\n options?.confirmDonationCB();\n };\n const cancelDonation = (): void => {\n options?.cancelDonationCB();\n };\n const modalTitle = options.donationType === DonationType.Upsell\n ? 'Confirm monthly donation'\n : 'Complete donation';\n\n const modalConfig = new ModalConfig({\n closeOnBackdropClick: false,\n headerColor: ModalHeaderColor.Green,\n title: html`${modalTitle}`,\n message: html`\n <confirm-donation-modal\n .amount=\"${options.amount}\"\n .currencyType=\"${options.currencyType}\"\n .donationType=\"${options.donationType}\"\n .confirmDonation=${confirmDonation}\n .cancelDonation=${cancelDonation}\n ></confirm-donation-modal>\n `,\n });\n return this.modalManager.showModal({\n config: modalConfig,\n userClosedModalCallback: cancelDonation\n });\n }\n\n /** @inheritdoc */\n showUpsellModal(options: {\n oneTimeAmount: number;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n ctaMode?: UpsellModalCTAMode;\n }): Promise<void> {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Green,\n title: html`\n Donation received\n `,\n processingImageMode: 'complete',\n showProcessingIndicator: true,\n });\n\n const upsellAmount = DonationFlowModalManager.getDefaultUpsellAmount(options.oneTimeAmount);\n if (options.amountChanged) {\n options.amountChanged(upsellAmount);\n }\n\n const modalContent = html`\n <upsell-modal-content\n .amount=${upsellAmount}\n .yesButtonMode=${options?.ctaMode ?? UpsellModalCTAMode.YesButton}\n @yesSelected=${(e: CustomEvent): void =>\n options?.yesSelected ? options.yesSelected(e.detail.amount) : undefined}\n @noThanksSelected=${options?.noSelected}\n @amountChanged=${(e: CustomEvent): void =>\n options?.amountChanged ? options.amountChanged(e.detail.amount) : undefined}\n >\n <slot name=\"paypal-upsell-button\"></slot>\n </upsell-modal-content>\n `;\n return this.modalManager.showModal({\n config: modalConfig,\n customModalContent: modalContent,\n userClosedModalCallback: options?.userClosedModalCallback,\n });\n }\n\n /** @inheritdoc */\n async startDonationSubmissionFlow(options: {\n nonce: string;\n paymentProvider: PaymentProvider;\n donationInfo: DonationPaymentInfo;\n billingInfo: BillingInfo;\n customerInfo: CustomerInfo;\n upsellOnetimeTransactionId?: string;\n customerId?: string;\n recaptchaToken?: string;\n bin?: string; // first 6 digits of CC\n binName?: string; // credit card bank name\n }): Promise<DonationResponse | undefined> {\n this.showProcessingModal();\n\n try {\n const response = await this.braintreeManager.submitDonation(options);\n\n if (response.success) {\n this.handleSuccessfulDonationResponse(\n options.donationInfo,\n response.value as SuccessResponse,\n );\n return response;\n } else {\n const error = response.value as ErrorResponse;\n this.showErrorModal({\n message: error.message,\n });\n return response;\n }\n } catch (error) {\n this.showErrorModal({\n message: `${error}`,\n });\n console.error('error getting a response', error);\n return undefined;\n }\n }\n\n private async upsellModalYesSelected(\n oneTimeDonationResponse: SuccessResponse,\n amount: number,\n ): Promise<DonationResponse | undefined> {\n this.showProcessingModal();\n\n try {\n const response = await this.braintreeManager.submitUpsellDonation({\n oneTimeDonationResponse: oneTimeDonationResponse,\n amount: amount,\n });\n\n if (response.success) {\n this.completeUpsell({\n successResponse: oneTimeDonationResponse,\n upsellSuccessResponse: response.value as SuccessResponse,\n });\n } else {\n const error = response.value as ErrorResponse;\n this.showErrorModal({\n message: error.message,\n });\n }\n\n return response;\n } catch (error) {\n this.showErrorModal({\n message: `${error}`,\n });\n console.error('error getting a response', error);\n return undefined;\n }\n }\n\n private completeUpsell(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n this.showThankYouModal(options);\n\n // post analytic\n const selectedPayment = options.successResponse.paymentProvider.replace(/\\s+/g, '');\n const action = `Donated-${selectedPayment}-upsell`;\n const label = options.successResponse.donationType;\n this.analytics.logEventNoSampling(action, label);\n\n this.braintreeManager.donationSuccessful(options);\n }\n\n static getDefaultUpsellAmount(oneTimeAmount: number): number {\n let amount = 5;\n\n if (oneTimeAmount <= 10) amount = 5;\n else if (oneTimeAmount > 10 && oneTimeAmount <= 25) amount = 10;\n else if (oneTimeAmount > 25 && oneTimeAmount <= 100) amount = 25;\n else if (oneTimeAmount > 100) amount = 50;\n\n return amount;\n }\n\n /** @inheritdoc */\n handleSuccessfulDonationResponse(\n donationInfo: DonationPaymentInfo,\n response: SuccessResponse,\n ): void {\n switch (donationInfo.donationType) {\n case DonationType.OneTime:\n this.showUpsellModal({\n oneTimeAmount: response.amount,\n yesSelected: (amount: number) => {\n this.upsellModalYesSelected(response, amount);\n },\n noSelected: () => {\n this.showThankYouModal({ successResponse: response });\n },\n userClosedModalCallback: () => {\n this.showThankYouModal({ successResponse: response });\n },\n });\n break;\n case DonationType.Monthly:\n this.showThankYouModal({ successResponse: response });\n break;\n // This case will never be reached, it is only here for completeness.\n // The upsell case gets handled in `modalYesSelected()` below\n case DonationType.Upsell:\n break;\n default:\n break;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"donation-flow-modal-manager.js","sourceRoot":"","sources":["../../../src/payment-flow-handlers/donation-flow-modal-manager.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAyB,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAIL,YAAY,GAKb,MAAM,4CAA4C,CAAC;AACpD,OAAO,+BAA+B,CAAC;AAGvC,IAAK,gBAIJ;AAJD,WAAK,gBAAgB;IACnB,oCAAgB,CAAA;IAChB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACjB,CAAC,EAJI,gBAAgB,KAAhB,gBAAgB,QAIpB;AA6HD,MAAM,OAAO,wBAAwB;IAOnC,YAAY,OAIX;QACC,I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,aAAa,IAAI,GAAG;YAAE,MAAM,GAAG,EAAE,CAAC;aAC5D,IAAI,aAAa,GAAG,GAAG;YAAE,MAAM,GAAG,EAAE,CAAC;QAE1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB,gCAAgC,CAC9B,YAAiC,EACjC,QAAyB;QAEzB,QAAQ,YAAY,CAAC,YAAY,EAAE;YACjC,KAAK,YAAY,CAAC,OAAO;gBACvB,IAAI,CAAC,eAAe,CAAC;oBACnB,aAAa,EAAE,QAAQ,CAAC,MAAM;oBAC9B,WAAW,EAAE,CAAC,MAAc,EAAE,EAAE;wBAC9B,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;oBAChD,CAAC;oBACD,UAAU,EAAE,GAAG,EAAE;wBACf,IAAI,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACxD,CAAC;oBACD,uBAAuB,EAAE,GAAG,EAAE;wBAC5B,IAAI,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACxD,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,YAAY,CAAC,OAAO;gBACvB,IAAI,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACtD,MAAM;YACR,qEAAqE;YACrE,6DAA6D;YAC7D,KAAK,YAAY,CAAC,MAAM;gBACtB,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;CACF","sourcesContent":["import { html } from 'lit';\nimport { ModalConfig, ModalManagerInterface } from '@internetarchive/modal-manager';\nimport { UpsellModalCTAMode } from '../modals/upsell-modal-content';\nimport '../modals/confirm-donation-modal-content';\nimport { BraintreeManagerInterface } from '../braintree-manager/braintree-interfaces';\nimport {\n SuccessResponse,\n ErrorResponse,\n DonationPaymentInfo,\n DonationType,\n PaymentProvider,\n BillingInfo,\n CustomerInfo,\n DonationResponse,\n} from '@internetarchive/donation-form-data-models';\nimport '../modals/error-modal-content';\nimport { DonationControllerEventLoggerInterface } from '../@types/analytics-handler';\n\nenum ModalHeaderColor {\n Blue = '#497fbf',\n Green = '#55A183',\n Red = '#691916',\n}\n\n/**\n * The DonationFlowModalManager is responsible for most of the high-level modal flows.\n *\n * Each of the payment providers has slightly different interactions, ie the PayPal button,\n * ApplePay popup, Venmo launching the app, etc. The modal flow is the same for all of them\n * so this class gets called by the individual payment flow handlers to take the user\n * through the modal flow.\n *\n * @export\n * @interface DonationFlowModalManagerInterface\n */\nexport interface DonationFlowModalManagerInterface {\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void>;\n /**\n * Close the modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n closeModal(): void;\n\n /**\n * Show the processing modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n showProcessingModal(): void;\n\n /**\n * Show the Thank You modal\n *\n * @memberof DonationFlowModalManagerInterface\n */\n showThankYouModal(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void;\n\n /**\n * Show the Error modal\n *\n * @param {{\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @memberof DonationFlowModalManagerInterface\n */\n showErrorModal(options: { message: string; userClosedModalCallback?: () => void }): void;\n\n /**\n * Show the upsell modal\n *\n * @param {{\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @returns {Promise<void>}\n * @memberof DonationFlowModalManagerInterface\n */\n showUpsellModal(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\n /**\n * Start the donation submission flow. This kicks off the \"main\" modal flow once the\n * user authorizes the donation through their payment provider, which provides\n * us the with the nonce used to complete the donation.\n *\n * @param {{\n * nonce: string;\n * paymentProvider: PaymentProvider;\n * donationInfo: DonationPaymentInfo;\n * billingInfo: BillingInfo;\n * customerInfo: CustomerInfo;\n * upsellOnetimeTransactionId?: string;\n * customerId?: string;\n * recaptchaToken?: string;\n * bin?: string; // first 6 digits of CC\n * binName?: string; // credit card bank name\n * }} options\n * @returns {(Promise<DonationResponse | undefined>)}\n * @memberof DonationFlowModalManagerInterface\n */\n startDonationSubmissionFlow(options: {\n nonce: string;\n paymentProvider: PaymentProvider;\n donationInfo: DonationPaymentInfo;\n billingInfo: BillingInfo;\n customerInfo: CustomerInfo;\n upsellOnetimeTransactionId?: string;\n customerId?: string;\n recaptchaToken?: string;\n bin?: string; // first 6 digits of CC\n binName?: string; // credit card bank name\n }): Promise<DonationResponse | undefined>;\n\n /**\n * Handle a successful donation response. This encapsulates the logic for the type of\n * donation that was made.\n * ie. If it was a one-time donation, show the upsell, if it was monthly do not.\n *\n * @param {DonationPaymentInfo} donationInfo\n * @param {SuccessResponse} response\n * @memberof DonationFlowModalManagerInterface\n */\n handleSuccessfulDonationResponse(\n donationInfo: DonationPaymentInfo,\n response: SuccessResponse,\n ): void;\n}\n\nexport class DonationFlowModalManager implements DonationFlowModalManagerInterface {\n private braintreeManager: BraintreeManagerInterface;\n\n private modalManager: ModalManagerInterface;\n\n private analytics: DonationControllerEventLoggerInterface;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n analytics: DonationControllerEventLoggerInterface;\n }) {\n this.modalManager = options.modalManager;\n this.braintreeManager = options.braintreeManager;\n this.analytics = options.analytics;\n }\n\n /** @inheritdoc */\n closeModal(): void {\n this.modalManager.closeModal();\n }\n\n /** @inheritdoc */\n showProcessingModal(): void {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Blue,\n showProcessingIndicator: true,\n closeOnBackdropClick: false,\n showCloseButton: false,\n processingImageMode: 'processing',\n title: html`\n Processing...\n `,\n });\n this.modalManager.showModal({ config: modalConfig });\n }\n\n /** @inheritdoc */\n showThankYouModal(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n const modalConfig = new ModalConfig({\n showProcessingIndicator: true,\n processingImageMode: 'complete',\n headerColor: ModalHeaderColor.Green,\n title: html`\n Thank You!\n `,\n });\n this.modalManager.showModal({\n config: modalConfig,\n });\n\n // post analytic\n const selectedPayment = options.successResponse.paymentProvider.replace(/\\s+/g, '');\n let action = `Donated-${selectedPayment}`;\n if (options.upsellSuccessResponse) {\n action += `-upsell`;\n }\n const label = options.successResponse.donationType;\n this.analytics.logDonationFlowEvent(action, label);\n\n // post donation\n this.braintreeManager.donationSuccessful(options);\n }\n\n /** @inheritdoc */\n showErrorModal(options: { message: string; userClosedModalCallback?: () => void }): void {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Red,\n title: html`\n Processing error\n `,\n headline: html`\n There's been a problem completing your donation.\n `,\n message: html`\n ${options?.message}\n `,\n });\n\n this.modalManager.showModal({\n config: modalConfig,\n userClosedModalCallback: options?.userClosedModalCallback,\n customModalContent: html`\n <donation-form-error-modal-content></donation-form-error-modal-content>\n `,\n });\n }\n\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void> {\n const confirmDonation = (): void => {\n options?.confirmDonationCB();\n };\n const cancelDonation = (): void => {\n options?.cancelDonationCB();\n };\n const modalTitle = options.donationType === DonationType.Upsell\n ? 'Confirm monthly donation'\n : 'Complete donation';\n\n const modalConfig = new ModalConfig({\n closeOnBackdropClick: false,\n headerColor: ModalHeaderColor.Green,\n title: html`${modalTitle}`,\n message: html`\n <confirm-donation-modal\n .amount=\"${options.amount}\"\n .currencyType=\"${options.currencyType}\"\n .donationType=\"${options.donationType}\"\n .confirmDonation=${confirmDonation}\n .cancelDonation=${cancelDonation}\n ></confirm-donation-modal>\n `,\n });\n return this.modalManager.showModal({\n config: modalConfig,\n userClosedModalCallback: cancelDonation\n });\n }\n\n /** @inheritdoc */\n showUpsellModal(options: {\n oneTimeAmount: number;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n ctaMode?: UpsellModalCTAMode;\n }): Promise<void> {\n const modalConfig = new ModalConfig({\n headerColor: ModalHeaderColor.Green,\n title: html`\n Donation received\n `,\n processingImageMode: 'complete',\n showProcessingIndicator: true,\n });\n\n const upsellAmount = DonationFlowModalManager.getDefaultUpsellAmount(options.oneTimeAmount);\n if (options.amountChanged) {\n options.amountChanged(upsellAmount);\n }\n\n const modalContent = html`\n <upsell-modal-content\n .amount=${upsellAmount}\n .yesButtonMode=${options?.ctaMode ?? UpsellModalCTAMode.YesButton}\n @yesSelected=${(e: CustomEvent): void =>\n options?.yesSelected ? options.yesSelected(e.detail.amount) : undefined}\n @noThanksSelected=${options?.noSelected}\n @amountChanged=${(e: CustomEvent): void =>\n options?.amountChanged ? options.amountChanged(e.detail.amount) : undefined}\n >\n <slot name=\"paypal-upsell-button\"></slot>\n </upsell-modal-content>\n `;\n return this.modalManager.showModal({\n config: modalConfig,\n customModalContent: modalContent,\n userClosedModalCallback: options?.userClosedModalCallback,\n });\n }\n\n /** @inheritdoc */\n async startDonationSubmissionFlow(options: {\n nonce: string;\n paymentProvider: PaymentProvider;\n donationInfo: DonationPaymentInfo;\n billingInfo: BillingInfo;\n customerInfo: CustomerInfo;\n upsellOnetimeTransactionId?: string;\n customerId?: string;\n recaptchaToken?: string;\n bin?: string; // first 6 digits of CC\n binName?: string; // credit card bank name\n }): Promise<DonationResponse | undefined> {\n this.showProcessingModal();\n\n try {\n const response = await this.braintreeManager.submitDonation(options);\n\n if (response.success) {\n this.handleSuccessfulDonationResponse(\n options.donationInfo,\n response.value as SuccessResponse,\n );\n return response;\n } else {\n const error = response.value as ErrorResponse;\n this.showErrorModal({\n message: error.message,\n });\n return response;\n }\n } catch (error) {\n this.showErrorModal({\n message: `${error}`,\n });\n console.error('error getting a response', error);\n return undefined;\n }\n }\n\n private async upsellModalYesSelected(\n oneTimeDonationResponse: SuccessResponse,\n amount: number,\n ): Promise<DonationResponse | undefined> {\n this.showProcessingModal();\n\n try {\n const response = await this.braintreeManager.submitUpsellDonation({\n oneTimeDonationResponse: oneTimeDonationResponse,\n amount: amount,\n });\n\n if (response.success) {\n this.completeUpsell({\n successResponse: oneTimeDonationResponse,\n upsellSuccessResponse: response.value as SuccessResponse,\n });\n } else {\n const error = response.value as ErrorResponse;\n this.showErrorModal({\n message: error.message,\n });\n }\n\n return response;\n } catch (error) {\n this.showErrorModal({\n message: `${error}`,\n });\n console.error('error getting a response', error);\n return undefined;\n }\n }\n\n private completeUpsell(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n this.showThankYouModal(options);\n\n // post analytic\n const selectedPayment = options.successResponse.paymentProvider.replace(/\\s+/g, '');\n const action = `Donated-${selectedPayment}-upsell`;\n const label = options.successResponse.donationType;\n this.analytics.logDonationFlowEvent(action, label);\n\n this.braintreeManager.donationSuccessful(options);\n }\n\n static getDefaultUpsellAmount(oneTimeAmount: number): number {\n let amount = 5;\n\n if (oneTimeAmount <= 10) amount = 5;\n else if (oneTimeAmount > 10 && oneTimeAmount <= 25) amount = 10;\n else if (oneTimeAmount > 25 && oneTimeAmount <= 100) amount = 25;\n else if (oneTimeAmount > 100) amount = 50;\n\n return amount;\n }\n\n /** @inheritdoc */\n handleSuccessfulDonationResponse(\n donationInfo: DonationPaymentInfo,\n response: SuccessResponse,\n ): void {\n switch (donationInfo.donationType) {\n case DonationType.OneTime:\n this.showUpsellModal({\n oneTimeAmount: response.amount,\n yesSelected: (amount: number) => {\n this.upsellModalYesSelected(response, amount);\n },\n noSelected: () => {\n this.showThankYouModal({ successResponse: response });\n },\n userClosedModalCallback: () => {\n this.showThankYouModal({ successResponse: response });\n },\n });\n break;\n case DonationType.Monthly:\n this.showThankYouModal({ successResponse: response });\n break;\n // This case will never be reached, it is only here for completeness.\n // The upsell case gets handled in `modalYesSelected()` below\n case DonationType.Upsell:\n break;\n default:\n break;\n }\n }\n}\n"]}
|
|
@@ -99,7 +99,7 @@ export declare class PaymentFlowHandlers implements PaymentFlowHandlersInterface
|
|
|
99
99
|
resources: {
|
|
100
100
|
analytics: {
|
|
101
101
|
logEvent: (action: string, label: string) => void;
|
|
102
|
-
|
|
102
|
+
logDonationFlowEvent: (action: string, label: string) => void;
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
105
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-flow-handlers.js","sourceRoot":"","sources":["../../../src/payment-flow-handlers/payment-flow-handlers.ts"],"names":[],"mappings":";AAEA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAA8B,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAG/F,OAAO,EAEL,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAA6B,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAEL,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AA2C3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,mBAAmB;IAqG9B,YAAY,OAUX;QACC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAEnC,IAAI,CAAC,wBAAwB,GAAG,IAAI,wBAAwB,CAAC;YAC3D,gBAA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AO,IAAI,CAAC,oBAAoB,CAAC;SAClC;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,mBAAmB,CAAC;YAClD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;SACxD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,IAAI,YAAY;QACd,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,OAAO,IAAI,CAAC,iBAAiB,CAAC;SAC/B;QAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,gBAAgB,CAAC;YAC5C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;SACxD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAI,gBAAgB;QAClB,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC9B,OAAO,IAAI,CAAC,qBAAqB,CAAC;SACnC;QAED,IAAI,CAAC,qBAAqB,GAAG,IAAI,oBAAoB,CAAC;YACpD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;SACxD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;CAyCF","sourcesContent":["import { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport {\n CreditCardFlowHandlerInterface,\n CreditCardFlowHandler,\n} from './handlers/creditcard-flow-handler';\nimport { PayPalFlowHandlerInterface, PayPalFlowHandler } from './handlers/paypal-flow-handler';\nimport { BraintreeManagerInterface } from '../braintree-manager/braintree-interfaces';\nimport { RecaptchaManagerInterface } from '../recaptcha-manager/recaptcha-manager';\nimport {\n ApplePayFlowHandlerInterface,\n ApplePayFlowHandler,\n} from './handlers/applepay-flow-handler';\nimport { VenmoFlowHandlerInterface, VenmoFlowHandler } from './handlers/venmo-flow-handler';\nimport {\n DonationFlowModalManagerInterface,\n DonationFlowModalManager,\n} from './donation-flow-modal-manager';\nimport {\n GooglePayFlowHandlerInterface,\n GooglePayFlowHandler,\n} from './handlers/googlepay-flow-handler';\nimport { UpsellModalCTAMode } from '../modals/upsell-modal-content';\nimport { DonationType } from '@internetarchive/donation-form-data-models';\n\nexport interface PaymentFlowHandlersInterface {\n startup(): Promise<void>;\n /**\n * Show the upsell modal\n *\n * @param {{\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @returns {Promise<void>}\n * @memberof DonationFlowModalManagerInterface\n */\n showUpsellModal(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\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void>;\n\n creditCardHandler: CreditCardFlowHandlerInterface | undefined;\n paypalHandler: PayPalFlowHandlerInterface | undefined;\n applePayHandler: ApplePayFlowHandlerInterface | undefined;\n venmoHandler: VenmoFlowHandlerInterface | undefined;\n googlePayHandler: GooglePayFlowHandlerInterface | undefined;\n}\n\n/**\n * This class is a container for all of the individual flow handlers.\n *\n * Flow Handlers are responsible for handling the provider-specific interactions between\n * the UI and the Data.\n *\n * For instance, when the user clicks on the \"Donate\" button for credit cards, we\n * pull in contact info from the form, trigger the recaptcha, tokenize the form,\n * submit, show the upsell, complete. The Credit Card Flow Handler is responsible for\n * managing that series of steps.\n *\n * For PayPal, the user initiates the payment from the PayPal button and once they're\n * done, we show the modal. The PayPal Flow Handler is responsible for handling that\n * series of events.\n *\n * @export\n * @class PaymentFlowHandlers\n * @implements {PaymentFlowHandlersInterface}\n */\nexport class PaymentFlowHandlers implements PaymentFlowHandlersInterface {\n async startup(): Promise<void> {\n this.venmoHandler?.startup();\n this.creditCardHandler?.startup();\n }\n\n /** @inheritdoc */\n async showUpsellModal(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 return this.donationFlowModalManager.showUpsellModal(options);\n }\n\n /** @inheritdoc */\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void> {\n return this.donationFlowModalManager.showConfirmationStepModal(options);\n }\n\n get creditCardHandler(): CreditCardFlowHandlerInterface | undefined {\n if (this.creditCardHandlerCache) {\n return this.creditCardHandlerCache;\n }\n\n this.creditCardHandlerCache = new CreditCardFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n return this.creditCardHandlerCache;\n }\n\n get paypalHandler(): PayPalFlowHandlerInterface | undefined {\n if (this.paypalHandlerCache) {\n return this.paypalHandlerCache;\n }\n\n this.paypalHandlerCache = new PayPalFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.paypalHandlerCache;\n }\n\n get applePayHandler(): ApplePayFlowHandlerInterface | undefined {\n if (this.applePayHandlerCache) {\n return this.applePayHandlerCache;\n }\n\n this.applePayHandlerCache = new ApplePayFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.applePayHandlerCache;\n }\n\n get venmoHandler(): VenmoFlowHandlerInterface | undefined {\n if (this.venmoHandlerCache) {\n return this.venmoHandlerCache;\n }\n\n this.venmoHandlerCache = new VenmoFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.venmoHandlerCache;\n }\n\n get googlePayHandler(): GooglePayFlowHandlerInterface | undefined {\n if (this.googlePayHandlerCache) {\n return this.googlePayHandlerCache;\n }\n\n this.googlePayHandlerCache = new GooglePayFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.googlePayHandlerCache;\n }\n\n private creditCardHandlerCache?: CreditCardFlowHandlerInterface;\n private paypalHandlerCache?: PayPalFlowHandlerInterface;\n private applePayHandlerCache?: ApplePayFlowHandlerInterface;\n private venmoHandlerCache?: VenmoFlowHandlerInterface;\n private googlePayHandlerCache?: GooglePayFlowHandlerInterface;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n recaptchaManager: RecaptchaManagerInterface;\n resources: {\n analytics: {\n logEvent: (action: string, label: string) => void;\n logEventNoSampling: (action: string, label: string) => void;\n };\n };\n }) {\n this.braintreeManager = options.braintreeManager;\n this.modalManager = options.modalManager;\n this.recaptchaManager = options.recaptchaManager;\n this.resources = options.resources;\n\n this.donationFlowModalManager = new DonationFlowModalManager({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n analytics: this.resources.analytics,\n });\n }\n\n private braintreeManager: BraintreeManagerInterface;\n private modalManager: ModalManagerInterface;\n private recaptchaManager: RecaptchaManagerInterface;\n private donationFlowModalManager: DonationFlowModalManagerInterface;\n private resources: {\n analytics: {\n logEvent: (action: string, label: string) => void;\n logEventNoSampling: (action: string, label: string) => void;\n };\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment-flow-handlers.js","sourceRoot":"","sources":["../../../src/payment-flow-handlers/payment-flow-handlers.ts"],"names":[],"mappings":";AAEA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAA8B,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAG/F,OAAO,EAEL,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAA6B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E,IAAI,CAAC,gBAAgB;YACvC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;SACxD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;CAyCF","sourcesContent":["import { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport {\n CreditCardFlowHandlerInterface,\n CreditCardFlowHandler,\n} from './handlers/creditcard-flow-handler';\nimport { PayPalFlowHandlerInterface, PayPalFlowHandler } from './handlers/paypal-flow-handler';\nimport { BraintreeManagerInterface } from '../braintree-manager/braintree-interfaces';\nimport { RecaptchaManagerInterface } from '../recaptcha-manager/recaptcha-manager';\nimport {\n ApplePayFlowHandlerInterface,\n ApplePayFlowHandler,\n} from './handlers/applepay-flow-handler';\nimport { VenmoFlowHandlerInterface, VenmoFlowHandler } from './handlers/venmo-flow-handler';\nimport {\n DonationFlowModalManagerInterface,\n DonationFlowModalManager,\n} from './donation-flow-modal-manager';\nimport {\n GooglePayFlowHandlerInterface,\n GooglePayFlowHandler,\n} from './handlers/googlepay-flow-handler';\nimport { UpsellModalCTAMode } from '../modals/upsell-modal-content';\nimport { DonationType } from '@internetarchive/donation-form-data-models';\n\nexport interface PaymentFlowHandlersInterface {\n startup(): Promise<void>;\n /**\n * Show the upsell modal\n *\n * @param {{\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} [options]\n * @returns {Promise<void>}\n * @memberof DonationFlowModalManagerInterface\n */\n showUpsellModal(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\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void>;\n\n creditCardHandler: CreditCardFlowHandlerInterface | undefined;\n paypalHandler: PayPalFlowHandlerInterface | undefined;\n applePayHandler: ApplePayFlowHandlerInterface | undefined;\n venmoHandler: VenmoFlowHandlerInterface | undefined;\n googlePayHandler: GooglePayFlowHandlerInterface | undefined;\n}\n\n/**\n * This class is a container for all of the individual flow handlers.\n *\n * Flow Handlers are responsible for handling the provider-specific interactions between\n * the UI and the Data.\n *\n * For instance, when the user clicks on the \"Donate\" button for credit cards, we\n * pull in contact info from the form, trigger the recaptcha, tokenize the form,\n * submit, show the upsell, complete. The Credit Card Flow Handler is responsible for\n * managing that series of steps.\n *\n * For PayPal, the user initiates the payment from the PayPal button and once they're\n * done, we show the modal. The PayPal Flow Handler is responsible for handling that\n * series of events.\n *\n * @export\n * @class PaymentFlowHandlers\n * @implements {PaymentFlowHandlersInterface}\n */\nexport class PaymentFlowHandlers implements PaymentFlowHandlersInterface {\n async startup(): Promise<void> {\n this.venmoHandler?.startup();\n this.creditCardHandler?.startup();\n }\n\n /** @inheritdoc */\n async showUpsellModal(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 return this.donationFlowModalManager.showUpsellModal(options);\n }\n\n /** @inheritdoc */\n showConfirmationStepModal(options: {\n amount: number;\n donationType: DonationType;\n currencyType: string;\n confirmDonationCB: Function;\n cancelDonationCB: Function;\n }): Promise<void> {\n return this.donationFlowModalManager.showConfirmationStepModal(options);\n }\n\n get creditCardHandler(): CreditCardFlowHandlerInterface | undefined {\n if (this.creditCardHandlerCache) {\n return this.creditCardHandlerCache;\n }\n\n this.creditCardHandlerCache = new CreditCardFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n return this.creditCardHandlerCache;\n }\n\n get paypalHandler(): PayPalFlowHandlerInterface | undefined {\n if (this.paypalHandlerCache) {\n return this.paypalHandlerCache;\n }\n\n this.paypalHandlerCache = new PayPalFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.paypalHandlerCache;\n }\n\n get applePayHandler(): ApplePayFlowHandlerInterface | undefined {\n if (this.applePayHandlerCache) {\n return this.applePayHandlerCache;\n }\n\n this.applePayHandlerCache = new ApplePayFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.applePayHandlerCache;\n }\n\n get venmoHandler(): VenmoFlowHandlerInterface | undefined {\n if (this.venmoHandlerCache) {\n return this.venmoHandlerCache;\n }\n\n this.venmoHandlerCache = new VenmoFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.venmoHandlerCache;\n }\n\n get googlePayHandler(): GooglePayFlowHandlerInterface | undefined {\n if (this.googlePayHandlerCache) {\n return this.googlePayHandlerCache;\n }\n\n this.googlePayHandlerCache = new GooglePayFlowHandler({\n braintreeManager: this.braintreeManager,\n donationFlowModalManager: this.donationFlowModalManager,\n });\n\n return this.googlePayHandlerCache;\n }\n\n private creditCardHandlerCache?: CreditCardFlowHandlerInterface;\n private paypalHandlerCache?: PayPalFlowHandlerInterface;\n private applePayHandlerCache?: ApplePayFlowHandlerInterface;\n private venmoHandlerCache?: VenmoFlowHandlerInterface;\n private googlePayHandlerCache?: GooglePayFlowHandlerInterface;\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n recaptchaManager: RecaptchaManagerInterface;\n resources: {\n analytics: {\n logEvent: (action: string, label: string) => void;\n logDonationFlowEvent: (action: string, label: string) => void;\n };\n };\n }) {\n this.braintreeManager = options.braintreeManager;\n this.modalManager = options.modalManager;\n this.recaptchaManager = options.recaptchaManager;\n this.resources = options.resources;\n\n this.donationFlowModalManager = new DonationFlowModalManager({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n analytics: this.resources.analytics,\n });\n }\n\n private braintreeManager: BraintreeManagerInterface;\n private modalManager: ModalManagerInterface;\n private recaptchaManager: RecaptchaManagerInterface;\n private donationFlowModalManager: DonationFlowModalManagerInterface;\n private resources: {\n analytics: {\n logEvent: (action: string, label: string) => void;\n logDonationFlowEvent: (action: string, label: string) => void;\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;
|
|
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"]}
|
|
@@ -14,7 +14,7 @@ describe('Donation Flow Modal Manager', () => {
|
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
analytics = {
|
|
16
16
|
logEvent: sinon.fake(),
|
|
17
|
-
|
|
17
|
+
logDonationFlowEvent: sinon.fake(),
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
afterEach(() => {
|
|
@@ -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;
|
|
@@ -96,14 +96,14 @@ describe('Donation Flow Modal Manager', () => {
|
|
|
96
96
|
`));
|
|
97
97
|
const mockBraintreeManager = new MockBraintreeManager();
|
|
98
98
|
const logEvent = sinon.fake();
|
|
99
|
-
const
|
|
99
|
+
const logDonationFlowEvent = sinon.fake();
|
|
100
100
|
const manager = new DonationFlowModalManager({
|
|
101
101
|
braintreeManager: mockBraintreeManager,
|
|
102
102
|
modalManager: mockModalManager,
|
|
103
103
|
analytics: {
|
|
104
104
|
logEvent,
|
|
105
|
-
|
|
106
|
-
}
|
|
105
|
+
logDonationFlowEvent,
|
|
106
|
+
},
|
|
107
107
|
});
|
|
108
108
|
manager.showThankYouModal({
|
|
109
109
|
successResponse: mockSuccessResponse,
|
|
@@ -124,14 +124,14 @@ describe('Donation Flow Modal Manager', () => {
|
|
|
124
124
|
`));
|
|
125
125
|
const mockBraintreeManager = new MockBraintreeManager();
|
|
126
126
|
const logEvent = sinon.fake();
|
|
127
|
-
const
|
|
127
|
+
const logDonationFlowEvent = sinon.fake();
|
|
128
128
|
const manager = new DonationFlowModalManager({
|
|
129
129
|
braintreeManager: mockBraintreeManager,
|
|
130
130
|
modalManager: mockModalManager,
|
|
131
131
|
analytics: {
|
|
132
132
|
logEvent,
|
|
133
|
-
|
|
134
|
-
}
|
|
133
|
+
logDonationFlowEvent,
|
|
134
|
+
},
|
|
135
135
|
});
|
|
136
136
|
const successResponse = mockSuccessResponse;
|
|
137
137
|
successResponse.paymentProvider = PaymentProvider.GooglePay;
|
|
@@ -139,9 +139,9 @@ describe('Donation Flow Modal Manager', () => {
|
|
|
139
139
|
successResponse: mockSuccessResponse,
|
|
140
140
|
});
|
|
141
141
|
// fires analytics
|
|
142
|
-
expect(
|
|
143
|
-
expect(
|
|
144
|
-
expect(
|
|
142
|
+
expect(logDonationFlowEvent.callCount).to.equal(1);
|
|
143
|
+
expect(logDonationFlowEvent.args[0][0]).to.equal(`Donated-GooglePay`);
|
|
144
|
+
expect(logDonationFlowEvent.args[0][1]).to.equal(DonationType.OneTime);
|
|
145
145
|
}));
|
|
146
146
|
it('can show the confirmation modal', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
147
|
var _f, _g;
|
|
@@ -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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AAE,OAAO;oBAClB,QAAQ,EAAE,YAAY;iBACvB;gBACD,WAAW,EAAE,KAAK;gBAClB,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 logEventNoSampling: 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 logEventNoSampling = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logEventNoSampling,\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 logEventNoSampling = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logEventNoSampling,\n }\n });\n const successResponse = mockSuccessResponse;\n successResponse.paymentProvider = PaymentProvider.GooglePay;\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n\n // fires analytics\n expect(logEventNoSampling.callCount).to.equal(1);\n expect(logEventNoSampling.args[0][0]).to.equal(`Donated-GooglePay`);\n expect(logEventNoSampling.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,OA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;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"]}
|
package/package.json
CHANGED
|
@@ -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.logEventNoSampling('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.logEventNoSampling('origin', this.origin);
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
if (
|
|
@@ -329,7 +327,7 @@ export class DonationFormController extends LitElement {
|
|
|
329
327
|
resources: {
|
|
330
328
|
analytics: {
|
|
331
329
|
logEvent: this.logEvent.bind(this),
|
|
332
|
-
|
|
330
|
+
logDonationFlowEvent: this.logDonationFlowEvent.bind(this),
|
|
333
331
|
} as DonationControllerEventLoggerInterface,
|
|
334
332
|
}
|
|
335
333
|
});
|
|
@@ -531,13 +529,13 @@ export class DonationFormController extends LitElement {
|
|
|
531
529
|
}
|
|
532
530
|
|
|
533
531
|
/**
|
|
534
|
-
*
|
|
532
|
+
* Logs `DonationFlow` Event category into no sample bucket
|
|
535
533
|
*
|
|
536
534
|
* @param {string} action Name of event
|
|
537
535
|
* @param {string} label Event label, optional
|
|
538
536
|
*/
|
|
539
|
-
private
|
|
540
|
-
const analyticEvent = { action, label, category:
|
|
537
|
+
private logDonationFlowEvent(action: string, label?: string): void {
|
|
538
|
+
const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;
|
|
541
539
|
this.analyticsHandler?.sendEventNoSampling(analyticEvent);
|
|
542
540
|
}
|
|
543
541
|
|
|
@@ -206,7 +206,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
206
206
|
action += `-upsell`;
|
|
207
207
|
}
|
|
208
208
|
const label = options.successResponse.donationType;
|
|
209
|
-
this.analytics.
|
|
209
|
+
this.analytics.logDonationFlowEvent(action, label);
|
|
210
210
|
|
|
211
211
|
// post donation
|
|
212
212
|
this.braintreeManager.donationSuccessful(options);
|
|
@@ -400,7 +400,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
400
400
|
const selectedPayment = options.successResponse.paymentProvider.replace(/\s+/g, '');
|
|
401
401
|
const action = `Donated-${selectedPayment}-upsell`;
|
|
402
402
|
const label = options.successResponse.donationType;
|
|
403
|
-
this.analytics.
|
|
403
|
+
this.analytics.logDonationFlowEvent(action, label);
|
|
404
404
|
|
|
405
405
|
this.braintreeManager.donationSuccessful(options);
|
|
406
406
|
}
|
|
@@ -189,7 +189,7 @@ export class PaymentFlowHandlers implements PaymentFlowHandlersInterface {
|
|
|
189
189
|
resources: {
|
|
190
190
|
analytics: {
|
|
191
191
|
logEvent: (action: string, label: string) => void;
|
|
192
|
-
|
|
192
|
+
logDonationFlowEvent: (action: string, label: string) => void;
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
}) {
|
|
@@ -212,7 +212,7 @@ export class PaymentFlowHandlers implements PaymentFlowHandlersInterface {
|
|
|
212
212
|
private resources: {
|
|
213
213
|
analytics: {
|
|
214
214
|
logEvent: (action: string, label: string) => void;
|
|
215
|
-
|
|
215
|
+
logDonationFlowEvent: (action: string, label: string) => void;
|
|
216
216
|
};
|
|
217
217
|
};
|
|
218
218
|
}
|