This should fix the few issues that are left

This commit is contained in:
Joshua Estes 2014-07-08 15:00:35 -04:00
parent d5e583a78e
commit afc19301b3
3 changed files with 10 additions and 24 deletions

View File

@ -245,6 +245,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
public function MarkOrderPaid($order)
{
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
//Mage::log($order->getData(), null, 'bitpay.log');
if ($order->getTotalDue() > 0)
{
@ -264,7 +265,7 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
*/
public function MarkOrderComplete($order)
{
if ($order->getTotalDue() >= 0)
if ($order->getTotalDue() >= 0 && $order->canInvoice())
{
if ($order->hasInvoices())
{
@ -283,10 +284,6 @@ class Bitpay_Bitcoins_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
}
}
}
else
{
Mage::log('MarkOrderComplete called but order '. $order->getId() .' has an outstanding balance that has not been paid.', Zend_Log::WARN, 'bitpay.log');
}
// If the $_bpCreateShipment option is set to true above, this code will
// programmatically create a shipment for you. By design, this will mark

View File

@ -53,6 +53,8 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
throw new Exception('Bitpay callback error:' . $invoice);
}
Mage::log($invoice, null, 'bitpay.log');
// get the order
if (isset($invoice['posData']['quoteId']))
{
@ -89,30 +91,17 @@ class Bitpay_Bitcoins_IndexController extends Mage_Core_Controller_Front_Action
// Map to Magento state Processing
case 'paid':
// Mark paid if there is an outstanding total
if ($order->getTotalDue() > 0)
{
$method = Mage::getModel('Bitcoins/paymentMethod');
$method->MarkOrderPaid($order);
}
else
{
Mage::log('Received a PAID notification from BitPay but there is nothing due on this invoice. Ignoring this IPN.', Zend_Log::INFO, 'bitpay.log');
}
$method = Mage::getModel('Bitcoins/paymentMethod');
$method->MarkOrderPaid($order);
break;
// Map to Magento status Complete
case 'confirmed':
case 'complete':
// Mark confirmed/complete if the order has been paid
if ($order->getTotalDue() <= 0)
{
$method = Mage::getModel('Bitcoins/paymentMethod');
$method->MarkOrderComplete($order);
}
else
{
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');
}
$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');
break;
// Map to Magento State Closed

View File

@ -26,7 +26,7 @@
global $bpconfig;
$bpconfig['host'] = "bitpay.com";
$bpconfig['host'] = "test.bitpay.com";
$bpconfig['port'] = 443;
$bpconfig['hostAndPort'] = $bpconfig['host'];