@paypal/checkout-components 5.0.256 → 5.0.258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +8 -0
  2. package/__sdk__.js +72 -76
  3. package/dist/button.js +1 -1
  4. package/globals.js +28 -30
  5. package/package.json +6 -4
  6. package/src/constants/button.js +37 -36
  7. package/src/constants/class.js +32 -30
  8. package/src/constants/index.js +3 -3
  9. package/src/constants/misc.js +14 -12
  10. package/src/declarations.js +19 -19
  11. package/src/funding/applepay/config.jsx +51 -50
  12. package/src/funding/applepay/index.js +1 -1
  13. package/src/funding/applepay/style.scoped.scss +1 -1
  14. package/src/funding/applepay/template.jsx +16 -11
  15. package/src/funding/bancontact/config.jsx +48 -37
  16. package/src/funding/bancontact/index.js +1 -2
  17. package/src/funding/blik/config.jsx +48 -37
  18. package/src/funding/blik/index.js +1 -2
  19. package/src/funding/boleto/config.jsx +50 -39
  20. package/src/funding/boleto/index.js +1 -2
  21. package/src/funding/card/amex/config.js +9 -8
  22. package/src/funding/card/amex/index.js +1 -2
  23. package/src/funding/card/config.jsx +246 -177
  24. package/src/funding/card/discover/config.js +9 -7
  25. package/src/funding/card/discover/index.js +1 -2
  26. package/src/funding/card/elo/config.js +6 -7
  27. package/src/funding/card/elo/index.js +1 -2
  28. package/src/funding/card/hiper/config.js +9 -7
  29. package/src/funding/card/hiper/index.js +1 -2
  30. package/src/funding/card/index.js +1 -1
  31. package/src/funding/card/jcb/config.js +6 -7
  32. package/src/funding/card/jcb/index.js +1 -2
  33. package/src/funding/card/mastercard/config.js +9 -7
  34. package/src/funding/card/mastercard/index.js +1 -2
  35. package/src/funding/card/visa/config.js +9 -7
  36. package/src/funding/card/visa/index.js +1 -2
  37. package/src/funding/common.jsx +242 -216
  38. package/src/funding/config.js +212 -65
  39. package/src/funding/content.jsx +1946 -337
  40. package/src/funding/credit/config.jsx +74 -57
  41. package/src/funding/credit/index.js +1 -2
  42. package/src/funding/eps/config.jsx +45 -37
  43. package/src/funding/eps/index.js +1 -2
  44. package/src/funding/funding.js +193 -100
  45. package/src/funding/giropay/config.jsx +48 -38
  46. package/src/funding/giropay/index.js +1 -2
  47. package/src/funding/ideal/config.jsx +48 -37
  48. package/src/funding/ideal/index.js +1 -2
  49. package/src/funding/index.js +2 -2
  50. package/src/funding/itau/config.jsx +41 -41
  51. package/src/funding/itau/index.js +1 -1
  52. package/src/funding/maxima/config.jsx +25 -19
  53. package/src/funding/maxima/index.js +1 -2
  54. package/src/funding/mercadopago/config.jsx +48 -37
  55. package/src/funding/mercadopago/index.js +1 -2
  56. package/src/funding/multibanco/config.jsx +50 -39
  57. package/src/funding/multibanco/index.js +1 -2
  58. package/src/funding/mybank/config.jsx +48 -37
  59. package/src/funding/mybank/index.js +1 -2
  60. package/src/funding/oxxo/config.jsx +50 -39
  61. package/src/funding/oxxo/index.js +1 -2
  62. package/src/funding/p24/config.jsx +45 -37
  63. package/src/funding/p24/index.js +1 -2
  64. package/src/funding/paidy/config.jsx +50 -39
  65. package/src/funding/paidy/index.js +1 -1
  66. package/src/funding/paylater/config.jsx +118 -111
  67. package/src/funding/paylater/index.js +1 -2
  68. package/src/funding/paypal/config.jsx +44 -46
  69. package/src/funding/paypal/index.js +1 -2
  70. package/src/funding/paypal/style.scoped.scss +80 -74
  71. package/src/funding/paypal/template.jsx +450 -354
  72. package/src/funding/payu/config.jsx +50 -39
  73. package/src/funding/payu/index.js +1 -1
  74. package/src/funding/satispay/config.jsx +50 -39
  75. package/src/funding/satispay/index.js +1 -1
  76. package/src/funding/sepa/config.jsx +19 -13
  77. package/src/funding/sepa/index.js +1 -2
  78. package/src/funding/sofort/config.jsx +48 -37
  79. package/src/funding/sofort/index.js +1 -2
  80. package/src/funding/trustly/config.jsx +50 -39
  81. package/src/funding/trustly/index.js +1 -2
  82. package/src/funding/venmo/config.jsx +80 -75
  83. package/src/funding/venmo/index.js +1 -2
  84. package/src/funding/venmo/style.scoped.scss +30 -32
  85. package/src/funding/venmo/template.jsx +56 -57
  86. package/src/funding/verkkopankki/config.jsx +50 -39
  87. package/src/funding/verkkopankki/index.js +1 -1
  88. package/src/funding/wechatpay/config.jsx +48 -37
  89. package/src/funding/wechatpay/index.js +1 -2
  90. package/src/funding/zimpler/config.jsx +19 -13
  91. package/src/funding/zimpler/index.js +1 -2
  92. package/src/interface/button.js +60 -44
  93. package/src/interface/card-fields.js +11 -8
  94. package/src/interface/fields.js +7 -4
  95. package/src/interface/marks.js +4 -4
  96. package/src/interface/payment-fields.js +7 -4
  97. package/src/interface/wallet.js +4 -4
  98. package/src/lib/errors.js +7 -7
  99. package/src/lib/index.js +5 -5
  100. package/src/lib/isRTLLanguage.js +3 -3
  101. package/src/lib/perceived-latency-instrumentation.js +54 -36
  102. package/src/lib/security.js +21 -17
  103. package/src/lib/session.js +39 -35
  104. package/src/marks/component.jsx +114 -65
  105. package/src/marks/index.js +1 -2
  106. package/src/marks/template.jsx +79 -65
  107. package/src/types.js +48 -48
  108. package/src/ui/buttons/button.jsx +311 -249
  109. package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
  110. package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
  111. package/src/ui/buttons/buttonDesigns/index.js +78 -75
  112. package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
  113. package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
  114. package/src/ui/buttons/buttonDesigns/types.js +6 -7
  115. package/src/ui/buttons/buttons.jsx +318 -212
  116. package/src/ui/buttons/config.js +62 -59
  117. package/src/ui/buttons/content.jsx +304 -119
  118. package/src/ui/buttons/index.js +1 -1
  119. package/src/ui/buttons/menu-button/index.js +1 -1
  120. package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
  121. package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
  122. package/src/ui/buttons/poweredBy.jsx +23 -23
  123. package/src/ui/buttons/props.js +680 -529
  124. package/src/ui/buttons/script.jsx +182 -160
  125. package/src/ui/buttons/spinner.jsx +4 -6
  126. package/src/ui/buttons/style.jsx +15 -14
  127. package/src/ui/buttons/styles/base.js +24 -16
  128. package/src/ui/buttons/styles/button.js +24 -22
  129. package/src/ui/buttons/styles/color.js +118 -118
  130. package/src/ui/buttons/styles/custom.js +30 -24
  131. package/src/ui/buttons/styles/index.js +1 -1
  132. package/src/ui/buttons/styles/labels.js +17 -13
  133. package/src/ui/buttons/styles/page.js +3 -3
  134. package/src/ui/buttons/styles/responsive.js +226 -118
  135. package/src/ui/buttons/tagline.jsx +53 -54
  136. package/src/ui/chevron.jsx +27 -16
  137. package/src/ui/index.js +3 -3
  138. package/src/ui/loading.jsx +25 -18
  139. package/src/ui/text/index.js +1 -1
  140. package/src/ui/text/style.scoped.scss +25 -26
  141. package/src/ui/text/text.jsx +42 -20
  142. package/src/ui/tracking.jsx +18 -11
  143. package/src/zoid/buttons/component.jsx +836 -684
  144. package/src/zoid/buttons/container.jsx +140 -107
  145. package/src/zoid/buttons/index.js +1 -1
  146. package/src/zoid/buttons/prerender.jsx +84 -64
  147. package/src/zoid/buttons/util.js +355 -254
  148. package/src/zoid/card-fields/component.jsx +581 -549
  149. package/src/zoid/card-fields/index.js +1 -1
  150. package/src/zoid/card-fields/prerender.jsx +20 -17
  151. package/src/zoid/card-form/component.js +155 -141
  152. package/src/zoid/card-form/index.js +1 -1
  153. package/src/zoid/checkout/component.jsx +314 -282
  154. package/src/zoid/checkout/config.js +2 -2
  155. package/src/zoid/checkout/content.js +190 -154
  156. package/src/zoid/checkout/hacks.js +31 -28
  157. package/src/zoid/checkout/index.js +2 -2
  158. package/src/zoid/checkout/props.js +27 -33
  159. package/src/zoid/installments/component.jsx +83 -70
  160. package/src/zoid/installments/index.js +1 -1
  161. package/src/zoid/installments/props.js +1 -1
  162. package/src/zoid/menu/component.jsx +53 -48
  163. package/src/zoid/menu/index.js +1 -1
  164. package/src/zoid/menu/props.js +1 -3
  165. package/src/zoid/modal/component.jsx +119 -106
  166. package/src/zoid/modal/index.js +1 -1
  167. package/src/zoid/modal/props.js +1 -3
  168. package/src/zoid/payment-fields/component.jsx +215 -191
  169. package/src/zoid/payment-fields/container.jsx +73 -64
  170. package/src/zoid/payment-fields/index.js +1 -1
  171. package/src/zoid/payment-fields/prerender.jsx +16 -14
  172. package/src/zoid/payment-fields/props.js +6 -6
  173. package/src/zoid/qr-code/component.jsx +131 -115
  174. package/src/zoid/qr-code/container.jsx +74 -68
  175. package/src/zoid/qr-code/index.js +1 -1
  176. package/src/zoid/qr-code/prerender.jsx +17 -12
  177. package/src/zoid/qr-code/types.js +2 -2
  178. package/src/zoid/wallet/component.jsx +298 -260
  179. package/src/zoid/wallet/container.jsx +73 -64
  180. package/src/zoid/wallet/index.js +1 -1
  181. package/src/zoid/wallet/prerender.jsx +14 -14
  182. package/src/zoid/wallet/props.js +4 -4
  183. package/src/actions/save/index.js +0 -40
  184. package/src/interface/actions.js +0 -14
  185. package/src/lib/getLogoCDNExperiment.js +0 -25
