2022-04-20 04:28:31 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-07-06 06:20:11 +00:00
|
|
|
import { Button } from '@wordpress/components';
|
2022-04-06 16:38:38 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-04-26 02:55:44 +00:00
|
|
|
import { getAdminLink } from '@woocommerce/settings';
|
2024-04-25 13:24:05 +00:00
|
|
|
import {
|
|
|
|
WCPayBanner,
|
|
|
|
WCPayBannerBody,
|
|
|
|
WCPayBannerFooter,
|
|
|
|
} from '@woocommerce/onboarding';
|
2022-08-17 03:33:24 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2022-04-20 04:28:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2022-04-06 16:38:38 +00:00
|
|
|
import './payment-recommendations.scss';
|
2022-05-16 22:07:42 +00:00
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2022-08-17 03:33:24 +00:00
|
|
|
import { usePaymentsBanner } from './use-payments-banner';
|
|
|
|
|
|
|
|
const recordTrack = () => {
|
|
|
|
recordEvent( 'settings_payments_banner_connect_click' );
|
|
|
|
};
|
2022-04-06 16:38:38 +00:00
|
|
|
|
2022-07-06 06:20:11 +00:00
|
|
|
const WCPaySettingBanner = () => {
|
2022-04-26 02:55:44 +00:00
|
|
|
const WC_PAY_SETUP_URL = getAdminLink(
|
2022-05-16 22:07:42 +00:00
|
|
|
'admin.php?wcpay-connect=1&_wpnonce=' +
|
|
|
|
getAdminSetting( 'wcpay_welcome_page_connect_nonce' )
|
2022-04-26 02:55:44 +00:00
|
|
|
);
|
2023-08-08 02:17:59 +00:00
|
|
|
const isWooPayEligible = getAdminSetting( 'isWooPayEligible' );
|
2022-05-16 22:07:42 +00:00
|
|
|
|
2022-04-06 16:38:38 +00:00
|
|
|
return (
|
2024-04-25 13:24:05 +00:00
|
|
|
<WCPayBanner>
|
|
|
|
<WCPayBannerBody
|
|
|
|
textPosition="right"
|
2022-07-06 06:20:11 +00:00
|
|
|
actionButton={
|
2022-08-17 03:33:24 +00:00
|
|
|
<Button
|
|
|
|
href={ WC_PAY_SETUP_URL }
|
2024-04-25 13:24:05 +00:00
|
|
|
isPrimary
|
2022-08-17 03:33:24 +00:00
|
|
|
onClick={ recordTrack }
|
|
|
|
>
|
2024-04-25 13:24:05 +00:00
|
|
|
{ __( 'Get started', 'woocommerce' ) }
|
2022-04-06 16:38:38 +00:00
|
|
|
</Button>
|
2022-07-06 06:20:11 +00:00
|
|
|
}
|
2023-08-08 02:17:59 +00:00
|
|
|
isWooPayEligible={ isWooPayEligible }
|
2022-07-06 06:20:11 +00:00
|
|
|
/>
|
2024-04-25 13:24:05 +00:00
|
|
|
<WCPayBannerFooter isWooPayEligible={ isWooPayEligible } />
|
|
|
|
</WCPayBanner>
|
2022-04-06 16:38:38 +00:00
|
|
|
);
|
|
|
|
};
|
2022-04-19 08:07:07 +00:00
|
|
|
|
2022-04-21 05:14:28 +00:00
|
|
|
const DefaultPaymentMethodsHeaderText = () => (
|
|
|
|
<>
|
2022-07-05 05:28:31 +00:00
|
|
|
<h2>{ __( 'Payment Methods', 'woocommerce' ) }</h2>
|
2022-04-21 05:14:28 +00:00
|
|
|
<div id="payment_gateways_options-description">
|
|
|
|
<p>
|
2022-07-05 05:28:31 +00:00
|
|
|
{ __(
|
|
|
|
'Installed payment methods are listed below and can be sorted to control their display order on the frontend.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
2022-04-21 05:14:28 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2022-04-20 07:29:29 +00:00
|
|
|
export const PaymentsBannerWrapper = () => {
|
2022-08-17 03:33:24 +00:00
|
|
|
const { hasFinishedResolution, shouldShowBanner } = usePaymentsBanner();
|
2022-04-19 08:07:07 +00:00
|
|
|
|
2022-08-17 03:33:24 +00:00
|
|
|
if ( hasFinishedResolution && shouldShowBanner ) {
|
2022-07-06 06:20:11 +00:00
|
|
|
return <WCPaySettingBanner />;
|
2022-04-19 08:07:07 +00:00
|
|
|
}
|
2022-04-21 05:14:28 +00:00
|
|
|
return <DefaultPaymentMethodsHeaderText />;
|
2022-04-19 08:07:07 +00:00
|
|
|
};
|