* @link http://dev.gaslightmedia.com/
*/
-// Load glmMesPluginSupport class
-// require_once (GLM_MES_PLUGIN_PATH . '/classes/glmMesPluginSupport.php');
-
/*
* This class performs all necessary additional work when this
* plugin is activated.
class glmMesPluginActivate // extends glmMesPluginSupport
{
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
/**
* Plugin Configuration Data
*
*
* Performs all the work for this model
*/
- public function __construct ($wpdb, $config)
+ public function __construct ()
{
// Make sure the current user has this capability
if (! current_user_can('activate_plugins')) {
$this->addNotice("Interesting, you don't have permission to activate plugins.");
die();
}
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
}
}
--- /dev/null
+<?php
+
+class TpgTransaction
+{
+
+ var $Post = true;
+
+ var $ApiHost = "https://cert.merchante-solutions.com/mes-api/tridentApi";
+
+ var $ProxyHost = "";
+
+ var $ProfileId;
+
+ var $ProfileKey;
+
+ var $TranType = "A";
+
+ var $CurlInfo;
+
+ var $ApiResponse;
+
+ var $ErrorMessage;
+
+ var $ResponseRaw;
+
+ var $ResponseFields;
+
+ var $RequestFields;
+
+ var $RequestFieldNames = array(
+ "avs_data",
+ "cardholder_street_address",
+ "cardholder_zip",
+ "cvv2",
+ "transaction_amount",
+ "card_number",
+ "card_exp_date",
+ "transaction_id",
+ "card_present",
+ "reference_number",
+ "merchant_name",
+ "merchant_city",
+ "merchant_state",
+ "merchant_zip",
+ "merchant_category_code",
+ "merchant_phone",
+ "invoice_number",
+ "tax_amount",
+ "ship_to_zip",
+ "moto_ecommerce_ind",
+ "industry_code",
+ "auth_code",
+ "card_id",
+ "country_code",
+ "fx_amount",
+ "fx_rate_id",
+ "currency_code",
+ "rctl_product_level",
+ "echo_customfield",
+ "3d_payload",
+ "3d_transaction_id",
+ "client_reference_number",
+ "bml_request",
+ "promo_code",
+ "order_num",
+ "order_desc",
+ "amount",
+ "ship_amount",
+ "ip_address",
+ "bill_first_name",
+ "bill_middle_name",
+ "bill_last_name",
+ "bill_addr1",
+ "bill_addr2",
+ "bill_city",
+ "bill_state",
+ "bill_zip",
+ "bill_phone1",
+ "bill_phone2",
+ "bill_email",
+ "ship_first_name",
+ "ship_middle_name",
+ "ship_last_name",
+ "ship_addr1",
+ "ship_addr2",
+ "ship_city",
+ "ship_state",
+ "ship_zip",
+ "ship_phone1",
+ "ship_phone2",
+ "ship_email"
+ );
+
+ var $url;
+ var $settings;
+
+ function TpgTransaction ($profileId = '', $profileKey = '')
+ {
+ $this->setProfile($profileId, $profileKey);
+ }
+
+ function execute ()
+ {
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: TpgTransaction::execute() called', 'success' );
+ }
+
+ if ($this->isValid()) {
+ $url .= "profile_id=" . $this->ProfileId;
+ $url .= "&profile_key=" . $this->ProfileKey;
+
+ $url .= "&transaction_type=" . $this->TranType;
+ foreach ($this->RequestFieldNames as $fname) {
+ if (isset($this->RequestFields[$fname])) {
+ $url .= "&" . $fname . "=" . $this->RequestFields[$fname];
+ }
+ }
+ $this->url = $url;
+
+ $this->processRequest();
+ }
+ }
+
+ function getResponseField ($fieldName)
+ {
+ $retVal = '';
+ if (isset($this->ResponseFields[$fieldName])) {
+ $retVal = $this->ResponseFields[$fieldName];
+ }
+ return ($retVal);
+ }
+
+ function isApproved ()
+ {
+ $errorCode = $this->getResponseField('error_code');
+ $retVal = FALSE;
+ if ($errorCode == '000') {
+ $retVal = TRUE;
+ } else
+ if ($errorCode == '085' && $this->TranType == 'A') {
+ $retVal = TRUE;
+ }
+ return ($retVal);
+ }
+
+ function isBlank ($value)
+ {
+ return ($value == "");
+ }
+
+ function isValid ()
+ {
+ $retVal = TRUE; // assume true
+ $this->ErrorMessage = "";
+ if ($this->isBlank($this->ProfileId) || $this->isBlank(
+ $this->ProfileKey)) {
+ $this->ErrorMessage = "Missing profile data";
+ } else
+ if (isset($this->RequestFields['transaction_amount']) &&
+ ! is_numeric($this->RequestFields['transaction_amount'])) {
+ $this->ErrorMessage = "Amount must be a number";
+ }
+
+ $isBlank = $this->isBlank($this->ErrorMessage);
+
+ if (!$isBlank) {
+ wc_add_notice('GLM MeS Gateway: '.$this->ErrorMessage.'</p><p>Check credentials for Merchant e-Solutions settings.</p>', 'error' );
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('Supplied Credentials: <p><b>ID:</b>'.$this->ProfileId.'<br><b>Key:</b>'.$this->ProfileKey.'<br>Check .</p>', 'error' );
+ }
+ }
+
+ return ($isBlank);
+ }
+
+ function parseResponse ($response)
+ {
+ $this->ResponseRaw = $response;
+ $responseFields = explode("&", $response);
+
+ if (GLM_MES_DEBUG && count($responseField) == 0) {
+ wc_add_notice('GLM MeS Gateway: parseResponse()<p>No Response Received!</p>', 'error' );
+ }
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: parseResponse() called<p><pre>'.print_r($responseFields,1).'</pre></p>', 'success' );
+ }
+
+ foreach ($responseFields as $field) {
+ $nameValue = explode("=", $field);
+ $this->ResponseFields[$nameValue[0]] = $nameValue[1];
+ }
+
+ }
+
+ function processRequest ()
+ {
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: processRequest() called', 'success' );
+ }
+
+ $ch = curl_init();
+
+ if ($this->Post) // Use POST
+ {
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->url);
+ curl_setopt($ch, CURLOPT_URL, $this->ApiHost);
+ // Use GET(cURL default)
+ } else {
+ curl_setopt($ch, CURLOPT_URL,
+ $url = $this->ApiHost . "?" . $this->url);
+ }
+
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+
+ if (! $this->isBlank($this->ProxyHost)) {
+ curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ curl_setopt($ch, CURLOPT_PROXY, $this->ProxyHost);
+ }
+
+ curl_setopt($ch, CURLOPT_TIMEOUT, 120);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+
+ $this->parseResponse(curl_exec($ch));
+
+ $this->CurlInfo = curl_getinfo($ch);
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: Curl Action Info<p><pre>'.print_r($this->CurlInfo,1).'</pre></p>', 'success');
+ }
+
+ }
+
+ function setAvsRequest ($cardholderStreetAddr, $cardholderZip)
+ {
+ $this->setRequestField("cardholder_street_address",
+ $cardholderStreetAddr);
+ $this->setRequestField("cardholder_zip", $cardholderZip);
+ }
+
+ function setHost ($host)
+ {
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: setHost() called', 'success');
+ }
+
+ $this->ApiHost = $host;
+ }
+
+ function setProfile ($profileId, $profileKey)
+ {
+ $this->ProfileId = $profileId;
+ $this->ProfileKey = $profileKey;
+ }
+
+ function setProxyHost ($proxyHost)
+ {
+ $this->ProxyHost = $proxyHost;
+ }
+
+ function setRequestField ($fieldName, $fieldValue)
+ {
+ $this->RequestFields[$fieldName] = urlencode($fieldValue);
+ }
+
+ function setTransactionData ($cardNumber, $expDate, $tranAmount = 0.0)
+ {
+ $this->RequestFields['card_number'] = $cardNumber;
+ $this->RequestFields['card_exp_date'] = $expDate;
+ $this->RequestFields['transaction_amount'] = $tranAmount;
+ }
+
+ function setPost ($bool)
+ {
+ $this->Post = $bool;
+ }
+
+ function setDynamicData ($name, $city, $state, $zip, $mcc, $phone)
+ {
+ $this->RequestFields['merchant_name'] = $name;
+ $this->RequestFields['merchant_city'] = $city;
+ $this->RequestFields['merchant_state'] = $state;
+ $this->RequestFields['merchant_zip'] = $zip;
+ $this->RequestFields['merchant_category_code'] = $mcc;
+ $this->RequestFields['merchant_phone'] = $phone;
+ }
+}
+
+class TpgPreAuth extends TpgTransaction
+{
+
+ function TpgPreAuth ($profileId = '', $profileKey = '')
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->TranType = "P"; // pre-auth
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+
+ function setFXData ($amt, $rid, $curr)
+ {
+ $this->RequestFields['fx_amount'] = $amt;
+ $this->RequestFields['fx_rate_id'] = $rid;
+ $this->RequestFields['currency_code'] = $curr;
+ }
+
+ function setEcommInd ($ind)
+ {
+ $this->RequestFields['moto_ecommerce_ind'] = $ind;
+ }
+}
+
+class TpgSale extends TpgTransaction
+{
+
+ function TpgSale ($profileId, $profileKey, $setings)
+ {
+
+ $this->settings = $settings;
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: TpgSale() called<p>', 'success' );
+ }
+
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->TranType = "D";
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+
+ function setFXData ($amt, $rid, $curr)
+ {
+ $this->RequestFields['fx_amount'] = $amt;
+ $this->RequestFields['fx_rate_id'] = $rid;
+ $this->RequestFields['currency_code'] = $curr;
+ }
+
+ function setEcommInd ($ind)
+ {
+ $this->RequestFields['moto_ecommerce_ind'] = $ind;
+ }
+}
+
+class TpgCredit extends TpgTransaction
+{
+
+ function TpgCredit ($profileId, $profileKey)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->TranType = "C";
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+}
+
+class TpgSettle extends TpgTransaction
+{
+
+ function TpgSettle ($profileId, $profileKey, $tranId, $settleAmount = 0)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->RequestFields['transaction_id'] = $tranId;
+ $this->RequestFields['transaction_amount'] = $settleAmount;
+ $this->TranType = "S";
+ }
+
+ function setSettlementAmount ($settleAmount)
+ {
+ $this->RequestFields['transaction_amount'] = $settleAmount;
+ }
+}
+
+class TpgRefund extends TpgTransaction
+{
+
+ function TpgRefund ($profileId, $profileKey, $tranId)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->RequestFields['transaction_id'] = $tranId;
+ $this->TranType = "U";
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+}
+
+class TpgVoid extends TpgTransaction
+{
+
+ function TpgVoid ($profileId, $profileKey, $tranId)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->RequestFields['transaction_id'] = $tranId;
+ $this->TranType = "V";
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+}
+
+class TpgOffline extends TpgTransaction
+{
+
+ function TpgOffline ($profileId, $profileKey, $authCode)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->RequestFields['auth_code'] = $authCode;
+ $this->TranType = "O";
+ }
+
+ function setStoredData ($cardId, $amount)
+ {
+ $this->RequestFields['card_id'] = $cardId;
+ $this->RequestFields['transaction_amount'] = $amount;
+ }
+}
+
+class TpgStoreData extends TpgTransaction
+{
+
+ function TpgStoreData ($profileId, $profileKey)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->TranType = "T";
+ }
+}
+
+class TpgRemoveData extends TpgTransaction
+{
+
+ function TpgRemoveData ($profileId, $profileKey, $cardId)
+ {
+ $this->TpgTransaction($profileId, $profileKey);
+ $this->RequestFields['card_id'] = $cardId;
+ $this->TranType = "X";
+ }
+}
+
+?>
\ No newline at end of file
class GlmMesGateway extends WC_Payment_Gateway
{
- /**
+ /**
* Gateway ID
*
* @var $id
* @access public
*/
public $id = 'merchant_e_solutions';
+ /**
+ * Gateway Title
+ *
+ * @var $title
+ * @access public
+ */
+ public $title;
+ /**
+ * Gateway Description
+ *
+ * @var $description
+ * @access public
+ */
+ public $description;
/**
* Gateway Icon URL
*
*/
public $method_title = 'Merchant e-Solutions';
/**
- * Payment Gateway Description
+ * Profile ID
*
- * @var $method_description
+ * @var $profile_id
* @access public
*/
- public $method_description = 'Processes credit card payments through the Merchant e-Solutions Payment Gateway';
+ public $profile_id;
+ /**
+ * Profile Key
+ *
+ * @var $profile_key
+ * @access public
+ */
+ public $profile_key;
+ /**
+ * Processing URL
+ *
+ * @var $url
+ * @access public
+ */
+ public $url;
public function __construct ()
{
-
// Add filter for our gateway
add_filter( 'woocommerce_payment_gateways', array( $this, 'glmMesAddGateway') );
// Setup Fields and Settings
- $this->glmMesInitFormFields();
- $this->glmMesInitSettings();
+ $this->init_form_fields();
+ $this->init_settings();
+
+ $this -> title = $this -> settings['title'];
+ $this -> description = $this -> settings['description'];
+
+ // Determine if we're in test or production mode
+ switch ($this -> settings['transaction_mode']) {
+
+ case 'test':
+ $this->profile_id = $this -> settings['test_profile_id'];
+ $this->profile_key = $this -> settings['test_profile_key'];
+ $this->host = $this -> settings['test_url'];
+ break;
+
+ case 'production':
+ $this->profile_id = $this -> settings['prod_profile_id'];
+ $this->profile_key = $this -> settings['prod_profile_key'];
+ $this->host = $this -> settings['prod_url'];
+ break;
+
+ }
- // Get any settings
- $this->title = $this->get_option('title');
+ if (!defined('GLM_MES_DEBUG')) {
+ $d = ($this -> settings['mes_debug'] == 'yes');
+ define('GLM_MES_DEBUG', $d);
+ $d = ($this -> settings['mes_debug_verbose'] == 'yes');
+ define('GLM_MES_DEBUG_VERBOSE', $d);
+ }
- add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'glmMesProcessAdminOptions' ) );
+ add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
}
*/
- public function glmMesInitFormFields()
+ public function init_form_fields()
{
$this->form_fields = array(
'title' => __( 'Customer Message', 'woocommerce' ),
'type' => 'textarea',
'default' => ''
- )
- );
+ ),
- }
+ 'sep_1' => array(
+ 'title' => __( 'Test Mode Credentials', 'woocommerce' ),
+ 'type' => 'title',
+ 'description' => '',
+ ),
- // Initialize Settings
- public function glmMesInitSettings()
- {
+ // MeS Gateway Profile ID
+ 'test_profile_id' => array(
+ 'title' => __( 'Test Profile ID', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( '9410000xxxxx00000001', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
- }
+ // MeS Gateway Profile Key
+ 'test_profile_key' => array(
+ 'title' => __( 'Test Profile Key', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
- // Init Form Fields
- public function glmMesProcessAdminOptions()
- {
+ // MeS Gateway Test URL
+ 'test_url' => array(
+ 'title' => __( 'Test URL', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( 'https://cert.merchante-solutions.com/mes-api/tridentApi', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
- }
+ 'sep_2' => array(
+ 'title' => __( '<p> </p>Production Mode Credentials', 'woocommerce' ),
+ 'type' => 'title',
+ 'description' => '',
+ ),
- // Process Admin Options
- public function glmProcessAdminOptions()
- {
+ // MeS Gateway Profile ID
+ 'prod_profile_id' => array(
+ 'title' => __( 'Production Profile ID', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( '9410000xxxxx00000001', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
+
+ // MeS Gateway Profile Key
+ 'prod_profile_key' => array(
+ 'title' => __( 'Production Profile Key', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
+
+ // MeS Gateway Test URL
+ 'prod_url' => array(
+ 'title' => __( 'Production URL', 'woocommerce' ),
+ 'type' => 'text',
+ 'default' => __( 'https://cert.merchante-solutions.com/mes-api/tridentApi', 'woocommerce' ),
+ 'desc_tip' => false,
+ ),
+
+ 'sep_3' => array(
+ 'title' => __( '<p> </p>Mode Selection', 'woocommerce' ),
+ 'type' => 'title',
+ 'description' => '',
+ ),
+
+ // Set Transaction Mode
+ 'transaction_mode' => array(
+ 'title' => __( 'Transaction Mode', 'woocommerce' ),
+ 'type' => 'select',
+ 'label' => __( 'Must be in "Production Mode" for live transactions.', 'woocommerce' ),
+ 'description' => __( 'See <a href="http://resources.merchante-solutions.com/display/TPGPUB/Payment+Gateway+Certification+Request+Form" target="_blank">MeS Payment Certification Form</a> to apply for required ID and Key below.', 'woocommerce' ),
+ 'default' => 'test',
+ 'desc_tip' => false,
+ 'options' => array(
+ 'test' => __( 'Test Mode', 'woocommerce' ),
+ 'production' => __( 'Production Mode', 'woocommerce' )
+ )
+ ),
+
+ // Set Debug Mode
+ 'mes_debug' => array(
+ 'title' => __( 'Enable Debug Information', 'woocommerce' ),
+ 'type' => 'checkbox',
+ 'label' => __( '', 'woocommerce' ),
+ 'default' => 'no'
+ ),
+
+ // Set Debug Verbose Mode
+ 'mes_debug_verbose' => array(
+ 'title' => __( 'Enable Verbose Debug', 'woocommerce' ),
+ 'type' => 'checkbox',
+ 'label' => __( '', 'woocommerce' ),
+ 'default' => 'no'
+ )
+
+ );
}
// Set Payment Fields
public function payment_fields()
{
-
require_once (GLM_MES_PLUGIN_PATH . '/views/paymentForm.html');
-
}
// Validate Payment Fields
global $woocommerce;
$order = new WC_Order( $order_id );
- /*
- * Process order here
- *
- * Returns various status states
- */
- $paymentState = 'complete';
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: process_payment() called', 'success' );
+ }
+
+ // Create transaction object
+ require_once (GLM_MES_PLUGIN_CLASS_PATH . '/MesTridentGateway.php');
+ $trans = new TpgSale( $this->profile_id, $this->profile_key, $this->settings );
+
+ // Set transaction data
+ $trans->setAvsRequest( '123 Main Street', '55555' );
+ $trans->setRequestField('cvv2', '123');
+ $trans->setRequestField('invoice_number','123456');
+ $trans->setTransactionData( "4012888812348882", "1212", "1.00" );
+
+ // Call the MeS Gateway
+ $trans->setHost($this->host);
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: Transaction Request<p><pre>'.print_r($trans,1).'</pre></p>', 'success');
+ }
+
+ $trans->execute();
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: Transaction Response<p>'.$this->ErrorMessage.'<br><pre>'.print_r($tran->ResponseFields,1).'</pre></p>', 'success');
+ }
+
+ // Check result
+ if( $tran->isApproved() ) {
+ $paymentState = 'approved';
+ } else {
+ $paymentState = 'fail';
+ }
// Take action based on payment state
switch ($paymentState) {
+++ /dev/null
-<?php
-
-/**
- * GLM WooCommerce Merchant e-Solutions Gateway
- * Plugin support class
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMerchantESolutions
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @release classes/glmMesPluginSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link http://dev.gaslightmedia.com/
- */
-
-/*
- * This class provides some standard methods used by this plugin
- */
-class GlmMesPluginSupport
-{
-
-
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-;
-; Main Configuration File
-; GLM WooCommerce Merchant e-Solutions Gateway
-;
-; Custom configurations for development and developer configuration at bottom of file.
-;
-
-[common]
-
-;
-; Site Configuration Options
-;
-
-; Debug Options
-debug = false
-debug_verbose = false
-
-; Site Time Zone
-timezone = America/Detroit
-
-;
-; End of site configuration options
-;
-
-; Phrases
-phrase['phrase_test'] = 'test'
-
-;
-; Override sections for various servers by GLM_HOST_ID
-;
-
-[production:common]
-
-
-[development:common]
-
-
-[chuck:common]
-debug = true
-debug_verbose = false
-
+++ /dev/null
-<?php
-
-/**
- * GLM WooCommerce Merchant e-Solutions Gateway
- * Controller
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMerchantESolutions
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @release controllers/controller.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link http://dev.gaslightmedia.com/
- */
-
-// Load glmMesPluginSupport class
-// require_once (GLM_MES_PLUGIN_PATH . '/classes/glmMesPluginSupport.php');
-
-/*
- * This class controls which models are used.
- */
-class glmMesController // extends GlmMesPluginSupport
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
-
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
-
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- add_action( 'plugins_loaded', array( $this, 'initMesGateway') );
-
- }
-
- /**
- * Initialize MES Gateway
- *
- * @return void
- * @access public
- */
- public function initMesGateway()
- {
- require_once (GLM_MES_PLUGIN_PATH . '/classes/glmMesGateway.php');
- new glmMesGateway();
-
- }
-
-
- /**
- * Controller
- *
- * @return void
- * @access public
- */
- public function controller ()
- {
-
- }
-}
-?>
\ No newline at end of file
* @link http://dev.gaslightmedia.com/
*/
-// Load glmMesPluginSupport class
-require_once (GLM_MES_PLUGIN_PATH . '/classes/glmMesPluginSupport.php');
-
/*
* This class performs all necessary additional work when this
* plugin is deactivated.
class glmMesPluginDeactivate // extends glmMesPluginSupport
{
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
/**
* Plugin Configuration Data
*
*
* Performs all the work for this model
*/
- public function __construct ($wpdb, $config)
+ public function __construct ()
{
// Make sure the current user has this capability
if (!current_user_can('activate_plugins')) {
die();
}
+ }
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
- }
}
?>
\ No newline at end of file
define('GLM_MES_PLUGIN_NAME', 'Gaslight Media WooCommerce Merchant e-Solutions Gateway');
define('GLM_MES_PLUGIN_DIR', 'glm-woocommerce-merchant-e-solutions-gateway');
-// Determine which system we're running on - If not provided, assume PRODUCTION
-$host = getenv('GLM_HOST_ID');
-if (trim($host) == '') {
- $host = 'PRODUCTION';
-}
-define('GLM_MES_PLUGIN_HOST', $host);
-
-// Determine current http/https protocol
-$pageProtocol = 'http';
-if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
- $pageProtocol = 'https';
-}
-define('GLM_MES_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
-
// Plugin Versions
define('GLM_MES_PLUGIN_VERSION', 0.1);
define('GLM_MES_PLUGIN_DB_VERSION', 0.1);
-// URLs
-$adminURL = admin_url('admin.php');
-define('GLM_MES_PLUGIN_ADMIN_URL', $adminURL);
-define('GLM_MES_PLUGIN_URL', plugin_dir_url(__FILE__));
-$pageUri = explode('?', $_SERVER['REQUEST_URI']); // Bust this up to access URL path and script name only
-define('GLM_MES_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MES_PLUGIN_DIR);
-define('GLM_MES_PLUGIN_CURRENT_URL', $pageProtocol.'://'.$_SERVER['SERVER_NAME'].$pageUri[0]);
-define('GLM_MES_PLUGIN_MEDIA_URL', WP_CONTENT_URL.'/plugins/'.GLM_MES_PLUGIN_DIR.'/media');
-
-
// Directories
define('GLM_MES_PLUGIN_PATH', dirname(__FILE__));
define('GLM_MES_PLUGIN_CLASS_PATH', GLM_MES_PLUGIN_PATH.'/classes');
-define('GLM_MES_PLUGIN_CONFIG_PATH', GLM_MES_PLUGIN_PATH.'/config');
-
-
-// Database table prefixes
-global $wpdb;
-define('GLM_MES_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_MES_');
?>
\ No newline at end of file
// Get standard defined parameters
require_once('defines.php');
-// Get plugin configuration
-$configData = parse_ini_file(GLM_MES_PLUGIN_PATH.'/config/plugin.ini', true);
-$config = $configData['common'];
-
-// Override parameters according to GLM_HOST_ID
-$hostSection = strtolower(GLM_MES_PLUGIN_HOST).':common';
-if (isset($configData[$hostSection])) {
- $config = array_replace($config, $configData[strtolower(GLM_MES_PLUGIN_HOST).':common']);
-} else {
- $startupNotices .=
- '<p><b>Bad configuration file section name or section not found:</b> '. $hostSection
- .'<br>See plugin '.GLM_MES_PLUGIN_PATH.'config/plugin.ini file.'
- .'<br>Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.</p>'
- ;
-}
-
-// Add Debug defines - These can't go into the defines.php file - Guess why.
-define('GLM_MES_PLUGIN_DEBUG', $config['debug']);
-define('GLM_MES_PLUGIN_DEBUG_VERBOSE', $config['debug_verbose']);
-
/**
* *******************************************************************************
*
// Activate
function glmMesPluginActivate ()
{
- global $wpdb, $config;
require_once (GLM_MES_PLUGIN_PATH . '/activate.php');
- new glmMesPluginActivate($wpdb, $config);
+ new glmMesPluginActivate();
}
register_activation_hook(__FILE__, 'glmMesPluginActivate');
// Deactivate
function glmMesPluginDeactivate ()
{
- global $wpdb, $config;
require_once (GLM_MES_PLUGIN_PATH . '/deactivate.php');
- $x = new glmMesPluginDeactivate($wpdb, $config);
+ $x = new glmMesPluginDeactivate();
return false;
}
register_deactivation_hook(__FILE__, 'glmMesPluginDeactivate');
*
*/
-require_once (GLM_MES_PLUGIN_PATH . '/controllers/controller.php');
-new glmMesController($wpdb, $config);
+add_action( 'plugins_loaded', 'initMesGateway' );
+
+/**
+ * Initialize MES Gateway
+ *
+ * @return void
+ * @access public
+ */
+function initMesGateway()
+{
+ require_once (GLM_MES_PLUGIN_CLASS_PATH . '/glmMesGateway.php');
+ new glmMesGateway();
+}
?>
\ No newline at end of file