id = 'appota_wallet';
// Đặt language cho phương thức thanh toán
$this->lang = 'vi';
// Đặt Icon trong cấu hình cho phương thức
$this->icon = plugins_url('images/appota-plugin-icon.png', __FILE__);
// Không hiện trường ngoài thanh toán người dùng
$this->has_fields = false;
// Tên phương thức thanh toán
$this->method_title = __('Appota Wallet', 'woocommerce');
// Mô tả phương thức thanh toán
$this->method_description = "Phương thức thanh toán an toàn với chi phí thấp qua cổng thanh toán Appotapay.com";
// Có dùng SSL verify khi gọi API Appota hay không. True: có, False: không
$this->ssl_verify = False;
// Gọi init_form_fields theo chuẩn Woocommerce
$this->init_form_fields();
// Thực hiện chuyển cấu hình init_form_fields thành form cấu hình trong admin
$this->init_settings();
// Lấy thông tin tiêu đề phương thức thanh toán
$this->title = $this->get_option('title');
// Mô tả phương thức thanh toán
$this->description = $this->get_option('description');
// Lấy tên cửa hàng bán
$this->appota_merchant_name = $this->get_option('appota_merchant_name');
// Lấy api key được lưu trong cấu hình
$this->appota_api_key = $this->get_option('appota_api_key');
// Lấy api secret được lưu trong cấu hình
$this->appota_api_secret = $this->get_option('appota_api_secret');
// Lấy api secret được lưu trong cấu hình
$this->appota_api_private_key = $this->get_option('appota_api_secret');
// Lấy tên log file.
$this->appota_log_file = $this->get_option('appota_log_file');
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
add_action('woocommerce_api_wc_appota_wallet', array($this, 'payment_complete'));
if (!$this->is_valid_for_use()) {
$this->enabled = false;
}
}
/**
* Cấu hình các trường dữ liệu cần lưu trong quản trị
*/
public function init_form_fields()
{
parent::init_form_fields();
$this->form_fields = array(
'enabled' => array(
'title' => __('Sử dụng phương thức', 'woocommerce'),
'type' => 'checkbox',
'label' => __('Đồng ý', 'woocommerce'),
'default' => 'yes'
),
'title' => array(
'title' => __('Tiêu đề', 'woocommerce'),
'type' => 'text',
'description' => __('Tiêu đề của phương thức thanh toán bạn muốn hiển thị cho người dùng.', 'woocommerce'),
'default' => __('Appota Wallet', 'woocommerce'),
'desc_tip' => true,
),
'description' => array(
'title' => __('Mô tả phương thức thanh toán', 'woocommerce'),
'type' => 'textarea',
'description' => __('Mô tả của phương thức thanh toán bạn muốn hiển thị cho người dùng.', 'woocommerce'),
'default' => __('Thanh toán an toàn với Appota Wallet. Thực hiện thanh toán với thẻ cào hoặc tài khoản ngân hàng trực tuyến', 'woocommerce')
),
'account_config' => array(
'title' => __('Cấu hình tài khoản', 'woocommerce'),
'type' => 'title',
'description' => '',
),
'appota_merchant_name' => array(
'title' => __('Tên cửa hàng', 'woocommerce'),
'type' => 'text',
'description' => __('Tên cửa hàng của người bán hàng sử dụng cổng thanh toán Appota Pay.', 'woocommerce'),
'default' => '',
'desc_tip' => true,
),
'appota_api_key' => array(
'title' => __('Appota API Key', 'woocommerce'),
'type' => 'text',
'description' => __('API Key của tài khoản.', 'woocommerce'),
'default' => '',
'desc_tip' => true,
),
'appota_api_secret' => array(
'title' => __('Appota API Secret', 'woocommerce'),
'type' => 'text',
'description' => __('API Secret của tài khoản.', 'woocommerce'),
'default' => '',
'desc_tip' => true,
),
'appota_api_private_key' => array(
'title' => __('Appota API Private Key', 'woocommerce'),
'type' => 'textarea',
'description' => __('Private Key để verify khi gọi API lên hệ thống.', 'woocommerce'),
'default' => '',
'desc_tip' => true,
),
'appota_log_file' => array(
'title' => __('Tên file lưu log', 'woocommerce'),
'type' => 'text',
'description' => sprintf(__('Tên file lưu trữ log trong quá trình thực hiện thanh toán bằng cổng Appota Wallet, truy cập file log woocommerce/logs/appota-wallet-%s.log', 'woocommerce'), date("d-m-Y")),
'default' => 'appota-wallet',
'desc_tip' => true,
),
);
}
/**
* Kiểm tra xem loại tiền tệ hệ thống dùng thanh toán có phù hợp với cổng thanh toán không
*
* @access public
* @return bool
*/
function is_valid_for_use()
{
if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_appota_supported_currencies', array('VND'))))
return false;
return true;
}
/**
* Admin Panel Options
* - Hiển thị quản trị cấu hình cho plugins
*
* @since 1.0.0
*/
public function admin_options()
{
?>
:
' . get_post_meta( $order->id, 'appota_wallet_transaction_id', true ). '
'; } } else { /** * Thông báo cài đặt hoặc kích hoạt Woocommerce nếu plugin chưa được cài đặt hoặc kích hoạt */ function appota_wallet_missing_woocommerce_notice() { $class = 'notice notice-error'; $message = __('Hệ thống chưa cài đặt hoặc kích hoạt plugin Woocommerce! Bạn cần cài đặt hoặc kích hoạt Woocommerce để sử dụng plugin Appota Wallet', 'woocomerce-missing-plugin'); printf('%2$s