@internetarchive/elements 1.1.7-webdev-9378.0 → 1.1.7-webdev-9054.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/elements/ia-donation-form/analytics.d.ts +12 -0
- package/dist/src/elements/ia-donation-form/analytics.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/analytics.js +2 -0
- package/dist/src/elements/ia-donation-form/analytics.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts +79 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts +73 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js +126 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts +10 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js +9 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts +47 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.js +104 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts +20 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts +21 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js +83 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js +13 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js +67 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts +19 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js +99 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts +14 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js +9 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts +40 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js +58 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts +8 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts +19 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js +45 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts +57 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts +14 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts +8 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js +65 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts +25 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts +18 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.js +99 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.js.map +1 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.d.ts +5 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.js +8 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts +118 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js +194 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts +24 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js +70 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts +44 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js +116 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts +24 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js +74 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts +47 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js +204 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts +30 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js +77 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts +80 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js +72 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts +2 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js +2 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts +3 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js +254 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts +68 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js +483 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts +26 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js +163 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts +39 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js +212 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts +118 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js +774 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts +31 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js +93 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts +33 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js +380 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js +59 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts +10 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js +75 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts +111 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js +522 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts +95 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.js +522 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.js.map +1 -0
- package/dist/src/elements/ia-donation-form/icons/apple-pay.svg +22 -0
- package/dist/src/elements/ia-donation-form/icons/calendar.svg +12 -0
- package/dist/src/elements/ia-donation-form/icons/credit-card.svg +7 -0
- package/dist/src/elements/ia-donation-form/icons/google-pay.svg +38 -0
- package/dist/src/elements/ia-donation-form/icons/lock.svg +6 -0
- package/dist/src/elements/ia-donation-form/icons/paypal.svg +39 -0
- package/dist/src/elements/ia-donation-form/icons/venmo.svg +9 -0
- package/dist/src/elements/ia-donation-form/icons.d.ts +9 -0
- package/dist/src/elements/ia-donation-form/icons.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/icons.js +27 -0
- package/dist/src/elements/ia-donation-form/icons.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js +195 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts +7 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js +63 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts +28 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js +313 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js.map +1 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts +36 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.js +76 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.js.map +1 -0
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.d.ts.map +1 -1
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js +2 -4
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js.map +1 -1
- package/package.json +12 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The analytics hooks the controller hands down to the flow handlers, so they
|
|
3
|
+
* can log events in the donation form's category without knowing about the
|
|
4
|
+
* analytics manager.
|
|
5
|
+
*/
|
|
6
|
+
export interface DonationEventLoggerInterface {
|
|
7
|
+
/** A sampled event in the form's own category */
|
|
8
|
+
logEvent(action: string, label?: string): void;
|
|
9
|
+
/** An unsampled event in the `DonationFlow` category, for the money-moving steps */
|
|
10
|
+
logDonationFlowEvent(action: string, label?: string): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/analytics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,oFAAoF;IACpF,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/analytics.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The analytics hooks the controller hands down to the flow handlers, so they\n * can log events in the donation form's category without knowing about the\n * analytics manager.\n */\nexport interface DonationEventLoggerInterface {\n /** A sampled event in the form's own category */\n logEvent(action: string, label?: string): void;\n /** An unsampled event in the `DonationFlow` category, for the money-moving steps */\n logDonationFlowEvent(action: string, label?: string): void;\n}\n"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type * as braintree from 'braintree-web';
|
|
2
|
+
import type { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
3
|
+
import type { Unsubscribe } from 'nanoevents';
|
|
4
|
+
import type { BillingInfo, CustomerInfo } from '../models/donor-contact-info.js';
|
|
5
|
+
import type { DonationPaymentInfo } from '../models/donation-payment-info.js';
|
|
6
|
+
import type { DonationRequest } from '../models/donation-request.js';
|
|
7
|
+
import type { DonationResponse, SuccessResponse } from '../models/donation-response.js';
|
|
8
|
+
import type { PaymentProvider } from '../models/payment-provider.js';
|
|
9
|
+
import type { PaymentProvidersInterface } from './payment-providers-interface.js';
|
|
10
|
+
export interface BraintreeManagerEvents {
|
|
11
|
+
paymentProvidersHostedFieldsRetry: (retryNumber: number) => void;
|
|
12
|
+
paymentProvidersHostedFieldsFailed: (error: unknown) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The BraintreeManager is the main entry point for the shared Braintree
|
|
16
|
+
* functionality. One instance is created and handed down through all of the
|
|
17
|
+
* components.
|
|
18
|
+
*/
|
|
19
|
+
export interface BraintreeManagerInterface {
|
|
20
|
+
on<E extends keyof BraintreeManagerEvents>(event: E, callback: BraintreeManagerEvents[E]): Unsubscribe;
|
|
21
|
+
/**
|
|
22
|
+
* The IA-specific handlers for each payment provider. They're data-focused
|
|
23
|
+
* rather than UI-focused, though there's some overlap with the flow handlers.
|
|
24
|
+
*/
|
|
25
|
+
paymentProviders: PaymentProvidersInterface;
|
|
26
|
+
/** The Braintree client instance, used to create the provider clients. */
|
|
27
|
+
instance: PromisedSingleton<braintree.Client>;
|
|
28
|
+
/** Set the referrer for later submission */
|
|
29
|
+
setReferrer(referrer: string): void;
|
|
30
|
+
/** Set the origin for later submission */
|
|
31
|
+
setOrigin(origin: string): void;
|
|
32
|
+
/** Set the logged-in user for later submission */
|
|
33
|
+
setLoggedInUser(loggedInUser: string): void;
|
|
34
|
+
/** Perform startup tasks like device data collection */
|
|
35
|
+
startup(): void;
|
|
36
|
+
/** Submit a donation to the backend */
|
|
37
|
+
submitDonation(options: {
|
|
38
|
+
nonce: string;
|
|
39
|
+
paymentProvider: PaymentProvider;
|
|
40
|
+
donationInfo: DonationPaymentInfo;
|
|
41
|
+
billingInfo: BillingInfo;
|
|
42
|
+
customerInfo: CustomerInfo;
|
|
43
|
+
upsellOnetimeTransactionId?: string;
|
|
44
|
+
customerId?: string;
|
|
45
|
+
recaptchaToken?: string;
|
|
46
|
+
/** First 6 digits of the credit card */
|
|
47
|
+
bin?: string;
|
|
48
|
+
/** The credit card's bank name */
|
|
49
|
+
binName?: string;
|
|
50
|
+
}): Promise<DonationResponse>;
|
|
51
|
+
/** Submit the monthly upsell that follows a one-time donation */
|
|
52
|
+
submitUpsellDonation(options: {
|
|
53
|
+
oneTimeDonationResponse: SuccessResponse;
|
|
54
|
+
amount: number;
|
|
55
|
+
}): Promise<DonationResponse>;
|
|
56
|
+
/** Finish the donation after a successful completion */
|
|
57
|
+
donationSuccessful(options: {
|
|
58
|
+
successResponse: SuccessResponse;
|
|
59
|
+
upsellSuccessResponse?: SuccessResponse;
|
|
60
|
+
}): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The consumer's bridge to its backend: it submits the donation request and
|
|
64
|
+
* is told when the whole flow is finished so it can redirect to a thank-you
|
|
65
|
+
* page.
|
|
66
|
+
*/
|
|
67
|
+
export interface BraintreeEndpointManagerInterface {
|
|
68
|
+
/** Submit the request to the backend and return its modeled response. */
|
|
69
|
+
submitData(request: DonationRequest): Promise<DonationResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Called once the donor is done with the flow, after a monthly donation or
|
|
72
|
+
* after the upsell step, so the consumer can redirect them.
|
|
73
|
+
*/
|
|
74
|
+
donationSuccessful(options: {
|
|
75
|
+
successResponse: SuccessResponse;
|
|
76
|
+
upsellSuccessResponse?: SuccessResponse;
|
|
77
|
+
}): void;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=braintree-manager-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braintree-manager-interface.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/braintree-manager-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,WAAW,sBAAsB;IACrC,iCAAiC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,kCAAkC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,CAAC,CAAC,SAAS,MAAM,sBAAsB,EACvC,KAAK,EAAE,CAA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M,WAAW,iCAAiC;IAChD,yEAAyE;IACzE,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEhE;;;OAGG;IACH,kBAAkB,CAAC,OAAO,EAAE;QAC1B,eAAe,EAAE,eAAe,CAAC;QACjC,qBAAqB,CAAC,EAAE,eAAe,CAAC;KACzC,GAAG,IAAI,CAAC;CACV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braintree-manager-interface.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/braintree-manager-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type * as braintree from 'braintree-web';\nimport type { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport type { Unsubscribe } from 'nanoevents';\n\nimport type { BillingInfo, CustomerInfo } from '../models/donor-contact-info';\nimport type { DonationPaymentInfo } from '../models/donation-payment-info';\nimport type { DonationRequest } from '../models/donation-request';\nimport type {\n DonationResponse,\n SuccessResponse,\n} from '../models/donation-response';\nimport type { PaymentProvider } from '../models/payment-provider';\nimport type { PaymentProvidersInterface } from './payment-providers-interface';\n\nexport interface BraintreeManagerEvents {\n paymentProvidersHostedFieldsRetry: (retryNumber: number) => void;\n paymentProvidersHostedFieldsFailed: (error: unknown) => void;\n}\n\n/**\n * The BraintreeManager is the main entry point for the shared Braintree\n * functionality. One instance is created and handed down through all of the\n * components.\n */\nexport interface BraintreeManagerInterface {\n on<E extends keyof BraintreeManagerEvents>(\n event: E,\n callback: BraintreeManagerEvents[E],\n ): Unsubscribe;\n\n /**\n * The IA-specific handlers for each payment provider. They're data-focused\n * rather than UI-focused, though there's some overlap with the flow handlers.\n */\n paymentProviders: PaymentProvidersInterface;\n\n /** The Braintree client instance, used to create the provider clients. */\n instance: PromisedSingleton<braintree.Client>;\n\n /** Set the referrer for later submission */\n setReferrer(referrer: string): void;\n\n /** Set the origin for later submission */\n setOrigin(origin: string): void;\n\n /** Set the logged-in user for later submission */\n setLoggedInUser(loggedInUser: string): void;\n\n /** Perform startup tasks like device data collection */\n startup(): void;\n\n /** Submit a donation to the backend */\n submitDonation(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 /** First 6 digits of the credit card */\n bin?: string;\n /** The credit card's bank name */\n binName?: string;\n }): Promise<DonationResponse>;\n\n /** Submit the monthly upsell that follows a one-time donation */\n submitUpsellDonation(options: {\n oneTimeDonationResponse: SuccessResponse;\n amount: number;\n }): Promise<DonationResponse>;\n\n /** Finish the donation after a successful completion */\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void;\n}\n\n/**\n * The consumer's bridge to its backend: it submits the donation request and\n * is told when the whole flow is finished so it can redirect to a thank-you\n * page.\n */\nexport interface BraintreeEndpointManagerInterface {\n /** Submit the request to the backend and return its modeled response. */\n submitData(request: DonationRequest): Promise<DonationResponse>;\n\n /**\n * Called once the donor is done with the flow, after a monthly donation or\n * after the upsell step, so the consumer can redirect them.\n */\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void;\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type * as braintree from 'braintree-web';
|
|
2
|
+
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
3
|
+
import { type Unsubscribe } from 'nanoevents';
|
|
4
|
+
import type { BillingInfo, CustomerInfo } from '../models/donor-contact-info.js';
|
|
5
|
+
import { DonationPaymentInfo } from '../models/donation-payment-info.js';
|
|
6
|
+
import { DonationResponse, type SuccessResponse } from '../models/donation-response.js';
|
|
7
|
+
import type { PaymentProvider } from '../models/payment-provider.js';
|
|
8
|
+
import type { BraintreeEndpointManagerInterface, BraintreeManagerEvents, BraintreeManagerInterface } from './braintree-manager-interface.js';
|
|
9
|
+
import type { HostingEnvironment } from './hosting-environment.js';
|
|
10
|
+
import type { PaymentClientsInterface } from './payment-clients.js';
|
|
11
|
+
import type { PaymentProvidersInterface } from './payment-providers-interface.js';
|
|
12
|
+
import type { HostedFieldConfiguration } from './payment-providers/credit-card/hosted-field-configuration.js';
|
|
13
|
+
export declare class BraintreeManager implements BraintreeManagerInterface {
|
|
14
|
+
private referrer?;
|
|
15
|
+
/**
|
|
16
|
+
* Campaign and A/B test information about where the donor came from, sent
|
|
17
|
+
* as a custom field. See `DonationRequestCustomFields.origin` for the format.
|
|
18
|
+
*/
|
|
19
|
+
private origin?;
|
|
20
|
+
private loggedInUser?;
|
|
21
|
+
/**
|
|
22
|
+
* The device data token from Braintree's DataCollector. Several providers
|
|
23
|
+
* submit it as an anti-fraud measure.
|
|
24
|
+
*/
|
|
25
|
+
private deviceData?;
|
|
26
|
+
private emitter;
|
|
27
|
+
on<E extends keyof BraintreeManagerEvents>(event: E, callback: BraintreeManagerEvents[E]): Unsubscribe;
|
|
28
|
+
paymentProviders: PaymentProvidersInterface;
|
|
29
|
+
startup(): Promise<void>;
|
|
30
|
+
instance: PromisedSingleton<braintree.Client>;
|
|
31
|
+
submitDonation(options: {
|
|
32
|
+
nonce: string;
|
|
33
|
+
paymentProvider: PaymentProvider;
|
|
34
|
+
donationInfo: DonationPaymentInfo;
|
|
35
|
+
billingInfo: BillingInfo;
|
|
36
|
+
customerInfo: CustomerInfo;
|
|
37
|
+
upsellOnetimeTransactionId?: string;
|
|
38
|
+
customerId?: string;
|
|
39
|
+
recaptchaToken?: string;
|
|
40
|
+
bin?: string;
|
|
41
|
+
binName?: string;
|
|
42
|
+
}): Promise<DonationResponse>;
|
|
43
|
+
submitUpsellDonation(options: {
|
|
44
|
+
oneTimeDonationResponse: SuccessResponse;
|
|
45
|
+
amount: number;
|
|
46
|
+
}): Promise<DonationResponse>;
|
|
47
|
+
donationSuccessful(options: {
|
|
48
|
+
successResponse: SuccessResponse;
|
|
49
|
+
upsellSuccessResponse?: SuccessResponse;
|
|
50
|
+
}): void;
|
|
51
|
+
private deviceDataCollectionStarted;
|
|
52
|
+
/** Collect Braintree device data, which helps with fraud detection. */
|
|
53
|
+
private collectDeviceData;
|
|
54
|
+
private authorizationToken;
|
|
55
|
+
private endpointManager;
|
|
56
|
+
private paymentClients;
|
|
57
|
+
constructor(options: {
|
|
58
|
+
authorizationToken: string;
|
|
59
|
+
paymentClients: PaymentClientsInterface;
|
|
60
|
+
endpointManager: BraintreeEndpointManagerInterface;
|
|
61
|
+
hostedFieldConfig: HostedFieldConfiguration;
|
|
62
|
+
hostingEnvironment: HostingEnvironment;
|
|
63
|
+
venmoProfileId?: string;
|
|
64
|
+
googlePayMerchantId?: string;
|
|
65
|
+
referrer?: string;
|
|
66
|
+
loggedInUser?: string;
|
|
67
|
+
origin?: string;
|
|
68
|
+
});
|
|
69
|
+
setReferrer(referrer: string): void;
|
|
70
|
+
setLoggedInUser(loggedInUser: string): void;
|
|
71
|
+
setOrigin(origin: string): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=braintree-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braintree-manager.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/braintree-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK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EAAE,eAAe,CAAC;QACzC,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoB7B,kBAAkB,CAAC,OAAO,EAAE;QAC1B,eAAe,EAAE,eAAe,CAAC;QACjC,qBAAqB,CAAC,EAAE,eAAe,CAAC;KACzC,GAAG,IAAI;IAIR,OAAO,CAAC,2BAA2B,CAAS;IAE5C,uEAAuE;YACzD,iBAAiB;IAoB/B,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,eAAe,CAAoC;IAE3D,OAAO,CAAC,cAAc,CAA0B;gBAEpC,OAAO,EAAE;QACnB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,uBAAuB,CAAC;QACxC,eAAe,EAAE,iCAAiC,CAAC;QACnD,iBAAiB,EAAE,wBAAwB,CAAC;QAC5C,kBAAkB,EAAE,kBAAkB,CAAC;QACvC,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IA2BD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAI3C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGhC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
2
|
+
import { createNanoEvents } from 'nanoevents';
|
|
3
|
+
import { DonationPaymentInfo } from '../models/donation-payment-info.js';
|
|
4
|
+
import { DonationRequest, DonationRequestCustomFields, } from '../models/donation-request.js';
|
|
5
|
+
import { DonationResponse, } from '../models/donation-response.js';
|
|
6
|
+
import { DonationType } from '../models/donation-type.js';
|
|
7
|
+
import { PaymentProviders } from './payment-providers.js';
|
|
8
|
+
export class BraintreeManager {
|
|
9
|
+
on(event, callback) {
|
|
10
|
+
return this.emitter.on(event, callback);
|
|
11
|
+
}
|
|
12
|
+
async startup() {
|
|
13
|
+
return this.collectDeviceData();
|
|
14
|
+
}
|
|
15
|
+
async submitDonation(options) {
|
|
16
|
+
// `donationInfo` doesn't always arrive as a DonationPaymentInfo instance.
|
|
17
|
+
// Coming back from Venmo in Chrome it's a plain object with none of the
|
|
18
|
+
// getters, so the fee and total are calculated from the fields instead.
|
|
19
|
+
const { amount, coverFees } = options.donationInfo;
|
|
20
|
+
const total = DonationPaymentInfo.calculateTotal(amount, coverFees);
|
|
21
|
+
const feeAmountCovered = coverFees
|
|
22
|
+
? DonationPaymentInfo.calculateFeeAmount(amount)
|
|
23
|
+
: 0;
|
|
24
|
+
const customFields = new DonationRequestCustomFields({
|
|
25
|
+
fee_amount_covered: feeAmountCovered,
|
|
26
|
+
logged_in_user: this.loggedInUser,
|
|
27
|
+
referrer: this.referrer,
|
|
28
|
+
origin: this.origin,
|
|
29
|
+
});
|
|
30
|
+
const donationRequest = new DonationRequest({
|
|
31
|
+
deviceData: this.deviceData,
|
|
32
|
+
paymentProvider: options.paymentProvider,
|
|
33
|
+
paymentMethodNonce: options.nonce,
|
|
34
|
+
amount: total,
|
|
35
|
+
donationType: options.donationInfo.donationType,
|
|
36
|
+
customer: options.customerInfo,
|
|
37
|
+
billing: options.billingInfo,
|
|
38
|
+
customFields,
|
|
39
|
+
upsellOnetimeTransactionId: options.upsellOnetimeTransactionId,
|
|
40
|
+
customerId: options.customerId,
|
|
41
|
+
recaptchaToken: options.recaptchaToken,
|
|
42
|
+
bin: options.bin,
|
|
43
|
+
binName: options.binName,
|
|
44
|
+
});
|
|
45
|
+
const jsonResponse = await this.endpointManager.submitData(donationRequest);
|
|
46
|
+
return new DonationResponse(jsonResponse);
|
|
47
|
+
}
|
|
48
|
+
async submitUpsellDonation(options) {
|
|
49
|
+
const response = options.oneTimeDonationResponse;
|
|
50
|
+
const donationInfo = new DonationPaymentInfo({
|
|
51
|
+
amount: options.amount,
|
|
52
|
+
donationType: DonationType.Upsell,
|
|
53
|
+
coverFees: false,
|
|
54
|
+
});
|
|
55
|
+
return this.submitDonation({
|
|
56
|
+
nonce: response.paymentMethodNonce,
|
|
57
|
+
paymentProvider: response.paymentProvider,
|
|
58
|
+
customerId: response.customer_id,
|
|
59
|
+
donationInfo,
|
|
60
|
+
customerInfo: response.customer,
|
|
61
|
+
billingInfo: response.billing,
|
|
62
|
+
upsellOnetimeTransactionId: response.transaction_id,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
donationSuccessful(options) {
|
|
66
|
+
this.endpointManager.donationSuccessful(options);
|
|
67
|
+
}
|
|
68
|
+
/** Collect Braintree device data, which helps with fraud detection. */
|
|
69
|
+
async collectDeviceData() {
|
|
70
|
+
if (this.deviceDataCollectionStarted) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.deviceDataCollectionStarted = true;
|
|
74
|
+
const instance = await this.instance.get();
|
|
75
|
+
if (!instance) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const collector = await this.paymentClients.dataCollector.get();
|
|
79
|
+
const dataCollector = await collector.create({
|
|
80
|
+
client: instance,
|
|
81
|
+
kount: false,
|
|
82
|
+
paypal: true,
|
|
83
|
+
});
|
|
84
|
+
this.deviceData = dataCollector.deviceData;
|
|
85
|
+
}
|
|
86
|
+
constructor(options) {
|
|
87
|
+
this.emitter = createNanoEvents();
|
|
88
|
+
this.instance = new PromisedSingleton({
|
|
89
|
+
generator: async () => {
|
|
90
|
+
const client = await this.paymentClients.braintreeClient.get();
|
|
91
|
+
return client.create({ authorization: this.authorizationToken });
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
this.deviceDataCollectionStarted = false;
|
|
95
|
+
this.authorizationToken = options.authorizationToken;
|
|
96
|
+
this.endpointManager = options.endpointManager;
|
|
97
|
+
this.paymentClients = options.paymentClients;
|
|
98
|
+
this.referrer = options.referrer;
|
|
99
|
+
this.loggedInUser = options.loggedInUser;
|
|
100
|
+
this.origin = options.origin;
|
|
101
|
+
this.paymentProviders = new PaymentProviders({
|
|
102
|
+
braintreeManager: this,
|
|
103
|
+
paymentClients: this.paymentClients,
|
|
104
|
+
venmoProfileId: options.venmoProfileId,
|
|
105
|
+
googlePayMerchantId: options.googlePayMerchantId,
|
|
106
|
+
hostingEnvironment: options.hostingEnvironment,
|
|
107
|
+
hostedFieldConfig: options.hostedFieldConfig,
|
|
108
|
+
});
|
|
109
|
+
this.paymentProviders.on('hostedFieldsRetry', (retryNumber) => {
|
|
110
|
+
this.emitter.emit('paymentProvidersHostedFieldsRetry', retryNumber);
|
|
111
|
+
});
|
|
112
|
+
this.paymentProviders.on('hostedFieldsFailed', (error) => {
|
|
113
|
+
this.emitter.emit('paymentProvidersHostedFieldsFailed', error);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
setReferrer(referrer) {
|
|
117
|
+
this.referrer = referrer;
|
|
118
|
+
}
|
|
119
|
+
setLoggedInUser(loggedInUser) {
|
|
120
|
+
this.loggedInUser = loggedInUser;
|
|
121
|
+
}
|
|
122
|
+
setOrigin(origin) {
|
|
123
|
+
this.origin = origin;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=braintree-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braintree-manager.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/braintree-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAoB,MAAM,YAAY,CAAC;AAGhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACL,eAAe,EACf,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,GAEjB,MAAM,6BA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,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;YAC9C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;SAC7C,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,WAAmB,EAAE,EAAE;YACpE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAc,EAAE,EAAE;YAChE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,WAAW,CAAC,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,eAAe,CAAC,YAAoB;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type * as braintree from 'braintree-web';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\n\nimport type { BillingInfo, CustomerInfo } from '../models/donor-contact-info';\nimport { DonationPaymentInfo } from '../models/donation-payment-info';\nimport {\n DonationRequest,\n DonationRequestCustomFields,\n} from '../models/donation-request';\nimport {\n DonationResponse,\n type SuccessResponse,\n} from '../models/donation-response';\nimport { DonationType } from '../models/donation-type';\nimport type { PaymentProvider } from '../models/payment-provider';\nimport type {\n BraintreeEndpointManagerInterface,\n BraintreeManagerEvents,\n BraintreeManagerInterface,\n} from './braintree-manager-interface';\nimport type { HostingEnvironment } from './hosting-environment';\nimport type { PaymentClientsInterface } from './payment-clients';\nimport { PaymentProviders } from './payment-providers';\nimport type { PaymentProvidersInterface } from './payment-providers-interface';\nimport type { HostedFieldConfiguration } from './payment-providers/credit-card/hosted-field-configuration';\n\nexport class BraintreeManager implements BraintreeManagerInterface {\n private referrer?: string;\n\n /**\n * Campaign and A/B test information about where the donor came from, sent\n * as a custom field. See `DonationRequestCustomFields.origin` for the format.\n */\n private origin?: string;\n\n private loggedInUser?: string;\n\n /**\n * The device data token from Braintree's DataCollector. Several providers\n * submit it as an anti-fraud measure.\n */\n private deviceData?: string;\n\n private emitter = createNanoEvents<BraintreeManagerEvents>();\n\n on<E extends keyof BraintreeManagerEvents>(\n event: E,\n callback: BraintreeManagerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n paymentProviders: PaymentProvidersInterface;\n\n async startup(): Promise<void> {\n return this.collectDeviceData();\n }\n\n instance = new PromisedSingleton<braintree.Client>({\n generator: async () => {\n const client = await this.paymentClients.braintreeClient.get();\n return client.create({ authorization: this.authorizationToken });\n },\n });\n\n async submitDonation(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;\n binName?: string;\n }): Promise<DonationResponse> {\n // `donationInfo` doesn't always arrive as a DonationPaymentInfo instance.\n // Coming back from Venmo in Chrome it's a plain object with none of the\n // getters, so the fee and total are calculated from the fields instead.\n const { amount, coverFees } = options.donationInfo;\n const total = DonationPaymentInfo.calculateTotal(amount, coverFees);\n const feeAmountCovered = coverFees\n ? DonationPaymentInfo.calculateFeeAmount(amount)\n : 0;\n\n const customFields = new DonationRequestCustomFields({\n fee_amount_covered: feeAmountCovered,\n logged_in_user: this.loggedInUser,\n referrer: this.referrer,\n origin: this.origin,\n });\n\n const donationRequest = new DonationRequest({\n deviceData: this.deviceData,\n paymentProvider: options.paymentProvider,\n paymentMethodNonce: options.nonce,\n amount: total,\n donationType: options.donationInfo.donationType,\n customer: options.customerInfo,\n billing: options.billingInfo,\n customFields,\n upsellOnetimeTransactionId: options.upsellOnetimeTransactionId,\n customerId: options.customerId,\n recaptchaToken: options.recaptchaToken,\n bin: options.bin,\n binName: options.binName,\n });\n\n const jsonResponse = await this.endpointManager.submitData(donationRequest);\n return new DonationResponse(jsonResponse);\n }\n\n async submitUpsellDonation(options: {\n oneTimeDonationResponse: SuccessResponse;\n amount: number;\n }): Promise<DonationResponse> {\n const response = options.oneTimeDonationResponse;\n\n const donationInfo = new DonationPaymentInfo({\n amount: options.amount,\n donationType: DonationType.Upsell,\n coverFees: false,\n });\n\n return this.submitDonation({\n nonce: response.paymentMethodNonce,\n paymentProvider: response.paymentProvider,\n customerId: response.customer_id,\n donationInfo,\n customerInfo: response.customer,\n billingInfo: response.billing,\n upsellOnetimeTransactionId: response.transaction_id,\n });\n }\n\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse;\n }): void {\n this.endpointManager.donationSuccessful(options);\n }\n\n private deviceDataCollectionStarted = false;\n\n /** Collect Braintree device data, which helps with fraud detection. */\n private async collectDeviceData(): Promise<void> {\n if (this.deviceDataCollectionStarted) {\n return;\n }\n this.deviceDataCollectionStarted = true;\n\n const instance = await this.instance.get();\n if (!instance) {\n return;\n }\n\n const collector = await this.paymentClients.dataCollector.get();\n const dataCollector = await collector.create({\n client: instance,\n kount: false,\n paypal: true,\n });\n this.deviceData = dataCollector.deviceData;\n }\n\n private authorizationToken: string;\n\n private endpointManager: BraintreeEndpointManagerInterface;\n\n private paymentClients: PaymentClientsInterface;\n\n constructor(options: {\n authorizationToken: string;\n paymentClients: PaymentClientsInterface;\n endpointManager: BraintreeEndpointManagerInterface;\n hostedFieldConfig: HostedFieldConfiguration;\n hostingEnvironment: HostingEnvironment;\n venmoProfileId?: string;\n googlePayMerchantId?: string;\n referrer?: string;\n loggedInUser?: string;\n origin?: string;\n }) {\n this.authorizationToken = options.authorizationToken;\n this.endpointManager = options.endpointManager;\n this.paymentClients = options.paymentClients;\n\n this.referrer = options.referrer;\n this.loggedInUser = options.loggedInUser;\n this.origin = options.origin;\n\n this.paymentProviders = new PaymentProviders({\n braintreeManager: this,\n paymentClients: this.paymentClients,\n venmoProfileId: options.venmoProfileId,\n googlePayMerchantId: options.googlePayMerchantId,\n hostingEnvironment: options.hostingEnvironment,\n hostedFieldConfig: options.hostedFieldConfig,\n });\n\n this.paymentProviders.on('hostedFieldsRetry', (retryNumber: number) => {\n this.emitter.emit('paymentProvidersHostedFieldsRetry', retryNumber);\n });\n\n this.paymentProviders.on('hostedFieldsFailed', (error: unknown) => {\n this.emitter.emit('paymentProvidersHostedFieldsFailed', error);\n });\n }\n\n setReferrer(referrer: string): void {\n this.referrer = referrer;\n }\n\n setLoggedInUser(loggedInUser: string): void {\n this.loggedInUser = loggedInUser;\n }\n\n setOrigin(origin: string): void {\n this.origin = origin;\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which set of payment endpoints to talk to. `Development` uses the Braintree,
|
|
3
|
+
* PayPal and Google Pay sandboxes.
|
|
4
|
+
*/
|
|
5
|
+
export declare const HostingEnvironment: {
|
|
6
|
+
readonly Development: "dev";
|
|
7
|
+
readonly Production: "prod";
|
|
8
|
+
};
|
|
9
|
+
export type HostingEnvironment = (typeof HostingEnvironment)[keyof typeof HostingEnvironment];
|
|
10
|
+
//# sourceMappingURL=hosting-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosting-environment.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/hosting-environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosting-environment.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/hosting-environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,MAAM;CACV,CAAC","sourcesContent":["/**\n * Which set of payment endpoints to talk to. `Development` uses the Braintree,\n * PayPal and Google Pay sandboxes.\n */\nexport const HostingEnvironment = {\n Development: 'dev',\n Production: 'prod',\n} as const;\n\nexport type HostingEnvironment =\n (typeof HostingEnvironment)[keyof typeof HostingEnvironment];\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type * as braintree from 'braintree-web';
|
|
2
|
+
import type * as paypal from 'paypal-checkout-components';
|
|
3
|
+
import type { LazyLoaderServiceInterface } from '@internetarchive/lazy-loader-service';
|
|
4
|
+
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
5
|
+
import { HostingEnvironment } from './hosting-environment.js';
|
|
6
|
+
export interface PaymentClientsInterface {
|
|
7
|
+
braintreeClient: PromisedSingleton<typeof braintree.client>;
|
|
8
|
+
dataCollector: PromisedSingleton<typeof braintree.dataCollector>;
|
|
9
|
+
hostedFields: PromisedSingleton<typeof braintree.hostedFields>;
|
|
10
|
+
venmo: PromisedSingleton<typeof braintree.venmo>;
|
|
11
|
+
payPal: PromisedSingleton<typeof braintree.paypalCheckout>;
|
|
12
|
+
applePay: PromisedSingleton<typeof braintree.applePay>;
|
|
13
|
+
googlePayBraintreeClient: PromisedSingleton<typeof braintree.googlePayment>;
|
|
14
|
+
googlePaymentsClient: PromisedSingleton<google.payments.api.PaymentsClient>;
|
|
15
|
+
recaptchaLibrary: PromisedSingleton<ReCaptchaV2.ReCaptcha>;
|
|
16
|
+
paypalLibrary: PromisedSingleton<typeof paypal>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Loads and hands around the payment libraries. Each one is lazy loaded from
|
|
20
|
+
* its CDN on first request, through the LazyLoaderService, and then cached,
|
|
21
|
+
* so the rest of the form deals in typed objects instead of the untyped
|
|
22
|
+
* globals the providers attach to `window`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class PaymentClients implements PaymentClientsInterface {
|
|
25
|
+
braintreeClient: PromisedSingleton<typeof braintree.client>;
|
|
26
|
+
dataCollector: PromisedSingleton<typeof braintree.dataCollector>;
|
|
27
|
+
hostedFields: PromisedSingleton<typeof braintree.hostedFields>;
|
|
28
|
+
venmo: PromisedSingleton<typeof braintree.venmo>;
|
|
29
|
+
payPal: PromisedSingleton<typeof braintree.paypalCheckout>;
|
|
30
|
+
applePay: PromisedSingleton<typeof braintree.applePay>;
|
|
31
|
+
googlePayBraintreeClient: PromisedSingleton<typeof braintree.googlePayment>;
|
|
32
|
+
googlePaymentsClient: PromisedSingleton<google.payments.api.PaymentsClient>;
|
|
33
|
+
recaptchaLibrary: PromisedSingleton<ReCaptchaV2.ReCaptcha>;
|
|
34
|
+
paypalLibrary: PromisedSingleton<typeof paypal>;
|
|
35
|
+
constructor(lazyLoader: LazyLoaderServiceInterface, environment: HostingEnvironment);
|
|
36
|
+
private loadBraintreeScript;
|
|
37
|
+
private braintreeVersion;
|
|
38
|
+
private environment;
|
|
39
|
+
private lazyLoader;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface Window {
|
|
43
|
+
/** Set while the recaptcha script is loading, see `PaymentClients.recaptchaLibrary`. */
|
|
44
|
+
iaDonationFormGrecaptchaLoaded?: () => void;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=payment-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-clients.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/payment-clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,KA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AAO,SAAS,CAAC,KAAK,CAAC,CAK7C;IAEH,MAAM,EAAE,iBAAiB,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,CAMrD;IAEL,QAAQ,EAAE,iBAAiB,CAAC,OAAO,SAAS,CAAC,QAAQ,CAAC,CAMjD;IAEL,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,SAAS,CAAC,aAAa,CAAC,CAMtE;IAEL,oBAAoB,wDAaf;IAEL,gBAAgB,2CAiBb;IAEH,aAAa,mCAWV;gBAGD,UAAU,EAAE,0BAA0B,EACtC,WAAW,EAAE,kBAAkB;YAMnB,mBAAmB;IAOjC,OAAO,CAAC,gBAAgB,CAAY;IAEpC,OAAO,CAAC,WAAW,CAAsD;IAEzE,OAAO,CAAC,UAAU,CAA6B;CAChD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,wFAAwF;QACxF,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;KAC7C;CACF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
2
|
+
import { HostingEnvironment } from './hosting-environment.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loads and hands around the payment libraries. Each one is lazy loaded from
|
|
5
|
+
* its CDN on first request, through the LazyLoaderService, and then cached,
|
|
6
|
+
* so the rest of the form deals in typed objects instead of the untyped
|
|
7
|
+
* globals the providers attach to `window`.
|
|
8
|
+
*/
|
|
9
|
+
export class PaymentClients {
|
|
10
|
+
constructor(lazyLoader, environment) {
|
|
11
|
+
this.braintreeClient = new PromisedSingleton({
|
|
12
|
+
generator: async () => {
|
|
13
|
+
await this.loadBraintreeScript('client');
|
|
14
|
+
return window.braintree.client;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
this.dataCollector = new PromisedSingleton({
|
|
18
|
+
generator: async () => {
|
|
19
|
+
await this.loadBraintreeScript('data-collector');
|
|
20
|
+
return window.braintree.dataCollector;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
this.hostedFields = new PromisedSingleton({
|
|
24
|
+
generator: async () => {
|
|
25
|
+
await this.loadBraintreeScript('hosted-fields');
|
|
26
|
+
return window.braintree.hostedFields;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
this.venmo = new PromisedSingleton({
|
|
30
|
+
generator: async () => {
|
|
31
|
+
await this.loadBraintreeScript('venmo');
|
|
32
|
+
return window.braintree.venmo;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
this.payPal = new PromisedSingleton({
|
|
36
|
+
generator: async () => {
|
|
37
|
+
await this.loadBraintreeScript('paypal-checkout');
|
|
38
|
+
return window.braintree.paypalCheckout;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
this.applePay = new PromisedSingleton({
|
|
42
|
+
generator: async () => {
|
|
43
|
+
await this.loadBraintreeScript('apple-pay');
|
|
44
|
+
return window.braintree.applePay;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
this.googlePayBraintreeClient = new PromisedSingleton({
|
|
48
|
+
generator: async () => {
|
|
49
|
+
await this.loadBraintreeScript('google-payment');
|
|
50
|
+
return window.braintree.googlePayment;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
this.googlePaymentsClient = new PromisedSingleton({
|
|
54
|
+
generator: async () => {
|
|
55
|
+
await this.lazyLoader.loadScript({
|
|
56
|
+
src: 'https://pay.google.com/gp/p/js/pay.js',
|
|
57
|
+
});
|
|
58
|
+
return new google.payments.api.PaymentsClient({
|
|
59
|
+
environment: this.environment === HostingEnvironment.Development
|
|
60
|
+
? 'TEST'
|
|
61
|
+
: 'PRODUCTION',
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
this.recaptchaLibrary = new PromisedSingleton({
|
|
66
|
+
generator: () => new Promise((resolve) => {
|
|
67
|
+
// The recaptcha library isn't usable the moment its script has loaded,
|
|
68
|
+
// so, as Google recommends, a callback is hung on `window` before the
|
|
69
|
+
// load starts and removed once it fires.
|
|
70
|
+
window.iaDonationFormGrecaptchaLoaded = () => {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
delete window.iaDonationFormGrecaptchaLoaded;
|
|
73
|
+
}, 10);
|
|
74
|
+
resolve(window.grecaptcha);
|
|
75
|
+
};
|
|
76
|
+
this.lazyLoader.loadScript({
|
|
77
|
+
src: 'https://www.google.com/recaptcha/api.js?onload=iaDonationFormGrecaptchaLoaded&render=explicit',
|
|
78
|
+
});
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
this.paypalLibrary = new PromisedSingleton({
|
|
82
|
+
generator: async () => {
|
|
83
|
+
await this.lazyLoader.loadScript({
|
|
84
|
+
src: 'https://www.paypalobjects.com/api/checkout.js',
|
|
85
|
+
attributes: {
|
|
86
|
+
'data-version-4': '',
|
|
87
|
+
'log-level': 'warn',
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
return window.paypal;
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
this.braintreeVersion = '3.62.2';
|
|
94
|
+
this.environment = HostingEnvironment.Development;
|
|
95
|
+
this.lazyLoader = lazyLoader;
|
|
96
|
+
this.environment = environment;
|
|
97
|
+
}
|
|
98
|
+
async loadBraintreeScript(scriptName) {
|
|
99
|
+
const extension = this.environment === HostingEnvironment.Production ? 'min.js' : 'js';
|
|
100
|
+
const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptName}.${extension}`;
|
|
101
|
+
await this.lazyLoader.loadScript({ src: url });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=payment-clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-clients.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/braintree/payment-clients.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,kBAAkB,EA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AAC,CAAC;YACL,CAAC,CAAC;SACL,CAAC,CAAC;QAEH,kBAAa,GAAG,IAAI,iBAAiB,CAAgB;YACnD,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;oBAC/B,GAAG,EAAE,+CAA+C;oBACpD,UAAU,EAAE;wBACV,gBAAgB,EAAE,EAAE;wBACpB,WAAW,EAAE,MAAM;qBACpB;iBACF,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC,MAAM,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QAiBK,qBAAgB,GAAG,QAAQ,CAAC;QAE5B,gBAAW,GAAuB,kBAAkB,CAAC,WAAW,CAAC;QAbvE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,UAAkB;QAClD,MAAM,SAAS,GACb,IAAI,CAAC,WAAW,KAAK,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,MAAM,GAAG,GAAG,uCAAuC,IAAI,CAAC,gBAAgB,OAAO,UAAU,IAAI,SAAS,EAAE,CAAC;QACzG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,CAAC;CAOF","sourcesContent":["import type * as braintree from 'braintree-web';\nimport type * as paypal from 'paypal-checkout-components';\nimport type { LazyLoaderServiceInterface } from '@internetarchive/lazy-loader-service';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\n\nimport { HostingEnvironment } from './hosting-environment';\n\nexport interface PaymentClientsInterface {\n braintreeClient: PromisedSingleton<typeof braintree.client>;\n dataCollector: PromisedSingleton<typeof braintree.dataCollector>;\n hostedFields: PromisedSingleton<typeof braintree.hostedFields>;\n venmo: PromisedSingleton<typeof braintree.venmo>;\n payPal: PromisedSingleton<typeof braintree.paypalCheckout>;\n applePay: PromisedSingleton<typeof braintree.applePay>;\n googlePayBraintreeClient: PromisedSingleton<typeof braintree.googlePayment>;\n\n googlePaymentsClient: PromisedSingleton<google.payments.api.PaymentsClient>;\n recaptchaLibrary: PromisedSingleton<ReCaptchaV2.ReCaptcha>;\n paypalLibrary: PromisedSingleton<typeof paypal>;\n}\n\n/**\n * Loads and hands around the payment libraries. Each one is lazy loaded from\n * its CDN on first request, through the LazyLoaderService, and then cached,\n * so the rest of the form deals in typed objects instead of the untyped\n * globals the providers attach to `window`.\n */\nexport class PaymentClients implements PaymentClientsInterface {\n braintreeClient: PromisedSingleton<typeof braintree.client> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('client');\n return window.braintree.client;\n },\n });\n\n dataCollector: PromisedSingleton<typeof braintree.dataCollector> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('data-collector');\n return window.braintree.dataCollector;\n },\n });\n\n hostedFields: PromisedSingleton<typeof braintree.hostedFields> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('hosted-fields');\n return window.braintree.hostedFields;\n },\n });\n\n venmo: PromisedSingleton<typeof braintree.venmo> = new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('venmo');\n return window.braintree.venmo;\n },\n });\n\n payPal: PromisedSingleton<typeof braintree.paypalCheckout> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('paypal-checkout');\n return window.braintree.paypalCheckout;\n },\n });\n\n applePay: PromisedSingleton<typeof braintree.applePay> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('apple-pay');\n return window.braintree.applePay;\n },\n });\n\n googlePayBraintreeClient: PromisedSingleton<typeof braintree.googlePayment> =\n new PromisedSingleton({\n generator: async () => {\n await this.loadBraintreeScript('google-payment');\n return window.braintree.googlePayment;\n },\n });\n\n googlePaymentsClient =\n new PromisedSingleton<google.payments.api.PaymentsClient>({\n generator: async () => {\n await this.lazyLoader.loadScript({\n src: 'https://pay.google.com/gp/p/js/pay.js',\n });\n return new google.payments.api.PaymentsClient({\n environment:\n this.environment === HostingEnvironment.Development\n ? 'TEST'\n : 'PRODUCTION',\n });\n },\n });\n\n recaptchaLibrary = new PromisedSingleton<ReCaptchaV2.ReCaptcha>({\n generator: () =>\n new Promise((resolve) => {\n // The recaptcha library isn't usable the moment its script has loaded,\n // so, as Google recommends, a callback is hung on `window` before the\n // load starts and removed once it fires.\n window.iaDonationFormGrecaptchaLoaded = (): void => {\n setTimeout(() => {\n delete window.iaDonationFormGrecaptchaLoaded;\n }, 10);\n resolve(window.grecaptcha);\n };\n\n this.lazyLoader.loadScript({\n src: 'https://www.google.com/recaptcha/api.js?onload=iaDonationFormGrecaptchaLoaded&render=explicit',\n });\n }),\n });\n\n paypalLibrary = new PromisedSingleton<typeof paypal>({\n generator: async () => {\n await this.lazyLoader.loadScript({\n src: 'https://www.paypalobjects.com/api/checkout.js',\n attributes: {\n 'data-version-4': '',\n 'log-level': 'warn',\n },\n });\n return window.paypal;\n },\n });\n\n constructor(\n lazyLoader: LazyLoaderServiceInterface,\n environment: HostingEnvironment,\n ) {\n this.lazyLoader = lazyLoader;\n this.environment = environment;\n }\n\n private async loadBraintreeScript(scriptName: string): Promise<void> {\n const extension =\n this.environment === HostingEnvironment.Production ? 'min.js' : 'js';\n const url = `https://js.braintreegateway.com/web/${this.braintreeVersion}/js/${scriptName}.${extension}`;\n await this.lazyLoader.loadScript({ src: url });\n }\n\n private braintreeVersion = '3.62.2';\n\n private environment: HostingEnvironment = HostingEnvironment.Development;\n\n private lazyLoader: LazyLoaderServiceInterface;\n}\n\ndeclare global {\n interface Window {\n /** Set while the recaptcha script is loading, see `PaymentClients.recaptchaLibrary`. */\n iaDonationFormGrecaptchaLoaded?: () => void;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as braintree from 'braintree-web';
|
|
2
|
+
import type { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
3
|
+
import type { DonationPaymentInfo } from '../../../models/donation-payment-info.js';
|
|
4
|
+
import type { ApplePaySessionDataSourceInterface } from './apple-pay-session-datasource-interface.js';
|
|
5
|
+
export interface ApplePayHandlerInterface {
|
|
6
|
+
/** Undefined when this browser can't make Apple Pay payments */
|
|
7
|
+
instance: PromisedSingleton<braintree.ApplePay | undefined>;
|
|
8
|
+
isAvailable(): Promise<boolean>;
|
|
9
|
+
createPaymentRequest(e: Event, donationInfo: DonationPaymentInfo): Promise<ApplePaySessionDataSourceInterface>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=apple-pay-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-pay-interface.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,0CAA0C,CAAC;AAEnG,MAAM,WAAW,wBAAwB;IACvC,gEAAgE;IAChE,QAAQ,EAAE,iBAAiB,CAAC,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAC5D,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,oBAAoB,CAClB,CAAC,EAAE,KAAK,EACR,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-pay-interface.js","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type * as braintree from 'braintree-web';\nimport type { PromisedSingleton } from '@internetarchive/promised-singleton';\n\nimport type { DonationPaymentInfo } from '../../../models/donation-payment-info';\nimport type { ApplePaySessionDataSourceInterface } from './apple-pay-session-datasource-interface';\n\nexport interface ApplePayHandlerInterface {\n /** Undefined when this browser can't make Apple Pay payments */\n instance: PromisedSingleton<braintree.ApplePay | undefined>;\n isAvailable(): Promise<boolean>;\n createPaymentRequest(\n e: Event,\n donationInfo: DonationPaymentInfo,\n ): Promise<ApplePaySessionDataSourceInterface>;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DonationPaymentInfo } from '../../../models/donation-payment-info.js';
|
|
2
|
+
import type { DonationResponse } from '../../../models/donation-response.js';
|
|
3
|
+
/** Anything interested in how an Apple Pay session ends. */
|
|
4
|
+
export interface ApplePaySessionDataSourceDelegate {
|
|
5
|
+
paymentComplete(response: DonationResponse): void;
|
|
6
|
+
paymentFailed(error: unknown): void;
|
|
7
|
+
paymentCancelled(): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Handles the callbacks of one `ApplePaySession`: validating the merchant,
|
|
11
|
+
* submitting the authorized payment, and cancellation.
|
|
12
|
+
*/
|
|
13
|
+
export interface ApplePaySessionDataSourceInterface {
|
|
14
|
+
delegate?: ApplePaySessionDataSourceDelegate;
|
|
15
|
+
donationInfo: DonationPaymentInfo;
|
|
16
|
+
onvalidatemerchant(event: ApplePayJS.ApplePayValidateMerchantEvent): Promise<void>;
|
|
17
|
+
onpaymentauthorized(event: ApplePayJS.ApplePayPaymentAuthorizedEvent): Promise<void>;
|
|
18
|
+
oncancel(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=apple-pay-session-datasource-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-pay-session-datasource-interface.d.ts","sourceRoot":"","sources":["../../../../../../../src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,WAAW,iCAAiC;IAChD,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClD,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,gBAAgB,IAAI,IAAI,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,YAAY,EAAE,mBAAmB,CAAC;IAClC,kBAAkB,CAChB,KAAK,EAAE,UAAU,CAAC,6BAA6B,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,mBAAmB,CACjB,KAAK,EAAE,UAAU,CAAC,8BAA8B,GAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
|