Added extra error handling and debugging

This commit is contained in:
Rich Morgan 2014-12-18 21:00:28 -05:00
parent 701fc2e833
commit faaf54206a
1 changed files with 12 additions and 1 deletions

View File

@ -15,11 +15,22 @@ class Bitpay_Core_Block_Info extends Mage_Payment_Block_Info
public function getBitpayInvoiceUrl()
{
$order = $this->getInfo()->getOrder();
if (false === isset($order) || true === empty($order)) {
Mage::helper('bitpay')->debugData('[ERROR] In Bitpay_Core_Block_Info::getBitpayInvoiceUrl(): could not obtain the order.');
throw new Exception('In Bitpay_Core_Block_Info::getBitpayInvoiceUrl(): could not obtain the order.');
}
$incrementId = $order->getIncrementId();
if (false === isset($incrementId) || true === empty($incrementId)) {
Mage::helper('bitpay')->debugData('[ERROR] In Bitpay_Core_Block_Info::getBitpayInvoiceUrl(): could not obtain the incrementId.');
throw new Exception('In Bitpay_Core_Block_Info::getBitpayInvoiceUrl(): could not obtain the incrementId.');
}
$bitpayInvoice = Mage::getModel('bitpay/invoice')->load($incrementId, 'increment_id');
if ($bitpayInvoice) {
if (true === isset($bitpayInvoice) && false === empty($bitpayInvoice)) {
return $bitpayInvoice->getUrl();
}
}