Centralized where the bitpay.log file is set

This commit is contained in:
Joshua Estes 2014-07-18 10:42:57 -04:00
parent ef7ea99452
commit 2c2a779ec6
5 changed files with 71 additions and 19 deletions

View File

@ -107,8 +107,8 @@ class Bitpay_Bitcoins_Block_Iframe extends Mage_Checkout_Block_Onepage_Payment
if (array_key_exists('error', $invoice))
{
Mage::log('Error creating bitpay invoice', null, 'bitpay.log');
Mage::log($invoice['error'], null, 'bitpay.log');
Mage::log('Error creating bitpay invoice', null, Mage::helper('bitpay')->getLogFile());
Mage::log($invoice['error'], null, Mage::helper('bitpay')->getLogFile());
Mage::throwException("Error creating bit-pay invoice. Please try again or use another payment option.");
return false;

View File

@ -0,0 +1,46 @@
<?php
/**
* The MIT License (MIT)
*
* Copyright (c) 2011-2014 BitPay LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class Bitpay_Bitcoins_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* File that is used to put all logging information in.
*
* @var string
*/
const LOG_FILE = 'bitpay.log';
/**
* Returns the file used for logging
*
* @return string
*/
public function getLogFile()
{
return self::LOG_FILE;
}
}

View File

@ -122,14 +122,14 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
{
if (!$this->isApiKeyConfigured())
{
Mage::log('Bitpay/Bitcoins: API key not entered', Zend_Log::ERR, 'bitpay.log');
Mage::log('Bitpay/Bitcoins: API key not entered', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
return false;
}
if (!$this->isTransactionSpeedConfigured())
{
Mage::log('Bitpay/Bitcoins: Transaction Speed invalid', Zend_Log::ERR, 'bitpay.log');
Mage::log('Bitpay/Bitcoins: Transaction Speed invalid', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
return false;
}
@ -195,7 +195,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
{
// This is the error that is displayed to the customer during checkout.
Mage::throwException("Order not paid for. Please pay first and then Place your Order.");
Mage::log('Order not paid for. Please pay first and then Place Your Order.', Zend_Log::CRIT, 'bitpay.log');
Mage::log('Order not paid for. Please pay first and then Place Your Order.', Zend_Log::CRIT, Mage::helper('bitpay')->getLogFile());
}
else if (!$ipn->GetQuoteComplete($quoteId))
{
@ -234,7 +234,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
catch (Exception $e)
{
Mage::log($e->getMessage(), Zend_Log::EMERG, 'bitpay.log');
Mage::log($e->getMessage(), Zend_Log::EMERG, Mage::helper('bitpay')->getLogFile());
Mage::logException($e);
}
}
@ -255,7 +255,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
else
{
Mage::log('MarkOrderPaid called but order '. $order->getId() .' does not have a balance due.', Zend_Log::WARN, 'bitpay.log');
Mage::log('MarkOrderPaid called but order '. $order->getId() .' does not have a balance due.', Zend_Log::WARN, Mage::helper('bitpay')->getLogFile());
}
}
@ -277,7 +277,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
catch (Exception $e)
{
Mage::log($e->getMessage(), Zend_Log::EMERG, 'bitpay.log');
Mage::log($e->getMessage(), Zend_Log::EMERG, Mage::helper('bitpay')->getLogFile());
Mage::logException($e);
}
}
@ -304,7 +304,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
catch (Exception $e)
{
Mage::log('Error creating shipment for order '. $order->getId() .'.', Zend_Log::ERR, 'bitpay.log');
Mage::log('Error creating shipment for order '. $order->getId() .'.', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
Mage::logException($e);
}
}
@ -329,7 +329,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
catch (Exception $e)
{
Mage::log($e->getMessage(), Zend_Log::EMERG, 'bitpay.log');
Mage::log($e->getMessage(), Zend_Log::EMERG, Mage::helper('bitpay')->getLogFile());
Mage::logException($e);
}
@ -346,7 +346,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
catch (Exception $e)
{
Mage::log('Could not cancel order '. $order->getId() .'.', null, 'bitpay.log');
Mage::log('Could not cancel order '. $order->getId() .'.', null, Mage::helper('bitpay')->getLogFile());
Mage::logException($e);
}
}
@ -418,8 +418,8 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
if (array_key_exists('error', $invoice))
{
Mage::log('Error creating bitpay invoice', Zend_Log::CRIT, 'bitpay.log');
Mage::log($invoice['error'], Zend_Log::CRIT, 'bitpay.log');
Mage::log('Error creating bitpay invoice', Zend_Log::CRIT, Mage::helper('bitpay')->getLogFile());
Mage::log($invoice['error'], Zend_Log::CRIT, Mage::helper('bitpay')->getLogFile());
Mage::throwException("Error creating BitPay invoice. Please try again or use another payment option.");
}
else
@ -458,7 +458,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
$quote = Mage::getModel('sales/quote')->load($quoteId, 'entity_id');
if (!$quote)
{
Mage::log('getQuoteTimestamp: quote not found', Zend_Log::ERR, 'bitpay.log');
Mage::log('getQuoteTimestamp: quote not found', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
return false;
}

View File

@ -49,7 +49,7 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
if (is_string($invoice))
{
Mage::log("bitpay callback error: $invoice", Zend_Log::ERR, 'bitpay.log');
Mage::log("bitpay callback error: $invoice", Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
throw new Exception('Bitpay callback error:' . $invoice);
}
@ -66,7 +66,7 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
}
else
{
Mage::log('Invalid posData, does not contain quoteId or orderId.', Zend_Log::ERR, 'bitpay.log');
Mage::log('Invalid posData, does not contain quoteId or orderId.', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
throw new Exception('Invalid Bitpay IPN received.');
}
@ -75,14 +75,14 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
if (!$order->getId())
{
Mage::log('Order object does not contain an ID', Zend_Log::ERR, 'bitpay.log');
Mage::log('Order object does not contain an ID', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
throw new Exception('Order object does not contain an ID');
}
// update the order if it exists already
// BitPay Statuses
// new, paid, confirmed, complete, expired, invalid
Mage::log('Received IPN with "' . $invoice['status'] . '" status', Zend_Log::DEBUG, 'bitpay.log');
Mage::log('Received IPN with "' . $invoice['status'] . '" status', Zend_Log::DEBUG, Mage::helper('bitpay')->getLogFile());
switch($invoice['status'])
{
@ -99,7 +99,7 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
// Mark confirmed/complete if the order has been paid
$method = Mage::getModel('Bitcoins/paymentMethod');
$method->MarkOrderComplete($order);
//Mage::log('Received a ' . $invoice['status'] . ' notification from BitPay but this order is not paid yet. Possible internal error with Magento. Check order status to confirm.', Zend_Log::ERR, 'bitpay.log');
//Mage::log('Received a ' . $invoice['status'] . ' notification from BitPay but this order is not paid yet. Possible internal error with Magento. Check order status to confirm.', Zend_Log::ERR, Mage::helper('bitpay')->getLogFile());
break;
// Map to Magento State Closed

View File

@ -58,6 +58,12 @@
</bitcoins>
</blocks>
<helpers>
<bitpay>
<class>Bitpay_Bitcoins_Helper</class>
</bitpay>
</helpers>
<models>
<Bitcoins>
<class>Bitpay_Bitcoins_Model</class>