@internetarchive/donation-form 0.5.20 → 0.5.21-a2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/demo/braintree-endpoint-manager.js +0 -1
- package/dist/demo/braintree-endpoint-manager.js.map +1 -1
- package/dist/demo/demo-analytics-handler.js.map +1 -1
- package/dist/demo/submit-form-with.js.map +1 -1
- package/dist/src/braintree-manager/braintree-manager.js +33 -35
- package/dist/src/braintree-manager/braintree-manager.js.map +1 -1
- package/dist/src/braintree-manager/payment-clients.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-delegate.js +1 -0
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js +15 -14
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js +3 -3
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js +6 -6
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/google-pay-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/google-pay.js +15 -15
- package/dist/src/braintree-manager/payment-providers/google-pay.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/paypal/paypal-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/paypal/paypal.js +1 -3
- package/dist/src/braintree-manager/payment-providers/paypal/paypal.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/venmo-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers/venmo.js +9 -8
- package/dist/src/braintree-manager/payment-providers/venmo.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers-interface.d.ts +1 -1
- package/dist/src/braintree-manager/payment-providers-interface.js +1 -0
- package/dist/src/braintree-manager/payment-providers.js +3 -3
- package/dist/src/braintree-manager/payment-providers.js.map +1 -1
- package/dist/src/donation-form-controller.js +6 -5
- package/dist/src/donation-form-controller.js.map +1 -1
- package/dist/src/donation-form.js +10 -10
- package/dist/src/donation-form.js.map +1 -1
- package/dist/src/form-elements/badged-input.js +1 -5
- package/dist/src/form-elements/badged-input.js.map +1 -1
- package/dist/src/form-elements/contact-form/autocomplete-field-options.d.ts +1 -1
- package/dist/src/form-elements/contact-form/autocomplete-field-options.js +1 -0
- package/dist/src/form-elements/contact-form/contact-form.js +12 -10
- package/dist/src/form-elements/contact-form/contact-form.js.map +1 -1
- package/dist/src/form-elements/header/donation-form-header.js +1 -3
- package/dist/src/form-elements/header/donation-form-header.js.map +1 -1
- package/dist/src/form-elements/header/donation-summary.js.map +1 -1
- package/dist/src/form-elements/payment-selector.js +4 -4
- package/dist/src/form-elements/payment-selector.js.map +1 -1
- package/dist/src/form-elements/total-amount.js.map +1 -1
- package/dist/src/modals/confirm-donation-modal-content.js +13 -3
- package/dist/src/modals/confirm-donation-modal-content.js.map +1 -1
- package/dist/src/modals/error-modal-content.js.map +1 -1
- package/dist/src/modals/upsell-modal-content.js +5 -15
- package/dist/src/modals/upsell-modal-content.js.map +1 -1
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js +8 -19
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/applepay-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/creditcard-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/googlepay-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js +6 -6
- package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js +2 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/payment-flow-handlers.js +11 -11
- package/dist/src/payment-flow-handlers/payment-flow-handlers.js.map +1 -1
- package/dist/test/mocks/flow-handlers/individual-handlers/mock-creditcard-flow-handler.js.map +1 -1
- package/dist/test/mocks/flow-handlers/individual-handlers/mock-googlepay-flow-handler.js.map +1 -1
- package/dist/test/mocks/flow-handlers/mock-payment-flow-handlers.js.map +1 -1
- package/dist/test/mocks/mock-braintree-manager.js.map +1 -1
- package/dist/test/mocks/mock-modal-manager.js.map +1 -1
- package/dist/test/mocks/mock-payment-clients.js +68 -58
- package/dist/test/mocks/mock-payment-clients.js.map +1 -1
- package/dist/test/mocks/models/mock-custom-fields.js +0 -1
- package/dist/test/mocks/models/mock-custom-fields.js.map +1 -1
- package/dist/test/mocks/models/mock-success-response.js +0 -1
- package/dist/test/mocks/models/mock-success-response.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-applepay-client.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-applepay-paymentauthorizedevent.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.js +3 -3
- package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-googlepay-library.js +4 -4
- package/dist/test/mocks/payment-clients/mock-googlepay-library.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-grecaptcha.js +8 -9
- package/dist/test/mocks/payment-clients/mock-grecaptcha.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-hostedfields-client.js +6 -6
- package/dist/test/mocks/payment-clients/mock-hostedfields-client.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-venmo-client.js +5 -5
- package/dist/test/mocks/payment-clients/mock-venmo-client.js.map +1 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js +13 -13
- package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js.map +1 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource.js.map +1 -1
- package/dist/test/mocks/payment-providers/mock-payment-providers.js +2 -1
- package/dist/test/mocks/payment-providers/mock-payment-providers.js.map +1 -1
- package/dist/test/tests/braintree-manager.test.js +0 -1
- package/dist/test/tests/braintree-manager.test.js.map +1 -1
- package/dist/test/tests/donation-form-controller.test.js +1 -3
- package/dist/test/tests/donation-form-controller.test.js.map +1 -1
- package/dist/test/tests/donation-form.test.js +4 -12
- package/dist/test/tests/donation-form.test.js.map +1 -1
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +7 -8
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js.map +1 -1
- package/dist/test/tests/form-elements/donation-summary.test.js +2 -6
- package/dist/test/tests/form-elements/donation-summary.test.js.map +1 -1
- package/dist/test/tests/form-elements/payment-selector.test.js +5 -15
- package/dist/test/tests/form-elements/payment-selector.test.js.map +1 -1
- package/dist/test/tests/modals/error-modal-content.test.js.map +1 -1
- package/dist/test/tests/modals/upsell-modal-content.test.js.map +1 -1
- package/dist/test/tests/payment-clients.test.js.map +1 -1
- package/dist/test/tests/payment-providers/applepay.test.js +1 -1
- package/dist/test/tests/payment-providers/applepay.test.js.map +1 -1
- package/dist/test/tests/payment-providers/paypal-button-datasource.test.js.map +1 -1
- package/dist/test/tests/payment-providers/venmo.test.js +1 -1
- package/dist/test/tests/payment-providers/venmo.test.js.map +1 -1
- package/dist/test/tests/recaptcha-manager.test.js +4 -12
- package/dist/test/tests/recaptcha-manager.test.js.map +1 -1
- package/package.json +31 -25
- package/src/braintree-manager/braintree-manager.ts +0 -2
- package/src/braintree-manager/payment-clients.ts +1 -2
- package/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.ts +1 -1
- package/src/braintree-manager/payment-providers/paypal/paypal.ts +3 -3
- package/src/donation-form-controller.ts +10 -9
- package/src/donation-form.ts +13 -16
- package/src/form-elements/badged-input.ts +1 -5
- package/src/form-elements/contact-form/contact-form.ts +25 -23
- package/src/form-elements/header/donation-form-header.ts +1 -3
- package/src/form-elements/payment-selector.ts +4 -4
- package/src/modals/confirm-donation-modal-content.ts +16 -6
- package/src/modals/upsell-modal-content.ts +5 -15
- package/src/payment-flow-handlers/donation-flow-modal-manager.ts +12 -22
- package/src/payment-flow-handlers/handlers/applepay-flow-handler.ts +2 -1
- package/src/payment-flow-handlers/handlers/creditcard-flow-handler.ts +2 -1
- package/src/payment-flow-handlers/handlers/googlepay-flow-handler.ts +4 -6
- package/src/payment-flow-handlers/handlers/paypal-flow-handler.ts +7 -6
- package/src/payment-flow-handlers/handlers/venmo-flow-handler.ts +2 -1
- package/src/payment-flow-handlers/payment-flow-handlers.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/donation-form",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21-a2",
|
|
4
4
|
"description": "The Internet Archive Donation Form",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"prepare": "yarn run build",
|
|
17
17
|
"build": "tsc -p tsconfig.build.json",
|
|
18
|
-
"start": "concurrently
|
|
18
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds --app-index demo/index.html --node-resolve --open --watch --preserve-symlinks\"",
|
|
19
19
|
"tsc:watch": "tsc --watch",
|
|
20
20
|
"lint:eslint": "eslint --ext .ts,.html . --ignore-path .gitignore",
|
|
21
21
|
"format:eslint": "eslint --ext .ts,.html . --fix --ignore-path .gitignore",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"lint": "yarn run lint:eslint && yarn run lint:prettier",
|
|
25
25
|
"format": "yarn run format:eslint && yarn run format:prettier",
|
|
26
26
|
"circular": "madge --circular --extensions ts .",
|
|
27
|
-
"test": "tsc && yarn run lint && yarn run circular &&
|
|
28
|
-
"test:watch": "concurrently
|
|
27
|
+
"test": "tsc && yarn run lint && yarn run circular && wtr dist/test/tests/**/*.test.js --node-resolve --coverage",
|
|
28
|
+
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr test/tests/**/*.test.ts --node-resolve --watch\""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@internetarchive/analytics-manager": "^0.1.2",
|
|
@@ -47,35 +47,41 @@
|
|
|
47
47
|
"@internetarchive/modal-manager": "^0.2.8",
|
|
48
48
|
"@internetarchive/promised-singleton": "^0.2.1",
|
|
49
49
|
"currency.js": "^2.0.2",
|
|
50
|
-
"lit": "^2.
|
|
50
|
+
"lit": "^2.8.0",
|
|
51
51
|
"nanoevents": "^5.1.8"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@open-wc/
|
|
56
|
-
"@open-wc/
|
|
57
|
-
"@open-wc/testing
|
|
58
|
-
"@open-wc/testing-karma-bs": "^1.0.0",
|
|
54
|
+
"@babel/core": "^7.23.3",
|
|
55
|
+
"@open-wc/eslint-config": "^12.0.2",
|
|
56
|
+
"@open-wc/prettier-config": "^1.1.0",
|
|
57
|
+
"@open-wc/testing": "^3.1.6",
|
|
59
58
|
"@types/applepayjs": "^3.0.0",
|
|
60
|
-
"@types/form-data": "^2.5.0",
|
|
61
59
|
"@types/googlepay": "^0.4.1",
|
|
62
60
|
"@types/grecaptcha": "^2.0.36",
|
|
63
|
-
"@
|
|
64
|
-
"@typescript-eslint/
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
61
|
+
"@types/mocha": "^10.0.4",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
63
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
64
|
+
"@web/dev-server": "^0.3.0",
|
|
65
|
+
"@web/test-runner": "^0.17.0",
|
|
66
|
+
"concurrently": "^8.0.0",
|
|
67
|
+
"eslint": "^8.18.0",
|
|
68
|
+
"eslint-config-prettier": "^8.5.0",
|
|
69
|
+
"eslint-plugin-html": "^7.1.0",
|
|
70
|
+
"eslint-plugin-import": "^2.26.0",
|
|
71
|
+
"eslint-plugin-lit": "^1.7.2",
|
|
72
|
+
"eslint-plugin-lit-a11y": "^4.1.1",
|
|
73
|
+
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
74
|
+
"eslint-plugin-wc": "^2.0.4",
|
|
68
75
|
"form-data": "^3.0.0",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"karma-coverage": "^2.0.1",
|
|
76
|
+
"husky": "^8.0.3",
|
|
77
|
+
"karma": "^6.4.2",
|
|
72
78
|
"lint-staged": "^8.0.0",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
+
"madge": "^6.0.0",
|
|
80
|
+
"prettier": "^3.1.0",
|
|
81
|
+
"sinon": "^16.0.0",
|
|
82
|
+
"ts-lit-plugin": "^1.2.1",
|
|
83
|
+
"tslib": "^2.4.0",
|
|
84
|
+
"typescript": "^4.7.4"
|
|
79
85
|
},
|
|
80
86
|
"eslintConfig": {
|
|
81
87
|
"extends": [
|
|
@@ -99,9 +99,7 @@ export class BraintreeManager implements BraintreeManagerInterface {
|
|
|
99
99
|
binName?: string; // credit card bank name
|
|
100
100
|
}): Promise<DonationResponse> {
|
|
101
101
|
const customFields = new DonationRequestCustomFields();
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
103
102
|
customFields.fee_amount_covered = options.donationInfo.feeAmountCovered;
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
105
103
|
customFields.logged_in_user = this.loggedInUser;
|
|
106
104
|
customFields.referrer = this.referrer;
|
|
107
105
|
customFields.origin = this.origin;
|
|
@@ -106,8 +106,7 @@ export class PaymentClients implements PaymentClientsInterface {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
this.lazyLoader.loadScript({
|
|
109
|
-
src:
|
|
110
|
-
'https://www.google.com/recaptcha/api.js?onload=donationFormGrecaptchaLoadedCallback&render=explicit',
|
|
109
|
+
src: 'https://www.google.com/recaptcha/api.js?onload=donationFormGrecaptchaLoadedCallback&render=explicit',
|
|
111
110
|
});
|
|
112
111
|
}),
|
|
113
112
|
});
|
|
@@ -112,7 +112,7 @@ export interface PayPalButtonDataSourceDelegate {
|
|
|
112
112
|
* @returns {Promise<void>}
|
|
113
113
|
* @memberof PayPalButtonDataSourceDelegate
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
payPalPaymentConfirmed(
|
|
116
116
|
dataSource: PayPalButtonDataSourceInterface,
|
|
117
117
|
payload: paypal.TokenizePayload,
|
|
118
118
|
): Promise<void>;
|
|
@@ -44,9 +44,9 @@ export class PayPalHandler implements PayPalHandlerInterface {
|
|
|
44
44
|
style: paypal.ButtonStyle;
|
|
45
45
|
donationInfo: DonationPaymentInfo;
|
|
46
46
|
}): Promise<PayPalButtonDataSourceInterface | undefined> {
|
|
47
|
-
const env: paypal.Environment = (
|
|
48
|
-
? 'sandbox'
|
|
49
|
-
|
|
47
|
+
const env: paypal.Environment = (
|
|
48
|
+
this.hostingEnvironment === HostingEnvironment.Development ? 'sandbox' : 'production'
|
|
49
|
+
) as paypal.Environment;
|
|
50
50
|
|
|
51
51
|
const paypalInstance = await this.instance.get();
|
|
52
52
|
if (!paypalInstance) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
1
2
|
import { LitElement, html, PropertyValues, TemplateResult } from 'lit';
|
|
2
3
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
4
|
|
|
@@ -32,9 +33,9 @@ import './form-elements/badged-input';
|
|
|
32
33
|
import { ContactForm } from './form-elements/contact-form/contact-form';
|
|
33
34
|
import './form-elements/contact-form/contact-form';
|
|
34
35
|
|
|
35
|
-
import creditCardImg from '@internetarchive/icon-credit-card';
|
|
36
|
-
import calendarImg from '@internetarchive/icon-calendar';
|
|
37
|
-
import lockImg from '@internetarchive/icon-lock';
|
|
36
|
+
import creditCardImg from '@internetarchive/icon-credit-card/index.js';
|
|
37
|
+
import calendarImg from '@internetarchive/icon-calendar/index.js';
|
|
38
|
+
import lockImg from '@internetarchive/icon-lock/index.js';
|
|
38
39
|
import { DonationControllerEventLoggerInterface } from './@types/analytics-handler';
|
|
39
40
|
import { AnalyticsManagerInterface, AnalyticsEvent } from '@internetarchive/analytics-manager';
|
|
40
41
|
import {
|
|
@@ -331,7 +332,7 @@ export class DonationFormController extends LitElement {
|
|
|
331
332
|
logEvent: this.logEvent.bind(this),
|
|
332
333
|
logDonationFlowEvent: this.logDonationFlowEvent.bind(this),
|
|
333
334
|
} as DonationControllerEventLoggerInterface,
|
|
334
|
-
}
|
|
335
|
+
},
|
|
335
336
|
});
|
|
336
337
|
|
|
337
338
|
this.donationForm.braintreeManager = this.braintreeManager;
|
|
@@ -536,10 +537,10 @@ export class DonationFormController extends LitElement {
|
|
|
536
537
|
* @param {string} action Name of event
|
|
537
538
|
* @param {string} label Event label, optional
|
|
538
539
|
*/
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
540
|
+
private logDonationFlowEvent(action: string, label?: string): void {
|
|
541
|
+
const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;
|
|
542
|
+
this.analyticsHandler?.sendEventNoSampling(analyticEvent);
|
|
543
|
+
}
|
|
543
544
|
|
|
544
545
|
/**
|
|
545
546
|
* This is not the normal LitElement styles block.
|
|
@@ -610,7 +611,7 @@ export class DonationFormController extends LitElement {
|
|
|
610
611
|
margin-bottom: 0.6rem;
|
|
611
612
|
}
|
|
612
613
|
|
|
613
|
-
.donation-form-controller-container div[slot=
|
|
614
|
+
.donation-form-controller-container div[slot='braintree-hosted-fields'] {
|
|
614
615
|
background-color: white;
|
|
615
616
|
}
|
|
616
617
|
</style>
|
package/src/donation-form.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
1
2
|
import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';
|
|
2
3
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
4
|
|
|
4
|
-
import lockImg from '@internetarchive/icon-lock';
|
|
5
|
+
import lockImg from '@internetarchive/icon-lock/index.js';
|
|
5
6
|
|
|
6
7
|
// we have to import the registered component independently from the definition below
|
|
7
8
|
// because inside each of these files, we're registering the custom element inside
|
|
@@ -121,15 +122,15 @@ export class DonationForm extends LitElement {
|
|
|
121
122
|
`;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
async showConfirmationModalDev(options: {
|
|
126
|
+
donationType: DonationType;
|
|
127
|
+
amount: number;
|
|
128
|
+
currencyType: string;
|
|
129
|
+
cancelDonationCB: Function;
|
|
130
|
+
confirmDonationCB: Function;
|
|
131
|
+
}): Promise<void> {
|
|
132
|
+
this.paymentFlowHandlers?.showConfirmationStepModal(options);
|
|
133
|
+
}
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* This is a developer convenience method that allows us to show the upsell modal without going
|
|
@@ -193,13 +194,9 @@ export class DonationForm extends LitElement {
|
|
|
193
194
|
|
|
194
195
|
<donation-form-section .sectionBadge=${this.paymentSelectorNumberingStart + 2}>
|
|
195
196
|
<slot name="recaptcha"></slot>
|
|
196
|
-
<button id="donate-button" @click=${this.donateClicked}>
|
|
197
|
-
Donate
|
|
198
|
-
</button>
|
|
197
|
+
<button id="donate-button" @click=${this.donateClicked}>Donate</button>
|
|
199
198
|
|
|
200
|
-
<div class="secure-process-note">
|
|
201
|
-
${lockImg} Your payment will be securely processed
|
|
202
|
-
</div>
|
|
199
|
+
<div class="secure-process-note">${lockImg} Your payment will be securely processed</div>
|
|
203
200
|
</donation-form-section>
|
|
204
201
|
`;
|
|
205
202
|
}
|
|
@@ -38,11 +38,7 @@ export class BadgedInput extends LitElement {
|
|
|
38
38
|
<div class="input-wrapper ${this.errorClass} ${this.iconSpaceOptionClass}">
|
|
39
39
|
<div class="icon-container">${this.icon}</div>
|
|
40
40
|
<div class="required-indicator ${this.requiredIndicatorSpaceOption}">
|
|
41
|
-
${this.required
|
|
42
|
-
? html`
|
|
43
|
-
*
|
|
44
|
-
`
|
|
45
|
-
: nothing}
|
|
41
|
+
${this.required ? html` * ` : nothing}
|
|
46
42
|
</div>
|
|
47
43
|
|
|
48
44
|
<slot></slot>
|
|
@@ -12,9 +12,9 @@ import { SpacerOption } from '../badged-input';
|
|
|
12
12
|
import { BadgedInput } from '../badged-input';
|
|
13
13
|
import '../badged-input';
|
|
14
14
|
|
|
15
|
-
import emailImg from '@internetarchive/icon-email';
|
|
16
|
-
import localePinImg from '@internetarchive/icon-locale-pin';
|
|
17
|
-
import userIcon from '@internetarchive/icon-user';
|
|
15
|
+
import emailImg from '@internetarchive/icon-email/index.js';
|
|
16
|
+
import localePinImg from '@internetarchive/icon-locale-pin/index.js';
|
|
17
|
+
import userIcon from '@internetarchive/icon-user/index.js';
|
|
18
18
|
|
|
19
19
|
import { countries } from './countries';
|
|
20
20
|
|
|
@@ -179,9 +179,7 @@ export class ContactForm extends LitElement {
|
|
|
179
179
|
iconSpaceOption: SpacerOption.CompressSpace,
|
|
180
180
|
})}
|
|
181
181
|
</div>
|
|
182
|
-
<div class="row">
|
|
183
|
-
${this.countrySelectorTemplate}
|
|
184
|
-
</div>
|
|
182
|
+
<div class="row">${this.countrySelectorTemplate}</div>
|
|
185
183
|
</fieldset>
|
|
186
184
|
</form>
|
|
187
185
|
${this.getStyles}
|
|
@@ -191,23 +189,27 @@ export class ContactForm extends LitElement {
|
|
|
191
189
|
private get countrySelectorTemplate(): TemplateResult {
|
|
192
190
|
return html`
|
|
193
191
|
<badged-input>
|
|
194
|
-
<select
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
<select
|
|
193
|
+
id="donation-contact-form-countryCodeAlpha2"
|
|
194
|
+
@change=${(e: Event) => {
|
|
195
|
+
const currCountry = this.selectedCountry;
|
|
196
|
+
this.selectedCountry = (e.target as HTMLInputElement)?.value
|
|
197
|
+
? ((e.target as HTMLInputElement)?.value as string)
|
|
198
|
+
: currCountry;
|
|
199
|
+
// update required visual cue on region/state/province & postal code fields
|
|
200
|
+
if (this.selectedCountry === 'US') {
|
|
201
|
+
this.postalBadgedInput?.setAttribute('required', '');
|
|
202
|
+
this.postalCodeField?.setAttribute('required', '');
|
|
203
|
+
this.regionBadgedInput?.setAttribute('required', '');
|
|
204
|
+
this.regionField?.setAttribute('required', '');
|
|
205
|
+
} else {
|
|
206
|
+
this.postalBadgedInput?.removeAttribute('required');
|
|
207
|
+
this.postalCodeField?.removeAttribute('required');
|
|
208
|
+
this.regionBadgedInput?.removeAttribute('required');
|
|
209
|
+
this.regionField?.removeAttribute('required');
|
|
210
|
+
}
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
211
213
|
${Object.keys(countries).map(key => {
|
|
212
214
|
const name = countries[key];
|
|
213
215
|
return html`
|
|
@@ -36,9 +36,7 @@ export class DonationFormHeader extends LitElement {
|
|
|
36
36
|
|
|
37
37
|
/** @inheritdoc */
|
|
38
38
|
render(): TemplateResult {
|
|
39
|
-
return html`
|
|
40
|
-
${this.currentTemplate}
|
|
41
|
-
`;
|
|
39
|
+
return html` ${this.currentTemplate} `;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
private get currentTemplate(): TemplateResult {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
3
|
|
|
4
|
-
import applePayButtonImage from '@internetarchive/icon-applepay';
|
|
5
|
-
import googlePayButtonImage from '@internetarchive/icon-googlepay';
|
|
6
|
-
import paypalButtonImage from '@internetarchive/icon-paypal';
|
|
7
|
-
import venmoButtonImage from '@internetarchive/icon-venmo';
|
|
4
|
+
import applePayButtonImage from '@internetarchive/icon-applepay/index.js';
|
|
5
|
+
import googlePayButtonImage from '@internetarchive/icon-googlepay/index.js';
|
|
6
|
+
import paypalButtonImage from '@internetarchive/icon-paypal/index.js';
|
|
7
|
+
import venmoButtonImage from '@internetarchive/icon-venmo/index.js';
|
|
8
8
|
import { PaymentProvidersInterface } from '../braintree-manager/payment-providers-interface';
|
|
9
9
|
|
|
10
10
|
enum PaymentButtonMode {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
3
|
import { LitElement, html, TemplateResult, css, CSSResultGroup } from 'lit';
|
|
3
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
5
|
import { DonationType } from '@internetarchive/donation-form-data-models';
|
|
@@ -24,18 +25,25 @@ export class ConfirmDonationContent extends LitElement {
|
|
|
24
25
|
|
|
25
26
|
@property({ type: Function }) confirmDonation: Function = (): void => {};
|
|
26
27
|
|
|
27
|
-
@property({ type: Function }) cancelDonation: Function= (): void => {};
|
|
28
|
+
@property({ type: Function }) cancelDonation: Function = (): void => {};
|
|
28
29
|
|
|
29
30
|
get confirmationText(): TemplateResult {
|
|
30
31
|
const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
|
|
31
32
|
return html`
|
|
32
|
-
|
|
33
|
+
<p>
|
|
34
|
+
You are about to make a <b>${this.donationType}</b> donation of
|
|
35
|
+
<b>${amount} ${this.currencyType}</b> to the Internet Archive.
|
|
36
|
+
</p>
|
|
33
37
|
`;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
get confirmUpsellText(): TemplateResult {
|
|
37
41
|
const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
|
|
38
|
-
return html`<p>
|
|
42
|
+
return html`<p>
|
|
43
|
+
You are about to begin making <b>monthly</b> donations of
|
|
44
|
+
<b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring
|
|
45
|
+
contribution will be next month.)
|
|
46
|
+
</p>`;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
confirm(): void {
|
|
@@ -47,7 +55,9 @@ export class ConfirmDonationContent extends LitElement {
|
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
get confirmCTA(): string {
|
|
50
|
-
return this.donationType === DonationType.Upsell
|
|
58
|
+
return this.donationType === DonationType.Upsell
|
|
59
|
+
? 'Start monthly donation'
|
|
60
|
+
: 'Complete donation';
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
/** @inheritdoc */
|
|
@@ -107,8 +117,8 @@ export class ConfirmDonationContent extends LitElement {
|
|
|
107
117
|
/**
|
|
108
118
|
* https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/
|
|
109
119
|
*/
|
|
110
|
-
|
|
111
|
-
switch(this.currencyType) {
|
|
120
|
+
get currencySymbol(): string {
|
|
121
|
+
switch (this.currencyType) {
|
|
112
122
|
case 'AUD':
|
|
113
123
|
return 'AU$';
|
|
114
124
|
case 'BRL':
|
|
@@ -33,14 +33,10 @@ export class UpsellModalContent extends LitElement {
|
|
|
33
33
|
render(): TemplateResult {
|
|
34
34
|
return html`
|
|
35
35
|
<h3>Thank you for donating!</h3>
|
|
36
|
-
<button @click=${this.noThanksSelected} class="cta-button" id="no-button">
|
|
37
|
-
Continue
|
|
38
|
-
</button>
|
|
36
|
+
<button @click=${this.noThanksSelected} class="cta-button" id="no-button">Continue</button>
|
|
39
37
|
<p class="or_separator"><span>or</span></p>
|
|
40
38
|
<h3>Consider donating monthly</h3>
|
|
41
|
-
<p class="appeal">
|
|
42
|
-
Monthly support helps us reliably plan for the future.
|
|
43
|
-
</p>
|
|
39
|
+
<p class="appeal">Monthly support helps us reliably plan for the future.</p>
|
|
44
40
|
<div class="monthly-amount">
|
|
45
41
|
<h1>Enter your monthly amount</h1>
|
|
46
42
|
<div class="amount-input">
|
|
@@ -79,9 +75,7 @@ export class UpsellModalContent extends LitElement {
|
|
|
79
75
|
return html`
|
|
80
76
|
<div class="paypal-upsell-slot-container">
|
|
81
77
|
<div class="paypal-upsell-slot-blocker ${this.error ? '' : 'hidden'}"></div>
|
|
82
|
-
<button class="cta-button" id="paypal-cover-button">
|
|
83
|
-
YES, I'll donate monthly
|
|
84
|
-
</button>
|
|
78
|
+
<button class="cta-button" id="paypal-cover-button">YES, I'll donate monthly</button>
|
|
85
79
|
<slot class="paypal-upsell-slot"></slot>
|
|
86
80
|
</div>
|
|
87
81
|
`;
|
|
@@ -100,9 +94,7 @@ export class UpsellModalContent extends LitElement {
|
|
|
100
94
|
private handleCustomAmountInput(value: string): void {
|
|
101
95
|
const amount = parseFloat(value);
|
|
102
96
|
if (isNaN(amount)) {
|
|
103
|
-
this.error = html`
|
|
104
|
-
Please enter a valid amount.
|
|
105
|
-
`;
|
|
97
|
+
this.error = html` Please enter a valid amount. `;
|
|
106
98
|
} else {
|
|
107
99
|
this.processAmount(amount);
|
|
108
100
|
}
|
|
@@ -119,9 +111,7 @@ export class UpsellModalContent extends LitElement {
|
|
|
119
111
|
|
|
120
112
|
if (amount < 1) {
|
|
121
113
|
if (this.amountInput && this.amountInput.value.length > 0) {
|
|
122
|
-
this.error = html`
|
|
123
|
-
The minimum donation amount is $1.
|
|
124
|
-
`;
|
|
114
|
+
this.error = html` The minimum donation amount is $1. `;
|
|
125
115
|
}
|
|
126
116
|
return;
|
|
127
117
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
1
2
|
import { html } from 'lit';
|
|
2
3
|
import { ModalConfig, ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
3
4
|
import { UpsellModalCTAMode } from '../modals/upsell-modal-content';
|
|
@@ -175,9 +176,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
175
176
|
closeOnBackdropClick: false,
|
|
176
177
|
showCloseButton: false,
|
|
177
178
|
processingImageMode: 'processing',
|
|
178
|
-
title: html`
|
|
179
|
-
Processing...
|
|
180
|
-
`,
|
|
179
|
+
title: html` Processing... `,
|
|
181
180
|
});
|
|
182
181
|
this.modalManager.showModal({ config: modalConfig });
|
|
183
182
|
}
|
|
@@ -191,9 +190,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
191
190
|
showProcessingIndicator: true,
|
|
192
191
|
processingImageMode: 'complete',
|
|
193
192
|
headerColor: ModalHeaderColor.Green,
|
|
194
|
-
title: html`
|
|
195
|
-
Thank You!
|
|
196
|
-
`,
|
|
193
|
+
title: html` Thank You! `,
|
|
197
194
|
});
|
|
198
195
|
this.modalManager.showModal({
|
|
199
196
|
config: modalConfig,
|
|
@@ -216,15 +213,9 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
216
213
|
showErrorModal(options: { message: string; userClosedModalCallback?: () => void }): void {
|
|
217
214
|
const modalConfig = new ModalConfig({
|
|
218
215
|
headerColor: ModalHeaderColor.Red,
|
|
219
|
-
title: html`
|
|
220
|
-
|
|
221
|
-
`,
|
|
222
|
-
headline: html`
|
|
223
|
-
There's been a problem completing your donation.
|
|
224
|
-
`,
|
|
225
|
-
message: html`
|
|
226
|
-
${options?.message}
|
|
227
|
-
`,
|
|
216
|
+
title: html` Processing error `,
|
|
217
|
+
headline: html` There's been a problem completing your donation. `,
|
|
218
|
+
message: html` ${options?.message} `,
|
|
228
219
|
});
|
|
229
220
|
|
|
230
221
|
this.modalManager.showModal({
|
|
@@ -249,9 +240,10 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
249
240
|
const cancelDonation = (): void => {
|
|
250
241
|
options?.cancelDonationCB();
|
|
251
242
|
};
|
|
252
|
-
const modalTitle =
|
|
253
|
-
|
|
254
|
-
|
|
243
|
+
const modalTitle =
|
|
244
|
+
options.donationType === DonationType.Upsell
|
|
245
|
+
? 'Confirm monthly donation'
|
|
246
|
+
: 'Complete donation';
|
|
255
247
|
|
|
256
248
|
const modalConfig = new ModalConfig({
|
|
257
249
|
closeOnBackdropClick: false,
|
|
@@ -269,7 +261,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
269
261
|
});
|
|
270
262
|
return this.modalManager.showModal({
|
|
271
263
|
config: modalConfig,
|
|
272
|
-
userClosedModalCallback: cancelDonation
|
|
264
|
+
userClosedModalCallback: cancelDonation,
|
|
273
265
|
});
|
|
274
266
|
}
|
|
275
267
|
|
|
@@ -284,9 +276,7 @@ export class DonationFlowModalManager implements DonationFlowModalManagerInterfa
|
|
|
284
276
|
}): Promise<void> {
|
|
285
277
|
const modalConfig = new ModalConfig({
|
|
286
278
|
headerColor: ModalHeaderColor.Green,
|
|
287
|
-
title: html`
|
|
288
|
-
Donation received
|
|
289
|
-
`,
|
|
279
|
+
title: html` Donation received `,
|
|
290
280
|
processingImageMode: 'complete',
|
|
291
281
|
showProcessingIndicator: true,
|
|
292
282
|
});
|
|
@@ -15,7 +15,8 @@ export interface ApplePayFlowHandlerInterface {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export class ApplePayFlowHandler
|
|
18
|
-
implements ApplePayFlowHandlerInterface, ApplePaySessionDataSourceDelegate
|
|
18
|
+
implements ApplePayFlowHandlerInterface, ApplePaySessionDataSourceDelegate
|
|
19
|
+
{
|
|
19
20
|
private donationFlowModalManager: DonationFlowModalManagerInterface;
|
|
20
21
|
|
|
21
22
|
private braintreeManager: BraintreeManagerInterface;
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { DonationFlowModalManagerInterface } from '../donation-flow-modal-manager';
|
|
12
12
|
import { HostedFieldName } from '../../braintree-manager/payment-providers/credit-card/hosted-field-container';
|
|
13
13
|
import { BadgedInput } from '../../form-elements/badged-input';
|
|
14
|
+
import { BraintreeError } from '../../@types/braintree-web';
|
|
14
15
|
|
|
15
16
|
export interface CreditCardFlowHandlerInterface {
|
|
16
17
|
/**
|
|
@@ -146,7 +147,7 @@ export class CreditCardFlowHandler implements CreditCardFlowHandlerInterface {
|
|
|
146
147
|
try {
|
|
147
148
|
hostedFieldsResponse = await handler?.tokenizeHostedFields();
|
|
148
149
|
} catch (error) {
|
|
149
|
-
this.handleHostedFieldTokenizationError(error);
|
|
150
|
+
this.handleHostedFieldTokenizationError(error as BraintreeError);
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -25,9 +25,8 @@ export class GooglePayFlowHandler implements GooglePayFlowHandlerInterface {
|
|
|
25
25
|
|
|
26
26
|
private braintreeManager: BraintreeManagerInterface;
|
|
27
27
|
|
|
28
|
-
private emitter: Emitter<GooglePayFlowHandlerEvents> =
|
|
29
|
-
GooglePayFlowHandlerEvents
|
|
30
|
-
>();
|
|
28
|
+
private emitter: Emitter<GooglePayFlowHandlerEvents> =
|
|
29
|
+
createNanoEvents<GooglePayFlowHandlerEvents>();
|
|
31
30
|
|
|
32
31
|
constructor(options: {
|
|
33
32
|
braintreeManager: BraintreeManagerInterface;
|
|
@@ -67,9 +66,8 @@ export class GooglePayFlowHandler implements GooglePayFlowHandlerInterface {
|
|
|
67
66
|
|
|
68
67
|
try {
|
|
69
68
|
const paymentData = await handler.paymentsClient.loadPaymentData(paymentDataRequest);
|
|
70
|
-
const result: braintree.GooglePaymentTokenizePayload =
|
|
71
|
-
paymentData
|
|
72
|
-
);
|
|
69
|
+
const result: braintree.GooglePaymentTokenizePayload =
|
|
70
|
+
await instance.parseResponse(paymentData);
|
|
73
71
|
|
|
74
72
|
const billingInfo = paymentData.paymentMethodData.info?.billingAddress;
|
|
75
73
|
const name = billingInfo?.name;
|
|
@@ -69,7 +69,8 @@ export interface PayPalFlowHandlerEvents {
|
|
|
69
69
|
* @implements {PayPalButtonDataSourceDelegate}
|
|
70
70
|
*/
|
|
71
71
|
export class PayPalFlowHandler
|
|
72
|
-
implements PayPalFlowHandlerInterface, PayPalButtonDataSourceDelegate
|
|
72
|
+
implements PayPalFlowHandlerInterface, PayPalButtonDataSourceDelegate
|
|
73
|
+
{
|
|
73
74
|
private upsellButtonDataSourceContainer?: UpsellDataSourceContainer;
|
|
74
75
|
|
|
75
76
|
private buttonDataSource?: PayPalButtonDataSourceInterface;
|
|
@@ -120,10 +121,10 @@ export class PayPalFlowHandler
|
|
|
120
121
|
* Once we have the dataSource & payload, we ask patron to confirm donation.
|
|
121
122
|
* Once confirmed, we move forward to: `payPalPaymentConfirmed`
|
|
122
123
|
*/
|
|
123
|
-
async payPalPaymentAuthorized(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
async payPalPaymentAuthorized(
|
|
125
|
+
dataSource: PayPalButtonDataSourceInterface,
|
|
126
|
+
payload: paypal.TokenizePayload,
|
|
127
|
+
): Promise<void> {
|
|
127
128
|
const { donationType, total } = dataSource.donationInfo;
|
|
128
129
|
this.donationFlowModalManager.showConfirmationStepModal({
|
|
129
130
|
donationType,
|
|
@@ -135,7 +136,7 @@ export class PayPalFlowHandler
|
|
|
135
136
|
cancelDonationCB: () => {
|
|
136
137
|
this.donationFlowModalManager.closeModal();
|
|
137
138
|
this.payPalPaymentCancelled(dataSource, {});
|
|
138
|
-
}
|
|
139
|
+
},
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
VenmoRestorationStateHandler,
|
|
10
10
|
} from './venmo-restoration-state-handler';
|
|
11
11
|
import { DonationFlowModalManagerInterface } from '../donation-flow-modal-manager';
|
|
12
|
+
import { BraintreeError } from '../../@types/braintree-web';
|
|
12
13
|
|
|
13
14
|
export interface VenmoFlowHandlerInterface {
|
|
14
15
|
startup(): Promise<void>;
|
|
@@ -81,7 +82,7 @@ export class VenmoFlowHandler implements VenmoFlowHandlerInterface {
|
|
|
81
82
|
this.handleTokenizationResult(result, contactInfo, donationInfo);
|
|
82
83
|
} catch (tokenizeError) {
|
|
83
84
|
this.restorationStateHandler.clearState();
|
|
84
|
-
this.handleTokenizationError(tokenizeError);
|
|
85
|
+
this.handleTokenizationError(tokenizeError as BraintreeError);
|
|
85
86
|
this.donationFlowModalManager.showErrorModal({
|
|
86
87
|
message: `There was a problem loading your donation information. Please try again.`,
|
|
87
88
|
});
|