From faaf54206ae6aedbe1f3e251b462f7f31d868789 Mon Sep 17 00:00:00 2001 From: Rich Morgan Date: Thu, 18 Dec 2014 21:00:28 -0500 Subject: [PATCH] Added extra error handling and debugging --- app/code/community/Bitpay/Core/Block/Info.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/code/community/Bitpay/Core/Block/Info.php b/app/code/community/Bitpay/Core/Block/Info.php index 4e003b1..765d93d 100644 --- a/app/code/community/Bitpay/Core/Block/Info.php +++ b/app/code/community/Bitpay/Core/Block/Info.php @@ -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(); } }