id = 'arsenalpay';
$this->icon = apply_filters( 'woocommerce_arsenalpay_icon', '' . plugin_dir_url(__FILE__) . 'wc-arsenalpay.png' );
$this->method_title = __( 'ArsenalPay', 'woocommerce' );
$this->method_description = __( 'Allows payments with ArsenalPay gateway', 'woocommerce' );
$this->has_fields = false;
// Load settings fields.
$this->init_form_fields();
$this->init_settings();
// Get the settings and load them into variables
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->debug = $this->get_option( 'debug' );
$this->arsenalpay_token = $this->get_option( 'arsenalpay_token' );
$this->arsenalpay_other_code = $this->get_option( 'arsenalpay_other_code' );
$this->arsenalpay_key = $this->get_option( 'arsenalpay_key' );
$this->arsenalpay_css = $this->get_option( 'arsenalpay_css' );
$this->arsenalpay_ip = $this->get_option( 'arsenalpay_ip' );
$this->arsenalpay_check_url = $this->get_option( 'arsenalpay_check_url' );
$this->arsenalpay_src = $this->get_option( 'arsenalpay_src' );
$this->arsenalpay_frame_url = $this->get_option( 'arsenalpay_frame_url' ) ;
$this->arsenalpay_frame_mode = $this->get_option( 'arsenalpay_frame_mode' );
$this->arsenalpay_frame_params = $this->get_option( 'arsenalpay_frame_params' );
// Logs
if ( 'yes' == $this->debug )
{
$this->log = new WC_Logger();
}
// Add display hook of receipt and save hook for settings:
add_action( 'woocommerce_receipt_arsenalpay', array( $this, 'receipt_page' ) );
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
// ArsenalPay callback hook:
add_action( 'woocommerce_api_wc_gw_arsenalpay', array( $this, 'callback_listener' ) );
if ( ! $this->is_valid_for_use() )
{
$this->enabled = false;
}
}
/**
* Check if this gateway is enabled and available in the user's country
*
* @access public
* @return bool
*/
function is_valid_for_use()
{
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_arsenalpay_supported_currencies', array( 'RUB' ) ) ) )
{
return false;
}
return true;
}
public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable ArsenalPay', 'wc-arsenalpay' ),
'default' => 'yes'
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'ArsenalPay', 'woocommerce' ),
'desc_tip' => true,
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'text',
'default' => __( 'Pay with ArsenalPay.', 'wc-arsenalpay' ),
'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce' ),
'desc_tip' => true,
),
'arsenalpay_token' => array(
'title' => __( 'Unique token', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'Assigned to merchant for the access to ArsenalPay payment frame. Required.', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_other_code' => array(
'title' => __( 'Other number or code required for making payments', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'Not accessible for editing to the user and not displayed if it is set. Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_frame_url' => array(
'title' => __( 'Frame URL', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'URL-address of ArsenalPay payment frame. Required.', 'wc-arsenalpay' ),
'default' => 'https://arsenalpay.ru/payframe/pay.php',
'desc_tip' => true,
),
'arsenalpay_src' => array(
'title' => __( 'src parameter', 'wc-arsenalpay' ),
'type' => 'select',
'description' => __( 'Payment type. Possible options: mk - payment from mobile phone (mobile commerce), card - payment by bank card (internet-acquiring). Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
'default' => 'mk',
'options' => array(
'mk' => __( 'mk', 'wc-arsenalpay' ),
'card' => __( 'card', 'wc-arsenalpay' )
)
),
'arsenalpay_css' => array(
'title' => __( 'css option', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'URL of CSS file if exists. Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_key' => array(
'title' => __( 'Sign key', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'With this key you check a validity of sign that comes with callback payment data. Required.', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_ip' => array(
'title' => __( 'Allowed IP-address', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'It can be allowed to receive ArsenalPay payment confirmation callback requests only from the ip address pointed out here. Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_check_url' => array(
'title' => __( 'Check URL.', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'URL to check the existance of transaction. Optional', 'wc-arsenalpay' ),
'desc_tip' => true,
),
'arsenalpay_frame_mode' => array(
'title' => __( 'Frame display mode', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( '1 - to display inside a frame, otherwise on fullscreen payment frame page. Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
'default' => '1',
),
'arsenalpay_frame_params' => array(
'title' => __( 'Frame parameters', 'wc-arsenalpay' ),
'type' => 'text',
'description' => __( 'Parameters of iFrame. Optional.', 'wc-arsenalpay' ),
'desc_tip' => true,
'default' => 'width = "700" height = "500" border = "0" scrolling = "auto"',
),
'debug' => array(
'title' => __( 'Debug Log', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable logging', 'woocommerce' ),
'default' => 'no',
'description' => sprintf( __( 'Log ArsenalPay events, such as callback requests', 'wc-arsenalpay' ), wc_get_log_file_path( 'arsenalpay' ) )
),
);
}
public function admin_options()
{
echo "
".get_bloginfo("url")."/?wc-api=wc_gw_arsenalpay&arsenalpay=success".get_bloginfo("url")."/?wc-api=wc_gw_arsenalpay&arsenalpay=fail".get_bloginfo("url")."/?wc-api=wc_gw_arsenalpay&arsenalpay=callback: