' . sprintf( __( 'Paystack requires WooCommerce to be installed and active. Click %s to install WooCommerce.', 'woo-paystack' ), 'here' ) . '
';
}
/**
* Display the test mode notice.
**/
function tbz_wc_paystack_testmode_notice() {
if ( ! class_exists( Notes::class ) ) {
return;
}
if ( ! class_exists( WC_Data_Store::class ) ) {
return;
}
if ( ! method_exists( Notes::class, 'get_note_by_name' ) ) {
return;
}
$test_mode_note = Notes::get_note_by_name( 'paystack-test-mode' );
if ( false !== $test_mode_note ) {
return;
}
$paystack_settings = get_option( 'woocommerce_paystack_settings' );
$test_mode = $paystack_settings['testmode'] ?? '';
if ( 'yes' !== $test_mode ) {
Notes::delete_notes_with_name( 'paystack-test-mode' );
return;
}
$note = new Note();
$note->set_title( __( 'Paystack test mode enabled', 'woo-paystack' ) );
$note->set_content( __( 'Paystack test mode is currently enabled. Remember to disable it when you want to start accepting live payment on your site.', 'woo-paystack' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_layout( 'plain' );
$note->set_is_snoozable( false );
$note->set_name( 'paystack-test-mode' );
$note->set_source( 'woo-paystack' );
$note->add_action( 'disable-paystack-test-mode', __( 'Disable Paystack test mode', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=paystack' ) );
$note->save();
}
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
);
/**
* Registers WooCommerce Blocks integration.
*/
function tbz_wc_gateway_paystack_woocommerce_block_support() {
if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
require_once __DIR__ . '/includes/class-wc-gateway-paystack-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/class-wc-gateway-custom-paystack-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/gateway-one/class-wc-gateway-paystack-one-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/gateway-two/class-wc-gateway-paystack-two-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/gateway-three/class-wc-gateway-paystack-three-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/gateway-four/class-wc-gateway-paystack-four-blocks-support.php';
require_once __DIR__ . '/includes/custom-gateways/gateway-five/class-wc-gateway-paystack-five-blocks-support.php';
add_action(
'woocommerce_blocks_payment_method_type_registration',
static function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register( new WC_Gateway_Paystack_Blocks_Support() );
$payment_method_registry->register( new WC_Gateway_Paystack_One_Blocks_Support() );
$payment_method_registry->register( new WC_Gateway_Paystack_Two_Blocks_Support() );
$payment_method_registry->register( new WC_Gateway_Paystack_Three_Blocks_Support() );
$payment_method_registry->register( new WC_Gateway_Paystack_Four_Blocks_Support() );
$payment_method_registry->register( new WC_Gateway_Paystack_Five_Blocks_Support() );
}
);
}
}
add_action( 'woocommerce_blocks_loaded', 'tbz_wc_gateway_paystack_woocommerce_block_support' );