@paypal/checkout-components 5.0.240 → 5.0.241-kitty

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.240",
3
+ "version": "5.0.241-kitty",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -94,7 +94,7 @@
94
94
  "@paypal/common-components": "^1.0.33",
95
95
  "@paypal/funding-components": "^1.0.27",
96
96
  "@paypal/sdk-client": "^4.0.166",
97
- "@paypal/sdk-constants": "^1.0.123",
97
+ "@paypal/sdk-constants": "1.0.124-kitty-2",
98
98
  "@paypal/sdk-logos": "^2.0.0"
99
99
  },
100
100
  "lint-staged": {
@@ -1,16 +1,17 @@
1
1
  /* @flow */
2
2
 
3
3
  export const ATTRIBUTE = {
4
- BUTTON: ('data-button' : 'data-button'),
5
- FUNDING_SOURCE: ('data-funding-source' : 'data-funding-source'),
6
- PAYMENT_METHOD_ID: ('data-payment-method-id' : 'data-payment-method-id'),
7
- INSTRUMENT_ID: ('data-instrument-id' : 'data-instrument-id'),
8
- INSTRUMENT_TYPE: ('data-instrument-type' : 'data-instrument-type'),
9
- VERSION: ('data-paypal-smart-button-version' : 'data-paypal-smart-button-version'),
10
- CARD: ('data-card' : 'data-card'),
11
- MENU: ('data-menu' : 'data-menu'),
12
- OPTIONAL: ('optional' : 'optional'),
13
- PAY_NOW: ('data-pay-now' : 'data-pay-now')
4
+ BUTTON: ('data-button' : 'data-button'),
5
+ FUNDING_SOURCE: ('data-funding-source' : 'data-funding-source'),
6
+ PAYMENT_METHOD_ID: ('data-payment-method-id' : 'data-payment-method-id'),
7
+ INSTRUMENT_ID: ('data-instrument-id' : 'data-instrument-id'),
8
+ INSTRUMENT_TYPE: ('data-instrument-type' : 'data-instrument-type'),
9
+ SECONDARY_INSTRUMENT_TYPE: ('data-secondary-instrument-type' : 'data-secondary-instrument-type'),
10
+ VERSION: ('data-paypal-smart-button-version' : 'data-paypal-smart-button-version'),
11
+ CARD: ('data-card' : 'data-card'),
12
+ MENU: ('data-menu' : 'data-menu'),
13
+ OPTIONAL: ('optional' : 'optional'),
14
+ PAY_NOW: ('data-pay-now' : 'data-pay-now')
14
15
  };
15
16
 
16
17
  export const DEFAULT = ('default' : 'default');
@@ -81,7 +81,8 @@ export type WalletLabelOptions = {|
81
81
  vault : boolean,
82
82
  nonce? : ?string,
83
83
  textColor : $Values<typeof TEXT_COLOR>,
84
- fundingSource : $Values<typeof FUNDING>
84
+ fundingSource : $Values<typeof FUNDING>,
85
+ showPayLabel : boolean
85
86
  |};
86
87
 
87
88
  export type TagOptions = {|
@@ -68,6 +68,14 @@
68
68
  margin-left: auto;
69
69
  }
70
70
 
71
+ .show-pay-label {
72
+ all: inherit;
73
+ }
74
+
75
+ .no-pay-label {
76
+ margin: auto;
77
+ }
78
+
71
79
  @media only screen and (max-width: 150px) {
72
80
  text-align: center;
73
81
  display: inline-block;
@@ -234,8 +234,87 @@ export function WalletLabelOld(opts : WalletLabelOptions) : ?ChildType {
234
234
  );
235
235
  }
236
236
 
237
+ function ShowPayLabel(opts) : ?ChildType {
238
+ const {instrument, content, payNow, textColor, logo, label } = opts;
239
+
240
+ return (
241
+ <div class='show-pay-label'>
242
+ <div class='pay-label' optional={ 2 }>
243
+ <Space />
244
+ {
245
+ (instrument && content)
246
+ ? <Text>{ payNow ? content.payNow : content.payWith }</Text>
247
+ : <Text><PlaceHolder chars={ 7 } color={ textColor } /></Text>
248
+ }
249
+ <Space />
250
+ </div>
251
+ <div class='logo' optional={ 1 }>
252
+ {
253
+ (instrument && logo)
254
+ ? logo
255
+ : <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
256
+ }
257
+ </div>
258
+ <div class='label'>
259
+ <Space />
260
+ {
261
+ (instrument && label)
262
+ ? <Text>{ label }</Text>
263
+ : <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
264
+ }
265
+ </div>
266
+ </div>
267
+ );
268
+ }
269
+
270
+ function NoPayLabel(opts) : ?ChildType {
271
+ const { instrument, textColor, logo, label, content } = opts;
272
+
273
+ return (
274
+ <div class='no-pay-label'>
275
+ {
276
+ instrument?.secondaryInstruments?.[0]
277
+ ? (
278
+ <div class='balance'>
279
+ <Text>{ content?.balance } &</Text>
280
+ <Space />
281
+ </div>
282
+ )
283
+ : null
284
+ }
285
+ {
286
+ (instrument?.type === "balance")
287
+ ? (
288
+ <div class='paypal-balance'>
289
+ <Text>{ content?.payPalBalance }</Text>
290
+ </div>
291
+ )
292
+ : (
293
+ <div class='no-paypal-balance'>
294
+ <div class='fi-logo' optional={ 1 }>
295
+ {
296
+ (instrument && logo)
297
+ ? logo
298
+ : <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
299
+ }
300
+ </div>
301
+ <div class='label'>
302
+ <Space />
303
+ {
304
+ (instrument && label)
305
+ ? <Text>{ label }</Text>
306
+ : <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
307
+ }
308
+ </div>
309
+ </div>
310
+ )
311
+ }
312
+ </div>
313
+ );
314
+ }
315
+
237
316
  export function WalletLabel(opts : WalletLabelOptions) : ?ChildType {
238
- const { logoColor, instrument, content, commit, vault, textColor, fundingSource } = opts;
317
+ const { logoColor, instrument, content, commit, vault, textColor, fundingSource, showPayLabel } = opts;
239
318
 
240
319
  if (instrument && !instrument.type) {
241
320
  return WalletLabelOld(opts);
@@ -305,31 +384,24 @@ export function WalletLabel(opts : WalletLabelOptions) : ?ChildType {
305
384
  )
306
385
  : null
307
386
  }
308
-
309
- <div class='pay-label' optional={ 2 }>
310
- <Space />
311
- {
312
- (instrument && content)
313
- ? <Text>{ payNow ? content.payNow : content.payWith }</Text>
314
- : <Text><PlaceHolder chars={ 7 } color={ textColor } /></Text>
315
- }
316
- <Space />
317
- </div>
318
- <div class='logo' optional={ 1 }>
319
- {
320
- (instrument && logo)
321
- ? logo
322
- : <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
323
- }
324
- </div>
325
- <div class='label'>
326
- <Space />
327
- {
328
- (instrument && label)
329
- ? <Text>{ label }</Text>
330
- : <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
331
- }
332
- </div>
387
+ {
388
+ showPayLabel
389
+ ? <ShowPayLabel
390
+ instrument={ instrument }
391
+ content={ content }
392
+ payNow={ payNow }
393
+ textColor={ textColor }
394
+ logo={ logo }
395
+ label={ label }
396
+ />
397
+ : <NoPayLabel
398
+ instrument={ instrument }
399
+ textColor={ textColor }
400
+ logo={ logo }
401
+ label={ label }
402
+ content={ content }
403
+ />
404
+ }
333
405
  </div>
334
406
  </Style>
335
407
  );
package/src/types.js CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  import { CARD, WALLET_INSTRUMENT } from '@paypal/sdk-constants/src';
4
4
 
5
+ export type SecondaryInstruments = {|
6
+ type : string,
7
+ label : string,
8
+ instrumentID : string
9
+ |};
10
+
5
11
  export type WalletInstrument = {|
6
12
  type? : $Values<typeof WALLET_INSTRUMENT>,
7
13
  label? : string,
@@ -10,7 +16,8 @@ export type WalletInstrument = {|
10
16
  tokenID? : string,
11
17
  vendor? : $Values<typeof CARD>,
12
18
  oneClick : boolean,
13
- branded : boolean
19
+ branded : boolean,
20
+ secondaryInstruments? : SecondaryInstruments
14
21
  |};
15
22
 
16
23
  export type WalletPaymentType = {|
@@ -38,7 +45,8 @@ export type ContentType = {|
38
45
  credit : string,
39
46
  payWith : string,
40
47
  payLater : string,
41
- flex : string
48
+ flex : string,
49
+ payPalBalance: string
42
50
  |};
43
51
 
44
52
  export type Experiment = {|
@@ -41,11 +41,12 @@ type IndividualButtonProps = {|
41
41
  vault : boolean,
42
42
  merchantFundingSource : ?$Values<typeof FUNDING>,
43
43
  instrument : ?WalletInstrument,
44
- experience? : string
44
+ experience? : string,
45
+ showPayLabel : boolean
45
46
  |};
46
47
 
47
48
  export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
48
- userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience } : IndividualButtonProps) : ElementNode {
49
+ userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience, showPayLabel } : IndividualButtonProps) : ElementNode {
49
50
 
50
51
  const { custom, layout, shape } = style;
51
52
  const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label;
@@ -174,7 +175,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
174
175
 
175
176
  if (
176
177
  WalletLabel &&
177
- flow === BUTTON_FLOW.PURCHASE &&
178
+ !showPayLabel &&
178
179
  (instrument || (__WEB__ && userIDToken && (fundingSource === FUNDING.PAYPAL || fundingSource === FUNDING.VENMO)))
179
180
  ) {
180
181
  labelNode = (
@@ -189,6 +190,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
189
190
  vault={ vault }
190
191
  textColor={ textColor }
191
192
  fundingSource={ fundingSource }
193
+ showPayLabel={ showPayLabel }
192
194
  />
193
195
  );
194
196
 
@@ -218,11 +220,12 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
218
220
  <div
219
221
  role='link'
220
222
  { ...{
221
- [ ATTRIBUTE.BUTTON ]: true,
222
- [ ATTRIBUTE.FUNDING_SOURCE ]: fundingSource,
223
- [ ATTRIBUTE.PAYMENT_METHOD_ID ]: instrument ? instrument.tokenID : null,
224
- [ ATTRIBUTE.INSTRUMENT_ID ]: instrument ? instrument.instrumentID : null,
225
- [ ATTRIBUTE.INSTRUMENT_TYPE ]: instrument ? instrument.type : null
223
+ [ ATTRIBUTE.BUTTON ]: true,
224
+ [ ATTRIBUTE.FUNDING_SOURCE ]: fundingSource,
225
+ [ ATTRIBUTE.PAYMENT_METHOD_ID ]: instrument ? instrument.tokenID : null,
226
+ [ ATTRIBUTE.INSTRUMENT_ID ]: instrument ? instrument.instrumentID : null,
227
+ [ ATTRIBUTE.INSTRUMENT_TYPE ]: instrument ? instrument.type : null,
228
+ [ ATTRIBUTE.SECONDARY_INSTRUMENT_TYPE ]: instrument?.secondaryInstruments ? instrument.secondaryInstruments[0].type : null
226
229
  } }
227
230
  class={ [
228
231
  CLASS.BUTTON,
@@ -104,7 +104,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
104
104
  const { onClick = noop } = props;
105
105
  const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
106
106
  nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
107
- supportsPopups, supportedNativeBrowser, experience } = normalizeButtonProps(props);
107
+ supportsPopups, supportedNativeBrowser, experience, showPayLabel } = normalizeButtonProps(props);
108
108
  const { custom, layout, shape, tagline } = style;
109
109
 
110
110
  const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label && custom.label.length !== 0;
@@ -192,6 +192,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
192
192
  vault={ vault }
193
193
  instrument={ instruments[source] }
194
194
  experience={ experience }
195
+ showPayLabel={ showPayLabel }
195
196
  />
196
197
  ))
197
198
  }
