|
1 | 1 | import { __ } from '@wordpress/i18n';
|
2 | 2 | import { useDispatch } from '@wordpress/data';
|
3 | 3 | import { React } from 'react';
|
4 |
| -import { Card, Button } from '@wordpress/components'; |
| 4 | +import { Card, Button, ExternalLink } from '@wordpress/components'; |
5 | 5 | import styled from '@emotion/styled';
|
| 6 | +import interpolateComponents from 'interpolate-components'; |
6 | 7 | import CardBody from '../card-body';
|
7 | 8 | import bannerIllustration from './banner-illustration.svg';
|
8 | 9 | import bannerIllustrationReConnect from './banner-illustration-re-connect.svg';
|
9 | 10 | import Pill from 'wcstripe/components/pill';
|
10 | 11 | import { recordEvent } from 'wcstripe/tracking';
|
11 |
| -import { useTestMode } from 'wcstripe/data'; |
| 12 | +import { useEnabledPaymentMethodIds, useTestMode } from 'wcstripe/data'; |
12 | 13 |
|
13 | 14 | const NewPill = styled( Pill )`
|
14 | 15 | border-color: #674399;
|
@@ -66,6 +67,9 @@ const PromotionalBannerSection = ( {
|
66 | 67 | 'core/notices'
|
67 | 68 | );
|
68 | 69 | const [ isTestModeEnabled ] = useTestMode();
|
| 70 | + const [ enabledPaymentMethodIds ] = useEnabledPaymentMethodIds(); |
| 71 | + const hasAPMEnabled = |
| 72 | + enabledPaymentMethodIds.filter( ( e ) => e !== 'card' ).length > 0; |
69 | 73 |
|
70 | 74 | const handleButtonClick = () => {
|
71 | 75 | const callback = async () => {
|
@@ -159,6 +163,65 @@ const PromotionalBannerSection = ( {
|
159 | 163 | </CardBody>
|
160 | 164 | );
|
161 | 165 |
|
| 166 | + const NewCheckoutExperienceAPMsBanner = () => ( |
| 167 | + <CardBody data-testid="new-checkout-apms-banner"> |
| 168 | + <CardInner> |
| 169 | + <CardColumn> |
| 170 | + <NewPill> |
| 171 | + { __( 'New', 'woocommerce-gateway-stripe' ) } |
| 172 | + </NewPill> |
| 173 | + <h4> |
| 174 | + { __( |
| 175 | + 'Enable the new Stripe checkout to continue accepting non-card payments', |
| 176 | + 'woocommerce-gateway-stripe' |
| 177 | + ) } |
| 178 | + </h4> |
| 179 | + <p> |
| 180 | + { interpolateComponents( { |
| 181 | + mixedString: __( |
| 182 | + 'Stripe will end support for non-card payment methods in the {{StripeLegacyLink}}legacy checkout on October 29, 2024{{/StripeLegacyLink}}. To continue accepting non-card payments, you must enable the new checkout experience or remove non-card payment methods from your checkout to avoid payment disruptions.', |
| 183 | + 'woocommerce-gateway-stripe' |
| 184 | + ), |
| 185 | + components: { |
| 186 | + StripeLegacyLink: ( |
| 187 | + <ExternalLink href="https://support.stripe.com/topics/shutdown-of-the-legacy-sources-api-for-non-card-payment-methods" /> |
| 188 | + ), |
| 189 | + }, |
| 190 | + } ) } |
| 191 | + </p> |
| 192 | + </CardColumn> |
| 193 | + <CardColumn> |
| 194 | + <BannerIllustration |
| 195 | + src={ bannerIllustration } |
| 196 | + alt={ __( |
| 197 | + 'New Checkout', |
| 198 | + 'woocommerce-gateway-stripe' |
| 199 | + ) } |
| 200 | + /> |
| 201 | + </CardColumn> |
| 202 | + </CardInner> |
| 203 | + <ButtonsRow> |
| 204 | + <MainCTALink |
| 205 | + variant="secondary" |
| 206 | + data-testid="disable-the-legacy-checkout" |
| 207 | + onClick={ handleButtonClick } |
| 208 | + > |
| 209 | + { __( |
| 210 | + 'Enable the new checkout', |
| 211 | + 'woocommerce-gateway-stripe' |
| 212 | + ) } |
| 213 | + </MainCTALink> |
| 214 | + <DismissButton |
| 215 | + variant="secondary" |
| 216 | + onClick={ handleBannerDismiss } |
| 217 | + data-testid="dismiss" |
| 218 | + > |
| 219 | + { __( 'Dismiss', 'woocommerce-gateway-stripe' ) } |
| 220 | + </DismissButton> |
| 221 | + </ButtonsRow> |
| 222 | + </CardBody> |
| 223 | + ); |
| 224 | + |
162 | 225 | const NewCheckoutExperienceBanner = () => (
|
163 | 226 | <CardBody>
|
164 | 227 | <CardInner>
|
@@ -215,7 +278,11 @@ const PromotionalBannerSection = ( {
|
215 | 278 | if ( isConnectedViaOAuth === false ) {
|
216 | 279 | BannerContent = <ReConnectAccountBanner />;
|
217 | 280 | } else if ( ! isUpeEnabled ) {
|
218 |
| - BannerContent = <NewCheckoutExperienceBanner />; |
| 281 | + if ( hasAPMEnabled ) { |
| 282 | + BannerContent = <NewCheckoutExperienceAPMsBanner />; |
| 283 | + } else { |
| 284 | + BannerContent = <NewCheckoutExperienceBanner />; |
| 285 | + } |
219 | 286 | }
|
220 | 287 |
|
221 | 288 | return (
|
|
0 commit comments