diff --git a/plugins/woocommerce-admin/readme.txt b/plugins/woocommerce-admin/readme.txt index bcd4ccbe708..235748b26cc 100644 --- a/plugins/woocommerce-admin/readme.txt +++ b/plugins/woocommerce-admin/readme.txt @@ -89,6 +89,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt - Add: Free extension list powered by remote config #6952 - Add: Add PayPal to fallback payment gateways #7001 - Add: Add a data store for WC Payments REST APIs #6918 +- Add: Add Paystack as fallback gateway #7025 - Dev: Update package-lock to fix versioning of local packages. #6843 - Dev: Use rule processing for remote payment methods #6830 - Dev: Update E2E jest config, so it correctly creates screenshots on failure. #6858 diff --git a/plugins/woocommerce-admin/src/Features/RemotePaymentMethods/DefaultPaymentGateways.php b/plugins/woocommerce-admin/src/Features/RemotePaymentMethods/DefaultPaymentGateways.php index d2490f060df..729d9579fff 100644 --- a/plugins/woocommerce-admin/src/Features/RemotePaymentMethods/DefaultPaymentGateways.php +++ b/plugins/woocommerce-admin/src/Features/RemotePaymentMethods/DefaultPaymentGateways.php @@ -20,16 +20,6 @@ class DefaultPaymentGateways { * @return array Default specs. */ public static function get_all() { - $stripe_countries = OnboardingTasks::get_stripe_supported_countries(); - $stripe_countries_rules = array(); - foreach ( $stripe_countries as $country ) { - $stripe_countries_rules[] = (object) array( - 'type' => 'base_location_country', - 'value' => $country, - 'operation' => '=', - ); - } - return array( array( 'key' => 'payfast', @@ -58,10 +48,7 @@ class DefaultPaymentGateways { 'image' => WC()->plugin_url() . '/assets/images/stripe.png', 'plugins' => array( 'woocommerce-gateway-stripe' ), 'is_visible' => array( - (object) array( - 'type' => 'or', - 'operands' => $stripe_countries_rules, - ), + self::get_rules_for_countries( OnboardingTasks::get_stripe_supported_countries() ), (object) array( 'type' => 'option', 'option_name' => 'woocommerce_onboarding_profile', @@ -70,6 +57,70 @@ class DefaultPaymentGateways { ), ), ), + array( + 'key' => 'paystack', + 'title' => __( 'Paystack', 'woocommerce-admin' ), + 'content' => __( 'Paystack helps African merchants accept one-time and recurring payments online with a modern, safe, and secure payment gateway.', 'woocommerce-admin' ), + 'image' => plugins_url( 'images/onboarding/paystack.png', WC_ADMIN_PLUGIN_FILE ), + 'plugins' => array( 'woo-paystack' ), + 'is_visible' => array( + self::get_rules_for_countries( array( 'ZA', 'GH', 'NG' ) ), + self::get_rules_for_cbd( false ), + ), + ), + ); + } + + /** + * Get rules that match the store base location to one of the provided countries. + * + * @param array $countries Array of countries to match. + * @return object Rules to match. + */ + public static function get_rules_for_countries( $countries ) { + $rules = array(); + + foreach ( $countries as $country ) { + $rules[] = (object) array( + 'type' => 'base_location_country', + 'value' => $country, + 'operation' => '=', + ); + } + + return (object) array( + 'type' => 'or', + 'operands' => $rules, + ); + } + + /** + * Get default rules for CBD based on given argument. + * + * @param bool $should_have Whether or not the store should have CBD as an industry (true) or not (false). + * @return array Rules to match. + */ + public static function get_rules_for_cbd( $should_have ) { + return (object) array( + 'type' => 'option', + 'transformers' => array( + (object) array( + 'use' => 'dot_notation', + 'arguments' => (object) array( + 'path' => 'industry', + ), + ), + (object) array( + 'use' => 'array_column', + 'arguments' => (object) array( + 'key' => 'slug', + ), + ), + ), + 'option_name' => 'woocommerce_onboarding_profile', + 'operation' => $should_have ? 'contains' : '!contains', + 'value' => 'cbd-other-hemp-derived-products', + 'default' => array(), ); }