@paypal/checkout-components 5.0.256-alpha.1 → 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 (184) 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 +7 -5
  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 -49
  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 -9
  16. package/src/funding/bancontact/config.jsx +48 -36
  17. package/src/funding/bancontact/index.js +1 -2
  18. package/src/funding/blik/config.jsx +48 -36
  19. package/src/funding/blik/index.js +1 -2
  20. package/src/funding/boleto/config.jsx +50 -38
  21. package/src/funding/boleto/index.js +1 -2
  22. package/src/funding/card/amex/config.js +9 -7
  23. package/src/funding/card/amex/index.js +1 -2
  24. package/src/funding/card/config.jsx +246 -178
  25. package/src/funding/card/discover/config.js +9 -6
  26. package/src/funding/card/discover/index.js +1 -2
  27. package/src/funding/card/elo/config.js +6 -6
  28. package/src/funding/card/elo/index.js +1 -2
  29. package/src/funding/card/hiper/config.js +9 -6
  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 -6
  33. package/src/funding/card/jcb/index.js +1 -2
  34. package/src/funding/card/mastercard/config.js +9 -6
  35. package/src/funding/card/mastercard/index.js +1 -2
  36. package/src/funding/card/visa/config.js +9 -6
  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 -54
  42. package/src/funding/credit/index.js +1 -2
  43. package/src/funding/eps/config.jsx +45 -36
  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 -37
  47. package/src/funding/giropay/index.js +1 -2
  48. package/src/funding/ideal/config.jsx +48 -36
  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 -40
  52. package/src/funding/itau/index.js +1 -1
  53. package/src/funding/maxima/config.jsx +25 -18
  54. package/src/funding/maxima/index.js +1 -2
  55. package/src/funding/mercadopago/config.jsx +48 -36
  56. package/src/funding/mercadopago/index.js +1 -2
  57. package/src/funding/multibanco/config.jsx +50 -38
  58. package/src/funding/multibanco/index.js +1 -2
  59. package/src/funding/mybank/config.jsx +48 -36
  60. package/src/funding/mybank/index.js +1 -2
  61. package/src/funding/oxxo/config.jsx +50 -38
  62. package/src/funding/oxxo/index.js +1 -2
  63. package/src/funding/p24/config.jsx +45 -36
  64. package/src/funding/p24/index.js +1 -2
  65. package/src/funding/paidy/config.jsx +50 -38
  66. package/src/funding/paidy/index.js +1 -1
  67. package/src/funding/paylater/config.jsx +118 -110
  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 -355
  73. package/src/funding/payu/config.jsx +50 -38
  74. package/src/funding/payu/index.js +1 -1
  75. package/src/funding/satispay/config.jsx +50 -38
  76. package/src/funding/satispay/index.js +1 -1
  77. package/src/funding/sepa/config.jsx +19 -12
  78. package/src/funding/sepa/index.js +1 -2
  79. package/src/funding/sofort/config.jsx +48 -36
  80. package/src/funding/sofort/index.js +1 -2
  81. package/src/funding/trustly/config.jsx +50 -38
  82. package/src/funding/trustly/index.js +1 -2
  83. package/src/funding/venmo/config.jsx +80 -74
  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 -56
  87. package/src/funding/verkkopankki/config.jsx +50 -38
  88. package/src/funding/verkkopankki/index.js +1 -1
  89. package/src/funding/wechatpay/config.jsx +48 -36
  90. package/src/funding/wechatpay/index.js +1 -2
  91. package/src/funding/zimpler/config.jsx +19 -12
  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 -677
  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
@@ -1,185 +1,253 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
3
 
