mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
✨ Add casual selling eligibility check
This commit is contained in:
parent
05657b8b27
commit
654b2e40e9
1 changed files with 24 additions and 4 deletions
|
@ -26,11 +26,12 @@ return array(
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'settings.data.onboarding' => static function ( ContainerInterface $container ) : OnboardingProfile {
|
'settings.data.onboarding' => static function ( ContainerInterface $container ) : OnboardingProfile {
|
||||||
$can_use_casual_selling = false;
|
$can_use_casual_selling = $container->get( 'settings.casual-selling.eligible' );
|
||||||
$can_use_vaulting = $container->has( 'save-payment-methods.eligible' ) && $container->get( 'save-payment-methods.eligible' );
|
$can_use_vaulting = $container->has( 'save-payment-methods.eligible' ) && $container->get( 'save-payment-methods.eligible' );
|
||||||
$can_use_card_payments = $container->has( 'card-fields.eligible' ) && $container->get( 'card-fields.eligible' );
|
$can_use_card_payments = $container->has( 'card-fields.eligible' ) && $container->get( 'card-fields.eligible' );
|
||||||
|
|
||||||
// Card payments are disabled for this plugin when WooPayments is active.
|
// Card payments are disabled for this plugin when WooPayments is active.
|
||||||
|
// TODO: Move this condition to the card-fields.eligible service?
|
||||||
if ( class_exists( '\WC_Payments' ) ) {
|
if ( class_exists( '\WC_Payments' ) ) {
|
||||||
$can_use_card_payments = false;
|
$can_use_card_payments = false;
|
||||||
}
|
}
|
||||||
|
@ -44,4 +45,23 @@ return array(
|
||||||
'settings.rest.onboarding' => static function ( ContainerInterface $container ) : OnboardingRestEndpoint {
|
'settings.rest.onboarding' => static function ( ContainerInterface $container ) : OnboardingRestEndpoint {
|
||||||
return new OnboardingRestEndpoint( $container->get( 'settings.data.onboarding' ) );
|
return new OnboardingRestEndpoint( $container->get( 'settings.data.onboarding' ) );
|
||||||
},
|
},
|
||||||
|
'settings.casual-selling.supported-countries' => static function ( ContainerInterface $container ) : array {
|
||||||
|
// TODO: This is a dummy list, while we wait for the official eligibility list.
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'US',
|
||||||
|
'CA',
|
||||||
|
'DE',
|
||||||
|
'ES',
|
||||||
|
'AT',
|
||||||
|
'CH',
|
||||||
|
'NL',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
'settings.casual-selling.eligible' => static function ( ContainerInterface $container ) : bool {
|
||||||
|
$country = $container->get( 'api.shop.country' );
|
||||||
|
$eligible_countries = $container->get( 'settings.casual-selling.supported-countries' );
|
||||||
|
|
||||||
|
return in_array( $country, $eligible_countries, true );
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue