@internetarchive/donation-form 1.0.2 → 1.0.3-alpha-webdev7960.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.
Files changed (210) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +115 -115
  3. package/dist/demo/braintree-endpoint-manager.js.map +1 -1
  4. package/dist/demo/demo-analytics-handler.js.map +1 -1
  5. package/dist/demo/submit-form-with.js.map +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/src/braintree-manager/braintree-interfaces.js.map +1 -1
  8. package/dist/src/braintree-manager/braintree-manager.js.map +1 -1
  9. package/dist/src/braintree-manager/payment-clients.js.map +1 -1
  10. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-interface.js.map +1 -1
  11. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-delegate.js.map +1 -1
  12. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-interface.js.map +1 -1
  13. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -1
  14. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-manager.js.map +1 -1
  15. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js.map +1 -1
  16. package/dist/src/braintree-manager/payment-providers/credit-card/credit-card-interface.js.map +1 -1
  17. package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js.map +1 -1
  18. package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-configuration.js.map +1 -1
  19. package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js.map +1 -1
  20. package/dist/src/braintree-manager/payment-providers/google-pay-interface.js.map +1 -1
  21. package/dist/src/braintree-manager/payment-providers/google-pay.js.map +1 -1
  22. package/dist/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.js.map +1 -1
  23. package/dist/src/braintree-manager/payment-providers/paypal/paypal-interface.js.map +1 -1
  24. package/dist/src/braintree-manager/payment-providers/paypal/paypal.js.map +1 -1
  25. package/dist/src/braintree-manager/payment-providers/venmo-interface.js.map +1 -1
  26. package/dist/src/braintree-manager/payment-providers/venmo.js.map +1 -1
  27. package/dist/src/braintree-manager/payment-providers-interface.js.map +1 -1
  28. package/dist/src/braintree-manager/payment-providers.js.map +1 -1
  29. package/dist/src/donation-form-controller.js +123 -123
  30. package/dist/src/donation-form-controller.js.map +1 -1
  31. package/dist/src/donation-form-error.js.map +1 -1
  32. package/dist/src/donation-form.js +107 -107
  33. package/dist/src/donation-form.js.map +1 -1
  34. package/dist/src/form-elements/badged-input.js +47 -47
  35. package/dist/src/form-elements/badged-input.js.map +1 -1
  36. package/dist/src/form-elements/contact-form/autocomplete-field-options.js.map +1 -1
  37. package/dist/src/form-elements/contact-form/contact-form.js +157 -157
  38. package/dist/src/form-elements/contact-form/contact-form.js.map +1 -1
  39. package/dist/src/form-elements/contact-form/countries.js.map +1 -1
  40. package/dist/src/form-elements/header/donation-form-header.js +14 -14
  41. package/dist/src/form-elements/header/donation-form-header.js.map +1 -1
  42. package/dist/src/form-elements/header/donation-summary.js +15 -15
  43. package/dist/src/form-elements/header/donation-summary.js.map +1 -1
  44. package/dist/src/form-elements/payment-selector.js +164 -164
  45. package/dist/src/form-elements/payment-selector.js.map +1 -1
  46. package/dist/src/form-elements/total-amount.js +16 -16
  47. package/dist/src/form-elements/total-amount.js.map +1 -1
  48. package/dist/src/modals/confirm-donation-modal-content.js +51 -51
  49. package/dist/src/modals/confirm-donation-modal-content.js.map +1 -1
  50. package/dist/src/modals/error-modal-content.js +22 -22
  51. package/dist/src/modals/error-modal-content.js.map +1 -1
  52. package/dist/src/modals/upsell-modal-content.js +182 -182
  53. package/dist/src/modals/upsell-modal-content.js.map +1 -1
  54. package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js +20 -20
  55. package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js.map +1 -1
  56. package/dist/src/payment-flow-handlers/handlers/applepay-flow-handler.js.map +1 -1
  57. package/dist/src/payment-flow-handlers/handlers/creditcard-flow-handler.js.map +1 -1
  58. package/dist/src/payment-flow-handlers/handlers/googlepay-flow-handler.js.map +1 -1
  59. package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js.map +1 -1
  60. package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js.map +1 -1
  61. package/dist/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.js.map +1 -1
  62. package/dist/src/payment-flow-handlers/payment-flow-handlers.js.map +1 -1
  63. package/dist/src/recaptcha-manager/recaptcha-manager.js.map +1 -1
  64. package/dist/src/util/promisedSleep.js.map +1 -1
  65. package/dist/test/helpers/fillInContactForm.js.map +1 -1
  66. package/dist/test/mocks/flow-handlers/individual-handlers/mock-applepay-flow-handler.js.map +1 -1
  67. package/dist/test/mocks/flow-handlers/individual-handlers/mock-creditcard-flow-handler.js.map +1 -1
  68. package/dist/test/mocks/flow-handlers/individual-handlers/mock-googlepay-flow-handler.js.map +1 -1
  69. package/dist/test/mocks/flow-handlers/individual-handlers/mock-paypal-flow-handler.js.map +1 -1
  70. package/dist/test/mocks/flow-handlers/individual-handlers/mock-venmo-flow-handler.js.map +1 -1
  71. package/dist/test/mocks/flow-handlers/mock-payment-flow-handlers.js.map +1 -1
  72. package/dist/test/mocks/mock-braintree-manager.js.map +1 -1
  73. package/dist/test/mocks/mock-donation-info.js.map +1 -1
  74. package/dist/test/mocks/mock-endpoint-manager.js.map +1 -1
  75. package/dist/test/mocks/mock-hosted-fields-config.js.map +1 -1
  76. package/dist/test/mocks/mock-hosted-fields-container.js.map +1 -1
  77. package/dist/test/mocks/mock-lazy-loader.js.map +1 -1
  78. package/dist/test/mocks/mock-modal-manager.js.map +1 -1
  79. package/dist/test/mocks/mock-payment-clients.js.map +1 -1
  80. package/dist/test/mocks/mock-paypal-button-renderer.js.map +1 -1
  81. package/dist/test/mocks/mock-recaptcha-manager.js.map +1 -1
  82. package/dist/test/mocks/models/mock-billing-info.js.map +1 -1
  83. package/dist/test/mocks/models/mock-custom-fields.js.map +1 -1
  84. package/dist/test/mocks/models/mock-customer-info.js.map +1 -1
  85. package/dist/test/mocks/models/mock-donation-request.js.map +1 -1
  86. package/dist/test/mocks/models/mock-success-response.js.map +1 -1
  87. package/dist/test/mocks/payment-clients/mock-applepay-client.js.map +1 -1
  88. package/dist/test/mocks/payment-clients/mock-applepay-payment.js.map +1 -1
  89. package/dist/test/mocks/payment-clients/mock-applepay-paymentauthorizedevent.js.map +1 -1
  90. package/dist/test/mocks/payment-clients/mock-applepay-session.js.map +1 -1
  91. package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.js.map +1 -1
  92. package/dist/test/mocks/payment-clients/mock-applepay-validatemerchantevent.js.map +1 -1
  93. package/dist/test/mocks/payment-clients/mock-braintree-client.js.map +1 -1
  94. package/dist/test/mocks/payment-clients/mock-data-collector.js.map +1 -1
  95. package/dist/test/mocks/payment-clients/mock-googlepay-client.js.map +1 -1
  96. package/dist/test/mocks/payment-clients/mock-googlepay-library.js.map +1 -1
  97. package/dist/test/mocks/payment-clients/mock-grecaptcha.js.map +1 -1
  98. package/dist/test/mocks/payment-clients/mock-hostedfields-client.js.map +1 -1
  99. package/dist/test/mocks/payment-clients/mock-hostedfieldstateobject-generator.js.map +1 -1
  100. package/dist/test/mocks/payment-clients/mock-hostedfieldtokenizepayload.js.map +1 -1
  101. package/dist/test/mocks/payment-clients/mock-paypal-client.js.map +1 -1
  102. package/dist/test/mocks/payment-clients/mock-paypal-library.js.map +1 -1
  103. package/dist/test/mocks/payment-clients/mock-venmo-client.js.map +1 -1
  104. package/dist/test/mocks/payment-providers/individual-providers/mock-applepay-datasource-delegate.js.map +1 -1
  105. package/dist/test/mocks/payment-providers/individual-providers/mock-applepay-handler.js.map +1 -1
  106. package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js.map +1 -1
  107. package/dist/test/mocks/payment-providers/individual-providers/mock-googlepay-handler.js.map +1 -1
  108. package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource-delegate.js.map +1 -1
  109. package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource.js.map +1 -1
  110. package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-handler.js.map +1 -1
  111. package/dist/test/mocks/payment-providers/individual-providers/mock-venmo-handler.js.map +1 -1
  112. package/dist/test/mocks/payment-providers/mock-payment-providers.js.map +1 -1
  113. package/dist/test/tests/braintree-manager.test.js.map +1 -1
  114. package/dist/test/tests/donation-form-controller.test.js +39 -39
  115. package/dist/test/tests/donation-form-controller.test.js.map +1 -1
  116. package/dist/test/tests/donation-form.test.js +4 -4
  117. package/dist/test/tests/donation-form.test.js.map +1 -1
  118. package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +14 -14
  119. package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js.map +1 -1
  120. package/dist/test/tests/form-elements/donation-summary.test.js.map +1 -1
  121. package/dist/test/tests/form-elements/payment-selector.test.js.map +1 -1
  122. package/dist/test/tests/modals/error-modal-content.test.js +2 -2
  123. package/dist/test/tests/modals/error-modal-content.test.js.map +1 -1
  124. package/dist/test/tests/modals/upsell-modal-content.test.js +31 -31
  125. package/dist/test/tests/modals/upsell-modal-content.test.js.map +1 -1
  126. package/dist/test/tests/models/donation-payment-info.test.js.map +1 -1
  127. package/dist/test/tests/payment-clients.test.js.map +1 -1
  128. package/dist/test/tests/payment-providers/applepay-sessiondatasource.test.js.map +1 -1
  129. package/dist/test/tests/payment-providers/applepay-sessionmanager.test.js.map +1 -1
  130. package/dist/test/tests/payment-providers/applepay.test.js.map +1 -1
  131. package/dist/test/tests/payment-providers/creditcard.test.js.map +1 -1
  132. package/dist/test/tests/payment-providers/googlepay.test.js.map +1 -1
  133. package/dist/test/tests/payment-providers/payment-providers.test.js.map +1 -1
  134. package/dist/test/tests/payment-providers/paypal-button-datasource.test.js.map +1 -1
  135. package/dist/test/tests/payment-providers/paypal.test.js.map +1 -1
  136. package/dist/test/tests/payment-providers/venmo.test.js.map +1 -1
  137. package/dist/test/tests/recaptcha-manager.test.js.map +1 -1
  138. package/package.json +107 -107
  139. package/src/@types/analytics-handler/index.d.ts +8 -8
  140. package/src/@types/braintree-web/LICENSE +21 -21
  141. package/src/@types/braintree-web/index.d.ts +93 -93
  142. package/src/@types/braintree-web/modules/american-express.d.ts +50 -50
  143. package/src/@types/braintree-web/modules/apple-pay.d.ts +213 -213
  144. package/src/@types/braintree-web/modules/client.d.ts +103 -103
  145. package/src/@types/braintree-web/modules/core.d.ts +34 -34
  146. package/src/@types/braintree-web/modules/data-collector.d.ts +13 -13
  147. package/src/@types/braintree-web/modules/google-payment.d.ts +269 -269
  148. package/src/@types/braintree-web/modules/hosted-fields.d.ts +366 -366
  149. package/src/@types/braintree-web/modules/paypal-checkout.d.ts +262 -262
  150. package/src/@types/braintree-web/modules/paypal.d.ts +177 -177
  151. package/src/@types/braintree-web/modules/three-d-secure.d.ts +141 -141
  152. package/src/@types/braintree-web/modules/unionpay.d.ts +224 -224
  153. package/src/@types/braintree-web/modules/us-bank-account.d.ts +81 -81
  154. package/src/@types/braintree-web/modules/venmo.d.ts +110 -110
  155. package/src/@types/braintree-web/package.json +64 -64
  156. package/src/@types/paypal-checkout-components/LICENSE +21 -21
  157. package/src/@types/paypal-checkout-components/index.d.ts +67 -67
  158. package/src/@types/paypal-checkout-components/modules/button.d.ts +50 -50
  159. package/src/@types/paypal-checkout-components/modules/callback-data.d.ts +244 -244
  160. package/src/@types/paypal-checkout-components/modules/configuration.d.ts +114 -114
  161. package/src/@types/paypal-checkout-components/package.json +58 -58
  162. package/src/braintree-manager/braintree-interfaces.ts +172 -172
  163. package/src/braintree-manager/braintree-manager.ts +281 -281
  164. package/src/braintree-manager/payment-clients.ts +146 -146
  165. package/src/braintree-manager/payment-providers/apple-pay/apple-pay-interface.ts +13 -13
  166. package/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-delegate.ts +8 -8
  167. package/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-interface.ts +10 -10
  168. package/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.ts +119 -119
  169. package/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-manager.ts +21 -21
  170. package/src/braintree-manager/payment-providers/apple-pay/apple-pay.ts +97 -97
  171. package/src/braintree-manager/payment-providers/credit-card/credit-card-interface.ts +21 -21
  172. package/src/braintree-manager/payment-providers/credit-card/credit-card.ts +130 -130
  173. package/src/braintree-manager/payment-providers/credit-card/hosted-field-configuration.ts +19 -19
  174. package/src/braintree-manager/payment-providers/credit-card/hosted-field-container.ts +85 -85
  175. package/src/braintree-manager/payment-providers/google-pay-interface.ts +8 -8
  176. package/src/braintree-manager/payment-providers/google-pay.ts +59 -59
  177. package/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.ts +218 -218
  178. package/src/braintree-manager/payment-providers/paypal/paypal-interface.ts +13 -13
  179. package/src/braintree-manager/payment-providers/paypal/paypal.ts +78 -78
  180. package/src/braintree-manager/payment-providers/venmo-interface.ts +8 -8
  181. package/src/braintree-manager/payment-providers/venmo.ts +67 -67
  182. package/src/braintree-manager/payment-providers-interface.ts +25 -25
  183. package/src/braintree-manager/payment-providers.ts +147 -147
  184. package/src/donation-form-controller.ts +623 -623
  185. package/src/donation-form-error.ts +6 -6
  186. package/src/donation-form.ts +576 -576
  187. package/src/form-elements/badged-input.ts +109 -109
  188. package/src/form-elements/contact-form/autocomplete-field-options.ts +63 -63
  189. package/src/form-elements/contact-form/contact-form.ts +434 -434
  190. package/src/form-elements/contact-form/countries.ts +252 -252
  191. package/src/form-elements/header/donation-form-header.ts +98 -98
  192. package/src/form-elements/header/donation-summary.ts +61 -61
  193. package/src/form-elements/payment-selector.ts +365 -365
  194. package/src/form-elements/total-amount.ts +46 -46
  195. package/src/modals/confirm-donation-modal-content.ts +168 -168
  196. package/src/modals/error-modal-content.ts +48 -48
  197. package/src/modals/upsell-modal-content.ts +284 -284
  198. package/src/payment-flow-handlers/donation-flow-modal-manager.ts +439 -439
  199. package/src/payment-flow-handlers/handlers/applepay-flow-handler.ts +109 -109
  200. package/src/payment-flow-handlers/handlers/creditcard-flow-handler.ts +232 -232
  201. package/src/payment-flow-handlers/handlers/googlepay-flow-handler.ts +111 -111
  202. package/src/payment-flow-handlers/handlers/paypal-flow-handler.ts +331 -331
  203. package/src/payment-flow-handlers/handlers/venmo-flow-handler.ts +119 -119
  204. package/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.ts +127 -127
  205. package/src/payment-flow-handlers/payment-flow-handlers.ts +218 -218
  206. package/src/recaptcha-manager/recaptcha-manager.ts +123 -123
  207. package/src/util/promisedSleep.ts +3 -3
  208. package/dist/demo/app-root.d.ts +0 -0
  209. package/dist/demo/app-root.js +0 -2
  210. package/dist/demo/app-root.js.map +0 -1