4
- import { node, Fragment } from '@krakenjs/jsx-pragmatic/src';
5
- import { CARD, COUNTRY, COMPONENTS, FUNDING } from '@paypal/sdk-constants/src';
6
- import { GlyphCard } from '@paypal/sdk-logos/src';
7
-
8
- import { BUTTON_LAYOUT, BUTTON_COLOR, DEFAULT, BUTTON_FLOW } from '../../constants';
9
- import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig, type CardConfig } from '../common';
10
- import { Text, Space } from '../../ui/text';
11
- import { isRTLLanguage } from '../../lib';
12
- import { WalletLabel } from '../paypal/template';
13
-
14
- import { getVisaConfig } from './visa';
15
- import { getMastercardConfig } from './mastercard';
16
- import { getAmexConfig } from './amex';
17
- import { getDiscoverConfig } from './discover';
18
- import { getHiperConfig } from './hiper';
19
- import { getEloConfig } from './elo';
20
- import { getJCBConfig } from './jcb';
21
-
22
- function getVendorConfig() : { [$Values<typeof CARD>] : ?CardConfig } {
23
- return {
24
- [ CARD.VISA ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.visa && __FUNDING_ELIGIBILITY__.card.vendors.visa.eligible)) ? getVisaConfig() : null,
25
- [ CARD.AMEX ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.amex && __FUNDING_ELIGIBILITY__.card.vendors.amex.eligible)) ? getAmexConfig() : null,
26
- [ CARD.MASTERCARD ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.mastercard && __FUNDING_ELIGIBILITY__.card.vendors.mastercard.eligible)) ? getMastercardConfig() : null,
27
- [ CARD.DISCOVER ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.discover && __FUNDING_ELIGIBILITY__.card.vendors.discover.eligible)) ? getDiscoverConfig() : null,
28
- [ CARD.JCB ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.jcb && __FUNDING_ELIGIBILITY__.card.vendors.jcb.eligible)) ? getJCBConfig() : null,
29
- [ CARD.ELO ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.elo && __FUNDING_ELIGIBILITY__.card.vendors.elo.eligible)) ? getEloConfig() : null,
30
- [ CARD.HIPER ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.hiper && __FUNDING_ELIGIBILITY__.card.vendors.hiper.eligible)) ? getHiperConfig() : null
31
- };
4
+ import { node, Fragment } from "@krakenjs/jsx-pragmatic/src";
5
+ import { CARD, COUNTRY, COMPONENTS, FUNDING } from "@paypal/sdk-constants/src";
6
+ import {
7
+ GlyphCardExternalImage,
8
+ GlyphCardInlineSVG,
9
+ } from "@paypal/sdk-logos/src";
10
+
11
+ import {
12
+ BUTTON_LAYOUT,
13
+ BUTTON_COLOR,
14
+ DEFAULT,
15
+ BUTTON_FLOW,
16
+ } from "../../constants";
17
+ import {
18
+ DEFAULT_FUNDING_CONFIG,
19
+ type FundingSourceConfig,
20
+ type CardConfig,
21
+ } from "../common";
22
+ import { Text, Space } from "../../ui/text";
23
+ import { isRTLLanguage } from "../../lib";
24
+ import { WalletLabel } from "../paypal/template";
25
+
26
+ import { getVisaConfig } from "./visa";
27
+ import { getMastercardConfig } from "./mastercard";
28
+ import { getAmexConfig } from "./amex";
29
+ import { getDiscoverConfig } from "./discover";
30
+ import { getHiperConfig } from "./hiper";
31
+ import { getEloConfig } from "./elo";
32
+ import { getJCBConfig } from "./jcb";
33
+
34
+ function getVendorConfig(): { [$Values<typeof CARD>]: ?CardConfig } {
35
+ return {
36
+ [CARD.VISA]:
37
+ !__TREE_SHAKE__ ||
38
+ (__FUNDING_ELIGIBILITY__.card &&
39
+ __FUNDING_ELIGIBILITY__.card.vendors &&
40
+ __FUNDING_ELIGIBILITY__.card.vendors.visa &&
41
+ __FUNDING_ELIGIBILITY__.card.vendors.visa.eligible)
42
+ ? getVisaConfig()
43
+ : null,
44
+ [CARD.AMEX]:
45
+ !__TREE_SHAKE__ ||
46
+ (__FUNDING_ELIGIBILITY__.card &&
47
+ __FUNDING_ELIGIBILITY__.card.vendors &&
48
+ __FUNDING_ELIGIBILITY__.card.vendors.amex &&
49
+ __FUNDING_ELIGIBILITY__.card.vendors.amex.eligible)
50
+ ? getAmexConfig()
51
+ : null,
52
+ [CARD.MASTERCARD]:
53
+ !__TREE_SHAKE__ ||
54
+ (__FUNDING_ELIGIBILITY__.card &&
55
+ __FUNDING_ELIGIBILITY__.card.vendors &&
56
+ __FUNDING_ELIGIBILITY__.card.vendors.mastercard &&
57
+ __FUNDING_ELIGIBILITY__.card.vendors.mastercard.eligible)
58
+ ? getMastercardConfig()
59
+ : null,
60
+ [CARD.DISCOVER]:
61
+ !__TREE_SHAKE__ ||
62
+ (__FUNDING_ELIGIBILITY__.card &&
63
+ __FUNDING_ELIGIBILITY__.card.vendors &&
64
+ __FUNDING_ELIGIBILITY__.card.vendors.discover &&
65
+ __FUNDING_ELIGIBILITY__.card.vendors.discover.eligible)
66
+ ? getDiscoverConfig()
67
+ : null,
68
+ [CARD.JCB]:
69
+ !__TREE_SHAKE__ ||
70
+ (__FUNDING_ELIGIBILITY__.card &&
71
+ __FUNDING_ELIGIBILITY__.card.vendors &&
72
+ __FUNDING_ELIGIBILITY__.card.vendors.jcb &&
73
+ __FUNDING_ELIGIBILITY__.card.vendors.jcb.eligible)
74
+ ? getJCBConfig()
75
+ : null,
76
+ [CARD.ELO]:
77
+ !__TREE_SHAKE__ ||
78
+ (__FUNDING_ELIGIBILITY__.card &&
79
+ __FUNDING_ELIGIBILITY__.card.vendors &&
80
+ __FUNDING_ELIGIBILITY__.card.vendors.elo &&
81
+ __FUNDING_ELIGIBILITY__.card.vendors.elo.eligible)
82
+ ? getEloConfig()
83
+ : null,
84
+ [CARD.HIPER]:
85
+ !__TREE_SHAKE__ ||
86
+ (__FUNDING_ELIGIBILITY__.card &&
87
+ __FUNDING_ELIGIBILITY__.card.vendors &&
88
+ __FUNDING_ELIGIBILITY__.card.vendors.hiper &&
89
+ __FUNDING_ELIGIBILITY__.card.vendors.hiper.eligible)
90
+ ? getHiperConfig()
91
+ : null,
92
+ };
32
93
  }
