Add Pay Later flag and pass it to welcome docs component

This commit is contained in:
Emili Castells Guasch 2025-02-26 15:46:18 +01:00
parent 109e6517f0
commit 7bf3e83d85
5 changed files with 17 additions and 6 deletions

View file

@ -12,7 +12,8 @@ import AdvancedOptionsForm from '../Components/AdvancedOptionsForm';
const StepWelcome = ( { setStep, currentStep } ) => {
const { storeCountry } = CommonHooks.useWooSettings();
const { canUseCardPayments, canUseFastlane } = OnboardingHooks.useFlags();
const { canUseCardPayments, canUseFastlane, canUsePayLater } =
OnboardingHooks.useFlags();
const nonAcdcIcons = [ 'paypal', 'visa', 'mastercard', 'amex', 'discover' ];
return (
@ -55,7 +56,7 @@ const StepWelcome = ( { setStep, currentStep } ) => {
<WelcomeDocs
useAcdc={ canUseCardPayments }
isFastlane={ canUseFastlane }
isPayLater={ true }
isPayLater={ canUsePayLater }
storeCountry={ storeCountry }
/>
<Separator text={ __( 'or', 'woocommerce-paypal-payments' ) } />

View file

@ -25,6 +25,7 @@ const defaultTransient = Object.freeze( {
canUseSubscriptions: false,
shouldSkipPaymentMethods: false,
canUseFastlane: false,
canUsePayLater: false,
} ),
} );

View file

@ -70,6 +70,7 @@ return array(
->plugin_is_active();
$should_skip_payment_methods = class_exists( '\WC_Payments' );
$can_use_fastlane = $container->get( 'axo.eligible' );
$can_use_pay_later = $container->get( 'button.helper.messages-apply' );
return new OnboardingProfile(
$can_use_casual_selling,
@ -77,7 +78,8 @@ return array(
$can_use_card_payments,
$can_use_subscriptions,
$should_skip_payment_methods,
$can_use_fastlane
$can_use_fastlane,
$can_use_pay_later->for_country()
);
},
'settings.data.general' => static function ( ContainerInterface $container ) : GeneralSettings {

View file

@ -44,6 +44,8 @@ class OnboardingProfile extends AbstractDataModel {
* @param bool $can_use_card_payments Whether credit card payments are possible.
* @param bool $can_use_subscriptions Whether WC Subscriptions plugin is active.
* @param bool $should_skip_payment_methods Whether it should skip payment methods screen.
* @param bool $can_use_fastlane Whether it can use Fastlane or not.
* @param bool $can_use_pay_later Whether it can use PAy Later or not.
*
* @throws RuntimeException If the OPTION_KEY is not defined in the child class.
*/
@ -53,7 +55,8 @@ class OnboardingProfile extends AbstractDataModel {
bool $can_use_card_payments = false,
bool $can_use_subscriptions = false,
bool $should_skip_payment_methods = false,
bool $can_use_fastlane = false
bool $can_use_fastlane = false,
bool $can_use_pay_later = false
) {
parent::__construct();
@ -62,7 +65,8 @@ class OnboardingProfile extends AbstractDataModel {
$this->flags['can_use_card_payments'] = $can_use_card_payments;
$this->flags['can_use_subscriptions'] = $can_use_subscriptions;
$this->flags['should_skip_payment_methods'] = $should_skip_payment_methods;
$this->flags['can_use_fastlane'] = $can_use_fastlane;
$this->flags['can_use_fastlane'] = $can_use_fastlane;
$this->flags['can_use_pay_later'] = $can_use_pay_later;
}
/**

View file

@ -83,9 +83,12 @@ class OnboardingRestEndpoint extends RestEndpoint {
'should_skip_payment_methods' => array(
'js_name' => 'shouldSkipPaymentMethods',
),
'can_use_fastlane' => array(
'can_use_fastlane' => array(
'js_name' => 'canUseFastlane',
),
'can_use_pay_later' => array(
'js_name' => 'canUsePayLater',
),
);
/**