我正在尝试在结帐页面上添加另一种WooCommerce付款方式,称为xxxx银行网关,并且选择该付款方式后,将加载如下所示的iframe(该iframe将重定向到银行网站,称为$ url)。
如何声明将在Checkout选项下显示的内容?
//Frontend:
<input id="payment_method_xxxx" type="radio" class="input-radio" name="payment_method" value="xxxx" data-order_button_text="">
<label for="payment_method_xxx">
xxx Payment </label>
到目前为止,这是我的代码:
<?php
/*
Plugin Name: xxxxxxx WooCommerce Payment Gateway
Plugin URI: http://www.xxxxxxx.com/
Description: xxxxxxx enables merchants to authorize, settle and manage credit card and electronic check transactions via Web sites, retail stores, mail order/telephone order (MOTO) call centers and mobile devices.
Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
* This action hook registers our PHP class as a WooCommerce payment gateway
*/
add_filter( 'woocommerce_payment_gateways', 'xxxxxxx_add_gateway_class' );
function xxxxxxx_add_gateway_class( $gateways ) {
$gateways[] = 'WC_xxxxxxx_Gateway'; // your class name is here
return $gateways;
}
/*
* The class itself, please note that it is inside plugins_loaded action hook
*/
add_action( 'plugins_loaded', 'xxxxxxx_init_gateway_class' );
function xxxxxxx_init_gateway_class() {
class WC_xxxxxxx_Gateway extends WC_Payment_Gateway {
/**
* Constructor
*/
public function __construct() {
// global ID
$this->id = 'xxxxxxx'; // payment gateway plugin ID
$this->icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name
$this->has_fields = true; // in case you need a custom credit card form
// Show Title
$this->method_title = 'xxxxxxx Gateway';
// Show Description
$this->method_description = 'Description of xxxxxxx payment gateway'; // will be displayed on the options page
// setting defines
$this->init_form_fields();
$this->init_settings();
$this->title = $this->get_option( 'title' );
// further check of SSL if you want
//add_action( 'admin_notices', array( $this, 'do_ssl_check' ) );
// This action hook saves the settings
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ));
}
public function init_form_fields(){
$this->form_fields = array(
'enabled' => array(
'title' => 'Enable/Disable',
'label' => 'Enable Epcipay Gateway',
'type' => 'checkbox',
'description' => '',
'default' => 'no'
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'xxxxxxx Payment', 'woocommerce' ),
'desc_tip' => true,
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'textarea',
'default' => ''
),
'terminal_id' => array(
'title' => 'Terminal Id',
'type' => 'text'
),
'api_key' => array(
'title' => 'API Key',
'type' => 'password',
),
'password' => array(
'title' => 'Password',
'type' => 'text'
),
'pageid' => array(
'title' => 'Page Id',
'type' => 'text'
)
);
}
public function payment_fields() {
//how to add script tag to show the hosted checkout
// credit card form loaded from third party server -- Iframe
}
}