@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.
- package/README.md +8 -0
- package/__sdk__.js +76 -76
- package/dist/button.js +1 -1
- package/globals.js +28 -30
- package/package.json +6 -4
- package/src/actions/save/index.js +17 -12
- package/src/constants/button.js +36 -36
- package/src/constants/class.js +32 -30
- package/src/constants/index.js +3 -3
- package/src/constants/misc.js +14 -12
- package/src/declarations.js +19 -19
- package/src/funding/applepay/config.jsx +51 -50
- package/src/funding/applepay/index.js +1 -1
- package/src/funding/applepay/style.scoped.scss +1 -1
- package/src/funding/applepay/template.jsx +16 -11
- package/src/funding/bancontact/config.jsx +48 -37
- package/src/funding/bancontact/index.js +1 -2
- package/src/funding/blik/config.jsx +48 -37
- package/src/funding/blik/index.js +1 -2
- package/src/funding/boleto/config.jsx +50 -39
- package/src/funding/boleto/index.js +1 -2
- package/src/funding/card/amex/config.js +9 -8
- package/src/funding/card/amex/index.js +1 -2
- package/src/funding/card/config.jsx +246 -177
- package/src/funding/card/discover/config.js +9 -7
- package/src/funding/card/discover/index.js +1 -2
- package/src/funding/card/elo/config.js +6 -7
- package/src/funding/card/elo/index.js +1 -2
- package/src/funding/card/hiper/config.js +9 -7
- package/src/funding/card/hiper/index.js +1 -2
- package/src/funding/card/index.js +1 -1
- package/src/funding/card/jcb/config.js +6 -7
- package/src/funding/card/jcb/index.js +1 -2
- package/src/funding/card/mastercard/config.js +9 -7
- package/src/funding/card/mastercard/index.js +1 -2
- package/src/funding/card/visa/config.js +9 -7
- package/src/funding/card/visa/index.js +1 -2
- package/src/funding/common.jsx +242 -216
- package/src/funding/config.js +212 -65
- package/src/funding/content.jsx +1946 -337
- package/src/funding/credit/config.jsx +74 -57
- package/src/funding/credit/index.js +1 -2
- package/src/funding/eps/config.jsx +45 -37
- package/src/funding/eps/index.js +1 -2
- package/src/funding/funding.js +193 -100
- package/src/funding/giropay/config.jsx +48 -38
- package/src/funding/giropay/index.js +1 -2
- package/src/funding/ideal/config.jsx +48 -37
- package/src/funding/ideal/index.js +1 -2
- package/src/funding/index.js +2 -2
- package/src/funding/itau/config.jsx +41 -41
- package/src/funding/itau/index.js +1 -1
- package/src/funding/maxima/config.jsx +25 -19
- package/src/funding/maxima/index.js +1 -2
- package/src/funding/mercadopago/config.jsx +48 -37
- package/src/funding/mercadopago/index.js +1 -2
- package/src/funding/multibanco/config.jsx +50 -39
- package/src/funding/multibanco/index.js +1 -2
- package/src/funding/mybank/config.jsx +48 -37
- package/src/funding/mybank/index.js +1 -2
- package/src/funding/oxxo/config.jsx +50 -39
- package/src/funding/oxxo/index.js +1 -2
- package/src/funding/p24/config.jsx +45 -37
- package/src/funding/p24/index.js +1 -2
- package/src/funding/paidy/config.jsx +50 -39
- package/src/funding/paidy/index.js +1 -1
- package/src/funding/paylater/config.jsx +118 -111
- package/src/funding/paylater/index.js +1 -2
- package/src/funding/paypal/config.jsx +43 -46
- package/src/funding/paypal/index.js +1 -2
- package/src/funding/paypal/style.scoped.scss +80 -74
- package/src/funding/paypal/template.jsx +450 -354
- package/src/funding/payu/config.jsx +50 -39
- package/src/funding/payu/index.js +1 -1
- package/src/funding/satispay/config.jsx +50 -39
- package/src/funding/satispay/index.js +1 -1
- package/src/funding/sepa/config.jsx +19 -13
- package/src/funding/sepa/index.js +1 -2
- package/src/funding/sofort/config.jsx +48 -37
- package/src/funding/sofort/index.js +1 -2
- package/src/funding/trustly/config.jsx +50 -39
- package/src/funding/trustly/index.js +1 -2
- package/src/funding/venmo/config.jsx +80 -75
- package/src/funding/venmo/index.js +1 -2
- package/src/funding/venmo/style.scoped.scss +30 -32
- package/src/funding/venmo/template.jsx +56 -57
- package/src/funding/verkkopankki/config.jsx +50 -39
- package/src/funding/verkkopankki/index.js +1 -1
- package/src/funding/wechatpay/config.jsx +48 -37
- package/src/funding/wechatpay/index.js +1 -2
- package/src/funding/zimpler/config.jsx +19 -13
- package/src/funding/zimpler/index.js +1 -2
- package/src/interface/actions.js +1 -1
- package/src/interface/button.js +60 -44
- package/src/interface/card-fields.js +11 -8
- package/src/interface/fields.js +7 -4
- package/src/interface/marks.js +4 -4
- package/src/interface/payment-fields.js +7 -4
- package/src/interface/wallet.js +4 -4
- package/src/lib/errors.js +7 -7
- package/src/lib/index.js +5 -5
- package/src/lib/isRTLLanguage.js +3 -3
- package/src/lib/perceived-latency-instrumentation.js +54 -36
- package/src/lib/security.js +21 -17
- package/src/lib/session.js +39 -35
- package/src/marks/component.jsx +114 -65
- package/src/marks/index.js +1 -2
- package/src/marks/template.jsx +79 -65
- package/src/types.js +48 -48
- package/src/ui/buttons/button.jsx +311 -249
- package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
- package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
- package/src/ui/buttons/buttonDesigns/index.js +78 -75
- package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
- package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
- package/src/ui/buttons/buttonDesigns/types.js +6 -7
- package/src/ui/buttons/buttons.jsx +318 -212
- package/src/ui/buttons/config.js +62 -59
- package/src/ui/buttons/content.jsx +304 -119
- package/src/ui/buttons/index.js +1 -1
- package/src/ui/buttons/menu-button/index.js +1 -1
- package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
- package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
- package/src/ui/buttons/poweredBy.jsx +23 -23
- package/src/ui/buttons/props.js +677 -529
- package/src/ui/buttons/script.jsx +182 -160
- package/src/ui/buttons/spinner.jsx +4 -6
- package/src/ui/buttons/style.jsx +15 -14
- package/src/ui/buttons/styles/base.js +24 -16
- package/src/ui/buttons/styles/button.js +24 -22
- package/src/ui/buttons/styles/color.js +118 -118
- package/src/ui/buttons/styles/custom.js +30 -24
- package/src/ui/buttons/styles/index.js +1 -1
- package/src/ui/buttons/styles/labels.js +17 -13
- package/src/ui/buttons/styles/page.js +3 -3
- package/src/ui/buttons/styles/responsive.js +226 -118
- package/src/ui/buttons/tagline.jsx +53 -54
- package/src/ui/chevron.jsx +27 -16
- package/src/ui/index.js +3 -3
- package/src/ui/loading.jsx +25 -18
- package/src/ui/text/index.js +1 -1
- package/src/ui/text/style.scoped.scss +25 -26
- package/src/ui/text/text.jsx +42 -20
- package/src/ui/tracking.jsx +18 -11
- package/src/zoid/buttons/component.jsx +820 -684
- package/src/zoid/buttons/container.jsx +140 -107
- package/src/zoid/buttons/index.js +1 -1
- package/src/zoid/buttons/prerender.jsx +84 -64
- package/src/zoid/buttons/util.js +346 -254
- package/src/zoid/card-fields/component.jsx +581 -549
- package/src/zoid/card-fields/index.js +1 -1
- package/src/zoid/card-fields/prerender.jsx +20 -17
- package/src/zoid/card-form/component.js +155 -141
- package/src/zoid/card-form/index.js +1 -1
- package/src/zoid/checkout/component.jsx +314 -282
- package/src/zoid/checkout/config.js +2 -2
- package/src/zoid/checkout/content.js +190 -154
- package/src/zoid/checkout/hacks.js +31 -28
- package/src/zoid/checkout/index.js +2 -2
- package/src/zoid/checkout/props.js +27 -33
- package/src/zoid/installments/component.jsx +83 -70
- package/src/zoid/installments/index.js +1 -1
- package/src/zoid/installments/props.js +1 -1
- package/src/zoid/menu/component.jsx +53 -48
- package/src/zoid/menu/index.js +1 -1
- package/src/zoid/menu/props.js +1 -3
- package/src/zoid/modal/component.jsx +119 -106
- package/src/zoid/modal/index.js +1 -1
- package/src/zoid/modal/props.js +1 -3
- package/src/zoid/payment-fields/component.jsx +215 -191
- package/src/zoid/payment-fields/container.jsx +73 -64
- package/src/zoid/payment-fields/index.js +1 -1
- package/src/zoid/payment-fields/prerender.jsx +16 -14
- package/src/zoid/payment-fields/props.js +6 -6
- package/src/zoid/qr-code/component.jsx +131 -115
- package/src/zoid/qr-code/container.jsx +74 -68
- package/src/zoid/qr-code/index.js +1 -1
- package/src/zoid/qr-code/prerender.jsx +17 -12
- package/src/zoid/qr-code/types.js +2 -2
- package/src/zoid/wallet/component.jsx +298 -260
- package/src/zoid/wallet/container.jsx +73 -64
- package/src/zoid/wallet/index.js +1 -1
- package/src/zoid/wallet/prerender.jsx +14 -14
- package/src/zoid/wallet/props.js +4 -4
- package/src/lib/getLogoCDNExperiment.js +0 -25
package/src/ui/buttons/props.js
CHANGED
|
@@ -1,39 +1,66 @@
|
|
|
1
1
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
2
2
|
/* @flow */
|
|
3
3
|
|
|
4
|
-
import { ZalgoPromise } from
|
|
5
|
-
import { values, uniqueID } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
order: {|
|
|
51
|
+
create: (OrderCreateRequest) => ZalgoPromise<string>,
|
|
52
|
+
|},
|
|
29
53
|
|};
|
|
30
54
|
|
|
31
|
-
export type CreateOrder = (
|
|
55
|
+
export type CreateOrder = (
|
|
56
|
+
CreateOrderData,
|
|
57
|
+
CreateOrderActions
|
|
58
|
+
) => ZalgoPromise<string> | string;
|
|
32
59
|
|
|
33
60
|
export type OnApproveData = {|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
75
|
+
subscription: {|
|
|
76
|
+
create: (CreateSubscriptionRequest) => ZalgoPromise<string>,
|
|
77
|
+
revise: (CreateSubscriptionRequest) => ZalgoPromise<string>,
|
|
78
|
+
|},
|
|
53
79
|
|};
|
|
54
80
|
|
|
55
|
-
export type CreateSubscription = (
|
|
81
|
+
export type CreateSubscription = (
|
|
82
|
+
CreateSubscriptionData,
|
|
83
|
+
CreateSubscriptionActions
|
|
84
|
+
) => ZalgoPromise<string> | string;
|
|
56
85
|
|
|
57
86
|
export type OnApproveActions = {|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
100
|
+
redirect: (string, CrossDomainWindowType) => ZalgoPromise<void>,
|
|
72
101
|
|};
|
|
73
102
|
|
|
74
|
-
export type OnApprove = (
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
city: string,
|
|
114
|
+
state: string,
|
|
115
|
+
country_code: string,
|
|
116
|
+
postal_code: string,
|
|
82
117
|
|};
|
|
83
118
|
|
|
84
119
|
type OnShippingChangeOption = {|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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 =
|
|
129
|
+
export type ON_SHIPPING_CHANGE_EVENT = "add" | "replace";
|
|
95
130
|
|
|
96
131
|
export type ShippingOption = {|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
143
|
+
op: ON_SHIPPING_CHANGE_EVENT,
|
|
144
|
+
path: string,
|
|
145
|
+
value: mixed,
|
|
111
146
|
|};
|
|
112
147
|
|
|
113
148
|
export type Breakdown = {|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
120
|
-
|
|
185
|
+
shipping?: {|
|
|
186
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
187
|
+
value: string,
|
|
121
188
|
|},
|
|
122
|
-
handling
|
|
123
|
-
|
|
124
|
-
|
|
189
|
+
handling?: {|
|
|
190
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
191
|
+
value: string,
|
|
125
192
|
|},
|
|
126
|
-
tax_total
|
|
127
|
-
|
|
128
|
-
|
|
193
|
+
tax_total?: {|
|
|
194
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
195
|
+
value: string,
|
|
129
196
|
|},
|
|
130
|
-
insurance
|
|
131
|
-
|
|
132
|
-
|
|
197
|
+
insurance?: {|
|
|
198
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
199
|
+
value: string,
|
|
133
200
|
|},
|
|
134
|
-
shipping_discount
|
|
135
|
-
|
|
136
|
-
|
|
201
|
+
shipping_discount?: {|
|
|
202
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
203
|
+
value: string,
|
|
137
204
|
|},
|
|
138
|
-
discount
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
176
|
-
|
|
209
|
+
|},
|
|
210
|
+
currency_code: $Values<typeof CURRENCY>,
|
|
211
|
+
value: string,
|
|
177
212
|
|};
|
|
178
213
|
|
|
179
214
|
export type OnShippingChangeData = {|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
224
|
+
order: {|
|
|
225
|
+
patch: () => ZalgoPromise<OrderGetResponse>,
|
|
226
|
+
|},
|
|
192
227
|
|};
|
|
193
228
|
|
|
194
|
-
export type OnShippingChange = (
|
|
229
|
+
export type OnShippingChange = (
|
|
230
|
+
data: OnShippingChangeData,
|
|
231
|
+
actions: OnShippingChangeActions
|
|
232
|
+
) => ZalgoPromise<void> | void;
|
|
195
233
|
|
|
196
234
|
export type OnShippingAddressChangeData = {|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
261
|
+
orderID: string,
|
|
262
|
+
payerID: string,
|
|
263
|
+
paymentID?: string,
|
|
264
|
+
selected_shipping_option: OnShippingChangeOption,
|
|
220
265
|
|};
|
|
221
266
|
export type OnShippingOptionsChangeActions = {|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
233
|
-
|
|
284
|
+
orderID: string,
|
|
285
|
+
paymentID?: string,
|
|
234
286
|
|};
|
|
235
287
|
|
|
236
288
|
export type OnCancelActions = {|
|
|
237
|
-
|
|
289
|
+
redirect: (string, CrossDomainWindowType) => ZalgoPromise<void>,
|
|
238
290
|
|};
|
|
239
291
|
|
|
240
|
-
export type OnCancel = (
|
|
292
|
+
export type OnCancel = (
|
|
293
|
+
OnCancelData,
|
|
294
|
+
OnCancelActions
|
|
295
|
+
) => ZalgoPromise<void> | void;
|
|
241
296
|
|
|
242
297
|
export type OnClickData = {|
|
|
243
|
-
|
|
244
|
-
|
|
298
|
+
fundingSource: $Values<typeof FUNDING>,
|
|
299
|
+
card?: $Values<typeof CARD>,
|
|
245
300
|
|};
|
|
246
301
|
|
|
247
302
|
export type OnClickActions = {|
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
279
|
-
|
|
333
|
+
logoColor: $Values<typeof LOGO_COLOR>,
|
|
334
|
+
period: ?number,
|
|
280
335
|
|};
|
|
281
336
|
|
|
282
337
|
export type Personalization = {|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
353
|
+
|},
|
|
354
|
+
buttonDesign?: {|
|
|
355
|
+
id: string,
|
|
356
|
+
text: string,
|
|
357
|
+
tracking: {|
|
|
358
|
+
impression: string,
|
|
359
|
+
click: string,
|
|
298
360
|
|},
|
|
299
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
372
|
+
type?: string, // 'final' | 'pending'
|
|
373
|
+
label?: string,
|
|
374
|
+
amount?: string,
|
|
320
375
|
|};
|
|
321
376
|
|
|
322
377
|
export type ApplePayShippingMethod = {|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
378
|
+
label: string,
|
|
379
|
+
detail: string,
|
|
380
|
+
amount: string,
|
|
381
|
+
identifier: string,
|
|
327
382
|
|};
|
|
328
383
|
|
|
329
384
|
export type ApplePayShippingContactUpdate = {|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
338
|
-
|
|
392
|
+
newTotal: ApplePayLineItem,
|
|
393
|
+
newLineItems?: $ReadOnlyArray<ApplePayLineItem>,
|
|
339
394
|
|};
|
|
340
395
|
|
|
341
396
|
export type ApplePayShippingMethodUpdate = {|
|
|
342
|
-
|
|
343
|
-
|
|
397
|
+
newTotal: ApplePayLineItem,
|
|
398
|
+
newLineItems?: $ReadOnlyArray<ApplePayLineItem>,
|
|
344
399
|
|};
|
|
345
400
|
|
|
346
401
|
export type ApplePayPaymentAuthorizationResult = {|
|
|
347
|
-
|
|
348
|
-
|
|
402
|
+
status: number,
|
|
403
|
+
errors?: $ReadOnlyArray<ApplePayError>,
|
|
349
404
|
|};
|
|
350
405
|
|
|
351
406
|
export type ApplePaySessionConfig = {|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|}
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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 = ()
|
|
516
|
-
|
|
579
|
+
const getDefaultButtonPropsInput = (): ButtonPropsInputs => {
|
|
580
|
+
return {};
|
|
517
581
|
};
|
|
518
582
|
|
|
519
|
-
export function normalizeButtonStyle(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
553
|
-
|
|
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 (
|
|
556
|
-
|
|
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
|
-
|
|
560
|
-
|
|
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
|
-
|
|
564
|
-
|
|
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 (
|
|
568
|
-
|
|
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 (
|
|
572
|
-
|
|
573
|
-
|
|
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 (
|
|
584
|
-
|
|
585
|
-
|
|
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
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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 = ()
|
|
620
|
-
|
|
621
|
-
|
|
720
|
+
const getDefaultStyle = (): ButtonStyleInputs => {
|
|
721
|
+
// $FlowFixMe
|
|
722
|
+
return {};
|
|
622
723
|
};
|
|
623
724
|
|
|
624
|
-
const getDefaultExperiment = ()
|
|
625
|
-
|
|
626
|
-
|
|
725
|
+
const getDefaultExperiment = (): Experiment => {
|
|
726
|
+
// $FlowFixMe
|
|
727
|
+
return {};
|
|
627
728
|
};
|
|
628
729
|
|
|
629
|
-
export function normalizeButtonProps(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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
|
-
|
|
636
|
-
|
|
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
|
-
|
|
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
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
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
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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
|
}
|