@internetarchive/donation-form 0.6.1-alpha.1 → 0.6.2-alpha.1
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/src/donation-form.js.map +1 -1
- package/dist/src/form-elements/payment-selector.js +26 -8
- package/dist/src/form-elements/payment-selector.js.map +1 -1
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +3 -2
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js.map +1 -1
- package/package.json +3 -3
- package/src/donation-form.ts +4 -3
- package/src/form-elements/payment-selector.ts +42 -19
- package/dist/src/models/donation-form-config.d.ts +0 -6
- package/dist/src/models/donation-form-config.js +0 -6
- package/dist/src/models/donation-form-config.js.map +0 -1
- package/dist/test/helpers/promisedSleep.d.ts +0 -1
- package/dist/test/helpers/promisedSleep.js +0 -4
- package/dist/test/helpers/promisedSleep.js.map +0 -1
- package/dist/test/mocks/mock-analytics-handler.d.ts +0 -8
- package/dist/test/mocks/mock-analytics-handler.js +0 -10
- package/dist/test/mocks/mock-analytics-handler.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form.js","sourceRoot":"","sources":["../../src/donation-form.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,OAAO,MAAM,qCAAqC,CAAC;AAE1D,qFAAqF;AACrF,kFAAkF;AAClF,6EAA6E;AAC7E,8EAA8E;AAC9E,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6CAA6C,CAAC;AAOrD,OAAO,EAEL,mBAAmB,EACnB,eAAe,EAEf,YAAY,EACZ,sBAAsB,GACvB,MAAM,4CAA4C,CAAC;AAIpD,OAAO,EACL,iCAAiC,EACjC,kCAAkC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AAE,CAAC;mDAAkD;AAEhD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DACmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DACiB;AAEf;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAmC;AAElC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDAAoC;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAkC;AAElC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAmD;AAEhD;IAA7B,KAAK,CAAC,qBAAqB,CAAC;wDAA0C;AAExC;IAA9B,KAAK,CAAC,sBAAsB,CAAC;wDAAyC;AAE5C;IAA1B,KAAK,CAAC,kBAAkB,CAAC;qDAAmC;AA/BlD,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA+gBxB;SA/gBY,YAAY","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport lockImg from '@internetarchive/icon-lock/index.js';\n\n// we have to import the registered component independently from the definition below\n// because inside each of these files, we're registering the custom element inside\n// these files and by simply importing the class name, you lose that behavior\n// See https://github.com/microsoft/TypeScript/issues/9191 for more discussion\nimport './form-elements/payment-selector';\nimport './form-elements/header/donation-form-header';\n\nimport { DonationFormHeader } from './form-elements/header/donation-form-header';\nimport { PaymentSelector } from './form-elements/payment-selector';\n\nimport { BraintreeManagerInterface } from './braintree-manager/braintree-interfaces';\n\nimport {\n DonationRequest,\n DonationPaymentInfo,\n PaymentProvider,\n DonorContactInfo,\n DonationType,\n defaultDonationAmounts,\n} from '@internetarchive/donation-form-data-models';\n\nimport { PaymentFlowHandlersInterface } from './payment-flow-handlers/payment-flow-handlers';\n\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport '@internetarchive/donation-form-section';\nimport {\n DonationFormSection,\n DonationFormSectionBadgeMode,\n} from '@internetarchive/donation-form-section';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/total-amount';\n\n@customElement('donation-form')\nexport class DonationForm extends LitElement {\n @property({ type: Object }) braintreeManager: BraintreeManagerInterface | undefined;\n\n @property({ type: Object }) paymentFlowHandlers: PaymentFlowHandlersInterface | undefined;\n\n @property({ type: Object }) donationRequest: DonationRequest | undefined;\n\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: Object }) contactForm?: ContactForm;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: Boolean }) private creditCardVisible = false;\n\n @property({ type: Boolean }) private contactFormVisible = false;\n\n @property({ type: Boolean }) private donationInfoValid = true;\n\n @property({ type: String }) private selectedPaymentProvider?: PaymentProvider;\n\n @query('#contactFormSection') contactFormSection?: DonationFormSection;\n\n @query('donation-form-header') donationFormHeader!: DonationFormHeader;\n\n @query('payment-selector') paymentSelector!: PaymentSelector;\n\n private paypalButtonNeedsRender = true;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <donation-form-header\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-header>\n\n <donation-form-section\n .badgeMode=${DonationFormSectionBadgeMode.HideBadgeLeaveSpacing}\n id=\"total-amount-section\"\n >\n <donation-form-total-amount .donationInfo=${this.donationInfo}>\n </donation-form-total-amount>\n </donation-form-section>\n\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart}\n headline=\"Choose a payment method\"\n >\n <payment-selector\n .paymentProviders=${this.braintreeManager?.paymentProviders}\n @firstUpdated=${this.paymentSelectorFirstUpdated}\n @creditCardSelected=${this.creditCardSelected}\n @venmoSelected=${this.venmoSelected}\n @applePaySelected=${this.applePaySelected}\n @googlePaySelected=${this.googlePaySelected}\n @paypalBlockerSelected=${this.paypalBlockerSelected}\n @resetPaymentMethod=${async () => {\n this.selectedPaymentProvider = undefined;\n this.contactFormVisible = false;\n this.requestUpdate();\n }}\n tabindex=\"0\"\n >\n <slot name=\"paypal-button\" slot=\"paypal-button\"></slot>\n </payment-selector>\n </donation-form-section>\n\n <div class=\"contact-form-section ${this.contactFormVisible ? '' : 'hidden'}\">\n ${this.contactFormSectionTemplate}\n </div>\n <slot name=\"recaptcha\"></slot>\n `;\n }\n\n async showConfirmationModalDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.paymentFlowHandlers?.showConfirmationStepModal(options);\n }\n\n /**\n * This is a developer convenience method that allows us to show the upsell modal without going\n * through the purchasing flow. If it's showing the PayPal button, it will trigger\n * the PayPal button render\n *\n * @param {{\n * oneTimeAmount: number;\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 DonationForm\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.paymentFlowHandlers?.showUpsellModal(options);\n\n if (options.ctaMode === UpsellModalCTAMode.PayPalUpsellSlot) {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n const donationInfo = new DonationPaymentInfo({\n amount: options.oneTimeAmount,\n donationType: DonationType.OneTime,\n coverFees: false,\n });\n handler?.renderPayPalButton({\n selector: '#paypal-upsell-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption,\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'responsive' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n }\n }\n\n get contactFormSectionTemplate(): TemplateResult {\n const headline = this.selectedPaymentProvider === PaymentProvider.Venmo\n ? 'Help us stay in touch'\n : 'Enter payment information';\n\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=${headline}\n id=\"contactFormSection\"\n >\n <slot name=\"contact-form\"></slot>\n <div class=\"credit-card-fields\" class=\"${this.creditCardVisible ? '' : 'hidden'}\">\n <slot name=\"braintree-hosted-fields\"></slot>\n </div>\n </donation-form-section>\n\n <donation-form-section .sectionBadge=${this.paymentSelectorNumberingStart + 2}>\n <slot name=\"recaptcha\"></slot>\n <button id=\"donate-button\" @click=${this.donateClicked}>Donate</button>\n\n <div class=\"secure-process-note\">${lockImg} Your payment will be securely processed</div>\n </donation-form-section>\n `;\n }\n\n /**\n * Where to start the numbering of the payment selector\n *\n * - If we show the frequency selector in button mode, it becomes section 1, which makes\n * the amount selection section 2, and the payment selector section 3.\n * - If we show the frequency selector in checkbox mode, it is no longer section 1. The amount\n * selector becomes section 1 and the payment selector becomes section 2.\n *\n * Visually:\n *\n * Button Mode:\n * 1. Frequency selector\n * 2. Amount selector\n * 3. Payment selector\n * 4. Contact info\n * 5. Donate button\n *\n * Checkbox Mode:\n * 1. Amount selector (including the monthly checkbox)\n * 2. Payment selector <-- changes from 3 to 2\n * 3. Contact info <-- changes from 4 to 3\n * 4. Donate button <-- changes from 5 to 4\n *\n * @readonly\n * @private\n * @type {number}\n * @memberof DonationForm\n */\n private get paymentSelectorNumberingStart(): number {\n return this.frequencySelectionMode === EditDonationFrequencySelectionMode.Button ? 3 : 2;\n }\n\n private editDonationError(): void {\n this.donationInfoValid = false;\n }\n\n private paymentSelectorFirstUpdated(): void {\n if (this.paymentFlowHandlers?.paypalHandler) {\n this.renderPayPalButtonIfNeeded();\n }\n }\n\n private applePaySelected(e: CustomEvent): void {\n this.selectedPaymentProvider = PaymentProvider.ApplePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const originalEvent = e.detail.originalEvent;\n this.donationInfo &&\n this.paymentFlowHandlers?.applePayHandler?.paymentInitiated(this.donationInfo, originalEvent);\n this.emitPaymentFlowStartedEvent();\n }\n\n private googlePaySelected(): void {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n } else {\n this.donationInfo &&\n this.paymentFlowHandlers?.googlePayHandler?.paymentInitiated(this.donationInfo);\n this.emitPaymentFlowStartedEvent();\n }\n }\n\n private async creditCardSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.CreditCard;\n this.contactFormVisible = true;\n this.creditCardVisible = true;\n this.focusContactForm();\n }\n\n private async venmoSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.Venmo;\n this.contactFormVisible = true;\n this.creditCardVisible = false;\n this.focusContactForm();\n }\n\n private paypalBlockerSelected(): void {\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n this.showInvalidDonationInfoAlert();\n }\n\n private async focusContactForm(): Promise<void> {\n await this.updateComplete;\n if (this.contactFormSection) {\n this.contactForm?.focus();\n }\n }\n\n private async donateClicked(): Promise<void> {\n if (!this.contactForm) {\n alert('Please enter contact info.');\n return;\n }\n if (!this.donationInfoValid || !this.donationInfo) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const contactInfo = this.contactForm.donorContactInfo;\n\n switch (this.selectedPaymentProvider) {\n case PaymentProvider.CreditCard:\n this.handleCreditCardDonationFlow(contactInfo, this.donationInfo);\n break;\n case PaymentProvider.Venmo:\n this.handleVenmoDonationFlow(contactInfo, this.donationInfo);\n break;\n }\n }\n\n private async handleCreditCardDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const creditCardFlowHandler = this.paymentFlowHandlers?.creditCardHandler;\n const creditCardHandler = await this.braintreeManager?.paymentProviders.creditCardHandler.get();\n creditCardHandler?.hideErrorMessage();\n const valid = this.contactForm?.reportValidity();\n const hostedFieldsResponse = await creditCardFlowHandler?.tokenizeFields();\n\n if (!valid || hostedFieldsResponse === undefined) {\n return;\n }\n\n this.emitPaymentFlowStartedEvent();\n creditCardFlowHandler?.paymentInitiated(hostedFieldsResponse, donationInfo, contactInfo);\n }\n\n private async handleVenmoDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const valid = this.contactForm?.reportValidity();\n if (!valid) {\n return;\n }\n this.paymentFlowHandlers?.venmoHandler?.paymentInitiated(contactInfo, donationInfo);\n }\n\n private emitPaymentFlowStartedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowStarted', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowConfirmedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowConfirmed', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowCancelledEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowCancelled', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowErrorEvent(error?: string): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowError', {\n detail: { paymentProvider: this.selectedPaymentProvider, error: error },\n });\n this.dispatchEvent(event);\n }\n\n private showInvalidDonationInfoAlert(): void {\n alert('Please enter a valid donation amount.');\n }\n\n private async renderPayPalButtonIfNeeded(): Promise<void> {\n if (!this.paypalButtonNeedsRender) {\n return;\n }\n this.paypalButtonNeedsRender = false;\n this.donationInfo &&\n (await this.paymentFlowHandlers?.paypalHandler?.renderPayPalButton(this.donationInfo));\n this.paymentSelector.showPaypalButton();\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('donationInfo') && this.donationInfo) {\n // The PayPal button has a standalone datasource since we don't initiate the payment\n // through code so it has to have the donation info ready when the user taps the button.\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n this.donationFormHeader.donationInfo = this.donationInfo;\n }\n\n if (\n (changedProperties.has('paymentFlowHandlers') || changedProperties.has('donationInfo')) &&\n this.donationInfo &&\n this.paymentFlowHandlers\n ) {\n this.setupFlowHandlers();\n }\n\n if (changedProperties.has('donationInfoValid')) {\n this.paymentSelector.donationInfoValid = this.donationInfoValid;\n }\n\n if (changedProperties.has('selectedPaymentProvider')) {\n const event = new CustomEvent('paymentProviderSelected', {\n detail: {\n paymentProvider: this.selectedPaymentProvider,\n previousPaymentProvider: changedProperties.get('selectedPaymentProvider'),\n },\n });\n this.dispatchEvent(event);\n }\n }\n\n private flowHandlersConfigured = false;\n\n private setupFlowHandlers(): void {\n if (this.flowHandlersConfigured) {\n return;\n }\n this.flowHandlersConfigured = true;\n this.bindFlowListenerEvents();\n this.renderPayPalButtonIfNeeded();\n this.donationInfo &&\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n }\n\n private flowHandlerListenersBound = false;\n\n private bindFlowListenerEvents(): void {\n if (this.flowHandlerListenersBound) {\n return;\n }\n this.flowHandlerListenersBound = true;\n\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentStarted', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowStartedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentConfirmed', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowConfirmedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowCancelledEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentError', (datasource, error) => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowErrorEvent(error);\n });\n\n this.paymentFlowHandlers?.googlePayHandler?.on('paymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.emitPaymentFlowCancelledEvent();\n });\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n const donationInfo: DonationPaymentInfo = e.detail.donationInfo;\n this.donationInfo = new DonationPaymentInfo({\n amount: donationInfo.amount,\n donationType: donationInfo.donationType,\n coverFees: donationInfo.coverFees,\n });\n this.donationInfoValid = true;\n const event = new CustomEvent('donationInfoChanged', { detail: { donationInfo } });\n this.dispatchEvent(event);\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const donateButtonFontSize = css`var(--donateButtonFontSize, 2.6rem)`;\n const donateButtonHeight = css`var(--donateButtonHeight, 4rem)`;\n const donateButtonColor = css`var(--donateButtonColor, rgba(49, 164, 129, 1))`;\n const donateButtonTextColor = css`var(--donateButtonTextColor, #fff)`;\n const donateButtonHoverColor = css`var(--donateButtonHoverColor, rgba(39, 131, 103, 1))`;\n const totalAmountTopMargin = css`var(--donateTotalAmountTopMargin, 1.5rem)`;\n const totalAmountBottomMargin = css`var(--donateTotalAmountBottomMargin, 1.2rem)`;\n\n return css`\n h1 {\n margin: 0;\n padding: 0;\n }\n\n .hidden {\n display: none;\n }\n\n .secure-process-note {\n margin-top: 0.5em;\n font-size: 0.75em;\n text-align: center;\n }\n\n .secure-process-note svg {\n width: 1.2rem;\n height: 1.5rem;\n vertical-align: bottom;\n }\n\n #donate-button {\n width: 100%;\n appearance: none;\n -webkit-appearance: none;\n font-size: ${donateButtonFontSize};\n font-weight: bold;\n text-align: center;\n color: ${donateButtonTextColor};\n cursor: pointer;\n border: none;\n border-radius: 5px;\n background-color: ${donateButtonColor};\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n height: ${donateButtonHeight};\n }\n\n #donate-button:hover {\n background-color: ${donateButtonHoverColor};\n }\n\n #total-amount-section {\n display: block;\n margin-top: ${totalAmountTopMargin};\n margin-bottom: ${totalAmountBottomMargin};\n }\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"donation-form.js","sourceRoot":"","sources":["../../src/donation-form.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,OAAO,MAAM,qCAAqC,CAAC;AAE1D,qFAAqF;AACrF,kFAAkF;AAClF,6EAA6E;AAC7E,8EAA8E;AAC9E,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6CAA6C,CAAC;AAOrD,OAAO,EAEL,mBAAmB,EACnB,eAAe,EAEf,YAAY,EACZ,sBAAsB,GACvB,MAAM,4CAA4C,CAAC;AAIpD,OAAO,EACL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAEL,4BAA4B,GAC7B,MAAM,wCAAwC,CAAC;AAChD,OAAO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,IAAI,EAAE,MAAM,EAAE,CAAC;4DACiB;AAEf;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAmC;AAElC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDAAoC;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAkC;AAElC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAmD;AAEhD;IAA7B,KAAK,CAAC,qBAAqB,CAAC;wDAA0C;AAExC;IAA9B,KAAK,CAAC,sBAAsB,CAAC;wDAAyC;AAE5C;IAA1B,KAAK,CAAC,kBAAkB,CAAC;qDAAmC;AA/BlD,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAghBxB;SAhhBY,YAAY","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport lockImg from '@internetarchive/icon-lock/index.js';\n\n// we have to import the registered component independently from the definition below\n// because inside each of these files, we're registering the custom element inside\n// these files and by simply importing the class name, you lose that behavior\n// See https://github.com/microsoft/TypeScript/issues/9191 for more discussion\nimport './form-elements/payment-selector';\nimport './form-elements/header/donation-form-header';\n\nimport { DonationFormHeader } from './form-elements/header/donation-form-header';\nimport { PaymentSelector } from './form-elements/payment-selector';\n\nimport { BraintreeManagerInterface } from './braintree-manager/braintree-interfaces';\n\nimport {\n DonationRequest,\n DonationPaymentInfo,\n PaymentProvider,\n DonorContactInfo,\n DonationType,\n defaultDonationAmounts,\n} from '@internetarchive/donation-form-data-models';\n\nimport { PaymentFlowHandlersInterface } from './payment-flow-handlers/payment-flow-handlers';\n\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport '@internetarchive/donation-form-section';\nimport {\n DonationFormSection,\n DonationFormSectionBadgeMode,\n} from '@internetarchive/donation-form-section';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/total-amount';\n\n@customElement('donation-form')\nexport class DonationForm extends LitElement {\n @property({ type: Object }) braintreeManager: BraintreeManagerInterface | undefined;\n\n @property({ type: Object }) paymentFlowHandlers: PaymentFlowHandlersInterface | undefined;\n\n @property({ type: Object }) donationRequest: DonationRequest | undefined;\n\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: Object }) contactForm?: ContactForm;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: Boolean }) private creditCardVisible = false;\n\n @property({ type: Boolean }) private contactFormVisible = false;\n\n @property({ type: Boolean }) private donationInfoValid = true;\n\n @property({ type: String }) private selectedPaymentProvider?: PaymentProvider;\n\n @query('#contactFormSection') contactFormSection?: DonationFormSection;\n\n @query('donation-form-header') donationFormHeader!: DonationFormHeader;\n\n @query('payment-selector') paymentSelector!: PaymentSelector;\n\n private paypalButtonNeedsRender = true;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <donation-form-header\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-header>\n\n <donation-form-section\n .badgeMode=${DonationFormSectionBadgeMode.HideBadgeLeaveSpacing}\n id=\"total-amount-section\"\n >\n <donation-form-total-amount .donationInfo=${this.donationInfo}>\n </donation-form-total-amount>\n </donation-form-section>\n\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart}\n headline=\"Choose a payment method\"\n >\n <payment-selector\n .paymentProviders=${this.braintreeManager?.paymentProviders}\n @firstUpdated=${this.paymentSelectorFirstUpdated}\n @creditCardSelected=${this.creditCardSelected}\n @venmoSelected=${this.venmoSelected}\n @applePaySelected=${this.applePaySelected}\n @googlePaySelected=${this.googlePaySelected}\n @paypalBlockerSelected=${this.paypalBlockerSelected}\n @resetPaymentMethod=${async () => {\n this.selectedPaymentProvider = undefined;\n this.contactFormVisible = false;\n this.requestUpdate();\n }}\n tabindex=\"0\"\n >\n <slot name=\"paypal-button\" slot=\"paypal-button\"></slot>\n </payment-selector>\n </donation-form-section>\n\n <div class=\"contact-form-section ${this.contactFormVisible ? '' : 'hidden'}\">\n ${this.contactFormSectionTemplate}\n </div>\n <slot name=\"recaptcha\"></slot>\n `;\n }\n\n async showConfirmationModalDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.paymentFlowHandlers?.showConfirmationStepModal(options);\n }\n\n /**\n * This is a developer convenience method that allows us to show the upsell modal without going\n * through the purchasing flow. If it's showing the PayPal button, it will trigger\n * the PayPal button render\n *\n * @param {{\n * oneTimeAmount: number;\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 DonationForm\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.paymentFlowHandlers?.showUpsellModal(options);\n\n if (options.ctaMode === UpsellModalCTAMode.PayPalUpsellSlot) {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n const donationInfo = new DonationPaymentInfo({\n amount: options.oneTimeAmount,\n donationType: DonationType.OneTime,\n coverFees: false,\n });\n handler?.renderPayPalButton({\n selector: '#paypal-upsell-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption,\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'responsive' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n }\n }\n\n get contactFormSectionTemplate(): TemplateResult {\n const headline =\n this.selectedPaymentProvider === PaymentProvider.Venmo\n ? 'Help us stay in touch'\n : 'Enter payment information';\n\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=${headline}\n id=\"contactFormSection\"\n >\n <slot name=\"contact-form\"></slot>\n <div class=\"credit-card-fields\" class=\"${this.creditCardVisible ? '' : 'hidden'}\">\n <slot name=\"braintree-hosted-fields\"></slot>\n </div>\n </donation-form-section>\n\n <donation-form-section .sectionBadge=${this.paymentSelectorNumberingStart + 2}>\n <slot name=\"recaptcha\"></slot>\n <button id=\"donate-button\" @click=${this.donateClicked}>Donate</button>\n\n <div class=\"secure-process-note\">${lockImg} Your payment will be securely processed</div>\n </donation-form-section>\n `;\n }\n\n /**\n * Where to start the numbering of the payment selector\n *\n * - If we show the frequency selector in button mode, it becomes section 1, which makes\n * the amount selection section 2, and the payment selector section 3.\n * - If we show the frequency selector in checkbox mode, it is no longer section 1. The amount\n * selector becomes section 1 and the payment selector becomes section 2.\n *\n * Visually:\n *\n * Button Mode:\n * 1. Frequency selector\n * 2. Amount selector\n * 3. Payment selector\n * 4. Contact info\n * 5. Donate button\n *\n * Checkbox Mode:\n * 1. Amount selector (including the monthly checkbox)\n * 2. Payment selector <-- changes from 3 to 2\n * 3. Contact info <-- changes from 4 to 3\n * 4. Donate button <-- changes from 5 to 4\n *\n * @readonly\n * @private\n * @type {number}\n * @memberof DonationForm\n */\n private get paymentSelectorNumberingStart(): number {\n return this.frequencySelectionMode === EditDonationFrequencySelectionMode.Button ? 3 : 2;\n }\n\n private editDonationError(): void {\n this.donationInfoValid = false;\n }\n\n private paymentSelectorFirstUpdated(): void {\n if (this.paymentFlowHandlers?.paypalHandler) {\n this.renderPayPalButtonIfNeeded();\n }\n }\n\n private applePaySelected(e: CustomEvent): void {\n this.selectedPaymentProvider = PaymentProvider.ApplePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const originalEvent = e.detail.originalEvent;\n this.donationInfo &&\n this.paymentFlowHandlers?.applePayHandler?.paymentInitiated(this.donationInfo, originalEvent);\n this.emitPaymentFlowStartedEvent();\n }\n\n private googlePaySelected(): void {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n } else {\n this.donationInfo &&\n this.paymentFlowHandlers?.googlePayHandler?.paymentInitiated(this.donationInfo);\n this.emitPaymentFlowStartedEvent();\n }\n }\n\n private async creditCardSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.CreditCard;\n this.contactFormVisible = true;\n this.creditCardVisible = true;\n this.focusContactForm();\n }\n\n private async venmoSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.Venmo;\n this.contactFormVisible = true;\n this.creditCardVisible = false;\n this.focusContactForm();\n }\n\n private paypalBlockerSelected(): void {\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n this.showInvalidDonationInfoAlert();\n }\n\n private async focusContactForm(): Promise<void> {\n await this.updateComplete;\n if (this.contactFormSection) {\n this.contactForm?.focus();\n }\n }\n\n private async donateClicked(): Promise<void> {\n if (!this.contactForm) {\n alert('Please enter contact info.');\n return;\n }\n if (!this.donationInfoValid || !this.donationInfo) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const contactInfo = this.contactForm.donorContactInfo;\n\n switch (this.selectedPaymentProvider) {\n case PaymentProvider.CreditCard:\n this.handleCreditCardDonationFlow(contactInfo, this.donationInfo);\n break;\n case PaymentProvider.Venmo:\n this.handleVenmoDonationFlow(contactInfo, this.donationInfo);\n break;\n }\n }\n\n private async handleCreditCardDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const creditCardFlowHandler = this.paymentFlowHandlers?.creditCardHandler;\n const creditCardHandler = await this.braintreeManager?.paymentProviders.creditCardHandler.get();\n creditCardHandler?.hideErrorMessage();\n const valid = this.contactForm?.reportValidity();\n const hostedFieldsResponse = await creditCardFlowHandler?.tokenizeFields();\n\n if (!valid || hostedFieldsResponse === undefined) {\n return;\n }\n\n this.emitPaymentFlowStartedEvent();\n creditCardFlowHandler?.paymentInitiated(hostedFieldsResponse, donationInfo, contactInfo);\n }\n\n private async handleVenmoDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const valid = this.contactForm?.reportValidity();\n if (!valid) {\n return;\n }\n this.paymentFlowHandlers?.venmoHandler?.paymentInitiated(contactInfo, donationInfo);\n }\n\n private emitPaymentFlowStartedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowStarted', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowConfirmedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowConfirmed', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowCancelledEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowCancelled', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowErrorEvent(error?: string): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowError', {\n detail: { paymentProvider: this.selectedPaymentProvider, error: error },\n });\n this.dispatchEvent(event);\n }\n\n private showInvalidDonationInfoAlert(): void {\n alert('Please enter a valid donation amount.');\n }\n\n private async renderPayPalButtonIfNeeded(): Promise<void> {\n if (!this.paypalButtonNeedsRender) {\n return;\n }\n this.paypalButtonNeedsRender = false;\n this.donationInfo &&\n (await this.paymentFlowHandlers?.paypalHandler?.renderPayPalButton(this.donationInfo));\n this.paymentSelector.showPaypalButton();\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('donationInfo') && this.donationInfo) {\n // The PayPal button has a standalone datasource since we don't initiate the payment\n // through code so it has to have the donation info ready when the user taps the button.\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n this.donationFormHeader.donationInfo = this.donationInfo;\n }\n\n if (\n (changedProperties.has('paymentFlowHandlers') || changedProperties.has('donationInfo')) &&\n this.donationInfo &&\n this.paymentFlowHandlers\n ) {\n this.setupFlowHandlers();\n }\n\n if (changedProperties.has('donationInfoValid')) {\n this.paymentSelector.donationInfoValid = this.donationInfoValid;\n }\n\n if (changedProperties.has('selectedPaymentProvider')) {\n const event = new CustomEvent('paymentProviderSelected', {\n detail: {\n paymentProvider: this.selectedPaymentProvider,\n previousPaymentProvider: changedProperties.get('selectedPaymentProvider'),\n },\n });\n this.dispatchEvent(event);\n }\n }\n\n private flowHandlersConfigured = false;\n\n private setupFlowHandlers(): void {\n if (this.flowHandlersConfigured) {\n return;\n }\n this.flowHandlersConfigured = true;\n this.bindFlowListenerEvents();\n this.renderPayPalButtonIfNeeded();\n this.donationInfo &&\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n }\n\n private flowHandlerListenersBound = false;\n\n private bindFlowListenerEvents(): void {\n if (this.flowHandlerListenersBound) {\n return;\n }\n this.flowHandlerListenersBound = true;\n\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentStarted', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowStartedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentConfirmed', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowConfirmedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowCancelledEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentError', (datasource, error) => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowErrorEvent(error);\n });\n\n this.paymentFlowHandlers?.googlePayHandler?.on('paymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.emitPaymentFlowCancelledEvent();\n });\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n const donationInfo: DonationPaymentInfo = e.detail.donationInfo;\n this.donationInfo = new DonationPaymentInfo({\n amount: donationInfo.amount,\n donationType: donationInfo.donationType,\n coverFees: donationInfo.coverFees,\n });\n this.donationInfoValid = true;\n const event = new CustomEvent('donationInfoChanged', { detail: { donationInfo } });\n this.dispatchEvent(event);\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const donateButtonFontSize = css`var(--donateButtonFontSize, 2.6rem)`;\n const donateButtonHeight = css`var(--donateButtonHeight, 4rem)`;\n const donateButtonColor = css`var(--donateButtonColor, rgba(49, 164, 129, 1))`;\n const donateButtonTextColor = css`var(--donateButtonTextColor, #fff)`;\n const donateButtonHoverColor = css`var(--donateButtonHoverColor, rgba(39, 131, 103, 1))`;\n const totalAmountTopMargin = css`var(--donateTotalAmountTopMargin, 1.5rem)`;\n const totalAmountBottomMargin = css`var(--donateTotalAmountBottomMargin, 1.2rem)`;\n\n return css`\n h1 {\n margin: 0;\n padding: 0;\n }\n\n .hidden {\n display: none;\n }\n\n .secure-process-note {\n margin-top: 0.5em;\n font-size: 0.75em;\n text-align: center;\n }\n\n .secure-process-note svg {\n width: 1.2rem;\n height: 1.5rem;\n vertical-align: bottom;\n }\n\n #donate-button {\n width: 100%;\n appearance: none;\n -webkit-appearance: none;\n font-size: ${donateButtonFontSize};\n font-weight: bold;\n text-align: center;\n color: ${donateButtonTextColor};\n cursor: pointer;\n border: none;\n border-radius: 5px;\n background-color: ${donateButtonColor};\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n height: ${donateButtonHeight};\n }\n\n #donate-button:hover {\n background-color: ${donateButtonHoverColor};\n }\n\n #total-amount-section {\n display: block;\n margin-top: ${totalAmountTopMargin};\n margin-bottom: ${totalAmountBottomMargin};\n }\n `;\n }\n}\n"]}
|
|
@@ -32,7 +32,10 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
32
32
|
>
|
|
33
33
|
<div class="payment-provider-container">
|
|
34
34
|
<button
|
|
35
|
-
class="applepay provider-button ${this.applePayMode} ${this.paymentModeSelected ===
|
|
35
|
+
class="applepay provider-button ${this.applePayMode} ${this.paymentModeSelected ===
|
|
36
|
+
'apple'
|
|
37
|
+
? 'selected'
|
|
38
|
+
: ''}"
|
|
36
39
|
@click=${(e) => {
|
|
37
40
|
this.paymentModeSelected = 'apple';
|
|
38
41
|
this.applePaySelected(e);
|
|
@@ -43,7 +46,10 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
43
46
|
</button>
|
|
44
47
|
|
|
45
48
|
<button
|
|
46
|
-
class="googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected ===
|
|
49
|
+
class="googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected ===
|
|
50
|
+
'google'
|
|
51
|
+
? 'selected'
|
|
52
|
+
: ''}"
|
|
47
53
|
@click=${() => {
|
|
48
54
|
this.paymentModeSelected = 'google';
|
|
49
55
|
this.googlePaySelected();
|
|
@@ -54,7 +60,9 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
54
60
|
</button>
|
|
55
61
|
|
|
56
62
|
<button
|
|
57
|
-
class="venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo'
|
|
63
|
+
class="venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo'
|
|
64
|
+
? 'selected'
|
|
65
|
+
: ''}"
|
|
58
66
|
@click=${() => {
|
|
59
67
|
this.paymentModeSelected = 'venmo';
|
|
60
68
|
this.venmoSelected();
|
|
@@ -64,13 +72,19 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
64
72
|
<div class="payment-image">${venmoButtonImage}</div>
|
|
65
73
|
</button>
|
|
66
74
|
|
|
67
|
-
<div
|
|
75
|
+
<div
|
|
76
|
+
class="paypal-container provider-button ${this.payPalMode}
|
|
77
|
+
${this.paymentModeSelected === 'paypal' ? 'selected' : ''}"
|
|
78
|
+
tabindex="0"
|
|
79
|
+
>
|
|
68
80
|
<div class="payment-image">
|
|
69
|
-
<div
|
|
81
|
+
<div
|
|
82
|
+
class="paypal-local-button"
|
|
70
83
|
@click=${() => {
|
|
71
84
|
this.paymentModeSelected = 'paypal';
|
|
72
85
|
this.localPaypalButtonClicked();
|
|
73
|
-
}}
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
74
88
|
${paypalButtonImage}
|
|
75
89
|
</div>
|
|
76
90
|
<slot name="paypal-button"></slot>
|
|
@@ -84,7 +98,9 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
84
98
|
this.paymentModeSelected = 'cc';
|
|
85
99
|
this.creditCardSelected();
|
|
86
100
|
}}
|
|
87
|
-
class="button-style credit-card-button ${this.paymentModeSelected === 'cc'
|
|
101
|
+
class="button-style credit-card-button ${this.paymentModeSelected === 'cc'
|
|
102
|
+
? 'selected'
|
|
103
|
+
: ''}"
|
|
88
104
|
tabindex="0"
|
|
89
105
|
>
|
|
90
106
|
<div class="cc-title">Credit Card</div>
|
|
@@ -102,7 +118,9 @@ let PaymentSelector = class PaymentSelector extends LitElement {
|
|
|
102
118
|
this.dispatchEvent(new Event('resetPaymentMethod'));
|
|
103
119
|
this.setButtonVisibility();
|
|
104
120
|
}}
|
|
105
|
-
>
|
|
121
|
+
>
|
|
122
|
+
Change payment method
|
|
123
|
+
</button>
|
|
106
124
|
`
|
|
107
125
|
: nothing}
|
|
108
126
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-selector.js","sourceRoot":"","sources":["../../../src/form-elements/payment-selector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,OAAO,EAAE,MAAM,KAAK,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAGpE,IAAK,iBAIJ;AAJD,WAAK,iBAAiB;IACpB,wCAAmB,CAAA;IACnB,4CAAuB,CAAA;IACvB,gDAA2B,CAAA;AAC7B,CAAC,EAJI,iBAAiB,KAAjB,iBAAiB,QAIrB;AAGM,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QACwB,sBAAiB,GAAG,IAAI,CAAC;QAIlB,iBAAY,GAAsB,iBAAiB,CAAC,OAAO,CAAC;QAE5D,kBAAa,GAAsB,iBAAiB,CAAC,OAAO,CAAC;QAE7D,cAAS,GAAsB,iBAAiB,CAAC,OAAO,CAAC;QAEzD,eAAU,GAAsB,iBAAiB,CAAC,OAAO,CAAC;QAE1D,wBAAmB,GAA+D,SAAS,CAAC;IAwTlI,CAAC;IAtTC,kBAAkB;IAClB,MAAM;QACJ,MAAM,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,E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eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport applePayButtonImage from '@internetarchive/icon-applepay/index.js';\nimport googlePayButtonImage from '@internetarchive/icon-googlepay/index.js';\nimport paypalButtonImage from '@internetarchive/icon-paypal/index.js';\nimport venmoButtonImage from '@internetarchive/icon-venmo/index.js';\nimport { PaymentProvidersInterface } from '../braintree-manager/payment-providers-interface';\n\nenum PaymentButtonMode {\n Loading = 'loading',\n Available = 'available',\n Unavailable = 'unavailable',\n}\n\n@customElement('payment-selector')\nexport class PaymentSelector extends LitElement {\n @property({ type: Boolean }) donationInfoValid = true;\n\n @property({ type: Object }) paymentProviders?: PaymentProvidersInterface;\n\n @property({ type: String }) private applePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private googlePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private venmoMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private payPalMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private paymentModeSelected: 'apple' | 'google' | 'venmo' | 'cc' | 'paypal' | undefined = undefined;\n\n /** @inheritdoc */\n render(): TemplateResult {\n const paymentSelectedCss = this.paymentModeSelected ? 'payment-selected' : '';\n return html`\n <div\n class=\"payment-container ${this.donationInfoValid\n ? 'donation-info-valid'\n : 'donation-info-invalid'} ${paymentSelectedCss}\"\n >\n <div class=\"payment-provider-container\">\n <button\n class=\"applepay provider-button ${this.applePayMode} ${this.paymentModeSelected === 'apple' ? 'selected' : ''}\"\n @click=${(e: Event) => {\n this.paymentModeSelected = 'apple';\n this.applePaySelected(e);}\n }\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${applePayButtonImage}</div>\n </button>\n\n <button\n class=\"googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected === 'google' ? 'selected' : ''}\"\n @click=${() => {\n this.paymentModeSelected = 'google';\n this.googlePaySelected();}\n }\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${googlePayButtonImage}</div>\n </button>\n\n <button\n class=\"venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo' ? 'selected' : ''}\"\n @click=${() => {\n this.paymentModeSelected = 'venmo';\n this.venmoSelected();}\n }\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${venmoButtonImage}</div>\n </button>\n\n <div class=\"paypal-container provider-button ${this.payPalMode} ${this.paymentModeSelected === 'paypal' ? 'selected' : ''}\" tabindex=\"0\">\n <div class=\"payment-image\">\n <div class=\"paypal-local-button\"\n @click=${() => {\n this.paymentModeSelected = 'paypal';\n this.localPaypalButtonClicked();}\n }>\n ${paypalButtonImage}\n </div>\n <slot name=\"paypal-button\"></slot>\n </div>\n </div>\n </div>\n\n <div class=\"credit-card-container\">\n <button\n @click=${() => {\n this.paymentModeSelected = 'cc';\n this.creditCardSelected();\n }}\n class=\"button-style credit-card-button ${this.paymentModeSelected === 'cc' ? 'selected' : ''}\"\n tabindex=\"0\"\n >\n <div class=\"cc-title\">Credit Card</div>\n <div class=\"cc-background\"></div>\n </button>\n </div>\n </div>\n\n ${this.paymentModeSelected\n ? html`\n <button\n id=\"change-payment-method\"\n @click=${() => {\n this.paymentModeSelected = undefined;\n this.dispatchEvent(new Event('resetPaymentMethod'));\n this.setButtonVisibility();\n }}\n >Change payment method</button>\n `\n : nothing\n }\n `;\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.dispatchEvent(new Event('firstUpdated'));\n }\n\n /** @inheritdoc */\n updated(changed: PropertyValues): void {\n if (changed.has('paymentProviders')) {\n this.setButtonVisibility();\n }\n }\n\n showPaypalButton(): void {\n this.payPalMode = PaymentButtonMode.Available;\n }\n\n private async setButtonVisibility(): Promise<void> {\n this.paymentProviders?.venmoHandler\n .get()\n .then(handler => {\n if (!handler) {\n this.venmoMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.venmoMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading venmo', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('venmo unavailable', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.applePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('applePayHandler unavailable');\n this.applePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isAvailable()\n .then(supported => {\n this.applePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading applepay', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('apple pay unavailable', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.googlePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('google pay handler unavailable');\n this.googlePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.googlePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading googlepay', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('google pay unavailable', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n }\n\n private googlePaySelected(): void {\n this.dispatchEvent(new Event('googlePaySelected'));\n }\n\n private applePaySelected(e: Event): void {\n const event = new CustomEvent('applePaySelected', { detail: { originalEvent: e } });\n this.dispatchEvent(event);\n }\n\n private venmoSelected(): void {\n this.dispatchEvent(new Event('venmoSelected'));\n }\n\n private creditCardSelected(): void {\n this.dispatchEvent(new Event('creditCardSelected'));\n }\n\n private localPaypalButtonClicked(): void {\n this.dispatchEvent(new Event('paypalBlockerSelected'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const paymentButtonWidthCss = css`var(--paymentButtonWidth, 5rem)`;\n const paymentButtonHeightCss = css`var(--paymentButtonHeight, 3.2rem)`;\n const creditCardFontSizeCss = css`var(--creditCardFontSize, 1.8rem)`;\n\n return css`\n button {\n color: inherit;\n font-family: inherit;\n }\n\n .payment-container {\n width: 100%;\n }\n\n .payment-provider-container {\n display: grid;\n grid-template-columns: 1fr 1fr 1fr 1fr;\n grid-gap: 1rem;\n margin-bottom: 1rem;\n max-width: 23rem;\n }\n\n .provider-button {\n border: 0;\n padding: 0;\n background: none;\n cursor: pointer;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .provider-button.unavailable {\n display: none;\n }\n\n .provider-button.loading {\n border: 1px solid #ddd;\n border-radius: 2px;\n /* account for the borders that don't exist once the provider loads, otherwise the layout shifts */\n margin-bottom: -2px;\n }\n\n .provider-button.loading .payment-image {\n display: none;\n }\n\n .paypal-local-button {\n position: absolute;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .donation-info-valid .paypal-local-button {\n z-index: 0;\n }\n\n .donation-info-invalid .paypal-local-button {\n z-index: 250;\n }\n\n .credit-card-button {\n color: var(--ccButtonFontColor, #333);\n background-color: var(--ccButtonColor, white);\n border: 1px solid #333;\n border-radius: 4px;\n cursor: pointer;\n margin: 0;\n padding: 0.7rem 1rem;\n width: 100%;\n }\n\n .credit-card-button .cc-background {\n height: 2.4rem;\n width: 100%;\n background-repeat: no-repeat;\n background-image: url(https://archive.org/images/cc_logos.png);\n background-position: 50% 50%;\n background-size: contain;\n }\n\n .credit-card-button .cc-title {\n font-size: ${creditCardFontSizeCss};\n font-weight: 700;\n margin-bottom: 0.5rem;\n }\n\n button#change-payment-method {\n margin-top: 10px;\n background: white;\n border: 1px solid;\n border-radius: 3px;\n padding: 5px;\n }\n\n button#change-payment-method:hover {\n cursor: pointer;\n }\n\n .payment-selected button:not(.selected),\n .payment-selected .paypal-container:not(.selected) {\n display: none;\n }\n `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AAC;IAED,kBAAkB;IAClB,MAAM,KAAK,MAAM;QACf,MAAM,qBAAqB,GAAG,GAAG,CAAA,iCAAiC,CAAC;QACnE,MAAM,sBAAsB,GAAG,GAAG,CAAA,oCAAoC,CAAC;QACvE,MAAM,qBAAqB,GAAG,GAAG,CAAA,mCAAmC,CAAC;QAErE,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;iBAuBG,qBAAqB;kBACpB,sBAAsB;;;;;;;;;;;;;;;;;;;;iBAoBvB,qBAAqB;kBACpB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCnB,qBAAqB;;;;;;;;;;;;;;;;;;;;;KAqBrC,CAAC;IACJ,CAAC;CACF,CAAA;AA3V8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAA0B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAqE;AAEpE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAsE;AAErE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAkE;AAEjE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAmE;AAElE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAMD;AAnBf,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CA4V3B;SA5VY,eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport applePayButtonImage from '@internetarchive/icon-applepay/index.js';\nimport googlePayButtonImage from '@internetarchive/icon-googlepay/index.js';\nimport paypalButtonImage from '@internetarchive/icon-paypal/index.js';\nimport venmoButtonImage from '@internetarchive/icon-venmo/index.js';\nimport { PaymentProvidersInterface } from '../braintree-manager/payment-providers-interface';\n\nenum PaymentButtonMode {\n Loading = 'loading',\n Available = 'available',\n Unavailable = 'unavailable',\n}\n\n@customElement('payment-selector')\nexport class PaymentSelector extends LitElement {\n @property({ type: Boolean }) donationInfoValid = true;\n\n @property({ type: Object }) paymentProviders?: PaymentProvidersInterface;\n\n @property({ type: String }) private applePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private googlePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private venmoMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private payPalMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private paymentModeSelected:\n | 'apple'\n | 'google'\n | 'venmo'\n | 'cc'\n | 'paypal'\n | undefined = undefined;\n\n /** @inheritdoc */\n render(): TemplateResult {\n const paymentSelectedCss = this.paymentModeSelected ? 'payment-selected' : '';\n return html`\n <div\n class=\"payment-container ${this.donationInfoValid\n ? 'donation-info-valid'\n : 'donation-info-invalid'} ${paymentSelectedCss}\"\n >\n <div class=\"payment-provider-container\">\n <button\n class=\"applepay provider-button ${this.applePayMode} ${this.paymentModeSelected ===\n 'apple'\n ? 'selected'\n : ''}\"\n @click=${(e: Event) => {\n this.paymentModeSelected = 'apple';\n this.applePaySelected(e);\n }}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${applePayButtonImage}</div>\n </button>\n\n <button\n class=\"googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected ===\n 'google'\n ? 'selected'\n : ''}\"\n @click=${() => {\n this.paymentModeSelected = 'google';\n this.googlePaySelected();\n }}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${googlePayButtonImage}</div>\n </button>\n\n <button\n class=\"venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo'\n ? 'selected'\n : ''}\"\n @click=${() => {\n this.paymentModeSelected = 'venmo';\n this.venmoSelected();\n }}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${venmoButtonImage}</div>\n </button>\n\n <div\n class=\"paypal-container provider-button ${this.payPalMode}\n ${this.paymentModeSelected === 'paypal' ? 'selected' : ''}\"\n tabindex=\"0\"\n >\n <div class=\"payment-image\">\n <div\n class=\"paypal-local-button\"\n @click=${() => {\n this.paymentModeSelected = 'paypal';\n this.localPaypalButtonClicked();\n }}\n >\n ${paypalButtonImage}\n </div>\n <slot name=\"paypal-button\"></slot>\n </div>\n </div>\n </div>\n\n <div class=\"credit-card-container\">\n <button\n @click=${() => {\n this.paymentModeSelected = 'cc';\n this.creditCardSelected();\n }}\n class=\"button-style credit-card-button ${this.paymentModeSelected === 'cc'\n ? 'selected'\n : ''}\"\n tabindex=\"0\"\n >\n <div class=\"cc-title\">Credit Card</div>\n <div class=\"cc-background\"></div>\n </button>\n </div>\n </div>\n\n ${this.paymentModeSelected\n ? html`\n <button\n id=\"change-payment-method\"\n @click=${() => {\n this.paymentModeSelected = undefined;\n this.dispatchEvent(new Event('resetPaymentMethod'));\n this.setButtonVisibility();\n }}\n >\n Change payment method\n </button>\n `\n : nothing}\n `;\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.dispatchEvent(new Event('firstUpdated'));\n }\n\n /** @inheritdoc */\n updated(changed: PropertyValues): void {\n if (changed.has('paymentProviders')) {\n this.setButtonVisibility();\n }\n }\n\n showPaypalButton(): void {\n this.payPalMode = PaymentButtonMode.Available;\n }\n\n private async setButtonVisibility(): Promise<void> {\n this.paymentProviders?.venmoHandler\n .get()\n .then(handler => {\n if (!handler) {\n this.venmoMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.venmoMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading venmo', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('venmo unavailable', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.applePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('applePayHandler unavailable');\n this.applePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isAvailable()\n .then(supported => {\n this.applePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading applepay', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('apple pay unavailable', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.googlePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('google pay handler unavailable');\n this.googlePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.googlePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading googlepay', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('google pay unavailable', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n }\n\n private googlePaySelected(): void {\n this.dispatchEvent(new Event('googlePaySelected'));\n }\n\n private applePaySelected(e: Event): void {\n const event = new CustomEvent('applePaySelected', { detail: { originalEvent: e } });\n this.dispatchEvent(event);\n }\n\n private venmoSelected(): void {\n this.dispatchEvent(new Event('venmoSelected'));\n }\n\n private creditCardSelected(): void {\n this.dispatchEvent(new Event('creditCardSelected'));\n }\n\n private localPaypalButtonClicked(): void {\n this.dispatchEvent(new Event('paypalBlockerSelected'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const paymentButtonWidthCss = css`var(--paymentButtonWidth, 5rem)`;\n const paymentButtonHeightCss = css`var(--paymentButtonHeight, 3.2rem)`;\n const creditCardFontSizeCss = css`var(--creditCardFontSize, 1.8rem)`;\n\n return css`\n button {\n color: inherit;\n font-family: inherit;\n }\n\n .payment-container {\n width: 100%;\n }\n\n .payment-provider-container {\n display: grid;\n grid-template-columns: 1fr 1fr 1fr 1fr;\n grid-gap: 1rem;\n margin-bottom: 1rem;\n max-width: 23rem;\n }\n\n .provider-button {\n border: 0;\n padding: 0;\n background: none;\n cursor: pointer;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .provider-button.unavailable {\n display: none;\n }\n\n .provider-button.loading {\n border: 1px solid #ddd;\n border-radius: 2px;\n /* account for the borders that don't exist once the provider loads, otherwise the layout shifts */\n margin-bottom: -2px;\n }\n\n .provider-button.loading .payment-image {\n display: none;\n }\n\n .paypal-local-button {\n position: absolute;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .donation-info-valid .paypal-local-button {\n z-index: 0;\n }\n\n .donation-info-invalid .paypal-local-button {\n z-index: 250;\n }\n\n .credit-card-button {\n color: var(--ccButtonFontColor, #333);\n background-color: var(--ccButtonColor, white);\n border: 1px solid #333;\n border-radius: 4px;\n cursor: pointer;\n margin: 0;\n padding: 0.7rem 1rem;\n width: 100%;\n }\n\n .credit-card-button .cc-background {\n height: 2.4rem;\n width: 100%;\n background-repeat: no-repeat;\n background-image: url(https://archive.org/images/cc_logos.png);\n background-position: 50% 50%;\n background-size: contain;\n }\n\n .credit-card-button .cc-title {\n font-size: ${creditCardFontSizeCss};\n font-weight: 700;\n margin-bottom: 0.5rem;\n }\n\n button#change-payment-method {\n margin-top: 10px;\n background: white;\n border: 1px solid;\n border-radius: 3px;\n padding: 5px;\n }\n\n button#change-payment-method:hover {\n cursor: pointer;\n }\n\n .payment-selected button:not(.selected),\n .payment-selected .paypal-container:not(.selected) {\n display: none;\n }\n `;\n }\n}\n"]}
|
|
@@ -33,10 +33,11 @@ describe('Donation Flow Modal Manager', () => {
|
|
|
33
33
|
expect(mockModalManager.closeCalled).to.be.true;
|
|
34
34
|
}));
|
|
35
35
|
it('can calculate the proper default upsell amount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const defaultAmount = 7.71;
|
|
36
37
|
let amount = DonationFlowModalManager.getDefaultUpsellAmount(1);
|
|
37
|
-
expect(amount).to.equal(
|
|
38
|
+
expect(amount).to.equal(defaultAmount);
|
|
38
39
|
amount = DonationFlowModalManager.getDefaultUpsellAmount(10);
|
|
39
|
-
expect(amount).to.equal(
|
|
40
|
+
expect(amount).to.equal(defaultAmount);
|
|
40
41
|
amount = DonationFlowModalManager.getDefaultUpsellAmount(10.01);
|
|
41
42
|
expect(amount).to.equal(10);
|
|
42
43
|
amount = DonationFlowModalManager.getDefaultUpsellAmount(25);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-flow-modal-manager.test.js","sourceRoot":"","sources":["../../../../test/tests/flow-handlers/donation-flow-modal-manager.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gEAAgE,CAAC;AAE1G,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,IAAI,SAAiD,CAAC;AAEtD,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,UAAU,CAAC,GAAG,EAAE;QACd,SAAS,GAAG;YACV,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE;YACtB,oBAAoB,EAAE,KAAK,CAAC,IA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,mBAAmB,CAAC;gBACpC,YAAY,EAAE,YAAY,CAAC,OAAO;gBAClC,MAAM,EAAE,CAAC;gBACT,SAAS,EAAE,KAAK;aACjB,CAAC;YACF,WAAW,EAAE,eAAe;YAC5B,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3B,OAAO,EAAE,IAAI;YACb,KAAK,EAAE;gBACL,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE;oBACP,iBAAiB,EAAE,IAAI;oBACvB,eAAe,EAAE,SAAS;oBAC1B,QAAQ,EAAE,eAAe;oBACzB,UAAU,EAAE,OAAO;oBACnB,MAAM,EAAE,IAAI;oBACZ,aAAa,EAAE,aAAa;iBAC7B;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,aAAa;oBACpB,SAAS,EAAE,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":["import { html, fixture, expect } from '@open-wc/testing';\nimport { DonationFlowModalManager } from '../../../src/payment-flow-handlers/donation-flow-modal-manager';\nimport { MockModalManager } from '../../mocks/mock-modal-manager';\nimport '../../mocks/mock-modal-manager';\nimport { MockBraintreeManager } from '../../mocks/mock-braintree-manager';\nimport { mockSuccessResponse } from '../../mocks/models/mock-success-response';\nimport {\n PaymentProvider,\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\nimport { mockBillingInfo } from '../../mocks/models/mock-billing-info';\nimport { mockCustomerInfo } from '../../mocks/models/mock-customer-info';\nimport { DonationControllerEventLoggerInterface } from '../../../src/@types/analytics-handler';\nimport sinon from 'sinon';\n\nlet analytics: DonationControllerEventLoggerInterface;\n\ndescribe('Donation Flow Modal Manager', () => {\n beforeEach(() => {\n analytics = {\n logEvent: sinon.fake(),\n logDonationFlowEvent: sinon.fake(),\n };\n });\n afterEach(() => {\n sinon.restore();\n });\n it('can close the modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.closeModal();\n expect(mockModalManager.closeCalled).to.be.true;\n });\n\n it('can calculate the proper default upsell amount', async () => {\n let amount = DonationFlowModalManager.getDefaultUpsellAmount(1);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10);\n expect(amount).to.equal(5);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10.01);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25.01);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100.01);\n expect(amount).to.equal(50);\n });\n\n it('can show the processing modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showProcessingModal();\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#497fbf');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.processingImageMode).to.equal('processing');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.false;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Processing...');\n });\n\n it('can show the error modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showErrorModal({ message: 'foo-error' });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#691916');\n expect(modalOptions?.config.showProcessingIndicator).to.be.false;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.headline?.strings[0]).to.contain(\n \"There's been a problem completing your donation.\",\n );\n expect(modalOptions?.config.message?.values[0]).to.equal('foo-error');\n });\n\n it('shows the thank you modal and calls `donationSuccessful` to take user to thank you page', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.processingImageMode).to.equal('complete');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Thank You!');\n const response = mockBraintreeManager.donationSuccessfulOptions?.successResponse;\n expect(response).to.deep.equal(mockSuccessResponse);\n });\n\n it('donation submitted analytics gets sent when drawing thank you modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n const successResponse = mockSuccessResponse;\n successResponse.paymentProvider = PaymentProvider.GooglePay;\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n\n // fires analytics\n expect(logDonationFlowEvent.callCount).to.equal(1);\n expect(logDonationFlowEvent.args[0][0]).to.equal(`Donated-GooglePay`);\n expect(logDonationFlowEvent.args[0][1]).to.equal(DonationType.OneTime);\n });\n\n it('can show the confirmation modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showConfirmationStepModal({\n donationType: DonationType.Upsell,\n amount: 8,\n currencyType: 'USD',\n cancelDonationCB: () => console.log('donation cancelled'),\n confirmDonationCB: () => console.log('donation confirmed'),\n });\n\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config?.title?.values).to.contain('Confirm monthly donation');\n });\n\n it('can start the donation submission flow', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n const result = await manager.startDonationSubmissionFlow({\n nonce: 'foo',\n paymentProvider: PaymentProvider.CreditCard,\n donationInfo: new DonationPaymentInfo({\n donationType: DonationType.OneTime,\n amount: 5,\n coverFees: false,\n }),\n billingInfo: mockBillingInfo,\n customerInfo: mockCustomerInfo,\n });\n\n expect(result).to.deep.equal({\n success: true,\n value: {\n amount: 5,\n billing: {\n countryCodeAlpha2: 'US',\n extendedAddress: 'Apt 123',\n locality: 'San Francisco',\n postalCode: '12345',\n region: 'CA',\n streetAddress: '123 Fake St',\n },\n customer: {\n email: 'foo@bar.com',\n firstName: 'Fooey',\n lastName: 'McBarrison',\n },\n customer_id: 'bar',\n donationType: 'one-time',\n paymentMethodNonce: 'foo',\n paymentProvider: 'Credit Card',\n transaction_id: 'foo',\n },\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"donation-flow-modal-manager.test.js","sourceRoot":"","sources":["../../../../test/tests/flow-handlers/donation-flow-modal-manager.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gEAAgE,CAAC;AAE1G,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,IAAI,SAAiD,CAAC;AAEtD,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,UAAU,CAAC,GAAG,EAAE;QACd,SAAS,GAAG;YACV,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE;YACtB,oBAAoB,EAAE,KAAK,CAAC,IAAI,EAAE;SACnC,CAAC;IACJ,CAAC,CAAC,CAAC;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AAC;gBACpC,YAAY,EAAE,YAAY,CAAC,OAAO;gBAClC,MAAM,EAAE,CAAC;gBACT,SAAS,EAAE,KAAK;aACjB,CAAC;YACF,WAAW,EAAE,eAAe;YAC5B,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3B,OAAO,EAAE,IAAI;YACb,KAAK,EAAE;gBACL,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE;oBACP,iBAAiB,EAAE,IAAI;oBACvB,eAAe,EAAE,SAAS;oBAC1B,QAAQ,EAAE,eAAe;oBACzB,UAAU,EAAE,OAAO;oBACnB,MAAM,EAAE,IAAI;oBACZ,aAAa,EAAE,aAAa;iBAC7B;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,aAAa;oBACpB,SAAS,EAAE,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":["import { 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 const defaultAmount = 7.71;\n let amount = DonationFlowModalManager.getDefaultUpsellAmount(1);\n expect(amount).to.equal(defaultAmount);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10);\n expect(amount).to.equal(defaultAmount);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(10.01);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25);\n expect(amount).to.equal(10);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(25.01);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100);\n expect(amount).to.equal(25);\n amount = DonationFlowModalManager.getDefaultUpsellAmount(100.01);\n expect(amount).to.equal(50);\n });\n\n it('can show the processing modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showProcessingModal();\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#497fbf');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.processingImageMode).to.equal('processing');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.false;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Processing...');\n });\n\n it('can show the error modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showErrorModal({ message: 'foo-error' });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#691916');\n expect(modalOptions?.config.showProcessingIndicator).to.be.false;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.headline?.strings[0]).to.contain(\n \"There's been a problem completing your donation.\",\n );\n expect(modalOptions?.config.message?.values[0]).to.equal('foo-error');\n });\n\n it('shows the thank you modal and calls `donationSuccessful` to take user to thank you page', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.processingImageMode).to.equal('complete');\n expect(modalOptions?.config.showProcessingIndicator).to.be.true;\n expect(modalOptions?.config.closeOnBackdropClick).to.be.true;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config.title?.strings[0]).to.contain('Thank You!');\n const response = mockBraintreeManager.donationSuccessfulOptions?.successResponse;\n expect(response).to.deep.equal(mockSuccessResponse);\n });\n\n it('donation submitted analytics gets sent when drawing thank you modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const logEvent = sinon.fake();\n const logDonationFlowEvent = sinon.fake();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics: {\n logEvent,\n logDonationFlowEvent,\n },\n });\n const successResponse = mockSuccessResponse;\n successResponse.paymentProvider = PaymentProvider.GooglePay;\n manager.showThankYouModal({\n successResponse: mockSuccessResponse,\n });\n\n // fires analytics\n expect(logDonationFlowEvent.callCount).to.equal(1);\n expect(logDonationFlowEvent.args[0][0]).to.equal(`Donated-GooglePay`);\n expect(logDonationFlowEvent.args[0][1]).to.equal(DonationType.OneTime);\n });\n\n it('can show the confirmation modal', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n manager.showConfirmationStepModal({\n donationType: DonationType.Upsell,\n amount: 8,\n currencyType: 'USD',\n cancelDonationCB: () => console.log('donation cancelled'),\n confirmDonationCB: () => console.log('donation confirmed'),\n });\n\n const modalOptions = mockModalManager.showModalOptions;\n expect(modalOptions?.config.headerColor).to.equal('#55A183');\n expect(modalOptions?.config.closeOnBackdropClick).to.be.false;\n expect(modalOptions?.config.showCloseButton).to.be.true;\n expect(modalOptions?.config?.title?.values).to.contain('Confirm monthly donation');\n });\n\n it('can start the donation submission flow', async () => {\n const mockModalManager = (await fixture(html`\n <mock-modal-manager></mock-modal-manager>\n `)) as MockModalManager;\n const mockBraintreeManager = new MockBraintreeManager();\n const manager = new DonationFlowModalManager({\n braintreeManager: mockBraintreeManager,\n modalManager: mockModalManager,\n analytics,\n });\n const result = await manager.startDonationSubmissionFlow({\n nonce: 'foo',\n paymentProvider: PaymentProvider.CreditCard,\n donationInfo: new DonationPaymentInfo({\n donationType: DonationType.OneTime,\n amount: 5,\n coverFees: false,\n }),\n billingInfo: mockBillingInfo,\n customerInfo: mockCustomerInfo,\n });\n\n expect(result).to.deep.equal({\n success: true,\n value: {\n amount: 5,\n billing: {\n countryCodeAlpha2: 'US',\n extendedAddress: 'Apt 123',\n locality: 'San Francisco',\n postalCode: '12345',\n region: 'CA',\n streetAddress: '123 Fake St',\n },\n customer: {\n email: 'foo@bar.com',\n firstName: 'Fooey',\n lastName: 'McBarrison',\n },\n customer_id: 'bar',\n donationType: 'one-time',\n paymentMethodNonce: 'foo',\n paymentProvider: 'Credit Card',\n transaction_id: 'foo',\n },\n });\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/donation-form",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-alpha.1",
|
|
4
4
|
"description": "The Internet Archive Donation Form",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@internetarchive/analytics-manager": "^0.1.2",
|
|
32
32
|
"@internetarchive/donation-form-currency-validator": "^0.3.0",
|
|
33
|
-
"@internetarchive/donation-form-data-models": "
|
|
34
|
-
"@internetarchive/donation-form-edit-donation": "
|
|
33
|
+
"@internetarchive/donation-form-data-models": "0.3.4-alpha.1",
|
|
34
|
+
"@internetarchive/donation-form-edit-donation": "1.1.2-alpha.1",
|
|
35
35
|
"@internetarchive/donation-form-section": "^0.3.5",
|
|
36
36
|
"@internetarchive/icon-applepay": "^1.3.2",
|
|
37
37
|
"@internetarchive/icon-calendar": "^1.3.2",
|
package/src/donation-form.ts
CHANGED
|
@@ -185,9 +185,10 @@ export class DonationForm extends LitElement {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
get contactFormSectionTemplate(): TemplateResult {
|
|
188
|
-
const headline =
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
const headline =
|
|
189
|
+
this.selectedPaymentProvider === PaymentProvider.Venmo
|
|
190
|
+
? 'Help us stay in touch'
|
|
191
|
+
: 'Enter payment information';
|
|
191
192
|
|
|
192
193
|
return html`
|
|
193
194
|
<donation-form-section
|
|
@@ -27,7 +27,13 @@ export class PaymentSelector extends LitElement {
|
|
|
27
27
|
|
|
28
28
|
@property({ type: String }) private payPalMode: PaymentButtonMode = PaymentButtonMode.Loading;
|
|
29
29
|
|
|
30
|
-
@property({ type: String }) private paymentModeSelected:
|
|
30
|
+
@property({ type: String }) private paymentModeSelected:
|
|
31
|
+
| 'apple'
|
|
32
|
+
| 'google'
|
|
33
|
+
| 'venmo'
|
|
34
|
+
| 'cc'
|
|
35
|
+
| 'paypal'
|
|
36
|
+
| undefined = undefined;
|
|
31
37
|
|
|
32
38
|
/** @inheritdoc */
|
|
33
39
|
render(): TemplateResult {
|
|
@@ -40,45 +46,59 @@ export class PaymentSelector extends LitElement {
|
|
|
40
46
|
>
|
|
41
47
|
<div class="payment-provider-container">
|
|
42
48
|
<button
|
|
43
|
-
class="applepay provider-button ${this.applePayMode} ${this.paymentModeSelected ===
|
|
49
|
+
class="applepay provider-button ${this.applePayMode} ${this.paymentModeSelected ===
|
|
50
|
+
'apple'
|
|
51
|
+
? 'selected'
|
|
52
|
+
: ''}"
|
|
44
53
|
@click=${(e: Event) => {
|
|
45
54
|
this.paymentModeSelected = 'apple';
|
|
46
|
-
this.applePaySelected(e);
|
|
47
|
-
|
|
55
|
+
this.applePaySelected(e);
|
|
56
|
+
}}
|
|
48
57
|
tabindex="0"
|
|
49
58
|
>
|
|
50
59
|
<div class="payment-image">${applePayButtonImage}</div>
|
|
51
60
|
</button>
|
|
52
61
|
|
|
53
62
|
<button
|
|
54
|
-
class="googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected ===
|
|
63
|
+
class="googlepay provider-button ${this.googlePayMode} ${this.paymentModeSelected ===
|
|
64
|
+
'google'
|
|
65
|
+
? 'selected'
|
|
66
|
+
: ''}"
|
|
55
67
|
@click=${() => {
|
|
56
68
|
this.paymentModeSelected = 'google';
|
|
57
|
-
this.googlePaySelected();
|
|
58
|
-
|
|
69
|
+
this.googlePaySelected();
|
|
70
|
+
}}
|
|
59
71
|
tabindex="0"
|
|
60
72
|
>
|
|
61
73
|
<div class="payment-image">${googlePayButtonImage}</div>
|
|
62
74
|
</button>
|
|
63
75
|
|
|
64
76
|
<button
|
|
65
|
-
class="venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo'
|
|
77
|
+
class="venmo provider-button ${this.venmoMode} ${this.paymentModeSelected === 'venmo'
|
|
78
|
+
? 'selected'
|
|
79
|
+
: ''}"
|
|
66
80
|
@click=${() => {
|
|
67
81
|
this.paymentModeSelected = 'venmo';
|
|
68
|
-
this.venmoSelected();
|
|
69
|
-
|
|
82
|
+
this.venmoSelected();
|
|
83
|
+
}}
|
|
70
84
|
tabindex="0"
|
|
71
85
|
>
|
|
72
86
|
<div class="payment-image">${venmoButtonImage}</div>
|
|
73
87
|
</button>
|
|
74
88
|
|
|
75
|
-
<div
|
|
89
|
+
<div
|
|
90
|
+
class="paypal-container provider-button ${this.payPalMode}
|
|
91
|
+
${this.paymentModeSelected === 'paypal' ? 'selected' : ''}"
|
|
92
|
+
tabindex="0"
|
|
93
|
+
>
|
|
76
94
|
<div class="payment-image">
|
|
77
|
-
<div
|
|
95
|
+
<div
|
|
96
|
+
class="paypal-local-button"
|
|
78
97
|
@click=${() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
98
|
+
this.paymentModeSelected = 'paypal';
|
|
99
|
+
this.localPaypalButtonClicked();
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
82
102
|
${paypalButtonImage}
|
|
83
103
|
</div>
|
|
84
104
|
<slot name="paypal-button"></slot>
|
|
@@ -92,7 +112,9 @@ export class PaymentSelector extends LitElement {
|
|
|
92
112
|
this.paymentModeSelected = 'cc';
|
|
93
113
|
this.creditCardSelected();
|
|
94
114
|
}}
|
|
95
|
-
class="button-style credit-card-button ${this.paymentModeSelected === 'cc'
|
|
115
|
+
class="button-style credit-card-button ${this.paymentModeSelected === 'cc'
|
|
116
|
+
? 'selected'
|
|
117
|
+
: ''}"
|
|
96
118
|
tabindex="0"
|
|
97
119
|
>
|
|
98
120
|
<div class="cc-title">Credit Card</div>
|
|
@@ -110,10 +132,11 @@ export class PaymentSelector extends LitElement {
|
|
|
110
132
|
this.dispatchEvent(new Event('resetPaymentMethod'));
|
|
111
133
|
this.setButtonVisibility();
|
|
112
134
|
}}
|
|
113
|
-
>
|
|
135
|
+
>
|
|
136
|
+
Change payment method
|
|
137
|
+
</button>
|
|
114
138
|
`
|
|
115
|
-
: nothing
|
|
116
|
-
}
|
|
139
|
+
: nothing}
|
|
117
140
|
`;
|
|
118
141
|
}
|
|
119
142
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form-config.js","sourceRoot":"","sources":["../../../src/models/donation-form-config.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAG7B,YAAY,OAA8C;QACxD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IACnE,CAAC;CACF","sourcesContent":["export class DonationFormConfig {\n showCreditCardButtonText: boolean;\n\n constructor(options: { showCreditCardButtonText: boolean }) {\n this.showCreditCardButtonText = options.showCreditCardButtonText;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function promisedSleep(ms: number): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promisedSleep.js","sourceRoot":"","sources":["../../../test/helpers/promisedSleep.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["export function promisedSleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AnalyticsHandlerInterface } from '../../src/@types/analytics-handler';
|
|
2
|
-
export declare class MockAnalyticHandler implements AnalyticsHandlerInterface {
|
|
3
|
-
callCategory?: string;
|
|
4
|
-
callAction?: string;
|
|
5
|
-
callLabel?: string;
|
|
6
|
-
callAdditionalEventParams?: object;
|
|
7
|
-
send_event(category: string, action: string, label?: string, additionalEventParams?: object): void;
|
|
8
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export class MockAnalyticHandler {
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
3
|
-
send_event(category, action, label, additionalEventParams) {
|
|
4
|
-
this.callCategory = category;
|
|
5
|
-
this.callAction = action;
|
|
6
|
-
this.callLabel = label;
|
|
7
|
-
this.callAdditionalEventParams = additionalEventParams;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=mock-analytics-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|