woocommerce-paypal-payments/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Steps/StepPaymentMethods.js

96 lines
2.4 KiB
JavaScript
Raw Normal View History

import { __ } from '@wordpress/i18n';
2025-02-07 19:25:40 +01:00
import { useMemo } from '@wordpress/element';
2025-01-10 13:30:06 +01:00
import { CommonHooks, OnboardingHooks } from '../../../../data';
import { OptionSelector } from '../../../ReusableComponents/Fields';
import PricingDescription from '../Components/PricingDescription';
2025-01-10 13:30:06 +01:00
import OnboardingHeader from '../Components/OnboardingHeader';
import PaymentFlow from '../Components/PaymentFlow';
2025-02-07 19:25:40 +01:00
const StepPaymentMethods = () => {
2025-01-23 19:52:17 +01:00
const { optionalMethods, setOptionalMethods } =
OnboardingHooks.useOptionalPaymentMethods();
2025-02-07 19:25:40 +01:00
const { isCasualSeller } = OnboardingHooks.useBusiness();
const optionalMethodTitle = useMemo( () => {
// The BCDC flow does not show a title.
if ( isCasualSeller ) {
return null;
}
return __(
'Available with additional application',
'woocommerce-paypal-payments'
);
}, [ isCasualSeller ] );
const methodChoices = [
{
value: true,
title: optionalMethodTitle,
description: <OptionalMethodDescription />,
},
{
title: __(
'No thanks, I prefer to use a different provider for processing credit cards, digital wallets, and local payment methods',
'woocommerce-paypal-payments'
),
value: false,
},
];
return (
<div className="ppcp-r-page-optional-payment-methods">
<OnboardingHeader title={ <PaymentStepTitle /> } />
<div className="ppcp-r-inner-container">
<OptionSelector
multiSelect={ false }
options={ methodChoices }
2025-01-23 19:52:17 +01:00
onChange={ setOptionalMethods }
value={ optionalMethods }
/>
<PricingDescription />
</div>
</div>
);
};
export default StepPaymentMethods;
const PaymentStepTitle = () => {
const { storeCountry } = CommonHooks.useWooSettings();
if ( 'US' === storeCountry ) {
return __(
'Add Expanded Checkout for More Ways to Pay',
'woocommerce-paypal-payments'
);
}
return __(
'Add optional payment methods to your Checkout',
'woocommerce-paypal-payments'
);
};
const OptionalMethodDescription = () => {
const { storeCountry, storeCurrency } = CommonHooks.useWooSettings();
const { isCasualSeller } = OnboardingHooks.useBusiness();
/**
* Casual sellers = Personal accounts. Those accounts have no ACDC-capabilities, but should get
* the choice for BCDC-payments.
*/
return (
<PaymentFlow
onlyOptional={ true }
useAcdc={ ! isCasualSeller }
isFastlane={ true }
isPayLater={ true }
storeCountry={ storeCountry }
storeCurrency={ storeCurrency }
/>
);
};