-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update return types update code sniffer config update ignore update comments update workflow update comment
- Loading branch information
Showing
4 changed files
with
135 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,73 @@ | ||
<?php | ||
/** | ||
* Class Coingate_For_Woocommerce_Blocks_Support | ||
* | ||
* Provides support for WooCommerce blocks integration with the CoinGate payment gateway. | ||
* | ||
* Extends the AbstractPaymentMethodType to implement specific functionality | ||
* required for handling CoinGate payment methods within WooCommerce Blocks. | ||
* | ||
* @package Coingate_For_Woocommerce | ||
* @subpackage Coingate_For_Woocommerce/includes | ||
* @author CoinGate <[email protected]> | ||
* | ||
* @final | ||
*/ | ||
|
||
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; | ||
|
||
/** | ||
* Class Coingate_For_Woocommerce_Blocks_Support | ||
* | ||
* Provides support for WooCommerce blocks integration with the CoinGate payment gateway. | ||
* | ||
* Extends the AbstractPaymentMethodType to implement specific functionality | ||
* required for handling CoinGate payment methods within WooCommerce Blocks. | ||
* | ||
* @package Coingate_For_Woocommerce | ||
* @subpackage Coingate_For_Woocommerce/includes | ||
* @author CoinGate <[email protected]> | ||
* | ||
* @final | ||
*/ | ||
final class Coingate_For_Woocommerce_Blocks_Support extends AbstractPaymentMethodType { | ||
|
||
/** | ||
* Payment gateway settings. | ||
* | ||
* @var array | ||
*/ | ||
private $gateway; | ||
protected $name = 'coingate'; // payment gateway id | ||
|
||
public function initialize() { | ||
$this->settings = get_option( "woocommerce_coingate_settings", array() ); | ||
} | ||
/** | ||
* Payment method name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'coingate'; | ||
|
||
public function is_active() { | ||
return ! empty( $this->settings[ 'enabled' ] ) && 'yes' === $this->settings[ 'enabled' ]; | ||
/** | ||
* Init | ||
*/ | ||
public function initialize(): void { | ||
$this->settings = get_option( 'woocommerce_coingate_settings', array() ); | ||
} | ||
|
||
public function get_payment_method_script_handles() { | ||
/** | ||
* Payment method enabled. | ||
* | ||
* @return bool | ||
*/ | ||
public function is_active(): bool { | ||
return ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled']; | ||
} | ||
|
||
/** | ||
* Script to use | ||
* | ||
* @return array | ||
*/ | ||
public function get_payment_method_script_handles(): array { | ||
wp_register_script( | ||
'wc-coingate-blocks-integration', | ||
plugin_dir_url( __DIR__ ) . 'build/index.js', | ||
|
@@ -24,20 +77,24 @@ public function get_payment_method_script_handles() { | |
'wp-element', | ||
'wp-html-entities', | ||
), | ||
null, | ||
false, | ||
true | ||
); | ||
|
||
return array( 'wc-coingate-blocks-integration' ); | ||
} | ||
|
||
public function get_payment_method_data() { | ||
return [ | ||
'title' => $this->get_setting( 'title' ), | ||
'description' => $this->get_setting( 'description' ), | ||
// TODO CAN ADD ICON pvz coingate | ||
// 'icon' => plugin_dir_url( __DIR__ ) . 'assets/icon.png', | ||
/** | ||
* Payment method data | ||
* | ||
* @return array | ||
*/ | ||
public function get_payment_method_data(): array { | ||
return array( | ||
'title' => $this->get_setting( 'title' ), | ||
'description' => $this->get_setting( 'description' ), | ||
// 'icon' => plugin_dir_url( __DIR__ ) . 'assets/icon.png', | ||
// 'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] ), | ||
]; | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,72 +19,69 @@ | |
* @subpackage Coingate_For_Woocommerce/public | ||
* @author CoinGate <[email protected]> | ||
*/ | ||
class Coingate_For_Woocommerce_Public | ||
{ | ||
class Coingate_For_Woocommerce_Public { | ||
|
||
/** | ||
* The ID of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $plugin_name The ID of this plugin. | ||
*/ | ||
private $plugin_name; | ||
/** | ||
* The ID of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $plugin_name The ID of this plugin. | ||
*/ | ||
private $plugin_name; | ||
|
||
/** | ||
* The version of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $version The current version of this plugin. | ||
*/ | ||
private $version; | ||
/** | ||
* The version of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $version The current version of this plugin. | ||
*/ | ||
private $version; | ||
|
||
/** | ||
* Initialize the class and set its properties. | ||
* | ||
* @param string $plugin_name The name of the plugin. | ||
* @param string $version The version of this plugin. | ||
* @since 1.0.0 | ||
*/ | ||
public function __construct($plugin_name, $version) | ||
{ | ||
/** | ||
* Initialize the class and set its properties. | ||
* | ||
* @param string $plugin_name The name of the plugin. | ||
* @param string $version The version of this plugin. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function __construct( $plugin_name, $version ) { | ||
|
||
$this->plugin_name = $plugin_name; | ||
$this->version = $version; | ||
$this->plugin_name = $plugin_name; | ||
$this->version = $version; | ||
|
||
} | ||
} | ||
|
||
/** | ||
* Register payment gateway. | ||
* | ||
* @param array $methods Payment gateway methods. | ||
* @return array | ||
*/ | ||
public function register_payment_gateway(array $methods) | ||
{ | ||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-coingate-for-woocommerce-payment-gateway.php'; | ||
/** | ||
* Register payment gateway. | ||
* | ||
* @param array $methods Payment gateway methods. | ||
* | ||
* @return array | ||
*/ | ||
public function register_payment_gateway( array $methods ) { | ||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-coingate-for-woocommerce-payment-gateway.php'; | ||
|
||
if (!isset($methods['Coingate_Payment_Gateway'])) { | ||
$methods['Coingate_Payment_Gateway'] = new Coingate_For_Woocommerce_Payment_Gateway(); | ||
} | ||
if ( ! isset( $methods['Coingate_Payment_Gateway'] ) ) { | ||
$methods['Coingate_Payment_Gateway'] = new Coingate_For_Woocommerce_Payment_Gateway(); | ||
} | ||
|
||
return $methods; | ||
} | ||
return $methods; | ||
} | ||
|
||
/** | ||
* Enable Block support | ||
* | ||
*/ | ||
public function woocommerce_gateway_coingate_block_support() | ||
{ | ||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-coingate-for-woocommerce-blocks-support.php'; | ||
/** | ||
* Enable Block support | ||
*/ | ||
public function woocommerce_gateway_coingate_block_support() { | ||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-coingate-for-woocommerce-blocks-support.php'; | ||
|
||
add_action( | ||
'woocommerce_blocks_payment_method_type_registration', | ||
function (\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { | ||
$payment_method_registry->register(new Coingate_For_Woocommerce_Blocks_Support); | ||
} | ||
); | ||
} | ||
add_action( | ||
'woocommerce_blocks_payment_method_type_registration', | ||
function ( \Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { | ||
$payment_method_registry->register( new Coingate_For_Woocommerce_Blocks_Support() ); | ||
} | ||
); | ||
} | ||
} |