@@ -1,213 +1,213 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { callback } from './core';
3
- import { Client } from './client';
4
-
5
- // more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest
6
-
7
- // billingContact
8
- // Billing contact information for the user.
9
- // countryCode
10
- // Required.The merchant’s two- letter ISO 3166 country code.
11
- // currencyCode
12
- // Required.The three- letter ISO 4217 currency code for the payment.
13
- // lineItems
14
- // A set of line items that explain recurring payments and additional charges.
15
- // merchantCapabilities
16
- // Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
17
- // requiredBillingContactFields
18
- // The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
19
- // requiredShippingContactFields
20
- // The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
21
- // shippingContact
22
- // Shipping contact information for the user.
23
- // shippingMethods
24
- // A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
25
- // shippingType
26
- // How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
27
- // supportedNetworks
28
- // Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
29
- // total
30
- // Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
31
- export interface ApplePayPaymentRequest {
32
- total: {
33
- label: string;
34
- amount: string;
35
- };
36
- countryCode: string;
37
- currencyCode: string;
38
- supportedNetworks: string[];
39
- merchantCapabilities: string[];
40
-
41
- billingContact?: any;
42
- shippingContact?: any;
43
- shippingMethods?: any;
44
- shippingType?: any;
45
- requiredBillingContactFields?: any;
46
- requiredShippingContactFields?: any;
47
- }
48
-
49
- export enum ApplePayStatusCodes {
50
- // The requested action succeeded.
51
- STATUS_SUCCESS = 1,
52
- // The requested action failed.
53
- STATUS_FAILURE,
54
- // The billing address is not valid.
55
- STATUS_INVALID_BILLING_POSTAL_ADDRESS,
56
- // The shipping address is not valid.
57
- STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
58
- // The shipping contact information is not valid.
59
- STATUS_INVALID_SHIPPING_CONTACT,
60
- // The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
61
- STATUS_PIN_REQUIRED,
62
- // The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
63
- STATUS_PIN_INCORRECT,
64
- // The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
65
- STATUS_PIN_LOCKOUT,
66
- }
67
-
68
- export interface ApplePayPayload {
69
- merchantIdentifier: string;
70
- domainName: string;
71
- displayName: string;
72
- }
73
-
74
- export class ApplePaySession {
75
- constructor(version: number, request: ApplePayPaymentRequest);
76
-
77
- canMakePayments(): boolean;
78
-
79
- canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;
80
-
81
- completeMerchantValidation(merchantSession: any): void;
82
-
83
- abort(): void;
84
-
85
- begin(): void;
86
-
87
- completePayment(status: ApplePayStatusCodes): void;
88
-
89
- completePaymentMethodSelection(newTotal: any, newLineItems: any): void;
90
-
91
- completeShippingContactSelection(
92
- status: ApplePayStatusCodes,
93
- newShippingMethods: any,
94
- newTotal: any,
95
- newLineItems: any,
96
- ): void;
97
-
98
- completeShippingMethodSelection(
99
- status: ApplePayStatusCodes,
100
- newTotal: any,
101
- newLineItems: any,
102
- ): void;
103
-
104
- supportsVersion(version: number): boolean;
105
-
106
- oncancel: (event: any) => void;
107
-
108
- onpaymentauthorized: (event: any) => void;
109
-
110
- onpaymentmethodselected: (event: any) => void;
111
-
112
- onshippingcontactselected: (event: any) => void;
113
-
114
- onshippingmethodselected: (event: any) => void;
115
-
116
- onvalidatemerchant: (event: any) => void;
117
- }
118
-
119
- /**
120
- * @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.*
121
- */
122
- export interface ApplePay {
123
- create(options: { client: Client }): Promise<any>;
124
- create(options: { client: Client }, callback?: callback): void;
125
-
126
- /**
127
- * @description The current version of the SDK, i.e. `3.0.2`.
128
- */
129
- VERSION: string;
130
-
131
- /**
132
- * Merges a payment request with Braintree defaults
133
- * The following properties are assigned to `paymentRequest` if not already defined
134
- * - countryCode
135
- * - currencyCode
136
- * - merchantCapabilities
137
- * - supportedNetworks * @example
138
- * var applePay = require('braintree-web/apple-pay');
139
- *
140
- * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
141
- * // ...
142
- * var paymentRequest = applePay.createPaymentRequest({
143
- * total: {
144
- * label: 'My Company',
145
- * amount: '19.99'
146
- * });
147
- *
148
- * console.log(paymentRequest);
149
- * // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
150
- *
151
- */
152
- createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest;
153
-
154
- /**
155
- * Validates the merchant website, as required by ApplePaySession before payment can be authorized. * - The canonical name for your store.
156
- * - The system may display this name to the user.
157
- * - Use a 128-character or less, UTF-8 string.
158
- * - Do not localize the name. * Your Apple merchant identifier. This is the Apple Merchant ID created on the Apple Developer Portal.
159
- * Defaults to the merchant identifier specified in the Braintree Control Panel.
160
- * You can use this field to override the merchant identifier for this transaction. * Pass the merchant session to your Apple Pay session's completeMerchantValidation method.
161
- * @example
162
- * var applePay = require('braintree-web/apple-pay');
163
- *
164
- * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
165
- * var session = new ApplePaySession(1, {
166
- * // This should be the payment request object that
167
- * // contains the information needed to display the payment sheet.
168
- * });
169
- *
170
- * session.onvalidatemerchant = function (event) {
171
- * applePay.performValidation({
172
- * validationURL: event.validationURL
173
- * }, function(err, validationData) {
174
- * if (err) {
175
- * console.error(err);
176
- * session.abort();
177
- * return;
178
- * }
179
- * session.completeMerchantValidation(validationData);
180
- * });
181
- * };
182
- * });
183
- */
184
- performValidation(
185
- options: { validationURL: string; displayName?: string; merchantIdentifier?: string },
186
- callback: callback,
187
- ): void;
188
-
189
- /**
190
- * Tokenizes an Apple Pay payment. * @example
191
- * var applePay = require('braintree-web/apple-pay');
192
- *
193
- * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
194
- * var session = new ApplePaySession(1, { });
195
- *
196
- * session.onpaymentauthorized = function (event) {
197
- * applePay.tokenize({
198
- * token: event.payment.token
199
- * }, function (err, tokenizedPayload) {
200
- * if (err) {
201
- * session.completePayment(ApplePaySession.STATUS_FAILURE);
202
- * return;
203
- * }
204
- * session.completePayment(ApplePaySession.STATUS_SUCCESS);
205
- *
206
- * // Send the tokenizedPayload to your server.
207
- * });
208
- * };
209
- * });
210
- */
211
- tokenize(options: { token: any }, callback: callback): void;
212
- tokenize(options: { token: any }): Promise<any>;
213
- }
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { callback } from './core';
3
+ import { Client } from './client';
4
+
5
+ // more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest
6
+
7
+ // billingContact
8
+ // Billing contact information for the user.
9
+ // countryCode
10
+ // Required.The merchant’s two- letter ISO 3166 country code.
11
+ // currencyCode
12
+ // Required.The three- letter ISO 4217 currency code for the payment.
13
+ // lineItems
14
+ // A set of line items that explain recurring payments and additional charges.
15
+ // merchantCapabilities
16
+ // Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
17
+ // requiredBillingContactFields
18
+ // The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
19
+ // requiredShippingContactFields
20
+ // The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
21
+ // shippingContact
22
+ // Shipping contact information for the user.
23
+ // shippingMethods
24
+ // A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
25
+ // shippingType
26
+ // How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
27
+ // supportedNetworks
28
+ // Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
29
+ // total
30
+ // Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
31
+ export interface ApplePayPaymentRequest {
32
+ total: {
33
+ label: string;
34
+ amount: string;
35
+ };
36
+ countryCode: string;
37
+ currencyCode: string;
38
+ supportedNetworks: string[];
39
+ merchantCapabilities: string[];
40
+
41
+ billingContact?: any;
42
+ shippingContact?: any;
43
+ shippingMethods?: any;
44
+ shippingType?: any;
45
+ requiredBillingContactFields?: any;
46
+ requiredShippingContactFields?: any;
47
+ }
48
+
49
+ export enum ApplePayStatusCodes {
50
+ // The requested action succeeded.
51
+ STATUS_SUCCESS = 1,
52
+ // The requested action failed.
53
+ STATUS_FAILURE,
54
+ // The billing address is not valid.
55
+ STATUS_INVALID_BILLING_POSTAL_ADDRESS,
56
+ // The shipping address is not valid.
57
+ STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
58
+ // The shipping contact information is not valid.
59
+ STATUS_INVALID_SHIPPING_CONTACT,
60
+ // The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
61
+ STATUS_PIN_REQUIRED,
62
+ // The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
63
+ STATUS_PIN_INCORRECT,
64
+ // The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
65
+ STATUS_PIN_LOCKOUT,
66
+ }
67
+
68
+ export interface ApplePayPayload {
69
+ merchantIdentifier: string;
70
+ domainName: string;
71
+ displayName: string;
72
+ }
73
+
74
+ export class ApplePaySession {
75
+ constructor(version: number, request: ApplePayPaymentRequest);
76
+
77
+ canMakePayments(): boolean;
78
+
79
+ canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;
80
+
81
+ completeMerchantValidation(merchantSession: any): void;
82
+
83
+ abort(): void;
84
+
85
+ begin(): void;
86
+
87
+ completePayment(status: ApplePayStatusCodes): void;
88
+
89
+ completePaymentMethodSelection(newTotal: any, newLineItems: any): void;
90
+
91
+ completeShippingContactSelection(
92
+ status: ApplePayStatusCodes,
93
+ newShippingMethods: any,
94
+ newTotal: any,
95
+ newLineItems: any,
96
+ ): void;
97
+
98
+ completeShippingMethodSelection(
99
+ status: ApplePayStatusCodes,
100
+ newTotal: any,
101
+ newLineItems: any,
102
+ ): void;
103
+
104
+ supportsVersion(version: number): boolean;
105
+
106
+ oncancel: (event: any) => void;
107
+
108
+ onpaymentauthorized: (event: any) => void;
109
+
110
+ onpaymentmethodselected: (event: any) => void;
111
+
112
+ onshippingcontactselected: (event: any) => void;
113
+
114
+ onshippingmethodselected: (event: any) => void;
115
+
116
+ onvalidatemerchant: (event: any) => void;
117
+ }
118
+
119
+ /**
120
+ * @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.*
121
+ */
122
+ export interface ApplePay {
123
+ create(options: { client: Client }): Promise<any>;
124
+ create(options: { client: Client }, callback?: callback): void;
125
+
126
+ /**
127
+ * @description The current version of the SDK, i.e. `3.0.2`.
128
+ */
129
+ VERSION: string;
130
+
131
+ /**
132
+ * Merges a payment request with Braintree defaults
133
+ * The following properties are assigned to `paymentRequest` if not already defined
134
+ * - countryCode
135
+ * - currencyCode
136
+ * - merchantCapabilities
137
+ * - supportedNetworks * @example
138
+ * var applePay = require('braintree-web/apple-pay');
139
+ *
140
+ * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
141
+ * // ...
142
+ * var paymentRequest = applePay.createPaymentRequest({
143
+ * total: {
144
+ * label: 'My Company',
145
+ * amount: '19.99'
146
+ * });
147
+ *
148
+ * console.log(paymentRequest);
149
+ * // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
150
+ *
151
+ */
152
+ createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest;
153
+
154
+ /**
155
+ * Validates the merchant website, as required by ApplePaySession before payment can be authorized. * - The canonical name for your store.
156
+ * - The system may display this name to the user.
157
+ * - Use a 128-character or less, UTF-8 string.
158
+ * - Do not localize the name. * Your Apple merchant identifier. This is the Apple Merchant ID created on the Apple Developer Portal.
159
+ * Defaults to the merchant identifier specified in the Braintree Control Panel.
160
+ * You can use this field to override the merchant identifier for this transaction. * Pass the merchant session to your Apple Pay session's completeMerchantValidation method.
161
+ * @example
162
+ * var applePay = require('braintree-web/apple-pay');
163
+ *
164
+ * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
165
+ * var session = new ApplePaySession(1, {
166
+ * // This should be the payment request object that
167
+ * // contains the information needed to display the payment sheet.
168
+ * });
169
+ *
170
+ * session.onvalidatemerchant = function (event) {
171
+ * applePay.performValidation({
172
+ * validationURL: event.validationURL
173
+ * }, function(err, validationData) {
174
+ * if (err) {
175
+ * console.error(err);
176
+ * session.abort();
177
+ * return;
178
+ * }
179
+ * session.completeMerchantValidation(validationData);
180
+ * });
181
+ * };
182
+ * });
183
+ */
184
+ performValidation(
185
+ options: { validationURL: string; displayName?: string; merchantIdentifier?: string },
186
+ callback: callback,
187
+ ): void;
188
+
189
+ /**
190
+ * Tokenizes an Apple Pay payment. * @example
191
+ * var applePay = require('braintree-web/apple-pay');
192
+ *
193
+ * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
194
+ * var session = new ApplePaySession(1, { });
195
+ *
196
+ * session.onpaymentauthorized = function (event) {
197
+ * applePay.tokenize({
198
+ * token: event.payment.token
199
+ * }, function (err, tokenizedPayload) {
200
+ * if (err) {
201
+ * session.completePayment(ApplePaySession.STATUS_FAILURE);
202
+ * return;
203
+ * }
204
+ * session.completePayment(ApplePaySession.STATUS_SUCCESS);
205
+ *
206
+ * // Send the tokenizedPayload to your server.
207
+ * });
208
+ * };
209
+ * });
210
+ */
211
+ tokenize(options: { token: any }, callback: callback): void;
212
+ tokenize(options: { token: any }): Promise<any>;
213
+ }
@@ -1,103 +1,103 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { callback } from './core';
3
-
4
- /**
5
- * This object is returned by {@link Client#getConfiguration|getConfiguration}. This information is used extensively by other Braintree modules to properly configure themselves.
6
- */
7
- export interface ClientAnalyticsMetadata {
8
- sessionId: string;
9
- sdkVersion: string;
10
- merchantAppId: string;
11
- }
12
-
13
- export interface Configuration {
14
- client: Client;
15
- gatewayConfiguration: any;
16
- analyticsMetadata: ClientAnalyticsMetadata;
17
- }
18
-
19
- export interface CreditCardInfo {
20
- number: string;
21
- cvv: string;
22
- expirationDate: string;
23
- billingAddress: {
24
- postalCode?: string;
25
- };
26
- }
27
-
28
- export interface Client {
29
- authorization: string;
30
-
31
- /**
32
- * @description This function is the entry point for the <code>braintree.client</code> module.
33
- * It is used for creating {@link Client} instances that service communication to Braintree servers.
34
- *
35
- * @example
36
- * var createClient = require('braintree-web/client').create;
37
- *
38
- * createClient({
39
- * authorization: CLIENT_AUTHORIZATION
40
- * }, function (createErr, clientInstance) {
41
- * ...
42
- * });
43
- */
44
- create(options: { authorization: string }): Promise<Client>;
45
- create(options: { authorization: string }, callback: callback): void;
46
-
47
- /**
48
- * @description The current version of the SDK, i.e. `3.0.2`.
49
- */
50
- VERSION: string;
51
-
52
- /**
53
- * Returns a copy of the configuration values.
54
- */
55
- getConfiguration(): Configuration;
56
-
57
- /**
58
- * Used by other modules to formulate all network requests to the Braintree gateway.
59
- * It is also capable of being used directly from your own form to tokenize credit card information.
60
- * However, be sure to satisfy PCI compliance if you use direct card tokenization.
61
- * * @example
62
- *
63
- * <caption>Direct Credit Card Tokenization</caption>
64
- * var createClient = require('braintree-web/client').create;
65
- *
66
- * createClient({
67
- * authorization: CLIENT_AUTHORIZATION
68
- * }, function (createErr, clientInstance) {
69
- * var form = document.getElementById('my-form-id');
70
- * var data = {
71
- * creditCard: {
72
- * number: form['cc-number'].value,
73
- * cvv: form['cc-cvv'].value,
74
- * expirationDate: form['cc-date'].value,
75
- * billingAddress: {
76
- * postalCode: form['cc-postal'].value
77
- * },
78
- * options: {
79
- * validate: false
80
- * }
81
- * }
82
- * };
83
- *
84
- * // Warning: For a merchant to be eligible for the easiest level of PCI compliance (SAQ A),
85
- * // payment fields cannot be hosted on your checkout page.
86
- * // For an alternative to the following, use Hosted Fields.
87
- * clientInstance.request({
88
- * endpoint: 'payment_methods/credit_cards',
89
- * method: 'post',
90
- * data: data
91
- * }, function (requestErr, response) {
92
- * // More detailed example of handling API errors: https://codepen.io/braintree/pen/MbwjdM
93
- * if (requestErr) { throw new Error(requestErr); }
94
- *
95
- * console.log('Got nonce:', response.creditCards[0].nonce);
96
- * });
97
- * });
98
- */
99
- request(
100
- options: { method: string; endpoint: string; data: any; timeout?: number },
101
- callback: callback,
102
- ): void;
103
- }
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { callback } from './core';
3
+
4
+ /**
5
+ * This object is returned by {@link Client#getConfiguration|getConfiguration}. This information is used extensively by other Braintree modules to properly configure themselves.
6
+ */
7
+ export interface ClientAnalyticsMetadata {
8
+ sessionId: string;
9
+ sdkVersion: string;
10
+ merchantAppId: string;
11
+ }
12
+
13
+ export interface Configuration {
14
+ client: Client;
15
+ gatewayConfiguration: any;
16
+ analyticsMetadata: ClientAnalyticsMetadata;
17
+ }
18
+
19
+ export interface CreditCardInfo {
20
+ number: string;
21
+ cvv: string;
22
+ expirationDate: string;
23
+ billingAddress: {
24
+ postalCode?: string;
25
+ };
26
+ }
27
+
28
+ export interface Client {
29
+ authorization: string;
30
+
31
+ /**
32
+ * @description This function is the entry point for the <code>braintree.client</code> module.
33
+ * It is used for creating {@link Client} instances that service communication to Braintree servers.
34
+ *
35
+ * @example
36
+ * var createClient = require('braintree-web/client').create;
37
+ *
38
+ * createClient({
39
+ * authorization: CLIENT_AUTHORIZATION
40
+ * }, function (createErr, clientInstance) {
41
+ * ...
42
+ * });
43
+ */
44
+ create(options: { authorization: string }): Promise<Client>;
45
+ create(options: { authorization: string }, callback: callback): void;
46
+
47
+ /**
48
+ * @description The current version of the SDK, i.e. `3.0.2`.
49
+ */
50
+ VERSION: string;
51
+
52
+ /**
53
+ * Returns a copy of the configuration values.
54
+ */
55
+ getConfiguration(): Configuration;
56
+
57
+ /**
58
+ * Used by other modules to formulate all network requests to the Braintree gateway.
59
+ * It is also capable of being used directly from your own form to tokenize credit card information.
60
+ * However, be sure to satisfy PCI compliance if you use direct card tokenization.
61
+ * * @example
62
+ *
63
+ * <caption>Direct Credit Card Tokenization</caption>
64
+ * var createClient = require('braintree-web/client').create;
65
+ *
66
+ * createClient({
67
+ * authorization: CLIENT_AUTHORIZATION
68
+ * }, function (createErr, clientInstance) {
69
+ * var form = document.getElementById('my-form-id');
70
+ * var data = {
71
+ * creditCard: {
72
+ * number: form['cc-number'].value,
73
+ * cvv: form['cc-cvv'].value,
74
+ * expirationDate: form['cc-date'].value,
75
+ * billingAddress: {
76
+ * postalCode: form['cc-postal'].value
77
+ * },
78
+ * options: {
79
+ * validate: false
80
+ * }
81
+ * }
82
+ * };
83
+ *
84
+ * // Warning: For a merchant to be eligible for the easiest level of PCI compliance (SAQ A),
85
+ * // payment fields cannot be hosted on your checkout page.
86
+ * // For an alternative to the following, use Hosted Fields.
87
+ * clientInstance.request({
88
+ * endpoint: 'payment_methods/credit_cards',
89
+ * method: 'post',
90
+ * data: data
91
+ * }, function (requestErr, response) {
92
+ * // More detailed example of handling API errors: https://codepen.io/braintree/pen/MbwjdM
93
+ * if (requestErr) { throw new Error(requestErr); }
94
+ *
95
+ * console.log('Got nonce:', response.creditCards[0].nonce);
96
+ * });
97
+ * });
98
+ */
99
+ request(
100
+ options: { method: string; endpoint: string; data: any; timeout?: number },
101
+ callback: callback,
102
+ ): void;
103
+ }