@@ -1,184 +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
- import { enableLogoCDNExperiment } from '../../lib/getLogoCDNExperiment';
14
-
15
- import { getVisaConfig } from './visa';
16
- import { getMastercardConfig } from './mastercard';
17
- import { getAmexConfig } from './amex';
18
- import { getDiscoverConfig } from './discover';
19
- import { getHiperConfig } from './hiper';
20
- import { getEloConfig } from './elo';
21
- import { getJCBConfig } from './jcb';
22
-
23
- function getVendorConfig() : { [$Values<typeof CARD>] : ?CardConfig } {
24
- return {
25
- [ CARD.VISA ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.visa && __FUNDING_ELIGIBILITY__.card.vendors.visa.eligible)) ? getVisaConfig() : null,
26
- [ CARD.AMEX ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.amex && __FUNDING_ELIGIBILITY__.card.vendors.amex.eligible)) ? getAmexConfig() : null,
27
- [ CARD.MASTERCARD ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.mastercard && __FUNDING_ELIGIBILITY__.card.vendors.mastercard.eligible)) ? getMastercardConfig() : null,
28
- [ CARD.DISCOVER ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.discover && __FUNDING_ELIGIBILITY__.card.vendors.discover.eligible)) ? getDiscoverConfig() : null,
29
- [ CARD.JCB ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.jcb && __FUNDING_ELIGIBILITY__.card.vendors.jcb.eligible)) ? getJCBConfig() : null,
30
- [ CARD.ELO ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.elo && __FUNDING_ELIGIBILITY__.card.vendors.elo.eligible)) ? getEloConfig() : null,
31
- [ CARD.HIPER ]: (!__TREE_SHAKE__ || (__FUNDING_ELIGIBILITY__.card && __FUNDING_ELIGIBILITY__.card.vendors && __FUNDING_ELIGIBILITY__.card.vendors.hiper && __FUNDING_ELIGIBILITY__.card.vendors.hiper.eligible)) ? getHiperConfig() : null
32
- };
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
+ };
33
93
  }