33
94
 
34
- export function getCardConfig() : FundingSourceConfig {
35
-
36
- const vendors = getVendorConfig();
37
-
38
- const maxCardForCountry = {
39
- [ COUNTRY.BR ]: 5
40
- };
41
-
42
- return {
43
- ...DEFAULT_FUNDING_CONFIG,
44
-
45
- eligible: ({ components, fundingSource, fundingEligibility, wallet }) => {
46
- const cardEligibility = fundingEligibility.card;
47
-
48
- const hostedFieldsRequested = Boolean(components.indexOf(COMPONENTS.HOSTED_FIELDS) !== -1);
49
- const cardEligible = Boolean(cardEligibility && cardEligibility.eligible);
50
- const cardBranded = Boolean(cardEligibility && cardEligibility.branded);
51
- const cardVaulted = Boolean(wallet && wallet.card && wallet.card.instruments && wallet.card.instruments.length);
52
-
53
- // If card is not eligible, never show card buttons
54
- if (!cardEligible) {
55
- return false;
56
- }
57
-
58
- // If card is branded, always show card buttons
59
- if (cardBranded) {
60
- return true;
61
- }
62
-
63
- // If there's a vaulted card, always show card button
64
- if (cardVaulted) {
65
- return true;
66
- }
67
-
68
- // If standalone card is selected, always show card button
69
- if (fundingSource === FUNDING.CARD) {
70
- return true;
71
- }
72
-
73
- // If hosted fields is requested, do not show card buttons
74
- if (hostedFieldsRequested) {
75
- return false;
76
- }
77
-
78
- // Otherwise default to show card buttons
79
- return true;
80
- },
81
-
82
- flows: [
83
- BUTTON_FLOW.PURCHASE,
84
- BUTTON_FLOW.BILLING_SETUP,
85
- BUTTON_FLOW.SUBSCRIPTION_SETUP
86
- ],
87
-
88
- layouts: [
89
- BUTTON_LAYOUT.VERTICAL
90
- ],
91
-
92
- maxCards: maxCardForCountry,
93
-
94
- vendors,
95
-
96
- colors: [
97
- BUTTON_COLOR.BLACK,
98
- BUTTON_COLOR.WHITE
99
- ],
100
-
101
- secondaryColors: {
102
- ...DEFAULT_FUNDING_CONFIG.secondaryColors,
103
- [ DEFAULT ]: BUTTON_COLOR.BLACK
104
- },
105
-
106
- logoColors: {
107
- [ BUTTON_COLOR.WHITE ]: BUTTON_COLOR.BLACK,
108
- [ DEFAULT ]: BUTTON_COLOR.WHITE
109
- },
110
-
111
- labelText: ({ content }) => {
112
- if (!__WEB__ && content) {
113
- return content.payWithDebitOrCreditCard;
114
- }
115
- return FUNDING.CARD;
116
- },
117
-
118
- Logo: ({ logoColor }) => {
119
- return (
120
- <GlyphCard logoColor={ logoColor } loadFromCDN={ __WEB__ } />
121
- );
122
- },
123
-
124
- Label: ({ logo, locale, content, custom }) => {
125
- if (custom && custom.label && custom.label.length) {
126
- const validLabels = {
127
- buy: 'Buy',
128
- checkout: 'Checkout',
129
- pay: 'Pay',
130
- 'buy now': 'Buy Now',
131
- 'pay now': 'Pay Now',
132
- 'checkout now': 'Checkout Now',
133
- 'proceed to checkout': 'Proceed to checkout'
134
- };
135
-
136
- let label = validLabels.checkout;
137
-
138
- const lowerCaseLabel = custom.label.toLowerCase();
139
- if (validLabels[lowerCaseLabel]) {
140
- label = validLabels[lowerCaseLabel];
141
- }
142
-
143
- return (
144
- <Fragment>
145
- <Text>{ label }</Text>
146
- <Space />
147
- </Fragment>
148
- );
149
- }
150
- const { lang } = locale;
151
- const isRTL = isRTLLanguage(lang);
152
- return (
153
- <Fragment>
154
- { (isRTL && !__WEB__ && content) ? (
155
- <Fragment>
156
- <Text animate optional>{ content.payWithDebitOrCreditCard }</Text>
157
- <Space />
158
- </Fragment>
159
- ) : null }
160
- { logo }
161
- {(!isRTL && !__WEB__ && content) ? (
162
- <Fragment>
163
- <Space />
164
- <Text animate optional>{ content.payWithDebitOrCreditCard }</Text>
165
- </Fragment>
166
- ) : null }
167
- </Fragment>
168
- );
169
- },
170
-
171
- WalletLabel,
172
-
173
- showWalletMenu: ({ instrument, userIDToken }) => {
174
- if (instrument.branded) {
175
- return false;
176
- } else {
177
- if (!instrument.tokenID?.match(/-/) && userIDToken) {
178
- return false
179
- }
180
-
181
- return true;
182
- }
95
+ export function getCardConfig(): FundingSourceConfig {
96
+ const vendors = getVendorConfig();
97
+
98
+ const maxCardForCountry = {
99
+ [COUNTRY.BR]: 5,
100
+ };
101
+
102
+ return {
103
+ ...DEFAULT_FUNDING_CONFIG,
104
+
105
+ eligible: ({ components, fundingSource, fundingEligibility, wallet }) => {
106
+ const cardEligibility = fundingEligibility.card;
107
+
108
+ const hostedFieldsRequested = Boolean(
109
+ components.indexOf(COMPONENTS.HOSTED_FIELDS) !== -1
110
+ );
111
+ const cardEligible = Boolean(cardEligibility && cardEligibility.eligible);
112
+ const cardBranded = Boolean(cardEligibility && cardEligibility.branded);
113
+ const cardVaulted = Boolean(
114
+ wallet &&
115
+ wallet.card &&
116
+ wallet.card.instruments &&
117
+ wallet.card.instruments.length
118
+ );
119
+
120
+ // If card is not eligible, never show card buttons
121
+ if (!cardEligible) {
122
+ return false;
123
+ }
124
+
125
+ // If card is branded, always show card buttons
126
+ if (cardBranded) {
127
+ return true;
128
+ }
129
+
130
+ // If there's a vaulted card, always show card button
131
+ if (cardVaulted) {
132
+ return true;
133
+ }
134
+
135
+ // If standalone card is selected, always show card button
136
+ if (fundingSource === FUNDING.CARD) {
137
+ return true;
138
+ }
139
+
140
+ // If hosted fields is requested, do not show card buttons
141
+ if (hostedFieldsRequested) {
142
+ return false;
143
+ }
144
+
145
+ // Otherwise default to show card buttons
146
+ return true;
147
+ },
148
+
149
+ flows: [
150
+ BUTTON_FLOW.PURCHASE,
151
+ BUTTON_FLOW.BILLING_SETUP,
152
+ BUTTON_FLOW.SUBSCRIPTION_SETUP,
153
+ ],
154
+
155
+ layouts: [BUTTON_LAYOUT.VERTICAL],
156
+
157
+ maxCards: maxCardForCountry,
158
+
159
+ vendors,
160
+
161
+ colors: [BUTTON_COLOR.BLACK, BUTTON_COLOR.WHITE],
162
+
163
+ secondaryColors: {
164
+ ...DEFAULT_FUNDING_CONFIG.secondaryColors,
165
+ [DEFAULT]: BUTTON_COLOR.BLACK,
166
+ },
167
+
168
+ logoColors: {
169
+ [BUTTON_COLOR.WHITE]: BUTTON_COLOR.BLACK,
170
+ [DEFAULT]: BUTTON_COLOR.WHITE,
171
+ },
172
+
173
+ labelText: ({ content }) => {
174
+ if (!__WEB__ && content) {
175
+ return content.payWithDebitOrCreditCard;
176
+ }
177
+ return FUNDING.CARD;
178
+ },
179
+
180
+ Logo: ({ logoColor }) => {
181
+ return __WEB__ ? (
182
+ <GlyphCardExternalImage logoColor={logoColor} />
183
+ ) : (
184
+ <GlyphCardInlineSVG logoColor={logoColor} />
185
+ );
186
+ },
187
+
188
+ Label: ({ logo, locale, content, custom }) => {
189
+ if (custom && custom.label && custom.label.length) {
190
+ const validLabels = {
191
+ buy: "Buy",
192
+ checkout: "Checkout",
193
+ pay: "Pay",
194
+ "buy now": "Buy Now",
195
+ "pay now": "Pay Now",
196
+ "checkout now": "Checkout Now",
197
+ "proceed to checkout": "Proceed to checkout",
198
+ };
199
+
200
+ let label = validLabels.checkout;
201
+
202
+ const lowerCaseLabel = custom.label.toLowerCase();
203
+ if (validLabels[lowerCaseLabel]) {
204
+ label = validLabels[lowerCaseLabel];
183
205
  }
184
- };
206
+
207
+ return (
208
+ <Fragment>
209
+ <Text>{label}</Text>
210
+ <Space />
211
+ </Fragment>
212
+ );
213
+ }
214
+ const { lang } = locale;
215
+ const isRTL = isRTLLanguage(lang);
216
+ return (
217
+ <Fragment>
218
+ {isRTL && !__WEB__ && content ? (
219
+ <Fragment>
220
+ <Text animate optional>
221
+ {content.payWithDebitOrCreditCard}
222
+ </Text>
223
+ <Space />
224
+ </Fragment>
225
+ ) : null}
226
+ {logo}
227
+ {!isRTL && !__WEB__ && content ? (
228
+ <Fragment>
229
+ <Space />
230
+ <Text animate optional>
231
+ {content.payWithDebitOrCreditCard}
232
+ </Text>
233
+ </Fragment>
234
+ ) : null}
235
+ </Fragment>
236
+ );
237
+ },
238
+
239
+ WalletLabel,
240
+
241
+ showWalletMenu: ({ instrument, userIDToken }) => {
242
+ if (instrument.branded) {
243
+ return false;
244
+ } else {
245
+ if (!instrument.tokenID?.match(/-/) && userIDToken) {
246
+ return false;
247
+ }
248
+
249
+ return true;
250
+ }
251
+ },
252
+ };
185
253
  }
@@ -1,11 +1,14 @@
1
1
  /* @flow */
2
2
 
3
- import { DiscoverLogo } from '@paypal/sdk-logos/src';
3
+ import {
4
+ DiscoverLogoInlineSVG,
5
+ DiscoverLogoExternalImage,
6
+ } from "@paypal/sdk-logos/src";
4
7
 
5
- import type { CardConfig } from '../../common';
8
+ import type { CardConfig } from "../../common";
6
9
 
7
- export function getDiscoverConfig() : CardConfig {
8
- return {
9
- Label: DiscoverLogo
10
- };
10
+ export function getDiscoverConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? DiscoverLogoExternalImage : DiscoverLogoInlineSVG,
13
+ };
11
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,11 +1,11 @@
1
1
  /* @flow */
2
2
 
3
- import { EloLogo } from '@paypal/sdk-logos/src';
3
+ import { EloLogoInlineSVG, EloLogoExternalImage } from "@paypal/sdk-logos/src";
4
4
 
5
- import type { CardConfig } from '../../common';
5
+ import type { CardConfig } from "../../common";
6
6
 
7
- export function getEloConfig() : CardConfig {
8
- return {
9
- Label: EloLogo
10
- };
7
+ export function getEloConfig(): CardConfig {
8
+ return {
9
+ Label: __WEB__ ? EloLogoExternalImage : EloLogoInlineSVG,
10
+ };
11
11
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,11 +1,14 @@
1
1
  /* @flow */
2
2
 
3
- import { HiperLogo } from '@paypal/sdk-logos/src';
3
+ import {
4
+ HiperLogoInlineSVG,
5
+ HiperLogoExternalImage,
6
+ } from "@paypal/sdk-logos/src";
4
7
 
5
- import type { CardConfig } from '../../common';
8
+ import type { CardConfig } from "../../common";
6
9
 
7
- export function getHiperConfig() : CardConfig {
8
- return {
9
- Label: HiperLogo
10
- };
10
+ export function getHiperConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? HiperLogoExternalImage : HiperLogoInlineSVG,
13
+ };
11
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,3 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
3
+ export * from "./config";
@@ -1,11 +1,11 @@
1
1
  /* @flow */
2
2
 
3
- import { JcbLogo } from '@paypal/sdk-logos/src';
3
+ import { JcbLogoInlineSVG, JcbLogoExternalImage } from "@paypal/sdk-logos/src";
4
4
 
5
- import type { CardConfig } from '../../common';
5
+ import type { CardConfig } from "../../common";
6
6
 
7
- export function getJCBConfig() : CardConfig {
8
- return {
9
- Label: JcbLogo
10
- };
7
+ export function getJCBConfig(): CardConfig {
8
+ return {
9
+ Label: __WEB__ ? JcbLogoExternalImage : JcbLogoInlineSVG,
10
+ };
11
11
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,11 +1,14 @@
1
1
  /* @flow */
2
2
 
3
- import { MastercardLogo } from '@paypal/sdk-logos/src';
3
+ import {
4
+ MastercardLogoInlineSVG,
5
+ MastercardLogoExternalImage,
6
+ } from "@paypal/sdk-logos/src";
4
7
 
5
- import type { CardConfig } from '../../common';
8
+ import type { CardConfig } from "../../common";
6
9
 
7
- export function getMastercardConfig() : CardConfig {
8
- return {
9
- Label: MastercardLogo
10
- };
10
+ export function getMastercardConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? MastercardLogoExternalImage : MastercardLogoInlineSVG,
13
+ };
11
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,11 +1,14 @@
1
1
  /* @flow */
2
2
 
3
- import { VisaLogo } from '@paypal/sdk-logos/src';
3
+ import {
4
+ VisaLogoInlineSVG,
5
+ VisaLogoExternalImage,
6
+ } from "@paypal/sdk-logos/src";
4
7
 
5
- import type { CardConfig } from '../../common';
8
+ import type { CardConfig } from "../../common";
6
9
 
7
- export function getVisaConfig() : CardConfig {
8
- return {
9
- Label: VisaLogo
10
- };
10
+ export function getVisaConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? VisaLogoExternalImage : VisaLogoInlineSVG,
13
+ };
11
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";