@paypal/checkout-components 5.0.256 → 5.0.258

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 (185) hide show
  1. package/README.md +8 -0
  2. package/__sdk__.js +72 -76
  3. package/dist/button.js +1 -1
  4. package/globals.js +28 -30
  5. package/package.json +6 -4
  6. package/src/constants/button.js +37 -36
  7. package/src/constants/class.js +32 -30
  8. package/src/constants/index.js +3 -3
  9. package/src/constants/misc.js +14 -12
  10. package/src/declarations.js +19 -19
  11. package/src/funding/applepay/config.jsx +51 -50
  12. package/src/funding/applepay/index.js +1 -1
  13. package/src/funding/applepay/style.scoped.scss +1 -1
  14. package/src/funding/applepay/template.jsx +16 -11
  15. package/src/funding/bancontact/config.jsx +48 -37
  16. package/src/funding/bancontact/index.js +1 -2
  17. package/src/funding/blik/config.jsx +48 -37
  18. package/src/funding/blik/index.js +1 -2
  19. package/src/funding/boleto/config.jsx +50 -39
  20. package/src/funding/boleto/index.js +1 -2
  21. package/src/funding/card/amex/config.js +9 -8
  22. package/src/funding/card/amex/index.js +1 -2
  23. package/src/funding/card/config.jsx +246 -177
  24. package/src/funding/card/discover/config.js +9 -7
  25. package/src/funding/card/discover/index.js +1 -2
  26. package/src/funding/card/elo/config.js +6 -7
  27. package/src/funding/card/elo/index.js +1 -2
  28. package/src/funding/card/hiper/config.js +9 -7
  29. package/src/funding/card/hiper/index.js +1 -2
  30. package/src/funding/card/index.js +1 -1
  31. package/src/funding/card/jcb/config.js +6 -7
  32. package/src/funding/card/jcb/index.js +1 -2
  33. package/src/funding/card/mastercard/config.js +9 -7
  34. package/src/funding/card/mastercard/index.js +1 -2
  35. package/src/funding/card/visa/config.js +9 -7
  36. package/src/funding/card/visa/index.js +1 -2
  37. package/src/funding/common.jsx +242 -216
  38. package/src/funding/config.js +212 -65
  39. package/src/funding/content.jsx +1946 -337
  40. package/src/funding/credit/config.jsx +74 -57
  41. package/src/funding/credit/index.js +1 -2
  42. package/src/funding/eps/config.jsx +45 -37
  43. package/src/funding/eps/index.js +1 -2
  44. package/src/funding/funding.js +193 -100
  45. package/src/funding/giropay/config.jsx +48 -38
  46. package/src/funding/giropay/index.js +1 -2
  47. package/src/funding/ideal/config.jsx +48 -37
  48. package/src/funding/ideal/index.js +1 -2
  49. package/src/funding/index.js +2 -2
  50. package/src/funding/itau/config.jsx +41 -41
  51. package/src/funding/itau/index.js +1 -1
  52. package/src/funding/maxima/config.jsx +25 -19
  53. package/src/funding/maxima/index.js +1 -2
  54. package/src/funding/mercadopago/config.jsx +48 -37
  55. package/src/funding/mercadopago/index.js +1 -2
  56. package/src/funding/multibanco/config.jsx +50 -39
  57. package/src/funding/multibanco/index.js +1 -2
  58. package/src/funding/mybank/config.jsx +48 -37
  59. package/src/funding/mybank/index.js +1 -2
  60. package/src/funding/oxxo/config.jsx +50 -39
  61. package/src/funding/oxxo/index.js +1 -2
  62. package/src/funding/p24/config.jsx +45 -37
  63. package/src/funding/p24/index.js +1 -2
  64. package/src/funding/paidy/config.jsx +50 -39
  65. package/src/funding/paidy/index.js +1 -1
  66. package/src/funding/paylater/config.jsx +118 -111
  67. package/src/funding/paylater/index.js +1 -2
  68. package/src/funding/paypal/config.jsx +44 -46
  69. package/src/funding/paypal/index.js +1 -2
  70. package/src/funding/paypal/style.scoped.scss +80 -74
  71. package/src/funding/paypal/template.jsx +450 -354
  72. package/src/funding/payu/config.jsx +50 -39
  73. package/src/funding/payu/index.js +1 -1
  74. package/src/funding/satispay/config.jsx +50 -39
  75. package/src/funding/satispay/index.js +1 -1
  76. package/src/funding/sepa/config.jsx +19 -13
  77. package/src/funding/sepa/index.js +1 -2
  78. package/src/funding/sofort/config.jsx +48 -37
  79. package/src/funding/sofort/index.js +1 -2
  80. package/src/funding/trustly/config.jsx +50 -39
  81. package/src/funding/trustly/index.js +1 -2
  82. package/src/funding/venmo/config.jsx +80 -75
  83. package/src/funding/venmo/index.js +1 -2
  84. package/src/funding/venmo/style.scoped.scss +30 -32
  85. package/src/funding/venmo/template.jsx +56 -57
  86. package/src/funding/verkkopankki/config.jsx +50 -39
  87. package/src/funding/verkkopankki/index.js +1 -1
  88. package/src/funding/wechatpay/config.jsx +48 -37
  89. package/src/funding/wechatpay/index.js +1 -2
  90. package/src/funding/zimpler/config.jsx +19 -13
  91. package/src/funding/zimpler/index.js +1 -2
  92. package/src/interface/button.js +60 -44
  93. package/src/interface/card-fields.js +11 -8
  94. package/src/interface/fields.js +7 -4
  95. package/src/interface/marks.js +4 -4
  96. package/src/interface/payment-fields.js +7 -4
  97. package/src/interface/wallet.js +4 -4
  98. package/src/lib/errors.js +7 -7
  99. package/src/lib/index.js +5 -5
  100. package/src/lib/isRTLLanguage.js +3 -3
  101. package/src/lib/perceived-latency-instrumentation.js +54 -36
  102. package/src/lib/security.js +21 -17
  103. package/src/lib/session.js +39 -35
  104. package/src/marks/component.jsx +114 -65
  105. package/src/marks/index.js +1 -2
  106. package/src/marks/template.jsx +79 -65
  107. package/src/types.js +48 -48
  108. package/src/ui/buttons/button.jsx +311 -249
  109. package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
  110. package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
  111. package/src/ui/buttons/buttonDesigns/index.js +78 -75
  112. package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
  113. package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
  114. package/src/ui/buttons/buttonDesigns/types.js +6 -7
  115. package/src/ui/buttons/buttons.jsx +318 -212
  116. package/src/ui/buttons/config.js +62 -59
  117. package/src/ui/buttons/content.jsx +304 -119
  118. package/src/ui/buttons/index.js +1 -1
  119. package/src/ui/buttons/menu-button/index.js +1 -1
  120. package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
  121. package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
  122. package/src/ui/buttons/poweredBy.jsx +23 -23
  123. package/src/ui/buttons/props.js +680 -529
  124. package/src/ui/buttons/script.jsx +182 -160
  125. package/src/ui/buttons/spinner.jsx +4 -6
  126. package/src/ui/buttons/style.jsx +15 -14
  127. package/src/ui/buttons/styles/base.js +24 -16
  128. package/src/ui/buttons/styles/button.js +24 -22
  129. package/src/ui/buttons/styles/color.js +118 -118
  130. package/src/ui/buttons/styles/custom.js +30 -24
  131. package/src/ui/buttons/styles/index.js +1 -1
  132. package/src/ui/buttons/styles/labels.js +17 -13
  133. package/src/ui/buttons/styles/page.js +3 -3
  134. package/src/ui/buttons/styles/responsive.js +226 -118
  135. package/src/ui/buttons/tagline.jsx +53 -54
  136. package/src/ui/chevron.jsx +27 -16
  137. package/src/ui/index.js +3 -3
  138. package/src/ui/loading.jsx +25 -18
  139. package/src/ui/text/index.js +1 -1
  140. package/src/ui/text/style.scoped.scss +25 -26
  141. package/src/ui/text/text.jsx +42 -20
  142. package/src/ui/tracking.jsx +18 -11
  143. package/src/zoid/buttons/component.jsx +836 -684
  144. package/src/zoid/buttons/container.jsx +140 -107
  145. package/src/zoid/buttons/index.js +1 -1
  146. package/src/zoid/buttons/prerender.jsx +84 -64
  147. package/src/zoid/buttons/util.js +355 -254
  148. package/src/zoid/card-fields/component.jsx +581 -549
  149. package/src/zoid/card-fields/index.js +1 -1
  150. package/src/zoid/card-fields/prerender.jsx +20 -17
  151. package/src/zoid/card-form/component.js +155 -141
  152. package/src/zoid/card-form/index.js +1 -1
  153. package/src/zoid/checkout/component.jsx +314 -282
  154. package/src/zoid/checkout/config.js +2 -2
  155. package/src/zoid/checkout/content.js +190 -154
  156. package/src/zoid/checkout/hacks.js +31 -28
  157. package/src/zoid/checkout/index.js +2 -2
  158. package/src/zoid/checkout/props.js +27 -33
  159. package/src/zoid/installments/component.jsx +83 -70
  160. package/src/zoid/installments/index.js +1 -1
  161. package/src/zoid/installments/props.js +1 -1
  162. package/src/zoid/menu/component.jsx +53 -48
  163. package/src/zoid/menu/index.js +1 -1
  164. package/src/zoid/menu/props.js +1 -3
  165. package/src/zoid/modal/component.jsx +119 -106
  166. package/src/zoid/modal/index.js +1 -1
  167. package/src/zoid/modal/props.js +1 -3
  168. package/src/zoid/payment-fields/component.jsx +215 -191
  169. package/src/zoid/payment-fields/container.jsx +73 -64
  170. package/src/zoid/payment-fields/index.js +1 -1
  171. package/src/zoid/payment-fields/prerender.jsx +16 -14
  172. package/src/zoid/payment-fields/props.js +6 -6
  173. package/src/zoid/qr-code/component.jsx +131 -115
  174. package/src/zoid/qr-code/container.jsx +74 -68
  175. package/src/zoid/qr-code/index.js +1 -1
  176. package/src/zoid/qr-code/prerender.jsx +17 -12
  177. package/src/zoid/qr-code/types.js +2 -2
  178. package/src/zoid/wallet/component.jsx +298 -260
  179. package/src/zoid/wallet/container.jsx +73 -64
  180. package/src/zoid/wallet/index.js +1 -1
  181. package/src/zoid/wallet/prerender.jsx +14 -14
  182. package/src/zoid/wallet/props.js +4 -4
  183. package/src/actions/save/index.js +0 -40
  184. package/src/interface/actions.js +0 -14
  185. package/src/lib/getLogoCDNExperiment.js +0 -25