34
94
 
35
- export function getCardConfig() : FundingSourceConfig {
36
-
37
- const vendors = getVendorConfig();
38
-
39
- const maxCardForCountry = {
40
- [ COUNTRY.BR ]: 5
41
- };
42
-
43
- return {
44
- ...DEFAULT_FUNDING_CONFIG,
45
-
46
- eligible: ({ components, fundingSource, fundingEligibility, wallet }) => {
47
- const cardEligibility = fundingEligibility.card;
48
-
49
- const hostedFieldsRequested = Boolean(components.indexOf(COMPONENTS.HOSTED_FIELDS) !== -1);
50
- const cardEligible = Boolean(cardEligibility && cardEligibility.eligible);
51
- const cardBranded = Boolean(cardEligibility && cardEligibility.branded);
52
- const cardVaulted = Boolean(wallet && wallet.card && wallet.card.instruments && wallet.card.instruments.length);
53
-
54
- // If card is not eligible, never show card buttons
55
- if (!cardEligible) {
56
- return false;
57
- }
58
-
59
- // If card is branded, always show card buttons
60
- if (cardBranded) {
61
- return true;
62
- }
63
-
64
- // If there's a vaulted card, always show card button
65
- if (cardVaulted) {
66
- return true;
67
- }
68
-
69
- // If standalone card is selected, always show card button
70
- if (fundingSource === FUNDING.CARD) {
71
- return true;
72
- }
73
-
74
- // If hosted fields is requested, do not show card buttons
75
- if (hostedFieldsRequested) {
76
- return false;
77
- }
78
-
79
- // Otherwise default to show card buttons
80
- return true;
81
- },
82
-
83
- flows: [
84
- BUTTON_FLOW.PURCHASE,
85
- BUTTON_FLOW.BILLING_SETUP,
86
- BUTTON_FLOW.SUBSCRIPTION_SETUP
87
- ],
88
-
89
- layouts: [
90
- BUTTON_LAYOUT.VERTICAL
91
- ],
92
-
93
- maxCards: maxCardForCountry,
94
-
95
- vendors,
96
-
97
- colors: [
98
- BUTTON_COLOR.BLACK,
99
- BUTTON_COLOR.WHITE
100
- ],
101
-
102
- secondaryColors: {
103
- ...DEFAULT_FUNDING_CONFIG.secondaryColors,
104
- [ DEFAULT ]: BUTTON_COLOR.BLACK
105
- },
106
-
107
- logoColors: {
108
- [ BUTTON_COLOR.WHITE ]: BUTTON_COLOR.BLACK,
109
- [ DEFAULT ]: BUTTON_COLOR.WHITE
110
- },
111
-
112
- labelText: ({ content }) => {
113
- if (!__WEB__ && content) {
114
- return content.payWithDebitOrCreditCard;
115
- }
116
- return FUNDING.CARD;
117
- },
118
-
119
- Logo: ({ logoColor }) => {
120
- return enableLogoCDNExperiment(GlyphCard, { logoColor });
121
- },
122
-
123
- Label: ({ logo, locale, content, custom }) => {
124
- if (custom && custom.label && custom.label.length) {
125
- const validLabels = {
126
- buy: 'Buy',
127
- checkout: 'Checkout',
128
- pay: 'Pay',
129
- 'buy now': 'Buy Now',
130
- 'pay now': 'Pay Now',
131
- 'checkout now': 'Checkout Now',
132
- 'proceed to checkout': 'Proceed to checkout'
133
- };
134
-
135
- let label = validLabels.checkout;
136
-
137
- const lowerCaseLabel = custom.label.toLowerCase();
138
- if (validLabels[lowerCaseLabel]) {
139
- label = validLabels[lowerCaseLabel];
140
- }
141
-
142
- return (
143
- <Fragment>
144
- <Text>{ label }</Text>
145
- <Space />
146
- </Fragment>
147
- );
148
- }
149
- const { lang } = locale;
150
- const isRTL = isRTLLanguage(lang);
151
- return (
152
- <Fragment>
153
- { (isRTL && !__WEB__ && content) ? (
154
- <Fragment>
155
- <Text animate optional>{ content.payWithDebitOrCreditCard }</Text>
156
- <Space />
157
- </Fragment>
158
- ) : null }
159
- { logo }
160
- {(!isRTL && !__WEB__ && content) ? (
161
- <Fragment>
162
- <Space />
163
- <Text animate optional>{ content.payWithDebitOrCreditCard }</Text>
164
- </Fragment>
165
- ) : null }
166
- </Fragment>
167
- );
168
- },
169
-
170
- WalletLabel,
171
-
172
- showWalletMenu: ({ instrument, userIDToken }) => {
173
- if (instrument.branded) {
174
- return false;
175
- } else {
176
- if (!instrument.tokenID?.match(/-/) && userIDToken) {
177
- return false
178
- }
179
-
180
- return true;
181
- }
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];
182
205
  }
183
- };
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
+ };
184
253
  }
