Merge conflict resolved
This commit is contained in:
commit
ea8e340a53
|
@ -107,8 +107,8 @@ class Bitpay_Bitcoins_Block_Iframe extends Mage_Checkout_Block_Onepage_Payment
|
||||||
|
|
||||||
if (array_key_exists('error', $invoice))
|
if (array_key_exists('error', $invoice))
|
||||||
{
|
{
|
||||||
Mage::log('Error creating bitpay invoice', null, 'bitpay.log');
|
Mage::log('Error creating bitpay invoice', null, Mage::helper('bitpay')->getLogFile());
|
||||||
Mage::log($invoice['error'], null, 'bitpay.log');
|
Mage::log($invoice['error'], null, Mage::helper('bitpay')->getLogFile());
|
||||||
Mage::throwException("Error creating bit-pay invoice. Please try again or use another payment option.");
|
Mage::throwException("Error creating bit-pay invoice. Please try again or use another payment option.");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the merchant has set their api key
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasApiKey()
|
||||||
|
{
|
||||||
|
$key = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
||||||
|
|
||||||
|
return !empty($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if Transaction Speed has been configured
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasTransactionSpeed()
|
||||||
|
{
|
||||||
|
$speed = Mage::getStoreConfig('payment/Bitcoins/speed');
|
||||||
|
|
||||||
|
return !empty($speed);
|
||||||
|
}
|
||||||
|
}
|
|
@ -103,12 +103,20 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
//protected $_infoBlockType = 'bitcoins/info';
|
//protected $_infoBlockType = 'bitcoins/info';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $currencyCode
|
* Check method for processing with base currency
|
||||||
|
* @see Mage_Payment_Model_Method_Abstract::canUseForCurrency()
|
||||||
*
|
*
|
||||||
|
* @param string $currencyCode
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canUseForCurrency($currencyCode)
|
public function canUseForCurrency($currencyCode)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Checking if can use currency "%s"', $currencyCode),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
$currencies = Mage::getStoreConfig('payment/Bitcoins/currencies');
|
$currencies = Mage::getStoreConfig('payment/Bitcoins/currencies');
|
||||||
$currencies = array_map('trim', explode(',', $currencies));
|
$currencies = array_map('trim', explode(',', $currencies));
|
||||||
|
|
||||||
|
@ -116,20 +124,33 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* Can be used in regular checkout
|
||||||
|
* @see Mage_Payment_Model_Method_Abstract::canUseCheckout()
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canUseCheckout()
|
public function canUseCheckout()
|
||||||
{
|
{
|
||||||
if (!$this->isApiKeyConfigured())
|
$helper = Mage::helper('bitpay');
|
||||||
|
|
||||||
|
if (!$helper->hasApiKey())
|
||||||
{
|
{
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->isTransactionSpeedConfigured())
|
if (!$helper->hasTransactionSpeed())
|
||||||
{
|
{
|
||||||
Mage::log('Bitpay/Bitcoins: Transaction Speed invalid', Zend_Log::ERR, 'bitpay.log');
|
Mage::log(
|
||||||
|
'Bitpay/Bitcoins: Transaction Speed has not been set',
|
||||||
|
Zend_Log::ERR,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -137,30 +158,6 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
return $this->_canUseCheckout;
|
return $this->_canUseCheckout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the merchant has set their api key
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function isApiKeyConfigured()
|
|
||||||
{
|
|
||||||
$key = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
|
||||||
|
|
||||||
return !empty($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if Transaction Speed has been configured
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function isTransactionSpeedConfigured()
|
|
||||||
{
|
|
||||||
$speed = Mage::getStoreConfig('payment/Bitcoins/speed');
|
|
||||||
|
|
||||||
return !empty($speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authorize payment method
|
* Authorize payment method
|
||||||
*
|
*
|
||||||
|
@ -171,6 +168,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function authorize(Varien_Object $payment, $amount)
|
public function authorize(Varien_Object $payment, $amount)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Authorizing payment'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
if (!Mage::getStoreConfig('payment/Bitcoins/fullscreen'))
|
if (!Mage::getStoreConfig('payment/Bitcoins/fullscreen'))
|
||||||
{
|
{
|
||||||
return $this->CheckForPayment($payment);
|
return $this->CheckForPayment($payment);
|
||||||
|
@ -188,6 +191,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function CheckForPayment($payment)
|
public function CheckForPayment($payment)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Checking for payment'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
$quoteId = $payment->getOrder()->getQuoteId();
|
$quoteId = $payment->getOrder()->getQuoteId();
|
||||||
$ipn = Mage::getModel('Bitcoins/ipn');
|
$ipn = Mage::getModel('Bitcoins/ipn');
|
||||||
|
|
||||||
|
@ -195,7 +204,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
{
|
{
|
||||||
// This is the error that is displayed to the customer during checkout.
|
// 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::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))
|
else if (!$ipn->GetQuoteComplete($quoteId))
|
||||||
{
|
{
|
||||||
|
@ -213,6 +222,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function invoiceOrder($order)
|
public function invoiceOrder($order)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Invoicing order'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!$order->canInvoice())
|
if (!$order->canInvoice())
|
||||||
|
@ -234,7 +249,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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);
|
Mage::logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,6 +259,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function MarkOrderPaid($order)
|
public function MarkOrderPaid($order)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Marking order paid'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
||||||
|
|
||||||
if ($order->getTotalDue() > 0)
|
if ($order->getTotalDue() > 0)
|
||||||
|
@ -255,7 +276,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
else
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +285,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function MarkOrderComplete($order)
|
public function MarkOrderComplete($order)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Marking order paid'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
if ($order->getTotalDue() >= 0 && $order->canInvoice())
|
if ($order->getTotalDue() >= 0 && $order->canInvoice())
|
||||||
{
|
{
|
||||||
if ($order->hasInvoices())
|
if ($order->hasInvoices())
|
||||||
|
@ -277,7 +304,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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);
|
Mage::logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +331,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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);
|
Mage::logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +356,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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);
|
Mage::logException($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,13 +367,19 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function MarkOrderCancelled($order)
|
public function MarkOrderCancelled($order)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Marking order cancelled'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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);
|
Mage::logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,6 +393,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function ExtractAddress($address)
|
public function ExtractAddress($address)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Extracting addess'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
$options['buyerName'] = $address->getName();
|
$options['buyerName'] = $address->getName();
|
||||||
|
|
||||||
|
@ -396,6 +435,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function CreateInvoiceAndRedirect($payment, $amount)
|
public function CreateInvoiceAndRedirect($payment, $amount)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Creating invoice and redirecting'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
include Mage::getBaseDir('lib').'/bitpay/bp_lib.php';
|
include Mage::getBaseDir('lib').'/bitpay/bp_lib.php';
|
||||||
|
|
||||||
$apiKey = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
$apiKey = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
||||||
|
@ -418,8 +463,8 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
|
|
||||||
if (array_key_exists('error', $invoice))
|
if (array_key_exists('error', $invoice))
|
||||||
{
|
{
|
||||||
Mage::log('Error creating bitpay invoice', 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, 'bitpay.log');
|
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.");
|
Mage::throwException("Error creating BitPay invoice. Please try again or use another payment option.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -436,6 +481,12 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function getOrderPlaceRedirectUrl()
|
public function getOrderPlaceRedirectUrl()
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Getting order place redirect url'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
if (Mage::getStoreConfig('payment/Bitcoins/fullscreen'))
|
if (Mage::getStoreConfig('payment/Bitcoins/fullscreen'))
|
||||||
{
|
{
|
||||||
return Mage::getSingleton('customer/session')->getRedirectUrl();
|
return Mage::getSingleton('customer/session')->getRedirectUrl();
|
||||||
|
@ -455,10 +506,16 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
||||||
*/
|
*/
|
||||||
public function getQuoteHash($quoteId)
|
public function getQuoteHash($quoteId)
|
||||||
{
|
{
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Getting the quote hash'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
$quote = Mage::getModel('sales/quote')->load($quoteId, 'entity_id');
|
$quote = Mage::getModel('sales/quote')->load($quoteId, 'entity_id');
|
||||||
if (!$quote)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,19 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
|
||||||
* bitpay's IPN lands here
|
* bitpay's IPN lands here
|
||||||
*/
|
*/
|
||||||
public function indexAction() {
|
public function indexAction() {
|
||||||
|
Mage::log(
|
||||||
|
sprintf('Incoming IPN from bitpay'),
|
||||||
|
Zend_Log::DEBUG,
|
||||||
|
Mage::helper('bitpay')->getLogFile()
|
||||||
|
);
|
||||||
|
|
||||||
require Mage::getBaseDir('lib').'/bitpay/bp_lib.php';
|
require Mage::getBaseDir('lib').'/bitpay/bp_lib.php';
|
||||||
$apiKey = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
$apiKey = Mage::getStoreConfig('payment/Bitcoins/api_key');
|
||||||
$invoice = bpVerifyNotification($apiKey);
|
$invoice = bpVerifyNotification($apiKey);
|
||||||
|
|
||||||
if (is_string($invoice))
|
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);
|
throw new Exception('Bitpay callback error:' . $invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +72,7 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
|
||||||
}
|
}
|
||||||
else
|
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.');
|
throw new Exception('Invalid Bitpay IPN received.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,14 +81,14 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
|
||||||
|
|
||||||
if (!$order->getId())
|
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');
|
throw new Exception('Order object does not contain an ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the order if it exists already
|
// update the order if it exists already
|
||||||
// BitPay Statuses
|
// BitPay Statuses
|
||||||
// new, paid, confirmed, complete, expired, invalid
|
// 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'])
|
switch($invoice['status'])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -99,7 +105,7 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
|
||||||
// Mark confirmed/complete if the order has been paid
|
// Mark confirmed/complete if the order has been paid
|
||||||
$method = Mage::getModel('Bitcoins/paymentMethod');
|
$method = Mage::getModel('Bitcoins/paymentMethod');
|
||||||
$method->MarkOrderComplete($order);
|
$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;
|
break;
|
||||||
|
|
||||||
// Map to Magento State Closed
|
// Map to Magento State Closed
|
||||||
|
|
|
@ -58,6 +58,12 @@
|
||||||
</bitcoins>
|
</bitcoins>
|
||||||
</blocks>
|
</blocks>
|
||||||
|
|
||||||
|
<helpers>
|
||||||
|
<bitpay>
|
||||||
|
<class>Bitpay_Bitcoins_Helper</class>
|
||||||
|
</bitpay>
|
||||||
|
</helpers>
|
||||||
|
|
||||||
<models>
|
<models>
|
||||||
<Bitcoins>
|
<Bitcoins>
|
||||||
<class>Bitpay_Bitcoins_Model</class>
|
<class>Bitpay_Bitcoins_Model</class>
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011-2014 BitPay
|
||||||
|
*
|
||||||
|
* 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_DataTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testHasApiKeyFalse()
|
||||||
|
{
|
||||||
|
Mage::app()->getStore()->setConfig('payment/Bitcoins/api_key', null);
|
||||||
|
|
||||||
|
$this->assertFalse(Mage::helper('bitpay')->hasApiKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasApiKeyTrue()
|
||||||
|
{
|
||||||
|
Mage::app()->getStore()->setConfig('payment/Bitcoins/api_key', 'ThisIsMyApiKey');
|
||||||
|
|
||||||
|
$this->assertTrue(Mage::helper('bitpay')->hasApiKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasTransactionSpeedFalse()
|
||||||
|
{
|
||||||
|
Mage::app()->getStore()->setConfig('payment/Bitcoins/speed', null);
|
||||||
|
|
||||||
|
$this->assertFalse(Mage::helper('bitpay')->hasTransactionSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasTransactionSpeedTrue()
|
||||||
|
{
|
||||||
|
Mage::app()->getStore()->setConfig('payment/Bitcoins/speed', 'low');
|
||||||
|
|
||||||
|
$this->assertTrue(Mage::helper('bitpay')->hasTransactionSpeed());
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
if ($mage = realpath(__DIR__ . '/../build/magento/app/Mage.php')) {
|
if ($mage = realpath(__DIR__ . '/../build/magento/app/Mage.php')) {
|
||||||
require_once $mage;
|
require_once $mage;
|
||||||
|
//Mage::setIsDeveloperMode(true);
|
||||||
Mage::app();
|
Mage::app();
|
||||||
} else {
|
} else {
|
||||||
exit('Could not find Mage.php');
|
exit('Could not find Mage.php');
|
||||||
|
|
Loading…
Reference in New Issue