@@ -1,614 +1,718 @@
1
1
  /* eslint-disable eslint-comments/disable-enable-pair */
2
2
  /* @flow */
3
3
 
4
- import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
5
- import { values, uniqueID } from '@krakenjs/belter/src';
6
- import { type OrderCreateRequest, type FundingEligibilityType,
7
- type OrderGetResponse, type OrderCaptureResponse, type OrderAuthorizeResponse } from '@paypal/sdk-client/src';
8
- import { CURRENCY, FUNDING, PLATFORM, INTENT, COMMIT, VAULT,
9
- ENV, COUNTRY, LANG, COUNTRY_LANGS, type LocaleType, CARD, COMPONENTS } from '@paypal/sdk-constants/src';
10
- import { type CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
11
- import { LOGO_COLOR } from '@paypal/sdk-logos/src';
12
- import { SUPPORTED_FUNDING_SOURCES } from '@paypal/funding-components/src';
13
- import type { ComponentFunctionType } from '@krakenjs/jsx-pragmatic/src';
14
-
15
- import type { ContentType, CustomStyle, Wallet, Experiment } from '../../types';
16
- import { BUTTON_LABEL, BUTTON_COLOR, BUTTON_LAYOUT, BUTTON_SHAPE, BUTTON_SIZE, BUTTON_FLOW, MENU_PLACEMENT } from '../../constants';
17
- import { getFundingConfig, isFundingEligible } from '../../funding';
18
-
19
- import { BUTTON_SIZE_STYLE } from './config';
20
-
21
- export type CreateOrderData = {|
22
-
23
- |} | {||};
4
+ import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
5
+ import { values, uniqueID } from "@krakenjs/belter/src";
6
+ import {
7
+ type OrderCreateRequest,
8
+ type FundingEligibilityType,
9
+ type OrderGetResponse,
10
+ type OrderCaptureResponse,
11
+ type OrderAuthorizeResponse,
12
+ } from "@paypal/sdk-client/src";
13
+ import {
14
+ CURRENCY,
15
+ FUNDING,
16
+ PLATFORM,
17
+ INTENT,
18
+ COMMIT,
19
+ VAULT,
20
+ ENV,
21
+ COUNTRY,
22
+ LANG,
23
+ COUNTRY_LANGS,
24
+ type LocaleType,
25
+ CARD,
26
+ COMPONENTS,
27
+ } from "@paypal/sdk-constants/src";
28
+ import { type CrossDomainWindowType } from "@krakenjs/cross-domain-utils/src";
29
+ import { LOGO_COLOR } from "@paypal/sdk-logos/src";
30
+ import { SUPPORTED_FUNDING_SOURCES } from "@paypal/funding-components/src";
31
+ import type { ComponentFunctionType } from "@krakenjs/jsx-pragmatic/src";
32
+
33
+ import type { ContentType, CustomStyle, Wallet, Experiment } from "../../types";
34
+ import {
35
+ BUTTON_LABEL,
36
+ BUTTON_COLOR,
37
+ BUTTON_LAYOUT,
38
+ BUTTON_SHAPE,
39
+ BUTTON_SIZE,
40
+ BUTTON_FLOW,
41
+ MENU_PLACEMENT,
42
+ } from "../../constants";
43
+ import { getFundingConfig, isFundingEligible } from "../../funding";
44
+
45
+ import { BUTTON_SIZE_STYLE } from "./config";
46
+
47
+ export type CreateOrderData = {||} | {||};
24
48
 
25
49
  export type CreateOrderActions = {|
26
- order : {|
27
- create : (OrderCreateRequest) => ZalgoPromise<string>
28
- |}
50
+ order: {|
51
+ create: (OrderCreateRequest) => ZalgoPromise<string>,
52
+ |},
29
53
  |};
30
54
 
31
- export type CreateOrder = (CreateOrderData, CreateOrderActions) => ZalgoPromise<string> | string;
55
+ export type CreateOrder = (
56
+ CreateOrderData,
57
+ CreateOrderActions
58
+ ) => ZalgoPromise<string> | string;
32
59
 
33
60
  export type OnApproveData = {|
34
- orderID : string,
35
- payerID : string,
36
- paymentID? : string
61
+ orderID: string,
62
+ payerID: string,
63
+ paymentID?: string,
37
64
  |};
38
65
 
39
66
  export type OnCompleteData = {||};
40
67
 
41
68
  export type CreateBillingAgreement = () => ZalgoPromise<string> | string;
42
69
 
70
+ export type CreateVaultSetupToken = () => ZalgoPromise<string>;
71
+
43
72
  export type CreateSubscriptionRequest = {||};
44
73
  export type SubscriptionResponse = {||} | {||};
45
- export type CreateSubscriptionData = {|
46
- |} | {||};
74
+ export type CreateSubscriptionData = {||} | {||};
47
75
 
48
76
  export type CreateSubscriptionActions = {|
49
- subscription : {|
50
- create : (CreateSubscriptionRequest) => ZalgoPromise<string>,
51
- revise : (CreateSubscriptionRequest) => ZalgoPromise<string>
52
- |}
77
+ subscription: {|
78
+ create: (CreateSubscriptionRequest) => ZalgoPromise<string>,
79
+ revise: (CreateSubscriptionRequest) => ZalgoPromise<string>,
80
+ |},
53
81
  |};
54
82
 
55
- export type CreateSubscription = (CreateSubscriptionData, CreateSubscriptionActions) => ZalgoPromise<string> | string;
83
+ export type CreateSubscription = (
84
+ CreateSubscriptionData,
85
+ CreateSubscriptionActions
86
+ ) => ZalgoPromise<string> | string;
56
87
 
57
88
  export type OnApproveActions = {|
58
- redirect : (string, CrossDomainWindowType) => ZalgoPromise<void>,
59
- order : {|
60
- capture : () => ZalgoPromise<OrderCaptureResponse>,
61
- get : () => ZalgoPromise<OrderGetResponse>,
62
- authorize : () => ZalgoPromise<OrderAuthorizeResponse>
63
- |},
64
- subscription : {|
65
- get : () => ZalgoPromise<SubscriptionResponse>,
66
- activate : () => ZalgoPromise<SubscriptionResponse>
67
- |}
89
+ redirect: (string, CrossDomainWindowType) => ZalgoPromise<void>,
90
+ order: {|
91
+ capture: () => ZalgoPromise<OrderCaptureResponse>,
92
+ get: () => ZalgoPromise<OrderGetResponse>,
93
+ authorize: () => ZalgoPromise<OrderAuthorizeResponse>,
94
+ |},
95
+ subscription: {|
96
+ get: () => ZalgoPromise<SubscriptionResponse>,
97
+ activate: () => ZalgoPromise<SubscriptionResponse>,
98
+ |},
68
99
  |};
69
100
 
70
101
  export type OnCompleteActions = {|
71
- redirect : (string, CrossDomainWindowType) => ZalgoPromise<void>
102
+ redirect: (string, CrossDomainWindowType) => ZalgoPromise<void>,
72
103
  |};
73
104
 
74
- export type OnApprove = (data : OnApproveData, actions : OnApproveActions) => ZalgoPromise<void> | void;
75
- export type OnComplete = (data : OnCompleteData, actions : OnCompleteActions) => ZalgoPromise<void> | void;
105
+ export type OnApprove = (
106
+ data: OnApproveData,
107
+ actions: OnApproveActions
108
+ ) => ZalgoPromise<void> | void;
109
+ export type OnComplete = (
110
+ data: OnCompleteData,
111
+ actions: OnCompleteActions
112
+ ) => ZalgoPromise<void> | void;
76
113
 
77
114
  type OnShippingChangeAddress = {|
78
- city : string,
79
- state : string,
80
- country_code : string,
81
- postal_code : string
115
+ city: string,
116
+ state: string,
117
+ country_code: string,
118
+ postal_code: string,
82
119
  |};
83
120
 
84
121
  type OnShippingChangeOption = {|
85
- id? : string,
86
- label : string,
87
- type : string,
88
- amount : {|
89
- currency_code : string,
90
- value : string
91
- |}
122
+ id?: string,
123
+ label: string,
124
+ type: string,
125
+ amount: {|
126
+ currency_code: string,
127
+ value: string,
128
+ |},
92
129
  |};
93
130
 
94
- export type ON_SHIPPING_CHANGE_EVENT = 'add' | 'replace';
131
+ export type ON_SHIPPING_CHANGE_EVENT = "add" | "replace";
95
132
 
96
133
  export type ShippingOption = {|
97
- id? : string,
98
- label : string,
99
- selected : boolean,
100
- type : string,
101
- amount : {|
102
- currency_code : string,
103
- value : string
104
- |}
134
+ id?: string,
135
+ label: string,
136
+ selected: boolean,
137
+ type: string,
138
+ amount: {|
139
+ currency_code: string,
140
+ value: string,
141
+ |},
105
142
  |};
106
143
 
107
144
  export type Query = {|
108
- op : ON_SHIPPING_CHANGE_EVENT,
109
- path : string,
110
- value : mixed
145
+ op: ON_SHIPPING_CHANGE_EVENT,
146
+ path: string,
147
+ value: mixed,
111
148
  |};
112
149
 
113
150
  export type Breakdown = {|
114
- item_total? : {|
115
- currency_code : $Values<typeof CURRENCY>,
116
- value : string
151
+ item_total?: {|
152
+ currency_code: $Values<typeof CURRENCY>,
153
+ value: string,
154
+ |},
155
+ shipping?: {|
156
+ currency_code: $Values<typeof CURRENCY>,
157
+ value: string,
158
+ |},
159
+ handling?: {|
160
+ currency_code: $Values<typeof CURRENCY>,
161
+ value: string,
162
+ |},
163
+ tax_total?: {|
164
+ currency_code: $Values<typeof CURRENCY>,
165
+ value: string,
166
+ |},
167
+ insurance?: {|
168
+ currency_code: $Values<typeof CURRENCY>,
169
+ value: string,
170
+ |},
171
+ shipping_discount?: {|
172
+ currency_code: $Values<typeof CURRENCY>,
173
+ value: string,
174
+ |},
175
+ discount?: {|
176
+ currency_code: $Values<typeof CURRENCY>,
177
+ value: string,
178
+ |},
179
+ |};
180
+
181
+ export type ShippingAmount = {|
182
+ breakdown?: {|
183
+ item_total?: {|
184
+ currency_code: $Values<typeof CURRENCY>,
185
+ value: string,
117
186
  |},
118
- shipping? : {|
119
- currency_code : $Values<typeof CURRENCY>,
120
- value : string
187
+ shipping?: {|
188
+ currency_code: $Values<typeof CURRENCY>,
189
+ value: string,
121
190
  |},
122
- handling? : {|
123
- currency_code : $Values<typeof CURRENCY>,
124
- value : string
191
+ handling?: {|
192
+ currency_code: $Values<typeof CURRENCY>,
193
+ value: string,
125
194
  |},
126
- tax_total? : {|
127
- currency_code : $Values<typeof CURRENCY>,
128
- value : string
195
+ tax_total?: {|
196
+ currency_code: $Values<typeof CURRENCY>,
197
+ value: string,
129
198
  |},
130
- insurance? : {|
131
- currency_code : $Values<typeof CURRENCY>,
132
- value : string
199
+ insurance?: {|
200
+ currency_code: $Values<typeof CURRENCY>,
201
+ value: string,
133
202
  |},
134
- shipping_discount? : {|
135
- currency_code : $Values<typeof CURRENCY>,
136
- value : string
203
+ shipping_discount?: {|
204
+ currency_code: $Values<typeof CURRENCY>,
205
+ value: string,
137
206
  |},
138
- discount? : {|
139
- currency_code : $Values<typeof CURRENCY>,
140
- value : string
141
- |}
142
- |};
143
-
144
- export type ShippingAmount = {|
145
- breakdown? : {|
146
- item_total? : {|
147
- currency_code : $Values<typeof CURRENCY>,
148
- value : string
149
- |},
150
- shipping? : {|
151
- currency_code : $Values<typeof CURRENCY>,
152
- value : string
153
- |},
154
- handling? : {|
155
- currency_code : $Values<typeof CURRENCY>,
156
- value : string
157
- |},
158
- tax_total? : {|
159
- currency_code : $Values<typeof CURRENCY>,
160
- value : string
161
- |},
162
- insurance? : {|
163
- currency_code : $Values<typeof CURRENCY>,
164
- value : string
165
- |},
166
- shipping_discount? : {|
167
- currency_code : $Values<typeof CURRENCY>,
168
- value : string
169
- |},
170
- discount? : {|
171
- currency_code : $Values<typeof CURRENCY>,
172
- value : string
173
- |}
207
+ discount?: {|
208
+ currency_code: $Values<typeof CURRENCY>,
209
+ value: string,
174
210
  |},
175
- currency_code : $Values<typeof CURRENCY>,
176
- value : string
211
+ |},
212
+ currency_code: $Values<typeof CURRENCY>,
213
+ value: string,
177
214
  |};
178
215
 
179
216
  export type OnShippingChangeData = {|
180
- orderID : string,
181
- payerID : string,
182
- paymentID? : string,
183
- shipping_address : OnShippingChangeAddress,
184
- selected_shipping_option : OnShippingChangeOption,
185
- amount? : ShippingAmount,
217
+ orderID: string,
218
+ payerID: string,
219
+ paymentID?: string,
220
+ shipping_address: OnShippingChangeAddress,
221
+ selected_shipping_option: OnShippingChangeOption,
222
+ amount?: ShippingAmount,
186
223
  |};
187
224
 
188
225
  export type OnShippingChangeActions = {|
189
- order : {|
190
- patch : () => ZalgoPromise<OrderGetResponse>
191
- |}
226
+ order: {|
227
+ patch: () => ZalgoPromise<OrderGetResponse>,
228
+ |},
192
229
  |};
193
230
 
194
- export type OnShippingChange = (data : OnShippingChangeData, actions : OnShippingChangeActions) => ZalgoPromise<void> | void;
231
+ export type OnShippingChange = (
232
+ data: OnShippingChangeData,
233
+ actions: OnShippingChangeActions
234
+ ) => ZalgoPromise<void> | void;
195
235
 
196
236
  export type OnShippingAddressChangeData = {|
197
- orderID : string,
198
- payerID? : string,
199
- paymentID? : string,
200
- amount? : ShippingAmount,
201
- event? : ON_SHIPPING_CHANGE_EVENT,
202
- shipping_address : OnShippingChangeAddress
237
+ orderID: string,
238
+ payerID?: string,
239
+ paymentID?: string,
240
+ amount?: ShippingAmount,
241
+ event?: ON_SHIPPING_CHANGE_EVENT,
242
+ shipping_address: OnShippingChangeAddress,
203
243
  |};
204
244
 
205
245
  export type OnShippingAddressChangeActions = {|
206
- patch : () => ZalgoPromise<OrderGetResponse>,
207
- query : () => $ReadOnlyArray<Query>,
208
- updateShippingDiscount : ({| discountAmount : string |}) => ZalgoPromise<void> | void,
209
- updateShippingOptions : ({| shippingOptions : $ReadOnlyArray<ShippingOption> |}) => ZalgoPromise<void> | void,
210
- updateTax : ({| taxAmount : string |})
211
- |};
212
-
213
- export type OnShippingAddressChange = (data : OnShippingAddressChangeData, actions : OnShippingAddressChangeActions) => ZalgoPromise<void> | void;
246
+ patch: () => ZalgoPromise<OrderGetResponse>,
247
+ query: () => $ReadOnlyArray<Query>,
248
+ updateShippingDiscount: ({|
249
+ discountAmount: string,
250
+ |}) => ZalgoPromise<void> | void,
251
+ updateShippingOptions: ({|
252
+ shippingOptions: $ReadOnlyArray<ShippingOption>,
253
+ |}) => ZalgoPromise<void> | void,
254
+ updateTax: {| taxAmount: string |},
255
+ |};
256
+
257
+ export type OnShippingAddressChange = (
258
+ data: OnShippingAddressChangeData,
259
+ actions: OnShippingAddressChangeActions
260
+ ) => ZalgoPromise<void> | void;
214
261
 
215
262
  export type OnShippingOptionsChangeData = {|
216
- orderID : string,
217
- payerID : string,
218
- paymentID? : string,
219
- selected_shipping_option : OnShippingChangeOption
263
+ orderID: string,
264
+ payerID: string,
265
+ paymentID?: string,
266
+ selected_shipping_option: OnShippingChangeOption,
220
267
  |};
221
268
  export type OnShippingOptionsChangeActions = {|
222
- patch : () => ZalgoPromise<OrderGetResponse>,
223
- query : () => string,
224
- updateShippingDiscount : ({| discountAmount : string |}) => ZalgoPromise<void> | void,
225
- updateShippingOptions : ({| shippingOptions : $ReadOnlyArray<ShippingOption> |}) => ZalgoPromise<void> | void,
226
- updateTax : ({| taxAmount : string |})
227
- |};
228
-
229
- export type OnShippingOptionsChange = (data : OnShippingOptionsChangeData, actions : OnShippingOptionsChangeActions) => ZalgoPromise<void> | void;
269
+ patch: () => ZalgoPromise<OrderGetResponse>,
270
+ query: () => string,
271
+ updateShippingDiscount: ({|
272
+ discountAmount: string,
273
+ |}) => ZalgoPromise<void> | void,
274
+ updateShippingOptions: ({|
275
+ shippingOptions: $ReadOnlyArray<ShippingOption>,
276
+ |}) => ZalgoPromise<void> | void,
277
+ updateTax: {| taxAmount: string |},
278
+ |};
279
+
280
+ export type OnShippingOptionsChange = (
281
+ data: OnShippingOptionsChangeData,
282
+ actions: OnShippingOptionsChangeActions
283
+ ) => ZalgoPromise<void> | void;
230
284
 
231
285
  export type OnCancelData = {|
232
- orderID : string,
233
- paymentID? : string
286
+ orderID: string,
287
+ paymentID?: string,
234
288
  |};
235
289
 
236
290
  export type OnCancelActions = {|
237
- redirect : (string, CrossDomainWindowType) => ZalgoPromise<void>
291
+ redirect: (string, CrossDomainWindowType) => ZalgoPromise<void>,
238
292
  |};
239
293
 
240
- export type OnCancel = (OnCancelData, OnCancelActions) => ZalgoPromise<void> | void;
294
+ export type OnCancel = (
295
+ OnCancelData,
296
+ OnCancelActions
297
+ ) => ZalgoPromise<void> | void;
241
298
 
242
299
  export type OnClickData = {|
243
- fundingSource : $Values<typeof FUNDING>,
244
- card? : $Values<typeof CARD>
300
+ fundingSource: $Values<typeof FUNDING>,
301
+ card?: $Values<typeof CARD>,
245
302
  |};
246
303
 
247
304
  export type OnClickActions = {|
248
- resolve : () => ZalgoPromise<void>,
249
- reject : () => ZalgoPromise<void>
305
+ resolve: () => ZalgoPromise<void>,
306
+ reject: () => ZalgoPromise<void>,
250
307
  |};
251
308
 
252
309
  export type OnClick = (OnClickData, OnClickActions) => void;
253
310
 
254
311
  export type ButtonStyle = {|
255
- label : $Values<typeof BUTTON_LABEL> | void,
256
- color : $Values<typeof BUTTON_COLOR>,
257
- shape : $Values<typeof BUTTON_SHAPE>,
258
- tagline : boolean,
259
- layout : $Values<typeof BUTTON_LAYOUT>,
260
- menuPlacement : $Values<typeof MENU_PLACEMENT>,
261
- period? : number,
262
- height? : number,
263
- custom? : ?CustomStyle
312
+ label: $Values<typeof BUTTON_LABEL> | void,
313
+ color: $Values<typeof BUTTON_COLOR>,
314
+ shape: $Values<typeof BUTTON_SHAPE>,
315
+ tagline: boolean,
316
+ layout: $Values<typeof BUTTON_LAYOUT>,
317
+ menuPlacement: $Values<typeof MENU_PLACEMENT>,
318
+ period?: number,
319
+ height?: number,
320
+ custom?: ?CustomStyle,
264
321
  |};
265
322
 
266
323
  export type ButtonStyleInputs = {|
267
- label? : $Values<typeof BUTTON_LABEL> | void,
268
- color? : $Values<typeof BUTTON_COLOR> | void,
269
- shape? : $Values<typeof BUTTON_SHAPE> | void,
270
- tagline? : boolean | void,
271
- layout? : $Values<typeof BUTTON_LAYOUT> | void,
272
- period? : number | void,
273
- height? : number | void,
274
- custom? : ?CustomStyle
324
+ label?: $Values<typeof BUTTON_LABEL> | void,
325
+ color?: $Values<typeof BUTTON_COLOR> | void,
326
+ shape?: $Values<typeof BUTTON_SHAPE> | void,
327
+ tagline?: boolean | void,
328
+ layout?: $Values<typeof BUTTON_LAYOUT> | void,
329
+ period?: number | void,
330
+ height?: number | void,
331
+ custom?: ?CustomStyle,
275
332
  |};
276
333
 
277
334
  type PersonalizationComponentProps = {|
278
- logoColor : $Values<typeof LOGO_COLOR>,
279
- period : ?number
335
+ logoColor: $Values<typeof LOGO_COLOR>,
336
+ period: ?number,
280
337
  |};
281
338
 
282
339
  export type Personalization = {|
283
- buttonText? : {|
284
- text : string,
285
- Component : ?ComponentFunctionType<PersonalizationComponentProps>,
286
- tracking : {|
287
- impression : string,
288
- click : string
289
- |}
340
+ buttonText?: {|
341
+ text: string,
342
+ Component: ?ComponentFunctionType<PersonalizationComponentProps>,
343
+ tracking: {|
344
+ impression: string,
345
+ click: string,
346
+ |},
347
+ |},
348
+ tagline?: {|
349
+ text: string,
350
+ Component: ?ComponentFunctionType<PersonalizationComponentProps>,
351
+ tracking: {|
352
+ impression: string,
353
+ click: string,
290
354
  |},
291
- tagline? : {|
292
- text : string,
293
- Component : ?ComponentFunctionType<PersonalizationComponentProps>,
294
- tracking : {|
295
- impression : string,
296
- click : string
297
- |}
355
+ |},
356
+ buttonDesign?: {|
357
+ id: string,
358
+ text: string,
359
+ tracking: {|
360
+ impression: string,
361
+ click: string,
298
362
  |},
299
- buttonDesign? : {|
300
- id : string,
301
- text : string,
302
- tracking : {|
303
- impression : string,
304
- click : string
305
- |}
306
- |}
363
+ |},
307
364
  |};
308
365
 
309
366
  // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerror/2970147-applepayerror
310
367
  export type ApplePayError = {|
311
- code : string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcode
312
- contactField : string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcontactfield
313
- message : string // custom error message
368
+ code: string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcode
369
+ contactField: string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcontactfield
370
+ message: string, // custom error message
314
371
  |};
315
372
 
316
373
  export type ApplePayLineItem = {|
317
- type? : string, // 'final' | 'pending'
318
- label? : string,
319
- amount? : string
374
+ type?: string, // 'final' | 'pending'
375
+ label?: string,
376
+ amount?: string,
320
377
  |};
321
378
 
322
379
  export type ApplePayShippingMethod = {|
323
- label : string,
324
- detail : string,
325
- amount : string,
326
- identifier : string
380
+ label: string,
381
+ detail: string,
382
+ amount: string,
383
+ identifier: string,
327
384
  |};
328
385
 
329
386
  export type ApplePayShippingContactUpdate = {|
330
- errors? : $ReadOnlyArray<ApplePayError>,
331
- newShippingMethods? : $ReadOnlyArray<ApplePayShippingMethod>,
332
- newTotal : ApplePayLineItem,
333
- newLineItems? : $ReadOnlyArray<ApplePayLineItem>
387
+ errors?: $ReadOnlyArray<ApplePayError>,
388
+ newShippingMethods?: $ReadOnlyArray<ApplePayShippingMethod>,
389
+ newTotal: ApplePayLineItem,
390
+ newLineItems?: $ReadOnlyArray<ApplePayLineItem>,
334
391
  |};
335
392
 
336
393
  export type ApplePayPaymentMethodUpdate = {|
337
- newTotal : ApplePayLineItem,
338
- newLineItems? : $ReadOnlyArray<ApplePayLineItem>
394
+ newTotal: ApplePayLineItem,
395
+ newLineItems?: $ReadOnlyArray<ApplePayLineItem>,
339
396
  |};
340
397
 
341
398
  export type ApplePayShippingMethodUpdate = {|
342
- newTotal : ApplePayLineItem,
343
- newLineItems? : $ReadOnlyArray<ApplePayLineItem>
399
+ newTotal: ApplePayLineItem,
400
+ newLineItems?: $ReadOnlyArray<ApplePayLineItem>,
344
401
  |};
345
402
 
346
403
  export type ApplePayPaymentAuthorizationResult = {|
347
- status : number,
348
- errors? : $ReadOnlyArray<ApplePayError>
404
+ status: number,
405
+ errors?: $ReadOnlyArray<ApplePayError>,
349
406
  |};
350
407
 
351
408
  export type ApplePaySessionConfig = {|
352
- begin : () => void,
353
- abort : () => void,
354
- addEventListener : (string, Function) => void,
355
- // eslint-disable-next-line flowtype/no-weak-types
356
- completeMerchantValidation : (validatedSession : any) => void,
357
- completeShippingMethodSelection : (update : ApplePayShippingMethodUpdate | {||}) => void,
358
- completeShippingContactSelection : (update : ApplePayShippingContactUpdate | {||}) => void,
359
- completePaymentMethodSelection : (update : ApplePayPaymentMethodUpdate | {||}) => void,
360
- completePayment : (result : ApplePayPaymentAuthorizationResult) => void
361
- |};
362
-
363
- export type ApplePaySessionConfigRequest = (version : number, request : Object) => ApplePaySessionConfig;
409
+ begin: () => void,
410
+ abort: () => void,
411
+ addEventListener: (string, Function) => void,
412
+ // eslint-disable-next-line flowtype/no-weak-types
413
+ completeMerchantValidation: (validatedSession: any) => void,
414
+ completeShippingMethodSelection: (
415
+ update: ApplePayShippingMethodUpdate | {||}
416
+ ) => void,
417
+ completeShippingContactSelection: (
418
+ update: ApplePayShippingContactUpdate | {||}
419
+ ) => void,
420
+ completePaymentMethodSelection: (
421
+ update: ApplePayPaymentMethodUpdate | {||}
422
+ ) => void,
423
+ completePayment: (result: ApplePayPaymentAuthorizationResult) => void,
424
+ |};
425
+
426
+ export type ApplePaySessionConfigRequest = (
427
+ version: number,
428
+ request: Object
429
+ ) => ApplePaySessionConfig;
364
430
 
365
431
  export type RenderButtonProps = {|
366
- style : ButtonStyle,
367
- locale : LocaleType,
368
- commit : boolean,
369
- fundingSource : ?$Values<typeof FUNDING>,
370
- env : $Values<typeof ENV>,
371
- stage? : string,
372
- stageUrl? : string,
373
- platform : $Values<typeof PLATFORM>,
374
- fundingEligibility : FundingEligibilityType,
375
- wallet : ?Wallet,
376
- remembered : $ReadOnlyArray<$Values<typeof FUNDING>>,
377
- clientID : string,
378
- sessionID : string,
379
- buttonSessionID : string,
380
- nonce : string,
381
- components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
382
- onShippingChange : ?OnShippingChange,
383
- onShippingAddressChange : ?OnShippingAddressChange,
384
- onShippingOptionsChange : ?OnShippingOptionsChange,
385
- personalization : ?Personalization,
386
- clientAccessToken : ?string,
387
- content? : ContentType,
388
- flow : $Values<typeof BUTTON_FLOW>,
389
- experiment : Experiment,
390
- vault : boolean,
391
- userIDToken : ?string,
392
- applePay : ApplePaySessionConfigRequest,
393
- applePaySupport : boolean,
394
- supportsPopups : boolean,
395
- supportedNativeBrowser : boolean,
396
- experience : string,
397
- showPayLabel : boolean
432
+ style: ButtonStyle,
433
+ locale: LocaleType,
434
+ commit: boolean,
435
+ fundingSource: ?$Values<typeof FUNDING>,
436
+ env: $Values<typeof ENV>,
437
+ stage?: string,
438
+ stageUrl?: string,
439
+ platform: $Values<typeof PLATFORM>,
440
+ fundingEligibility: FundingEligibilityType,
441
+ wallet: ?Wallet,
442
+ remembered: $ReadOnlyArray<$Values<typeof FUNDING>>,
443
+ clientID: string,
444
+ sessionID: string,
445
+ buttonSessionID: string,
446
+ nonce: string,
447
+ components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
448
+ onShippingChange: ?OnShippingChange,
449
+ onShippingAddressChange: ?OnShippingAddressChange,
450
+ onShippingOptionsChange: ?OnShippingOptionsChange,
451
+ personalization: ?Personalization,
452
+ clientAccessToken: ?string,
453
+ content?: ContentType,
454
+ flow: $Values<typeof BUTTON_FLOW>,
455
+ experiment: Experiment,
456
+ vault: boolean,
457
+ userIDToken: ?string,
458
+ applePay: ApplePaySessionConfigRequest,
459
+ applePaySupport: boolean,
460
+ supportsPopups: boolean,
461
+ supportedNativeBrowser: boolean,
462
+ experience: string,
463
+ showPayLabel: boolean,
398
464
  |};
399
465
 
400
466
  export type PrerenderDetails = {|
401
- win : ?CrossDomainWindowType,
402
- fundingSource : $Values<typeof FUNDING>,
403
- card : ?$Values<typeof CARD>
467
+ win: ?CrossDomainWindowType,
468
+ fundingSource: $Values<typeof FUNDING>,
469
+ card: ?$Values<typeof CARD>,
404
470
  |};
405
471
 
406
472
  export type GetPrerenderDetails = () => PrerenderDetails | void;
407
473
 
408
474
  export type ButtonProps = {|
409
- fundingSource? : ?$Values<typeof FUNDING>,
410
- intent : $Values<typeof INTENT>,
411
- createOrder : CreateOrder,
412
- createBillingAgreement : CreateBillingAgreement,
413
- createSubscription : CreateSubscription,
414
- currency : string,
415
- disableFunding? : $ReadOnlyArray<$Values<typeof FUNDING>>,
416
- oncancel : OnCancel,
417
- onApprove : OnApprove,
418
- onComplete : OnComplete,
419
- onClick : OnClick,
420
- getPrerenderDetails : GetPrerenderDetails,
421
- style : ButtonStyle,
422
- locale : LocaleType,
423
- commit : boolean,
424
- env : $Values<typeof ENV>,
425
- stage? : string,
426
- stageUrl? : string,
427
- platform : $Values<typeof PLATFORM>,
428
- fundingEligibility : FundingEligibilityType,
429
- remembered : $ReadOnlyArray<$Values<typeof FUNDING>>,
430
- remember : ($ReadOnlyArray<$Values<typeof FUNDING>>) => void,
431
- clientID : string,
432
- sessionID : string,
433
- buttonLocation : string,
434
- buttonSessionID : string,
435
- onShippingChange : ?OnShippingChange,
436
- onShippingAddressChange : ?OnShippingAddressChange,
437
- onShippingOptionsChange : ?OnShippingOptionsChange,
438
- clientAccessToken? : ?string,
439
- nonce : string,
440
- merchantID? : $ReadOnlyArray<string>,
441
- merchantRequestedPopupsDisabled : ?boolean,
442
- userIDToken : ?string,
443
- flow : $Values<typeof BUTTON_FLOW>,
444
- experiment : Experiment,
445
- vault : boolean,
446
- components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
447
- supportsPopups : boolean,
448
- supportedNativeBrowser : boolean,
449
- applePaySupport : boolean,
450
- applePay : ApplePaySessionConfigRequest,
451
- meta : {||},
452
- renderedButtons : $ReadOnlyArray<$Values<typeof FUNDING>>,
453
- experience : string
475
+ fundingSource?: ?$Values<typeof FUNDING>,
476
+ intent: $Values<typeof INTENT>,
477
+ createOrder: CreateOrder,
478
+ createBillingAgreement: CreateBillingAgreement,
479
+ createSubscription: CreateSubscription,
480
+ currency: string,
481
+ disableFunding?: $ReadOnlyArray<$Values<typeof FUNDING>>,
482
+ oncancel: OnCancel,
483
+ onApprove: OnApprove,
484
+ onComplete: OnComplete,
485
+ onClick: OnClick,
486
+ getPrerenderDetails: GetPrerenderDetails,
487
+ style: ButtonStyle,
488
+ locale: LocaleType,
489
+ commit: boolean,
490
+ env: $Values<typeof ENV>,
491
+ stage?: string,
492
+ stageUrl?: string,
493
+ platform: $Values<typeof PLATFORM>,
494
+ fundingEligibility: FundingEligibilityType,
495
+ remembered: $ReadOnlyArray<$Values<typeof FUNDING>>,
496
+ remember: ($ReadOnlyArray<$Values<typeof FUNDING>>) => void,
497
+ clientID: string,
498
+ sessionID: string,
499
+ buttonLocation: string,
500
+ buttonSessionID: string,
501
+ onShippingChange: ?OnShippingChange,
502
+ onShippingAddressChange: ?OnShippingAddressChange,
503
+ onShippingOptionsChange: ?OnShippingOptionsChange,
504
+ clientAccessToken?: ?string,
505
+ nonce: string,
506
+ merchantID?: $ReadOnlyArray<string>,
507
+ merchantRequestedPopupsDisabled: ?boolean,
508
+ userIDToken: ?string,
509
+ flow: $Values<typeof BUTTON_FLOW>,
510
+ experiment: Experiment,
511
+ vault: boolean,
512
+ components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
513
+ supportsPopups: boolean,
514
+ supportedNativeBrowser: boolean,
515
+ applePaySupport: boolean,
516
+ applePay: ApplePaySessionConfigRequest,
517
+ meta: {||},
518
+ renderedButtons: $ReadOnlyArray<$Values<typeof FUNDING>>,
519
+ experience: string,
520
+ createVaultSetupToken: CreateVaultSetupToken,
454
521
  |};
455
522
 
456
523
  // eslint-disable-next-line flowtype/require-exact-type
457
524
  export type ButtonPropsInputs = {
458
- clientID : string,
459
- fundingSource? : ?$Values<typeof FUNDING>,
460
- style? : ButtonStyleInputs | void,
461
- locale? : $PropertyType<ButtonProps, 'locale'> | void,
462
- commit? : $PropertyType<ButtonProps, 'commit'> | void,
463
- env? : $PropertyType<ButtonProps, 'env'> | void,
464
- meta? : $PropertyType<ButtonProps, 'meta'> | void,
465
- stage? : $PropertyType<ButtonProps, 'stage'> | void,
466
- stageUrl? : $PropertyType<ButtonProps, 'stageUrl'> | void,
467
- platform? : $PropertyType<ButtonProps, 'platform'> | void,
468
- fundingEligibility? : $PropertyType<ButtonProps, 'fundingEligibility'> | void,
469
- remembered? : $PropertyType<ButtonProps, 'remembered'> | void,
470
- remember? : $PropertyType<ButtonProps, 'remember'> | void,
471
- sessionID? : $PropertyType<ButtonProps, 'sessionID'> | void,
472
- buttonSessionID? : $PropertyType<ButtonProps, 'buttonSessionID'> | void,
473
- nonce : string,
474
- components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
475
- onShippingChange : ?Function,
476
- onShippingAddressChange : ?Function,
477
- onShippingOptionsChange : ?Function,
478
- personalization? : Personalization,
479
- clientAccessToken? : ?string,
480
- wallet? : ?Wallet,
481
- csp : {|
482
- nonce : string
483
- |},
484
- content? : ContentType,
485
- flow? : $Values<typeof BUTTON_FLOW>,
486
- experiment : Experiment,
487
- vault : boolean,
488
- userIDToken : ?string,
489
- applePay : ApplePaySessionConfigRequest,
490
- applePaySupport : boolean,
491
- supportsPopups : boolean,
492
- supportedNativeBrowser : boolean,
493
- experience : string,
494
- showPayLabel : boolean
525
+ clientID: string,
526
+ fundingSource?: ?$Values<typeof FUNDING>,
527
+ style?: ButtonStyleInputs | void,
528
+ locale?: $PropertyType<ButtonProps, "locale"> | void,
529
+ commit?: $PropertyType<ButtonProps, "commit"> | void,
530
+ env?: $PropertyType<ButtonProps, "env"> | void,
531
+ meta?: $PropertyType<ButtonProps, "meta"> | void,
532
+ stage?: $PropertyType<ButtonProps, "stage"> | void,
533
+ stageUrl?: $PropertyType<ButtonProps, "stageUrl"> | void,
534
+ platform?: $PropertyType<ButtonProps, "platform"> | void,
535
+ fundingEligibility?: $PropertyType<ButtonProps, "fundingEligibility"> | void,
536
+ remembered?: $PropertyType<ButtonProps, "remembered"> | void,
537
+ remember?: $PropertyType<ButtonProps, "remember"> | void,
538
+ sessionID?: $PropertyType<ButtonProps, "sessionID"> | void,
539
+ buttonSessionID?: $PropertyType<ButtonProps, "buttonSessionID"> | void,
540
+ nonce: string,
541
+ components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
542
+ onShippingChange: ?Function,
543
+ onShippingAddressChange: ?Function,
544
+ onShippingOptionsChange: ?Function,
545
+ personalization?: Personalization,
546
+ clientAccessToken?: ?string,
547
+ wallet?: ?Wallet,
548
+ csp: {|
549
+ nonce: string,
550
+ |},
551
+ content?: ContentType,
552
+ flow?: $Values<typeof BUTTON_FLOW>,
553
+ experiment: Experiment,
554
+ vault: boolean,
555
+ userIDToken: ?string,
556
+ applePay: ApplePaySessionConfigRequest,
557
+ applePaySupport: boolean,
558
+ supportsPopups: boolean,
559
+ supportedNativeBrowser: boolean,
560
+ experience: string,
561
+ showPayLabel: boolean,
495
562
  };
496
563
 
497
564
  export const DEFAULT_STYLE = {
498
- LAYOUT: BUTTON_LAYOUT.VERTICAL,
499
- COLOR: BUTTON_COLOR.GOLD,
500
- SHAPE: BUTTON_SHAPE.RECT
565
+ LAYOUT: BUTTON_LAYOUT.VERTICAL,
566
+ COLOR: BUTTON_COLOR.GOLD,
567
+ SHAPE: BUTTON_SHAPE.RECT,
501
568
  };
502
569
 
503
570
  export const DEFAULT_PROPS = {
504
- LOCALE: {
505
- country: COUNTRY.US,
506
- lang: LANG.EN
507
- },
508
- COMMIT: COMMIT.TRUE,
509
- VAULT: VAULT.FALSE,
510
- INTENT: INTENT.CAPTURE,
511
- ENV: ENV.PRODUCTION,
512
- PLATFORM: PLATFORM.DESKTOP
571
+ LOCALE: {
572
+ country: COUNTRY.US,
573
+ lang: LANG.EN,
574
+ },
575
+ COMMIT: COMMIT.TRUE,
576
+ VAULT: VAULT.FALSE,
577
+ INTENT: INTENT.CAPTURE,
578
+ ENV: ENV.PRODUCTION,
579
+ PLATFORM: PLATFORM.DESKTOP,
513
580
  };
514
581
 
515
- const getDefaultButtonPropsInput = () : ButtonPropsInputs => {
516
- return {};
582
+ const getDefaultButtonPropsInput = (): ButtonPropsInputs => {
583
+ return {};
517
584
  };
518
585
 
519
- export function normalizeButtonStyle(props : ?ButtonPropsInputs, style : ButtonStyleInputs) : ButtonStyle {
520
-
521
- if (!style) {
522
- throw new Error(`Expected props.style to be set`);
523
- }
524
-
525
- props = props || getDefaultButtonPropsInput();
526
- const { fundingSource } = props;
527
-
528
- const FUNDING_CONFIG = getFundingConfig();
529
- const fundingConfig = FUNDING_CONFIG[fundingSource || FUNDING.PAYPAL] || FUNDING_CONFIG[FUNDING.PAYPAL];
530
-
531
- if (!fundingConfig) {
532
- throw new Error(`Expected ${ fundingSource || FUNDING.PAYPAL } to be eligible`);
533
- }
534
-
535
- let {
536
- label,
537
- layout = fundingSource ? BUTTON_LAYOUT.HORIZONTAL : fundingConfig.layouts[0],
538
- shape = fundingConfig.shapes[0],
539
- tagline = (layout === BUTTON_LAYOUT.HORIZONTAL && !fundingSource),
540
- height,
541
- period,
542
- menuPlacement = MENU_PLACEMENT.BELOW,
543
- custom
544
- } = style;
545
-
586
+ export function normalizeButtonStyle(
587
+ props: ?ButtonPropsInputs,
588
+ style: ButtonStyleInputs
589
+ ): ButtonStyle {
590
+ if (!style) {
591
+ throw new Error(`Expected props.style to be set`);
592
+ }
593
+
594
+ props = props || getDefaultButtonPropsInput();
595
+ const { fundingSource } = props;
596
+
597
+ const FUNDING_CONFIG = getFundingConfig();
598
+ const fundingConfig =
599
+ FUNDING_CONFIG[fundingSource || FUNDING.PAYPAL] ||
600
+ FUNDING_CONFIG[FUNDING.PAYPAL];
601
+
602
+ if (!fundingConfig) {
603
+ throw new Error(
604
+ `Expected ${fundingSource || FUNDING.PAYPAL} to be eligible`
605
+ );
606
+ }
607
+
608
+ let {
609
+ label,
610
+ layout = fundingSource
611
+ ? BUTTON_LAYOUT.HORIZONTAL
612
+ : fundingConfig.layouts[0],
613
+ shape = fundingConfig.shapes[0],
614
+ tagline = layout === BUTTON_LAYOUT.HORIZONTAL && !fundingSource,
615
+ height,
616
+ period,
617
+ menuPlacement = MENU_PLACEMENT.BELOW,
618
+ custom,
619
+ } = style;
620
+
621
+ // $FlowFixMe
622
+ if (tagline === "false") {
546
623
  // $FlowFixMe
547
- if (tagline === 'false') {
548
- // $FlowFixMe
549
- tagline = false;
624
+ tagline = false;
625
+ }
626
+
627
+ // if color is a falsy value, set it to the default color from the funding config
628
+ const color = style.color ? style.color : fundingConfig.colors[0];
629
+
630
+ if (values(BUTTON_LAYOUT).indexOf(layout) === -1) {
631
+ throw new Error(`Invalid layout: ${layout}`);
632
+ }
633
+
634
+ if (label && values(BUTTON_LABEL).indexOf(label) === -1) {
635
+ throw new Error(`Invalid label: ${label}`);
636
+ }
637
+
638
+ if (color && fundingConfig.colors.indexOf(color) === -1) {
639
+ throw new Error(
640
+ `Unexpected style.color for ${
641
+ fundingSource || FUNDING.PAYPAL
642
+ } button: ${color}, expected ${fundingConfig.colors.join(", ")}`
643
+ );
644
+ }
645
+
646
+ if (shape && fundingConfig.shapes.indexOf(shape) === -1) {
647
+ throw new Error(
648
+ `Unexpected style.shape for ${
649
+ fundingSource || FUNDING.PAYPAL
650
+ } button: ${shape}, expected ${fundingConfig.shapes.join(", ")}`
651
+ );
652
+ }
653
+
654
+ if (height !== undefined) {
655
+ if (typeof height !== "number") {
656
+ throw new TypeError(
657
+ `Expected style.height to be a number, got: ${height}`
658
+ );
550
659
  }
551
660
 
552
- // if color is a falsy value, set it to the default color from the funding config
553
- const color = style.color ? style.color : fundingConfig.colors[0];
661
+ const [minHeight, maxHeight] = [
662
+ BUTTON_SIZE_STYLE[BUTTON_SIZE.SMALL].minHeight,
663
+ BUTTON_SIZE_STYLE[BUTTON_SIZE.HUGE].maxHeight,
664
+ ];
554
665
 
555
- if (values(BUTTON_LAYOUT).indexOf(layout) === -1) {
556
- throw new Error(`Invalid layout: ${ layout }`);
666
+ if (height < minHeight || height > maxHeight) {
667
+ throw new Error(
668
+ `Expected style.height to be between ${minHeight}px and ${maxHeight}px - got ${height}px`
669
+ );
557
670
  }
671
+ }
558
672
 
559
- if (label && values(BUTTON_LABEL).indexOf(label) === -1) {
560
- throw new Error(`Invalid label: ${ label }`);
673
+ if (layout === BUTTON_LAYOUT.VERTICAL) {
674
+ if (tagline) {
675
+ throw new Error(
676
+ `style.tagline is not allowed for ${BUTTON_LAYOUT.VERTICAL} layout`
677
+ );
561
678
  }
679
+ }
562
680
 
563
- if (color && fundingConfig.colors.indexOf(color) === -1) {
564
- throw new Error(`Unexpected style.color for ${ fundingSource || FUNDING.PAYPAL } button: ${ color }, expected ${ fundingConfig.colors.join(', ') }`);
681
+ if (custom) {
682
+ if (custom.label && typeof custom.label !== "string") {
683
+ throw new Error(`style.custom.label is expected to be a String.`);
565
684
  }
566
685
 
567
- if (shape && fundingConfig.shapes.indexOf(shape) === -1) {
568
- throw new Error(`Unexpected style.shape for ${ fundingSource || FUNDING.PAYPAL } button: ${ shape }, expected ${ fundingConfig.shapes.join(', ') }`);
686
+ if (custom.css && typeof custom.css !== "object") {
687
+ throw new Error(`style.custom.css is expected to be JSON.`);
569
688
  }
570
689
 
571
- if (height !== undefined) {
572
- if (typeof height !== 'number') {
573
- throw new TypeError(`Expected style.height to be a number, got: ${ height }`);
574
- }
575
-
576
- const [ minHeight, maxHeight ] = [ BUTTON_SIZE_STYLE[BUTTON_SIZE.SMALL].minHeight, BUTTON_SIZE_STYLE[BUTTON_SIZE.HUGE].maxHeight ];
577
-
578
- if (height < minHeight || height > maxHeight) {
579
- throw new Error(`Expected style.height to be between ${ minHeight }px and ${ maxHeight }px - got ${ height }px`);
580
- }
690
+ if (custom.css && custom.label && custom.label.length === 0) {
691
+ throw new Error(
692
+ `Expected style.custom.label to be used with style.custom.css`
693
+ );
581
694
  }
582
695
 
583
- if (layout === BUTTON_LAYOUT.VERTICAL) {
584
- if (tagline) {
585
- throw new Error(`style.tagline is not allowed for ${ BUTTON_LAYOUT.VERTICAL } layout`);
586
- }
696
+ if (custom.label && custom.label.length > 0 && !custom.css) {
697
+ custom.css = {
698
+ "background-color": "black",
699
+ height: "48px",
700
+ "margin-bottom": "15px",
701
+ };
587
702
  }
588
-
589
- if (custom) {
590
- if (custom.label && typeof custom.label !== 'string') {
591
- throw new Error(`style.custom.label is expected to be a String.`);
592
- }
593
-
594
- if (custom.css && typeof custom.css !== 'object') {
595
- throw new Error(`style.custom.css is expected to be JSON.`);
596
- }
597
-
598
- if (custom.css && custom.label && custom.label.length === 0) {
599
- throw new Error(`Expected style.custom.label to be used with style.custom.css`);
600
- }
601
-
602
- if (custom.label && custom.label.length > 0 && !custom.css) {
603
- custom.css = {
604
- 'background-color': 'black',
605
- 'height': '48px',
606
- 'margin-bottom': '15px'
607
- }
608
- }
609
- }
610
-
611
- return { custom, label, layout, color, shape, tagline, height, period, menuPlacement };
703
+ }
704
+
705
+ return {
706
+ custom,
707
+ label,
708
+ layout,
709
+ color,
710
+ shape,
711
+ tagline,
712
+ height,
713
+ period,
714
+ menuPlacement,
715
+ };
612
716
  }
613
717
 
614
718
  const COUNTRIES = values(COUNTRY);
@@ -616,94 +720,141 @@ const FUNDING_SOURCES = values(FUNDING);
616
720
  const ENVS = values(ENV);
617
721
  const PLATFORMS = values(PLATFORM);
618
722
 
619
- const getDefaultStyle = () : ButtonStyleInputs => {
620
- // $FlowFixMe
621
- return {};
723
+ const getDefaultStyle = (): ButtonStyleInputs => {
724
+ // $FlowFixMe
725
+ return {};
622
726
  };
623
727
 
624
- const getDefaultExperiment = () : Experiment => {
625
- // $FlowFixMe
626
- return {};
728
+ const getDefaultExperiment = (): Experiment => {
729
+ // $FlowFixMe
730
+ return {};
627
731
  };
628
732
 
629
- export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonProps {
630
-
631
- if (!props) {
632
- throw new Error(`Expected props`);
733
+ export function normalizeButtonProps(
734
+ props: ?ButtonPropsInputs
735
+ ): RenderButtonProps {
736
+ if (!props) {
737
+ throw new Error(`Expected props`);
738
+ }
739
+
740
+ let {
741
+ clientID,
742
+ fundingSource,
743
+ style = getDefaultStyle(),
744
+ remembered = [],
745
+ locale = DEFAULT_PROPS.LOCALE,
746
+ env = DEFAULT_PROPS.ENV,
747
+ platform = DEFAULT_PROPS.PLATFORM,
748
+ commit = DEFAULT_PROPS.COMMIT,
749
+ fundingEligibility,
750
+ sessionID = uniqueID(),
751
+ buttonSessionID = uniqueID(),
752
+ components = [COMPONENTS.BUTTONS],
753
+ nonce,
754
+ onShippingChange,
755
+ onShippingAddressChange,
756
+ onShippingOptionsChange,
757
+ personalization,
758
+ clientAccessToken,
759
+ content,
760
+ wallet,
761
+ flow = BUTTON_FLOW.PURCHASE,
762
+ experiment = getDefaultExperiment(),
763
+ vault,
764
+ userIDToken,
765
+ applePay,
766
+ applePaySupport = false,
767
+ supportsPopups = false,
768
+ supportedNativeBrowser = false,
769
+ experience = "",
770
+ showPayLabel = true,
771
+ } = props;
772
+
773
+ const { country, lang } = locale;
774
+
775
+ if (!country || COUNTRIES.indexOf(country) === -1) {
776
+ throw new Error(`Expected valid country, got ${country || "undefined"}`);
777
+ }
778
+
779
+ if (!lang || COUNTRY_LANGS[country].indexOf(lang) === -1) {
780
+ throw new Error(`Expected valid lang, got ${lang || "undefined"}`);
781
+ }
782
+
783
+ if (remembered.some((source) => FUNDING_SOURCES.indexOf(source) === -1)) {
784
+ throw new Error(
785
+ `Expected valid funding sources, got ${JSON.stringify(remembered)}`
786
+ );
787
+ }
788
+
789
+ if (ENVS.indexOf(env) === -1) {
790
+ throw new Error(`Expected valid env, got ${env || "undefined"}`);
791
+ }
792
+
793
+ if (!fundingEligibility) {
794
+ throw new Error(`Expected fundingEligibility`);
795
+ }
796
+
797
+ if (PLATFORMS.indexOf(platform) === -1) {
798
+ throw new Error(`Expected valid platform, got ${platform || "undefined"}`);
799
+ }
800
+
801
+ if (fundingSource) {
802
+ if (SUPPORTED_FUNDING_SOURCES.indexOf(fundingSource) === -1) {
803
+ throw new Error(`Invalid funding source: ${fundingSource}`);
633
804
  }
634
805
 
635
- let {
636
- clientID,
806
+ if (
807
+ !isFundingEligible(fundingSource, {
808
+ platform,
637
809
  fundingSource,
638
- style = getDefaultStyle(),
639
- remembered = [],
640
- locale = DEFAULT_PROPS.LOCALE,
641
- env = DEFAULT_PROPS.ENV,
642
- platform = DEFAULT_PROPS.PLATFORM,
643
- commit = DEFAULT_PROPS.COMMIT,
644
810
  fundingEligibility,
645
- sessionID = uniqueID(),
646
- buttonSessionID = uniqueID(),
647
- components = [ COMPONENTS.BUTTONS ],
648
- nonce,
811
+ components,
649
812
  onShippingChange,
650
813
  onShippingAddressChange,
651
814
  onShippingOptionsChange,
652
- personalization,
653
- clientAccessToken,
654
- content,
655
815
  wallet,
656
- flow = BUTTON_FLOW.PURCHASE,
657
- experiment = getDefaultExperiment(),
658
- vault,
659
- userIDToken,
660
- applePay,
661
- applePaySupport = false,
662
- supportsPopups = false,
663
- supportedNativeBrowser = false,
664
- experience = '',
665
- showPayLabel = true
666
- } = props;
667
-
668
- const { country, lang } = locale;
669
-
670
- if (!country || COUNTRIES.indexOf(country) === -1) {
671
- throw new Error(`Expected valid country, got ${ country || 'undefined' }`);
816
+ flow,
817
+ applePaySupport,
818
+ supportsPopups,
819
+ supportedNativeBrowser,
820
+ })
821
+ ) {
822
+ throw new Error(`Funding Source not eligible: ${fundingSource}`);
672
823
  }
673
-
674
- if (!lang || COUNTRY_LANGS[country].indexOf(lang) === -1) {
675
- throw new Error(`Expected valid lang, got ${ lang || 'undefined' }`);
676
- }
677
-
678
- if (remembered.some(source => FUNDING_SOURCES.indexOf(source) === -1)) {
679
- throw new Error(`Expected valid funding sources, got ${ JSON.stringify(remembered) }`);
680
- }
681
-
682
- if (ENVS.indexOf(env) === -1) {
683
- throw new Error(`Expected valid env, got ${ env || 'undefined' }`);
684
- }
685
-
686
- if (!fundingEligibility) {
687
- throw new Error(`Expected fundingEligibility`);
688
- }
689
-
690
- if (PLATFORMS.indexOf(platform) === -1) {
691
- throw new Error(`Expected valid platform, got ${ platform || 'undefined' }`);
692
- }
693
-
694
- if (fundingSource) {
695
- if (SUPPORTED_FUNDING_SOURCES.indexOf(fundingSource) === -1) {
696
- throw new Error(`Invalid funding source: ${ fundingSource }`);
697
- }
698
-
699
- if (!isFundingEligible(fundingSource, { platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, wallet, flow, applePaySupport, supportsPopups, supportedNativeBrowser })) {
700
- throw new Error(`Funding Source not eligible: ${ fundingSource }`);
701
- }
702
- }
703
-
704
- style = normalizeButtonStyle(props, style);
705
-
706
- return { clientID, fundingSource, style, locale, remembered, env, fundingEligibility, platform, clientAccessToken,
707
- buttonSessionID, commit, sessionID, nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, content, wallet, flow,
708
- experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience, showPayLabel };
824
+ }
825
+
826
+ style = normalizeButtonStyle(props, style);
827
+
828
+ return {
829
+ clientID,
830
+ fundingSource,
831
+ style,
832
+ locale,
833
+ remembered,
834
+ env,
835
+ fundingEligibility,
836
+ platform,
837
+ clientAccessToken,
838
+ buttonSessionID,
839
+ commit,
840
+ sessionID,
841
+ nonce,
842
+ components,
843
+ onShippingChange,
844
+ onShippingAddressChange,
845
+ onShippingOptionsChange,
846
+ personalization,
847
+ content,
848
+ wallet,
849
+ flow,
850
+ experiment,
851
+ vault,
852
+ userIDToken,
853
+ applePay,
854
+ applePaySupport,
855
+ supportsPopups,
856
+ supportedNativeBrowser,
857
+ experience,
858
+ showPayLabel,
859
+ };
709
860
  }