@internetarchive/donation-form 0.5.12-a2 → 0.5.12-a3
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/modals/confirm-donation-modal-content.js +2 -2
- package/dist/src/modals/confirm-donation-modal-content.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/handlers/paypal-flow-handler.js +2 -2
- package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js.map +1 -1
- package/package.json +1 -1
- package/src/modals/confirm-donation-modal-content.ts +2 -2
- package/src/payment-flow-handlers/donation-flow-modal-manager.ts +2 -2
- package/src/payment-flow-handlers/handlers/paypal-flow-handler.ts +2 -2
|
@@ -31,7 +31,7 @@ let ConfirmDonationContent = class ConfirmDonationContent extends LitElement {
|
|
|
31
31
|
}
|
|
32
32
|
get confirmUpsellText() {
|
|
33
33
|
const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
|
|
34
|
-
return html `<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive
|
|
34
|
+
return html `<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring contribution will be next month.)</p>`;
|
|
35
35
|
}
|
|
36
36
|
confirm() {
|
|
37
37
|
this === null || this === void 0 ? void 0 : this.confirmDonation();
|
|
@@ -40,7 +40,7 @@ let ConfirmDonationContent = class ConfirmDonationContent extends LitElement {
|
|
|
40
40
|
this === null || this === void 0 ? void 0 : this.cancelDonation();
|
|
41
41
|
}
|
|
42
42
|
get confirmCTA() {
|
|
43
|
-
return this.donationType === DonationType.Upsell ? 'Start
|
|
43
|
+
return this.donationType === DonationType.Upsell ? 'Start monthly donation' : 'Complete donation';
|
|
44
44
|
}
|
|
45
45
|
/** @inheritdoc */
|
|
46
46
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-donation-modal-content.js","sourceRoot":"","sources":["../../../src/modals/confirm-donation-modal-content.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,GAAG,EAA2B,MAAM,KAAK,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC;;;;;;;;;GASG;AAEH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,UAAU;IAAtD;;QAC8B,WAAM,GAAG,CAAC,CAAC;QAEX,iBAAY,GAAG,GAAG,CAAC;QAEnB,iBAAY,GAAiB,YAAY,CAAC,OAAO,CAAC;QAEhD,oBAAe,GAAa,GAAS,EAAE,GAAE,CAAC,CAAC;QAE3C,mBAAc,GAAY,GAAS,EAAE,GAAE,CAAC,CAAC;IAqIzE,CAAC;IAnIC,IAAI,gBAAgB;QAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAA;oCACqB,IAAI,CAAC,YAAY,uBAAuB,MAAM,IAAI,IAAI,CAAC,YAAY;KAClG,CAAC;IACJ,CAAC;IAED,IAAI,iBAAiB;QACnB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAA,mEAAmE,MAAM,IAAI,IAAI,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"confirm-donation-modal-content.js","sourceRoot":"","sources":["../../../src/modals/confirm-donation-modal-content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AI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,GAAG,CAAC,CAAC,wBAAwB;SACvC;IACH,CAAC;CACF,CAAA;AA7I6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmD;AAEhD;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;+DAA4C;AAE3C;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8DAA0C;AAT5D,sBAAsB;IADlC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,sBAAsB,CA8IlC;SA9IY,sBAAsB","sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport { LitElement, html, TemplateResult, css, CSSResultGroup, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { DonationType } from '@internetarchive/donation-form-data-models';\nimport currency from 'currency.js';\n\n/**\n * This is the content that we show in the upsell modal.\n *\n * It has an amount input, \"Yes\" and \"No Thanks\" options and a switch to optionally\n * show the PayPal upsell button.\n *\n * @export\n * @class ConfirmDonationContent\n * @extends {LitElement}\n */\n@customElement('confirm-donation-modal')\nexport class ConfirmDonationContent extends LitElement {\n @property({ type: Number }) amount = 5;\n\n @property({ type: String }) currencyType = '$';\n\n @property({ type: String }) donationType: DonationType = DonationType.OneTime;\n\n @property({ type: Function }) confirmDonation: Function = (): void => {};\n\n @property({ type: Function }) cancelDonation: Function= (): void => {};\n\n get confirmationText(): TemplateResult {\n const amount = currency(this.amount, { symbol: this.currencySymbol }).format();\n return html`\n <p>You are about to make a <b>${this.donationType}</b> donation of <b>${amount} ${this.currencyType}</b> to the Internet Archive.</p>\n `;\n }\n\n get confirmUpsellText(): TemplateResult {\n const amount = currency(this.amount, { symbol: this.currencySymbol }).format();\n return html`<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring contribution will be next month.)</p>`;\n }\n\n confirm(): void {\n this?.confirmDonation();\n }\n\n cancel(): void {\n this?.cancelDonation();\n }\n\n get confirmCTA(): string {\n return this.donationType === DonationType.Upsell ? 'Start monthly donation' : 'Complete donation';\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n ${this.donationType === DonationType.Upsell ? this.confirmUpsellText : this.confirmationText}\n\n <div class=\"cta-group\">\n <button id=\"confirm\" @click=${(): void => this.confirm()}>${this.confirmCTA}</button>\n <button id=\"cancel\" @click=${(): void => this.cancel()}>Cancel</button>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n const ctaButtonColor = css`var(--upsellCTAButtonColor, #194880)`;\n const ctaButtonDisabledColor = css`var(--upsellCTAButtonDisabledColor, rgba(109,148,201,0.5))`;\n\n return css`\n :host {\n display: block;\n }\n\n button {\n outline: none;\n cursor: pointer;\n }\n\n button#confirm {\n font-size: 2rem;\n display: block;\n width: 100%;\n margin-top: 0.5rem;\n padding: 1rem 2rem;\n background-color: ${ctaButtonColor};\n color: #fff;\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n }\n\n button#cancel {\n margin-top: 1rem;\n border: 0;\n text-decoration: underline;\n background-color: transparent;\n }\n\n button:disabled {\n background-color: ${ctaButtonDisabledColor};\n cursor: not-allowed;\n }\n }`;\n }\n\n /**\n * https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/\n */\n get currencySymbol(): string {\n switch(this.currencyType) {\n case 'AUD':\n return 'AU$';\n case 'BRL':\n return 'R$';\n case 'CAD':\n return 'CA$';\n case 'CHF':\n return 'Fr';\n case 'CNY':\n return '¥';\n case 'CZK':\n return 'Kč';\n case 'DKK':\n return 'Kr';\n case 'EUR':\n return '€';\n case 'GBP':\n return '£';\n case 'HKD':\n return 'HK$';\n case 'HUF':\n return 'Ft';\n case 'ILS':\n return '₪';\n case 'JPY':\n return '¥';\n case 'MXN':\n return 'MX$';\n case 'MYR':\n return 'RM';\n case 'NOK':\n return 'kr';\n case 'PLN':\n return 'zł';\n case 'RUB':\n return '₽';\n case 'SEK':\n return 'kr';\n case 'SGD':\n return 'S$';\n case 'THB':\n return '฿';\n case 'TYD':\n return 'NT$';\n default:\n return '$'; // $ as default USD, NZD\n }\n }\n}\n"]}
|
|
@@ -79,8 +79,8 @@ export class DonationFlowModalManager {
|
|
|
79
79
|
options === null || options === void 0 ? void 0 : options.cancelDonationCB();
|
|
80
80
|
};
|
|
81
81
|
const modalTitle = options.donationType === DonationType.Upsell
|
|
82
|
-
? 'Confirm monthly
|
|
83
|
-
: '
|
|
82
|
+
? 'Confirm monthly donation'
|
|
83
|
+
: 'Complete donation';
|
|
84
84
|
const modalConfig = new ModalConfig({
|
|
85
85
|
closeOnBackdropClick: false,
|
|
86
86
|
headerColor: ModalHeaderColor.Green,
|
|
@@ -1 +1 @@
|
|
|
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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AM;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';\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 constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n }) {\n this.modalManager = options.modalManager;\n this.braintreeManager = options.braintreeManager;\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 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 donations'\n : 'Confirm 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 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;AAEvC,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;IAKnC,YAAY,OAGX;QACC,IAAI,CAAC,Y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C,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';\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 constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n modalManager: ModalManagerInterface;\n }) {\n this.modalManager = options.modalManager;\n this.braintreeManager = options.braintreeManager;\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 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 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"]}
|
|
@@ -58,10 +58,10 @@ export class PayPalFlowHandler {
|
|
|
58
58
|
// we need to send it to `payPalPaymentConfirmed`
|
|
59
59
|
// after patron confirms the payment
|
|
60
60
|
console.log('payPalPaymentAuthorized *******', { dataSource, payload });
|
|
61
|
-
const { donationType,
|
|
61
|
+
const { donationType, total } = dataSource.donationInfo;
|
|
62
62
|
this.donationFlowModalManager.showConfirmationStepModal({
|
|
63
63
|
donationType,
|
|
64
|
-
amount,
|
|
64
|
+
amount: total,
|
|
65
65
|
currencyType: 'USD',
|
|
66
66
|
confirmDonationCB: () => {
|
|
67
67
|
this.payPalPaymentConfirmed(dataSource, payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-flow-handler.js","sourceRoot":"","sources":["../../../../src/payment-flow-handlers/handlers/paypal-flow-handler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AAMpE,OAAO,EAEL,YAAY,EACZ,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,eAAe,GAEhB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAEL,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAYxC;;;;GAIG;AACH,MAAM,yBAAyB;IAK7B,YAAY,OAIX;QACC,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAC7D,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,sBAAsB,GAAG,OAAO,CA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gBAAgB,0CAAE,gBAAgB,CAAC,aAAa,CAAC,GAAG,GAAE,CAAC;YAElF,MAAM,sBAAsB,GAAG,OAAM,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,kBAAkB,CAAC;gBAC/D,QAAQ,EAAE,uBAAuB;gBACjC,KAAK,EAAE;oBACL,KAAK,EAAE,MAAkC;oBACzC,KAAK,EAAE,QAAoC;oBAC3C,KAAK,EAAE,MAAkC;oBACzC,IAAI,EAAE,YAAuC;oBAC7C,OAAO,EAAE,KAAK;iBACf;gBACD,YAAY,EAAE,OAAO,CAAC,YAAY;aACnC,EAAC,CAAC;YAEH,IAAI,sBAAsB,EAAE;gBAC1B,sBAAsB,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACvC,IAAI,CAAC,+BAA+B,GAAG,IAAI,yBAAyB,CAAC;oBACnE,sBAAsB,EAAE,sBAAsB;oBAC9C,cAAc,EAAE,OAAO,CAAC,cAAc;oBACtC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;iBACvD,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;aACvD;;KACF;CACF","sourcesContent":["import { createNanoEvents, Emitter, Unsubscribe } from 'nanoevents';\n\nimport {\n PayPalButtonDataSourceInterface,\n PayPalButtonDataSourceDelegate,\n} from '../../braintree-manager/payment-providers/paypal/paypal-button-datasource';\nimport {\n DonationResponse,\n DonationType,\n DonationPaymentInfo,\n SuccessResponse,\n CustomerInfo,\n BillingInfo,\n PaymentProvider,\n ErrorResponse,\n} from '@internetarchive/donation-form-data-models';\nimport { BraintreeManagerInterface } from '../../braintree-manager/braintree-interfaces';\n\nimport { UpsellModalCTAMode } from '../../modals/upsell-modal-content';\nimport {\n DonationFlowModalManagerInterface,\n DonationFlowModalManager,\n} from '../donation-flow-modal-manager';\n\nexport interface PayPalFlowHandlerInterface {\n updateDonationInfo(donationInfo: DonationPaymentInfo): void;\n updateUpsellDonationInfo(donationInfo: DonationPaymentInfo): void;\n renderPayPalButton(donationInfo: DonationPaymentInfo): Promise<void>;\n on<E extends keyof PayPalFlowHandlerEvents>(\n event: E,\n callback: PayPalFlowHandlerEvents[E],\n ): Unsubscribe;\n}\n\n/**\n * This is a class to combine the data from the one-time purchase to the upsell\n *\n * @class UpsellDataSourceContainer\n */\nclass UpsellDataSourceContainer {\n upsellButtonDataSource: PayPalButtonDataSourceInterface;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n\n constructor(options: {\n upsellButtonDataSource: PayPalButtonDataSourceInterface;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n }) {\n this.upsellButtonDataSource = options.upsellButtonDataSource;\n this.oneTimePayload = options.oneTimePayload;\n this.oneTimeSuccessResponse = options.oneTimeSuccessResponse;\n }\n}\n\nexport interface PayPalFlowHandlerEvents {\n payPalPaymentStarted: (dataSource: PayPalButtonDataSourceInterface, options: object) => void;\n payPalPaymentCancelled: (dataSource: PayPalButtonDataSourceInterface, data: object) => void;\n payPalPaymentError: (dataSource: PayPalButtonDataSourceInterface, error: string) => void;\n}\n\n/**\n * This class manages the user-flow for PayPal.\n *\n * @export\n * @class PayPalFlowHandler\n * @implements {PayPalFlowHandlerInterface}\n * @implements {PayPalButtonDataSourceDelegate}\n */\nexport class PayPalFlowHandler\n implements PayPalFlowHandlerInterface, PayPalButtonDataSourceDelegate {\n private upsellButtonDataSourceContainer?: UpsellDataSourceContainer;\n\n private buttonDataSource?: PayPalButtonDataSourceInterface;\n\n private donationFlowModalManager: DonationFlowModalManagerInterface;\n\n private braintreeManager: BraintreeManagerInterface;\n\n private emitter: Emitter<PayPalFlowHandlerEvents> = createNanoEvents<PayPalFlowHandlerEvents>();\n\n updateDonationInfo(donationInfo: DonationPaymentInfo): void {\n if (this.buttonDataSource) {\n this.buttonDataSource.donationInfo = donationInfo;\n }\n }\n\n updateUpsellDonationInfo(donationInfo: DonationPaymentInfo): void {\n if (this.upsellButtonDataSourceContainer) {\n this.upsellButtonDataSourceContainer.upsellButtonDataSource.donationInfo = donationInfo;\n }\n }\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n donationFlowModalManager: DonationFlowModalManagerInterface;\n }) {\n this.braintreeManager = options.braintreeManager;\n this.donationFlowModalManager = options.donationFlowModalManager;\n }\n\n on<E extends keyof PayPalFlowHandlerEvents>(\n event: E,\n callback: PayPalFlowHandlerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n async payPalPaymentStarted(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dataSource: PayPalButtonDataSourceInterface,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options: object,\n ): Promise<void> {\n console.log('payPalPaymentStarted *******', { dataSource, options });\n this.emitter.emit('payPalPaymentStarted', dataSource, options);\n }\n\n async payPalPaymentAuthorized(dataSource: PayPalButtonDataSourceInterface,\n payload: paypal.TokenizePayload\n ): Promise<void> {\n\n // we got dataSource & payload\n // we need to send it to `payPalPaymentConfirmed`\n // after patron confirms the payment\n console.log('payPalPaymentAuthorized *******', { dataSource, payload });\n\n const { donationType, amount } = dataSource.donationInfo;\n this.donationFlowModalManager.showConfirmationStepModal({\n donationType,\n amount,\n currencyType: 'USD', // defaults to USD for now\n confirmDonationCB: () => {\n this.payPalPaymentConfirmed(dataSource, payload);\n },\n cancelDonationCB: () => {\n this.donationFlowModalManager.closeModal();\n this.payPalPaymentCancelled(dataSource, {});\n }\n });\n\n // cancel payment on modal X\n // cancel payment on cancel\n \n }\n\n async payPalPaymentConfirmed(\n dataSource: PayPalButtonDataSourceInterface,\n payload: paypal.TokenizePayload,\n ): Promise<void> {\n this.donationFlowModalManager.showProcessingModal();\n\n const donationType = dataSource.donationInfo.donationType;\n\n const details = payload?.details;\n\n const customerInfo = new CustomerInfo({\n email: details?.email,\n firstName: details?.firstName,\n lastName: details?.lastName,\n });\n\n const shippingAddress = details.shippingAddress;\n\n const billingInfo = new BillingInfo({\n streetAddress: shippingAddress?.line1,\n extendedAddress: shippingAddress?.line2,\n locality: shippingAddress?.city,\n region: shippingAddress?.state,\n postalCode: shippingAddress?.postalCode,\n countryCodeAlpha2: shippingAddress?.countryCode,\n });\n\n const oneTimeTransaction = this.upsellButtonDataSourceContainer\n ? this.upsellButtonDataSourceContainer.oneTimeSuccessResponse.transaction_id\n : undefined;\n\n const response: DonationResponse = await this.braintreeManager.submitDonation({\n nonce: payload.nonce,\n paymentProvider: PaymentProvider.PayPal,\n donationInfo: dataSource.donationInfo,\n customerInfo: customerInfo,\n billingInfo: billingInfo,\n upsellOnetimeTransactionId: oneTimeTransaction,\n });\n\n if (!response.success) {\n const error = response.value as ErrorResponse;\n this.donationFlowModalManager.showErrorModal({\n message: error.message,\n });\n return;\n }\n\n const successResponse = response.value as SuccessResponse;\n\n switch (donationType) {\n case DonationType.OneTime:\n this.showUpsellModal(payload, successResponse);\n break;\n case DonationType.Monthly:\n // show thank you, redirect\n this.donationFlowModalManager.showThankYouModal({ successResponse });\n break;\n case DonationType.Upsell:\n if (this.upsellButtonDataSourceContainer) {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: this.upsellButtonDataSourceContainer.oneTimeSuccessResponse,\n upsellSuccessResponse: successResponse,\n });\n } else {\n // we're in the upsell flow, but no upsell data source container.. this should not happen\n this.donationFlowModalManager.showErrorModal({\n message: 'Error setting up monthly donation',\n });\n }\n break;\n }\n }\n\n async payPalPaymentCancelled(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dataSource: PayPalButtonDataSourceInterface,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n data: object,\n ): Promise<void> {\n this.emitter.emit('payPalPaymentCancelled', dataSource, data);\n }\n\n async payPalPaymentError(\n dataSource: PayPalButtonDataSourceInterface,\n error: string,\n ): Promise<void> {\n this.emitter.emit('payPalPaymentError', dataSource, error);\n console.error(\n 'PaymentSector:payPalPaymentError error:',\n dataSource,\n dataSource.donationInfo,\n error,\n );\n }\n\n async renderPayPalButton(donationInfo: DonationPaymentInfo): Promise<void> {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n\n this.buttonDataSource = await handler?.renderPayPalButton({\n selector: '#paypal-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption, // I'm not sure why I can't access the enum directly here.. I get a UMD error\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'medium' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n\n if (this.buttonDataSource) {\n this.buttonDataSource.delegate = this;\n }\n }\n\n private async showUpsellModal(\n oneTimePayload: paypal.TokenizePayload,\n oneTimeSuccessResponse: SuccessResponse,\n ): Promise<void> {\n this.donationFlowModalManager.showUpsellModal({\n oneTimeAmount: oneTimeSuccessResponse.amount,\n amountChanged: this.upsellAmountChanged.bind(this),\n noSelected: () => {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: oneTimeSuccessResponse,\n });\n },\n ctaMode: UpsellModalCTAMode.PayPalUpsellSlot,\n userClosedModalCallback: () => {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: oneTimeSuccessResponse,\n });\n },\n });\n\n const amount = DonationFlowModalManager.getDefaultUpsellAmount(oneTimeSuccessResponse.amount);\n\n const upsellDonationInfo = new DonationPaymentInfo({\n amount: amount,\n donationType: DonationType.Upsell,\n coverFees: false,\n });\n\n if (!this.upsellButtonDataSourceContainer) {\n this.renderUpsellPayPalButton({\n donationInfo: upsellDonationInfo,\n oneTimePayload,\n oneTimeSuccessResponse,\n });\n }\n }\n\n private upsellAmountChanged(amount: number): void {\n if (this.upsellButtonDataSourceContainer) {\n this.upsellButtonDataSourceContainer.upsellButtonDataSource.donationInfo.amount = amount;\n }\n }\n\n private async renderUpsellPayPalButton(options: {\n donationInfo: DonationPaymentInfo;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n }): Promise<void> {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n\n const upsellButtonDataSource = await 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: options.donationInfo,\n });\n\n if (upsellButtonDataSource) {\n upsellButtonDataSource.delegate = this;\n this.upsellButtonDataSourceContainer = new UpsellDataSourceContainer({\n upsellButtonDataSource: upsellButtonDataSource,\n oneTimePayload: options.oneTimePayload,\n oneTimeSuccessResponse: options.oneTimeSuccessResponse,\n });\n } else {\n console.error('error rendering paypal upsell button');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"paypal-flow-handler.js","sourceRoot":"","sources":["../../../../src/payment-flow-handlers/handlers/paypal-flow-handler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AAMpE,OAAO,EAEL,YAAY,EACZ,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,eAAe,GAEhB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAEL,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAYxC;;;;GAIG;AACH,MAAM,yBAAyB;IAK7B,YAAY,OAIX;QACC,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAC7D,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAC/D,CAAC;CACF;AAQD;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAiB;IAwB5B,YAAY,OAGX;QAjBO,YAAO,GAAqC,gBAAgB,EAA2B,CAAC;QAkB9F,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB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K,EAAE;oBACL,KAAK,EAAE,MAAkC;oBACzC,KAAK,EAAE,QAAoC;oBAC3C,KAAK,EAAE,MAAkC;oBACzC,IAAI,EAAE,YAAuC;oBAC7C,OAAO,EAAE,KAAK;iBACf;gBACD,YAAY,EAAE,OAAO,CAAC,YAAY;aACnC,EAAC,CAAC;YAEH,IAAI,sBAAsB,EAAE;gBAC1B,sBAAsB,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACvC,IAAI,CAAC,+BAA+B,GAAG,IAAI,yBAAyB,CAAC;oBACnE,sBAAsB,EAAE,sBAAsB;oBAC9C,cAAc,EAAE,OAAO,CAAC,cAAc;oBACtC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;iBACvD,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;aACvD;;KACF;CACF","sourcesContent":["import { createNanoEvents, Emitter, Unsubscribe } from 'nanoevents';\n\nimport {\n PayPalButtonDataSourceInterface,\n PayPalButtonDataSourceDelegate,\n} from '../../braintree-manager/payment-providers/paypal/paypal-button-datasource';\nimport {\n DonationResponse,\n DonationType,\n DonationPaymentInfo,\n SuccessResponse,\n CustomerInfo,\n BillingInfo,\n PaymentProvider,\n ErrorResponse,\n} from '@internetarchive/donation-form-data-models';\nimport { BraintreeManagerInterface } from '../../braintree-manager/braintree-interfaces';\n\nimport { UpsellModalCTAMode } from '../../modals/upsell-modal-content';\nimport {\n DonationFlowModalManagerInterface,\n DonationFlowModalManager,\n} from '../donation-flow-modal-manager';\n\nexport interface PayPalFlowHandlerInterface {\n updateDonationInfo(donationInfo: DonationPaymentInfo): void;\n updateUpsellDonationInfo(donationInfo: DonationPaymentInfo): void;\n renderPayPalButton(donationInfo: DonationPaymentInfo): Promise<void>;\n on<E extends keyof PayPalFlowHandlerEvents>(\n event: E,\n callback: PayPalFlowHandlerEvents[E],\n ): Unsubscribe;\n}\n\n/**\n * This is a class to combine the data from the one-time purchase to the upsell\n *\n * @class UpsellDataSourceContainer\n */\nclass UpsellDataSourceContainer {\n upsellButtonDataSource: PayPalButtonDataSourceInterface;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n\n constructor(options: {\n upsellButtonDataSource: PayPalButtonDataSourceInterface;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n }) {\n this.upsellButtonDataSource = options.upsellButtonDataSource;\n this.oneTimePayload = options.oneTimePayload;\n this.oneTimeSuccessResponse = options.oneTimeSuccessResponse;\n }\n}\n\nexport interface PayPalFlowHandlerEvents {\n payPalPaymentStarted: (dataSource: PayPalButtonDataSourceInterface, options: object) => void;\n payPalPaymentCancelled: (dataSource: PayPalButtonDataSourceInterface, data: object) => void;\n payPalPaymentError: (dataSource: PayPalButtonDataSourceInterface, error: string) => void;\n}\n\n/**\n * This class manages the user-flow for PayPal.\n *\n * @export\n * @class PayPalFlowHandler\n * @implements {PayPalFlowHandlerInterface}\n * @implements {PayPalButtonDataSourceDelegate}\n */\nexport class PayPalFlowHandler\n implements PayPalFlowHandlerInterface, PayPalButtonDataSourceDelegate {\n private upsellButtonDataSourceContainer?: UpsellDataSourceContainer;\n\n private buttonDataSource?: PayPalButtonDataSourceInterface;\n\n private donationFlowModalManager: DonationFlowModalManagerInterface;\n\n private braintreeManager: BraintreeManagerInterface;\n\n private emitter: Emitter<PayPalFlowHandlerEvents> = createNanoEvents<PayPalFlowHandlerEvents>();\n\n updateDonationInfo(donationInfo: DonationPaymentInfo): void {\n if (this.buttonDataSource) {\n this.buttonDataSource.donationInfo = donationInfo;\n }\n }\n\n updateUpsellDonationInfo(donationInfo: DonationPaymentInfo): void {\n if (this.upsellButtonDataSourceContainer) {\n this.upsellButtonDataSourceContainer.upsellButtonDataSource.donationInfo = donationInfo;\n }\n }\n\n constructor(options: {\n braintreeManager: BraintreeManagerInterface;\n donationFlowModalManager: DonationFlowModalManagerInterface;\n }) {\n this.braintreeManager = options.braintreeManager;\n this.donationFlowModalManager = options.donationFlowModalManager;\n }\n\n on<E extends keyof PayPalFlowHandlerEvents>(\n event: E,\n callback: PayPalFlowHandlerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n async payPalPaymentStarted(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dataSource: PayPalButtonDataSourceInterface,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options: object,\n ): Promise<void> {\n console.log('payPalPaymentStarted *******', { dataSource, options });\n this.emitter.emit('payPalPaymentStarted', dataSource, options);\n }\n\n async payPalPaymentAuthorized(dataSource: PayPalButtonDataSourceInterface,\n payload: paypal.TokenizePayload\n ): Promise<void> {\n\n // we got dataSource & payload\n // we need to send it to `payPalPaymentConfirmed`\n // after patron confirms the payment\n console.log('payPalPaymentAuthorized *******', { dataSource, payload });\n\n const { donationType, total } = dataSource.donationInfo;\n this.donationFlowModalManager.showConfirmationStepModal({\n donationType,\n amount: total,\n currencyType: 'USD', // defaults to USD for now\n confirmDonationCB: () => {\n this.payPalPaymentConfirmed(dataSource, payload);\n },\n cancelDonationCB: () => {\n this.donationFlowModalManager.closeModal();\n this.payPalPaymentCancelled(dataSource, {});\n }\n });\n\n // cancel payment on modal X\n // cancel payment on cancel\n \n }\n\n async payPalPaymentConfirmed(\n dataSource: PayPalButtonDataSourceInterface,\n payload: paypal.TokenizePayload,\n ): Promise<void> {\n this.donationFlowModalManager.showProcessingModal();\n\n const donationType = dataSource.donationInfo.donationType;\n\n const details = payload?.details;\n\n const customerInfo = new CustomerInfo({\n email: details?.email,\n firstName: details?.firstName,\n lastName: details?.lastName,\n });\n\n const shippingAddress = details.shippingAddress;\n\n const billingInfo = new BillingInfo({\n streetAddress: shippingAddress?.line1,\n extendedAddress: shippingAddress?.line2,\n locality: shippingAddress?.city,\n region: shippingAddress?.state,\n postalCode: shippingAddress?.postalCode,\n countryCodeAlpha2: shippingAddress?.countryCode,\n });\n\n const oneTimeTransaction = this.upsellButtonDataSourceContainer\n ? this.upsellButtonDataSourceContainer.oneTimeSuccessResponse.transaction_id\n : undefined;\n\n const response: DonationResponse = await this.braintreeManager.submitDonation({\n nonce: payload.nonce,\n paymentProvider: PaymentProvider.PayPal,\n donationInfo: dataSource.donationInfo,\n customerInfo: customerInfo,\n billingInfo: billingInfo,\n upsellOnetimeTransactionId: oneTimeTransaction,\n });\n\n if (!response.success) {\n const error = response.value as ErrorResponse;\n this.donationFlowModalManager.showErrorModal({\n message: error.message,\n });\n return;\n }\n\n const successResponse = response.value as SuccessResponse;\n\n switch (donationType) {\n case DonationType.OneTime:\n this.showUpsellModal(payload, successResponse);\n break;\n case DonationType.Monthly:\n // show thank you, redirect\n this.donationFlowModalManager.showThankYouModal({ successResponse });\n break;\n case DonationType.Upsell:\n if (this.upsellButtonDataSourceContainer) {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: this.upsellButtonDataSourceContainer.oneTimeSuccessResponse,\n upsellSuccessResponse: successResponse,\n });\n } else {\n // we're in the upsell flow, but no upsell data source container.. this should not happen\n this.donationFlowModalManager.showErrorModal({\n message: 'Error setting up monthly donation',\n });\n }\n break;\n }\n }\n\n async payPalPaymentCancelled(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dataSource: PayPalButtonDataSourceInterface,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n data: object,\n ): Promise<void> {\n this.emitter.emit('payPalPaymentCancelled', dataSource, data);\n }\n\n async payPalPaymentError(\n dataSource: PayPalButtonDataSourceInterface,\n error: string,\n ): Promise<void> {\n this.emitter.emit('payPalPaymentError', dataSource, error);\n console.error(\n 'PaymentSector:payPalPaymentError error:',\n dataSource,\n dataSource.donationInfo,\n error,\n );\n }\n\n async renderPayPalButton(donationInfo: DonationPaymentInfo): Promise<void> {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n\n this.buttonDataSource = await handler?.renderPayPalButton({\n selector: '#paypal-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption, // I'm not sure why I can't access the enum directly here.. I get a UMD error\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'medium' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n\n if (this.buttonDataSource) {\n this.buttonDataSource.delegate = this;\n }\n }\n\n private async showUpsellModal(\n oneTimePayload: paypal.TokenizePayload,\n oneTimeSuccessResponse: SuccessResponse,\n ): Promise<void> {\n this.donationFlowModalManager.showUpsellModal({\n oneTimeAmount: oneTimeSuccessResponse.amount,\n amountChanged: this.upsellAmountChanged.bind(this),\n noSelected: () => {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: oneTimeSuccessResponse,\n });\n },\n ctaMode: UpsellModalCTAMode.PayPalUpsellSlot,\n userClosedModalCallback: () => {\n this.donationFlowModalManager.showThankYouModal({\n successResponse: oneTimeSuccessResponse,\n });\n },\n });\n\n const amount = DonationFlowModalManager.getDefaultUpsellAmount(oneTimeSuccessResponse.amount);\n\n const upsellDonationInfo = new DonationPaymentInfo({\n amount: amount,\n donationType: DonationType.Upsell,\n coverFees: false,\n });\n\n if (!this.upsellButtonDataSourceContainer) {\n this.renderUpsellPayPalButton({\n donationInfo: upsellDonationInfo,\n oneTimePayload,\n oneTimeSuccessResponse,\n });\n }\n }\n\n private upsellAmountChanged(amount: number): void {\n if (this.upsellButtonDataSourceContainer) {\n this.upsellButtonDataSourceContainer.upsellButtonDataSource.donationInfo.amount = amount;\n }\n }\n\n private async renderUpsellPayPalButton(options: {\n donationInfo: DonationPaymentInfo;\n oneTimePayload: paypal.TokenizePayload;\n oneTimeSuccessResponse: SuccessResponse;\n }): Promise<void> {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n\n const upsellButtonDataSource = await 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: options.donationInfo,\n });\n\n if (upsellButtonDataSource) {\n upsellButtonDataSource.delegate = this;\n this.upsellButtonDataSourceContainer = new UpsellDataSourceContainer({\n upsellButtonDataSource: upsellButtonDataSource,\n oneTimePayload: options.oneTimePayload,\n oneTimeSuccessResponse: options.oneTimeSuccessResponse,\n });\n } else {\n console.error('error rendering paypal upsell button');\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ export class ConfirmDonationContent extends LitElement {
|
|
|
35
35
|
|
|
36
36
|
get confirmUpsellText(): TemplateResult {
|
|
37
37
|
const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
|
|
38
|
-
return html`<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive
|
|
38
|
+
return html`<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring contribution will be next month.)</p>`;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
confirm(): void {
|
|
@@ -47,7 +47,7 @@ export class ConfirmDonationContent extends LitElement {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
get confirmCTA(): string {
|
|
50
|
-
return this.donationType === DonationType.Upsell ? 'Start
|
|
50
|
+
return this.donationType === DonationType.Upsell ? 'Start monthly donation' : 'Complete donation';
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/** @inheritdoc */
|
|
@@ -234,8 +234,8 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
234
234
|
options?.cancelDonationCB();
|
|
235
235
|
};
|
|
236
236
|
const modalTitle = options.donationType === DonationType.Upsell
|
|
237
|
-
? 'Confirm monthly
|
|
238
|
-
: '
|
|
237
|
+
? 'Confirm monthly donation'
|
|
238
|
+
: 'Complete donation';
|
|
239
239
|
|
|
240
240
|
const modalConfig = new ModalConfig({
|
|
241
241
|
closeOnBackdropClick: false,
|
|
@@ -125,10 +125,10 @@ export class PayPalFlowHandler
|
|
|
125
125
|
// after patron confirms the payment
|
|
126
126
|
console.log('payPalPaymentAuthorized *******', { dataSource, payload });
|
|
127
127
|
|
|
128
|
-
const { donationType,
|
|
128
|
+
const { donationType, total } = dataSource.donationInfo;
|
|
129
129
|
this.donationFlowModalManager.showConfirmationStepModal({
|
|
130
130
|
donationType,
|
|
131
|
-
amount,
|
|
131
|
+
amount: total,
|
|
132
132
|
currencyType: 'USD', // defaults to USD for now
|
|
133
133
|
confirmDonationCB: () => {
|
|
134
134
|
this.payPalPaymentConfirmed(dataSource, payload);
|