@@ -393,7 +393,8 @@ export type RenderButtonProps = {|
393
393
  applePaySupport : boolean,
394
394
  supportsPopups : boolean,
395
395
  supportedNativeBrowser : boolean,
396
- experience : string
396
+ experience : string,
397
+ showPayLabel : boolean
397
398
  |};
398
399
 
399
400
  export type PrerenderDetails = {|
@@ -488,7 +489,8 @@ export type ButtonPropsInputs = {
488
489
  applePaySupport : boolean,
489
490
  supportsPopups : boolean,
490
491
  supportedNativeBrowser : boolean,
491
- experience : string
492
+ experience : string,
493
+ showPayLabel : boolean
492
494
  };
493
495
 
494
496
  export const DEFAULT_STYLE = {
@@ -658,7 +660,8 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
658
660
  applePaySupport = false,
659
661
  supportsPopups = false,
660
662
  supportedNativeBrowser = false,
661
- experience = ''
663
+ experience = '',
664
+ showPayLabel
662
665
  } = props;
663
666
 
664
667
  const { country, lang } = locale;
@@ -701,5 +704,5 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
701
704
 
702
705
  return { clientID, fundingSource, style, locale, remembered, env, fundingEligibility, platform, clientAccessToken,
703
706
  buttonSessionID, commit, sessionID, nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, content, wallet, flow,
704
- experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience };
707
+ experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience, showPayLabel };
705
708
  }