@@ -1,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
8
+ import type { CardConfig } from "../../common";
7
9
 
8
- export function getDiscoverConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(DiscoverLogo)
11
- };
10
+ export function getDiscoverConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? DiscoverLogoExternalImage : DiscoverLogoInlineSVG,
13
+ };
12
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
5
+ import type { CardConfig } from "../../common";
7
6
 
8
- export function getEloConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(EloLogo)
11
- };
7
+ export function getEloConfig(): CardConfig {
8
+ return {
9
+ Label: __WEB__ ? EloLogoExternalImage : EloLogoInlineSVG,
10
+ };
12
11
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
8
+ import type { CardConfig } from "../../common";
7
9
 
8
- export function getHiperConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(HiperLogo)
11
- };
10
+ export function getHiperConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? HiperLogoExternalImage : HiperLogoInlineSVG,
13
+ };
12
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,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
5
+ import type { CardConfig } from "../../common";
7
6
 
8
- export function getJCBConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(JcbLogo)
11
- };
7
+ export function getJCBConfig(): CardConfig {
8
+ return {
9
+ Label: __WEB__ ? JcbLogoExternalImage : JcbLogoInlineSVG,
10
+ };
12
11
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
8
+ import type { CardConfig } from "../../common";
7
9
 
8
- export function getMastercardConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(MastercardLogo)
11
- };
10
+ export function getMastercardConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? MastercardLogoExternalImage : MastercardLogoInlineSVG,
13
+ };
12
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";
@@ -1,12 +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';
6
- import { enableLogoCDNExperiment } from '../../../lib/getLogoCDNExperiment';
8
+ import type { CardConfig } from "../../common";
7
9
 
8
- export function getVisaConfig() : CardConfig {
9
- return {
10
- Label: () => enableLogoCDNExperiment(VisaLogo)
11
- };
10
+ export function getVisaConfig(): CardConfig {
11
+ return {
12
+ Label: __WEB__ ? VisaLogoExternalImage : VisaLogoInlineSVG,
13
+ };
12
14
  }
@@ -1,4 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './config';
4
-
3
+ export * from "./config";