wp-woocommerce-pay/includes/blocks/class-easypay-usdt-blocks.php
feibisi daf7932d59
Some checks are pending
gitleaks 密钥泄露扫描 / gitleaks (push) Waiting to run
feicode/ai-security No obvious risky pattern in latest diff
WordPress 插件 CI / ci (push) Successful in -8h1m15s
fix: phpcbf 自动修复 + phpcs.xml 代码规范配置
- phpcbf 自动修复 3893 处格式问题
- 添加 phpcs.xml 排除不适用的规则
- 安全相关规则降级为 warning 保持可见

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 15:19:03 +08:00

130 lines
2.9 KiB
PHP

<?php
/**
* Easypay USDT Blocks Integration
*
* @package WenPaiEPay
* @since 1.0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
/**
* Easypay USDT Blocks Class
*/
class Easypay_Usdt_Blocks extends AbstractPaymentMethodType {
/**
* Payment method name
*
* @var string
*/
protected $name = 'easypay_usdt';
/**
* Constructor
*/
public function __construct() {
// Initialize the payment method
}
/**
* Initialize the payment method
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_easypay_usdt_settings', array() );
}
/**
* Check if the payment method is active
*
* @return boolean
*/
public function is_active() {
// Check if WooCommerce is available
if ( ! function_exists( 'WC' ) || ! WC()->payment_gateways ) {
return false;
}
$payment_gateways = WC()->payment_gateways->payment_gateways();
return isset( $payment_gateways[ $this->name ] ) && 'yes' === $payment_gateways[ $this->name ]->enabled;
}
/**
* Get payment method script handles
*
* @return array
*/
public function get_payment_method_script_handles() {
$script_path = plugin_dir_path( __FILE__ ) . '../../assets/js/easypay-blocks.js';
// Check if script file exists
if ( ! file_exists( $script_path ) ) {
error_log( 'EasyPay Blocks: Script file not found: ' . $script_path );
return array();
}
wp_register_script(
'easypay-blocks-integration',
plugin_dir_url( __FILE__ ) . '../../assets/js/easypay-blocks.js',
array(
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
),
'1.0.1',
true
);
return array( 'easypay-blocks-integration' );
}
/**
* Get payment method data
*
* @return array
*/
public function get_payment_method_data() {
return array(
'name' => $this->name,
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
'logo_url' => plugin_dir_url( __FILE__ ) . '../../assets/logo/usdt-logo.svg',
);
}
/**
* Get supported features
*
* @return array
*/
public function get_supported_features() {
// Check if WooCommerce is available
if ( ! function_exists( 'WC' ) || ! WC()->payment_gateways ) {
return array();
}
$payment_gateways = WC()->payment_gateways->payment_gateways();
if ( isset( $payment_gateways[ $this->name ] ) ) {
return $payment_gateways[ $this->name ]->supports;
}
return array();
}
/**
* Get setting value
*
* @param string $name Setting name.
* @param mixed $default Default value.
* @return mixed
*/
protected function get_setting( $name, $default = '' ) {
return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $default;
}
}