How to add iframe payment gateway in woocommerce?

Viewed 1331

I am trying to add another WooCommerce payment method called xxxx Bank Gateway on checkout page and when selected, this payment method will load an iframe like below (the iframe will redirect to the banks site lets call it $url).

How can I declare the content that will be displayed below the Checkout option?

//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>

Here is my code so far:

<?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
}
}
0 Answers
Related