@paypal/checkout-components 5.0.222 → 5.0.225

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.222",
3
+ "version": "5.0.225",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -6,7 +6,7 @@ import { SUPPORTED_FUNDING_SOURCES } from '@paypal/funding-components/src';
6
6
 
7
7
  import type { Wallet, Experiment } from '../types';
8
8
  import { BUTTON_LAYOUT, BUTTON_FLOW } from '../constants';
9
- import type { OnShippingChange } from '../ui/buttons/props';
9
+ import type { OnShippingChange, OnShippingAddressChange, OnShippingOptionsChange } from '../ui/buttons/props';
10
10
 
11
11
  import { getFundingConfig } from './config';
12
12
 
@@ -18,6 +18,8 @@ type IsFundingEligibleOptions = {|
18
18
  fundingEligibility : FundingEligibilityType,
19
19
  components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
20
20
  onShippingChange : ?Function,
21
+ onShippingAddressChange : ?Function,
22
+ onShippingOptionsChange : ?Function,
21
23
  wallet? : ?Wallet,
22
24
  applePaySupport : boolean,
23
25
  supportsPopups : boolean,
@@ -26,7 +28,7 @@ type IsFundingEligibleOptions = {|
26
28
  |};
27
29
 
28
30
  export function isFundingEligible(source : $Values<typeof FUNDING>,
29
- { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment } : IsFundingEligibleOptions) : boolean {
31
+ { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment } : IsFundingEligibleOptions) : boolean {
30
32
 
31
33
  if (!fundingEligibility[source] || !fundingEligibility[source].eligible) {
32
34
  return false;
@@ -78,7 +80,7 @@ export function isFundingEligible(source : $Values<typeof FUNDING>,
78
80
  }
79
81
  }
80
82
 
81
- if (fundingConfig.shippingChange === false && onShippingChange) {
83
+ if (fundingConfig.shippingChange === false && (onShippingChange || onShippingAddressChange || onShippingOptionsChange)) {
82
84
  return false;
83
85
  }
84
86
 
@@ -89,17 +91,17 @@ export function isFundingEligible(source : $Values<typeof FUNDING>,
89
91
  return true;
90
92
  }
91
93
 
92
- export function determineEligibleFunding({ fundingSource, layout, platform, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment } :
94
+ export function determineEligibleFunding({ fundingSource, layout, platform, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment } :
93
95
  {| fundingSource : ?$Values<typeof FUNDING>, remembered : $ReadOnlyArray<$Values<typeof FUNDING>>, layout : $Values<typeof BUTTON_LAYOUT>,
94
96
  platform : $Values<typeof PLATFORM>, fundingEligibility : FundingEligibilityType, components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
95
- onShippingChange? : ?Function, flow : $Values<typeof BUTTON_FLOW>, wallet? : ?Wallet, applePaySupport : boolean, supportsPopups : boolean, supportedNativeBrowser : boolean, experiment : Experiment |}) : $ReadOnlyArray<$Values<typeof FUNDING>> {
97
+ onShippingChange? : ?Function, onShippingAddressChange? : ?Function, onShippingOptionsChange? : ?Function, flow : $Values<typeof BUTTON_FLOW>, wallet? : ?Wallet, applePaySupport : boolean, supportsPopups : boolean, supportedNativeBrowser : boolean, experiment : Experiment |}) : $ReadOnlyArray<$Values<typeof FUNDING>> {
96
98
 
97
99
  if (fundingSource) {
98
100
  return [ fundingSource ];
99
101
  }
100
102
 
101
103
  let eligibleFunding = SUPPORTED_FUNDING_SOURCES.filter(source =>
102
- isFundingEligible(source, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment }));
104
+ isFundingEligible(source, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment }));
103
105
 
104
106
  if (layout === BUTTON_LAYOUT.HORIZONTAL) {
105
107
  eligibleFunding = eligibleFunding.slice(0, 2);
@@ -110,12 +112,12 @@ export function determineEligibleFunding({ fundingSource, layout, platform, fund
110
112
  return eligibleFunding;
111
113
  }
112
114
 
113
- export function isWalletFundingEligible({ wallet, onShippingChange } : {| wallet : ?Wallet, onShippingChange : ?OnShippingChange |}) : boolean {
115
+ export function isWalletFundingEligible({ wallet, onShippingChange, onShippingAddressChange, onShippingOptionsChange } : {| wallet : ?Wallet, onShippingChange : ?OnShippingChange, onShippingAddressChange : ?OnShippingAddressChange, onShippingOptionsChange : ?OnShippingOptionsChange |}) : boolean {
114
116
  if (!wallet) {
115
117
  return false;
116
118
  }
117
119
 
118
- if (onShippingChange) {
120
+ if (onShippingChange || onShippingAddressChange || onShippingOptionsChange) {
119
121
  return false;
120
122
  }
121
123
 
@@ -8,7 +8,7 @@ import { PLATFORM, FUNDING } from '@paypal/sdk-constants/src';
8
8
  import { getRememberedFunding } from '@paypal/funding-components/src';
9
9
  import { getComponents, getFundingEligibility, getEnv } from '@paypal/sdk-client/src';
10
10
 
11
- import type { OnShippingChange } from '../ui/buttons/props';
11
+ import type { OnShippingChange, OnShippingAddressChange, OnShippingOptionsChange } from '../ui/buttons/props';
12
12
  import { BUTTON_LAYOUT, BUTTON_FLOW } from '../constants';
13
13
  import { determineEligibleFunding, isFundingEligible } from '../funding';
14
14
  import { isSupportedNativeBrowser, getVenmoExperiment } from '../zoid/buttons/util';
@@ -24,13 +24,15 @@ type MarksInstance = {|
24
24
 
25
25
  type MarksProps = {|
26
26
  fundingSource? : ?$Values<typeof FUNDING>,
27
- onShippingChange? : OnShippingChange
27
+ onShippingChange? : OnShippingChange,
28
+ onShippingAddressChange? : OnShippingAddressChange,
29
+ onShippingOptionsChange? : OnShippingOptionsChange
28
30
  |};
29
31
 
30
32
  export type MarksComponent = (MarksProps) => MarksInstance;
31
33
 
32
34
  export const getMarksComponent : () => MarksComponent = memoize(() => {
33
- function Marks({ fundingSource, onShippingChange } : MarksProps = {}) : MarksInstance {
35
+ function Marks({ fundingSource, onShippingChange, onShippingAddressChange, onShippingOptionsChange } : MarksProps = {}) : MarksInstance {
34
36
 
35
37
  const height = DEFAULT_HEIGHT;
36
38
  const fundingEligibility = getFundingEligibility();
@@ -51,7 +53,7 @@ export const getMarksComponent : () => MarksComponent = memoize(() => {
51
53
  return true;
52
54
  }
53
55
 
54
- return isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
56
+ return isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
55
57
  };
56
58
 
57
59
  const render = (container) => {
@@ -13,7 +13,7 @@ import { getFundingConfig } from '../../funding';
13
13
  import { DesignExperimentLabel } from '../../funding/paypal/template';
14
14
 
15
15
  import { getButtonDesign } from './buttonDesigns';
16
- import type { ButtonStyle, Personalization, OnShippingChange } from './props';
16
+ import type { ButtonStyle, Personalization, OnShippingChange, OnShippingAddressChange, OnShippingOptionsChange } from './props';
17
17
  import { Spinner } from './spinner';
18
18
  import { MenuButton } from './menu-button';
19
19
 
@@ -27,6 +27,8 @@ type IndividualButtonProps = {|
27
27
  wallet? : ?Wallet,
28
28
  fundingEligibility : FundingEligibilityType,
29
29
  onShippingChange : ?OnShippingChange,
30
+ onShippingAddressChange : ?OnShippingAddressChange,
31
+ onShippingOptionsChange : ?OnShippingOptionsChange,
30
32
  i : number,
31
33
  nonce : string,
32
34
  userIDToken : ?string,
@@ -12,7 +12,7 @@ import { ValidationError } from '../../lib';
12
12
 
13
13
  import { getButtonDesign } from './buttonDesigns';
14
14
  import { ButtonDesignExperimentScriptWrapper } from './buttonDesigns/script';
15
- import { normalizeButtonProps, type ButtonPropsInputs, type OnShippingChange } from './props';
15
+ import { normalizeButtonProps, type ButtonPropsInputs, type OnShippingChange, type OnShippingAddressChange, type OnShippingOptionsChange } from './props';
16
16
  import { Style } from './style';
17
17
  import { Button } from './button';
18
18
  import { TagLine } from './tagline';
@@ -22,11 +22,13 @@ import { PoweredByPayPal } from './poweredBy';
22
22
  type GetWalletInstrumentOptions = {|
23
23
  wallet : ?Wallet,
24
24
  fundingSource : $Values<typeof FUNDING>,
25
- onShippingChange : ?OnShippingChange
25
+ onShippingChange : ?OnShippingChange,
26
+ onShippingAddressChange : ?OnShippingAddressChange,
27
+ onShippingOptionsChange : ?OnShippingOptionsChange
26
28
  |};
27
29
 
28
- function getWalletInstrument({ wallet, fundingSource, onShippingChange } : GetWalletInstrumentOptions) : ?WalletInstrument {
29
- if (!isWalletFundingEligible({ wallet, onShippingChange })) {
30
+ function getWalletInstrument({ wallet, fundingSource, onShippingChange, onShippingAddressChange, onShippingOptionsChange } : GetWalletInstrumentOptions) : ?WalletInstrument {
31
+ if (!isWalletFundingEligible({ wallet, onShippingChange, onShippingAddressChange, onShippingOptionsChange })) {
30
32
  return;
31
33
  }
32
34
 
@@ -48,14 +50,16 @@ type GetWalletInstrumentsOptions = {|
48
50
  wallet : ?Wallet,
49
51
  fundingSources : $ReadOnlyArray<$Values<typeof FUNDING>>,
50
52
  onShippingChange : ?OnShippingChange,
53
+ onShippingAddressChange : ?OnShippingAddressChange,
54
+ onShippingOptionsChange : ?OnShippingOptionsChange,
51
55
  layout : $Values<typeof BUTTON_LAYOUT>
52
56
  |};
53
57
 
54
- function getWalletInstruments({ wallet, layout, fundingSources, onShippingChange } : GetWalletInstrumentsOptions) : {| [$Values<typeof FUNDING>] : WalletInstrument |} {
58
+ function getWalletInstruments({ wallet, layout, fundingSources, onShippingChange, onShippingAddressChange, onShippingOptionsChange } : GetWalletInstrumentsOptions) : {| [$Values<typeof FUNDING>] : WalletInstrument |} {
55
59
 
56
60
  const instruments = {};
57
61
  for (const source of fundingSources) {
58
- const instrument = getWalletInstrument({ wallet, fundingSource: source, onShippingChange });
62
+ const instrument = getWalletInstrument({ wallet, fundingSource: source, onShippingChange, onShippingAddressChange, onShippingOptionsChange });
59
63
 
60
64
  if (instrument) {
61
65
  instruments[source] = instrument;
@@ -99,10 +103,11 @@ export function validateButtonProps(props : ButtonPropsInputs) {
99
103
  export function Buttons(props : ButtonsProps) : ElementNode {
100
104
  const { onClick = noop } = props;
101
105
  const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
102
- nonce, components, onShippingChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
106
+ nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
103
107
  supportsPopups, supportedNativeBrowser, experience } = normalizeButtonProps(props);
104
108
  const { custom, layout, shape, tagline } = style;
105
- const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label;
109
+
110
+ const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label && custom.label.length !== 0;
106
111
 
107
112
  let fundingSources = determineEligibleFunding({ fundingSource, layout, remembered, platform, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
108
113
  const multiple = fundingSources.length > 1;
@@ -119,7 +124,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
119
124
  }
120
125
  }
121
126
 
122
- const instruments = getWalletInstruments({ wallet, fundingSources, layout, onShippingChange });
127
+ const instruments = getWalletInstruments({ wallet, fundingSources, layout, onShippingChange, onShippingAddressChange, onShippingOptionsChange });
123
128
 
124
129
  const isWallet = (
125
130
  flow === BUTTON_FLOW.PURCHASE &&
@@ -171,6 +176,8 @@ export function Buttons(props : ButtonsProps) : ElementNode {
171
176
  fundingEligibility={ fundingEligibility }
172
177
  wallet={ wallet }
173
178
  onShippingChange={ onShippingChange }
179
+ onShippingAddressChange={ onShippingAddressChange }
180
+ onShippingOptionsChange={ onShippingOptionsChange }
174
181
  onClick={ onClick }
175
182
  userIDToken={ userIDToken }
176
183
  personalization={ personalization }
@@ -5,7 +5,7 @@ import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
5
5
  import { values, uniqueID } from '@krakenjs/belter/src';
6
6
  import { type OrderCreateRequest, type FundingEligibilityType,
7
7
  type OrderGetResponse, type OrderCaptureResponse, type OrderAuthorizeResponse } from '@paypal/sdk-client/src';
8
- import { FUNDING, PLATFORM, INTENT, COMMIT, VAULT,
8
+ import { CURRENCY, FUNDING, PLATFORM, INTENT, COMMIT, VAULT,
9
9
  ENV, COUNTRY, LANG, COUNTRY_LANGS, type LocaleType, CARD, COMPONENTS } from '@paypal/sdk-constants/src';
10
10
  import { type CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
11
11
  import { LOGO_COLOR } from '@paypal/sdk-logos/src';
@@ -81,7 +81,8 @@ type OnShippingChangeAddress = {|
81
81
  postal_code : string
82
82
  |};
83
83
 
84
- type OnShippingChangeMethod = {|
84
+ type OnShippingChangeOption = {|
85
+ id? : string,
85
86
  label : string,
86
87
  type : string,
87
88
  amount : {|
@@ -90,12 +91,98 @@ type OnShippingChangeMethod = {|
90
91
  |}
91
92
  |};
92
93
 
94
+ export type ON_SHIPPING_CHANGE_EVENT = 'add' | 'replace';
95
+
96
+ 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
+ |}
105
+ |};
106
+
107
+ export type Query = {|
108
+ op : ON_SHIPPING_CHANGE_EVENT,
109
+ path : string,
110
+ value : mixed
111
+ |};
112
+
113
+ export type Breakdown = {|
114
+ item_total? : {|
115
+ currency_code : $Values<typeof CURRENCY>,
116
+ value : string
117
+ |},
118
+ shipping? : {|
119
+ currency_code : $Values<typeof CURRENCY>,
120
+ value : string
121
+ |},
122
+ handling? : {|
123
+ currency_code : $Values<typeof CURRENCY>,
124
+ value : string
125
+ |},
126
+ tax_total? : {|
127
+ currency_code : $Values<typeof CURRENCY>,
128
+ value : string
129
+ |},
130
+ insurance? : {|
131
+ currency_code : $Values<typeof CURRENCY>,
132
+ value : string
133
+ |},
134
+ shipping_discount? : {|
135
+ currency_code : $Values<typeof CURRENCY>,
136
+ value : string
137
+ |},
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
+ |}
174
+ |},
175
+ currency_code : $Values<typeof CURRENCY>,
176
+ value : string
177
+ |};
178
+
93
179
  export type OnShippingChangeData = {|
94
180
  orderID : string,
95
181
  payerID : string,
96
182
  paymentID? : string,
97
183
  shipping_address : OnShippingChangeAddress,
98
- selected_shipping_method : OnShippingChangeMethod
184
+ selected_shipping_option : OnShippingChangeOption,
185
+ amount? : ShippingAmount,
99
186
  |};
100
187
 
101
188
  export type OnShippingChangeActions = {|
@@ -106,6 +193,41 @@ export type OnShippingChangeActions = {|
106
193
 
107
194
  export type OnShippingChange = (data : OnShippingChangeData, actions : OnShippingChangeActions) => ZalgoPromise<void> | void;
108
195
 
196
+ 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
203
+ |};
204
+
205
+ 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;
214
+
215
+ export type OnShippingOptionsChangeData = {|
216
+ orderID : string,
217
+ payerID : string,
218
+ paymentID? : string,
219
+ selected_shipping_option : OnShippingChangeOption
220
+ |};
221
+ 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;
230
+
109
231
  export type OnCancelData = {|
110
232
  orderID : string,
111
233
  paymentID? : string
@@ -257,6 +379,8 @@ export type RenderButtonProps = {|
257
379
  nonce : string,
258
380
  components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
259
381
  onShippingChange : ?OnShippingChange,
382
+ onShippingAddressChange : ?OnShippingAddressChange,
383
+ onShippingOptionsChange : ?OnShippingOptionsChange,
260
384
  personalization : ?Personalization,
261
385
  clientAccessToken : ?string,
262
386
  content? : ContentType,
@@ -306,6 +430,8 @@ export type ButtonProps = {|
306
430
  sessionID : string,
307
431
  buttonSessionID : string,
308
432
  onShippingChange : ?OnShippingChange,
433
+ onShippingAddressChange : ?OnShippingAddressChange,
434
+ onShippingOptionsChange : ?OnShippingOptionsChange,
309
435
  clientAccessToken? : ?string,
310
436
  nonce : string,
311
437
  merchantID? : $ReadOnlyArray<string>,
@@ -344,6 +470,8 @@ export type ButtonPropsInputs = {
344
470
  nonce : string,
345
471
  components : $ReadOnlyArray<$Values<typeof COMPONENTS>>,
346
472
  onShippingChange : ?Function,
473
+ onShippingAddressChange : ?Function,
474
+ onShippingOptionsChange : ?Function,
347
475
  personalization? : Personalization,
348
476
  clientAccessToken? : ?string,
349
477
  wallet? : ?Wallet,
@@ -515,6 +643,8 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
515
643
  components = [ COMPONENTS.BUTTONS ],
516
644
  nonce,
517
645
  onShippingChange,
646
+ onShippingAddressChange,
647
+ onShippingOptionsChange,
518
648
  personalization,
519
649
  clientAccessToken,
520
650
  content,
@@ -561,7 +691,7 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
561
691
  throw new Error(`Invalid funding source: ${ fundingSource }`);
562
692
  }
563
693
 
564
- if (!isFundingEligible(fundingSource, { platform, fundingSource, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser })) {
694
+ if (!isFundingEligible(fundingSource, { platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, wallet, flow, applePaySupport, supportsPopups, supportedNativeBrowser })) {
565
695
  throw new Error(`Funding Source not eligible: ${ fundingSource }`);
566
696
  }
567
697
  }
@@ -569,6 +699,6 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
569
699
  style = normalizeButtonStyle(props, style);
570
700
 
571
701
  return { clientID, fundingSource, style, locale, remembered, env, fundingEligibility, platform, clientAccessToken,
572
- buttonSessionID, commit, sessionID, nonce, components, onShippingChange, personalization, content, wallet, flow,
702
+ buttonSessionID, commit, sessionID, nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, content, wallet, flow,
573
703
  experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience };
574
704
  }
@@ -107,6 +107,8 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
107
107
  const {
108
108
  fundingSource,
109
109
  onShippingChange,
110
+ onShippingAddressChange,
111
+ onShippingOptionsChange,
110
112
  style = {},
111
113
  fundingEligibility = getRefinedFundingEligibility(),
112
114
  supportsPopups = userAgentSupportsPopups(),
@@ -133,7 +135,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
133
135
  const platform = getPlatform();
134
136
  const components = getComponents();
135
137
 
136
- if (isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment })) {
138
+ if (isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment })) {
137
139
  return {
138
140
  eligible: true
139
141
  };
@@ -163,7 +165,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
163
165
  required: false,
164
166
 
165
167
  validate: ({ props }) => {
166
- const { fundingSource, onShippingChange, style = {}, fundingEligibility = getRefinedFundingEligibility(),
168
+ const { fundingSource, onShippingChange, onShippingAddressChange, onShippingOptionsChange, style = {}, fundingEligibility = getRefinedFundingEligibility(),
167
169
  applePaySupport, supportsPopups, supportedNativeBrowser, createBillingAgreement, createSubscription } = props;
168
170
 
169
171
  const flow = determineFlow({ createBillingAgreement, createSubscription });
@@ -172,7 +174,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
172
174
  const platform = getPlatform();
173
175
  const components = getComponents();
174
176
 
175
- if (fundingSource && !isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser })) {
177
+ if (fundingSource && !isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser })) {
176
178
  throw new Error(`${ fundingSource } is not eligible`);
177
179
  }
178
180
  }
@@ -258,6 +260,24 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
258
260
  }
259
261
  },
260
262
 
263
+ onShippingAddressChange: {
264
+ type: 'function',
265
+ required: false,
266
+ queryParam: true,
267
+ queryValue: ({ value }) => {
268
+ return value ? QUERY_BOOL.TRUE : QUERY_BOOL.FALSE;
269
+ }
270
+ },
271
+
272
+ onShippingOptionsChange: {
273
+ type: 'function',
274
+ required: false,
275
+ queryParam: true,
276
+ queryValue: ({ value }) => {
277
+ return value ? QUERY_BOOL.TRUE : QUERY_BOOL.FALSE;
278
+ }
279
+ },
280
+
261
281
  onCancel: {
262
282
  type: 'function',
263
283
  required: false
@@ -651,12 +671,45 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
651
671
  required: false,
652
672
  type: 'string',
653
673
  value: ({ props }) => {
654
- const { commit, createBillingAgreement, currency, disableFunding = [], fundingEligibility, locale, merchantID = [], style: { layout }, vault } = props || {};
674
+ const { env, clientID, merchantID, commit, createBillingAgreement, currency, disableFunding = [], experience, fundingEligibility, locale, style: { layout }, vault } = props || {};
675
+
676
+ if (experience === 'inline') {
677
+ return EXPERIENCE.INLINE;
678
+ }
655
679
 
656
680
  const inlineCheckoutEligibility : InlineXOEligibilityType = __INLINE_CHECKOUT_ELIGIBILITY__ || {
657
681
  eligible: false
658
682
  };
659
- return inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && isInlineXOEligible({ props: {
683
+
684
+ let alphaEligible = true;
685
+ if (env === 'sandbox') {
686
+ const validMerchantIDs = [
687
+ 'PJEHAEK4YBEDJ',
688
+ 'RMADGM9SZGSPJ',
689
+ '5AZBQ2LU7HVE6',
690
+ 'SMJKX2JD3V27L',
691
+ 'RB28JB2TP9RA4'
692
+ ];
693
+ const eligibleMerchantID = merchantID && merchantID.length && merchantID.reduce((acc, id) => {
694
+ return acc && validMerchantIDs.indexOf(id) !== -1;
695
+ }, true);
696
+
697
+ alphaEligible = clientID === 'AbUf2xGyVtp8HedZjyx9we1V2eRV9-Q7bLTVfr9Y-FFpG8dbWAaQ0AFqeh2dq_HYHrV_1GUPXGv6GMKp'
698
+ && eligibleMerchantID;
699
+ } else if (env === 'production') {
700
+ const validMerchantIDs = [
701
+ 'G4Z8SJD6PEZ2G'
702
+ ];
703
+
704
+ const eligibleMerchantID = merchantID && merchantID.length && merchantID.reduce((acc, id) => {
705
+ return acc && validMerchantIDs.indexOf(id) !== -1;
706
+ }, true);
707
+
708
+ alphaEligible = clientID === 'AT2hsh6PFa_pvqYVni64Ik2Ojaluh_l9DU3KwXuHb-sgj8q9zZrmob2TUsmvu4rjJ869oHUAlIAqJf9R'
709
+ && eligibleMerchantID;
710
+ }
711
+
712
+ return inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && alphaEligible && isInlineXOEligible({ props: {
660
713
  commit,
661
714
  createBillingAgreement,
662
715
  currency,
@@ -664,7 +717,6 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
664
717
  fundingEligibility,
665
718
  layout,
666
719
  locale,
667
- merchantID,
668
720
  vault
669
721
  } }) ? EXPERIENCE.INLINE : '';
670
722
  }
@@ -151,7 +151,7 @@ export function getVenmoAppLabelExperiment() : EligibilityExperiment {
151
151
  }
152
152
 
153
153
  export function getRenderedButtons(props : ButtonProps) : $ReadOnlyArray<$Values<typeof FUNDING>> {
154
- const { fundingSource, onShippingChange, style = {}, fundingEligibility = getRefinedFundingEligibility(),
154
+ const { fundingSource, onShippingChange, onShippingAddressChange, onShippingOptionsChange, style = {}, fundingEligibility = getRefinedFundingEligibility(),
155
155
  experiment = getVenmoExperiment(), applePaySupport, supportsPopups = userAgentSupportsPopups(),
156
156
  supportedNativeBrowser = isSupportedNativeBrowser(), createBillingAgreement, createSubscription } = props;
157
157
 
@@ -161,7 +161,7 @@ export function getRenderedButtons(props : ButtonProps) : $ReadOnlyArray<$Values
161
161
  const platform = getPlatform();
162
162
  const components = getComponents();
163
163
 
164
- const renderedButtons = determineEligibleFunding({ fundingSource, remembered, layout, platform, fundingEligibility, components, onShippingChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
164
+ const renderedButtons = determineEligibleFunding({ fundingSource, remembered, layout, platform, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
165
165
  return renderedButtons;
166
166
  }
167
167
 
@@ -306,11 +306,12 @@ type InlineCheckoutEligibilityProps = {|
306
306
  layout : $Values<typeof BUTTON_LAYOUT>,
307
307
  locale : LocaleType,
308
308
  merchantID? : $ReadOnlyArray<string>,
309
+ onComplete? : Function,
309
310
  vault : boolean
310
311
  |};
311
312
 
312
313
  export function isInlineXOEligible({ props } : {| props : InlineCheckoutEligibilityProps |}) : boolean {
313
- const { commit, currency, createBillingAgreement, disableFunding, fundingEligibility, layout, locale, merchantID, vault } = props;
314
+ const { commit, currency, createBillingAgreement, disableFunding, fundingEligibility, layout, locale, vault } = props;
314
315
 
315
316
  const isEligible = (
316
317
  locale.country === COUNTRY.US &&
@@ -320,7 +321,6 @@ export function isInlineXOEligible({ props } : {| props : InlineCheckoutEligibil
320
321
  (disableFunding?.indexOf(FUNDING.CARD) === -1) &&
321
322
  (fundingEligibility?.card?.eligible || false) &&
322
323
  layout === BUTTON_LAYOUT.VERTICAL &&
323
- merchantID?.length === 0 &&
324
324
  vault === false
325
325
  );
326
326
 
@@ -201,6 +201,16 @@ export function getCheckoutComponent() : CheckoutComponent {
201
201
  type: 'function',
202
202
  required: false
203
203
  },
204
+
205
+ onShippingAddressChange: {
206
+ type: 'function',
207
+ required: false
208
+ },
209
+
210
+ onShippingOptionsChange: {
211
+ type: 'function',
212
+ required: false
213
+ },
204
214
 
205
215
  clientMetadataID: {
206
216
  type: 'string',