@paypal/checkout-components 5.0.256 → 5.0.257

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