mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +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
|
@ -14,7 +14,7 @@ use WooCommerce\PayPalCommerce\Settings\Endpoint\OnboardingRestEndpoint;
|
|||
use WooCommerce\PayPalCommerce\Settings\Data\OnboardingProfile;
|
||||
|
||||
return array(
|
||||
'settings.url' => static function ( ContainerInterface $container ) : string {
|
||||
'settings.url' => static function ( ContainerInterface $container ) : string {
|
||||
/**
|
||||
* The path cannot be false.
|
||||
*
|
||||
|
@ -25,12 +25,13 @@ return array(
|
|||
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
|
||||
);
|
||||
},
|
||||
'settings.data.onboarding' => static function ( ContainerInterface $container ) : OnboardingProfile {
|
||||
$can_use_casual_selling = false;
|
||||
'settings.data.onboarding' => static function ( ContainerInterface $container ) : OnboardingProfile {
|
||||
$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_card_payments = $container->has( 'card-fields.eligible' ) && $container->get( 'card-fields.eligible' );
|
||||
|
||||
// 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' ) ) {
|
||||
$can_use_card_payments = false;
|
||||
}
|
||||
|
@ -41,7 +42,26 @@ return array(
|
|||
$can_use_card_payments
|
||||
);
|
||||
},
|
||||
'settings.rest.onboarding' => static function ( ContainerInterface $container ) : OnboardingRestEndpoint {
|
||||
'settings.rest.onboarding' => static function ( ContainerInterface $container ) : OnboardingRestEndpoint {
|
||||
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