diff --git a/CHANGELOG b/CHANGELOG index debf998..3a77c5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +2.1.16 + Fixed creating after payment a second invoice in database instead of update invoice issue 2.1.14 Use Magento shop base currency to create a BitPay invoice (instead of the shopper's selected currency) 2.1.13 diff --git a/app/code/community/Bitpay/Core/controllers/IpnController.php b/app/code/community/Bitpay/Core/controllers/IpnController.php index f9afb68..e6ea69a 100644 --- a/app/code/community/Bitpay/Core/controllers/IpnController.php +++ b/app/code/community/Bitpay/Core/controllers/IpnController.php @@ -116,13 +116,15 @@ class Bitpay_Core_IpnController extends Mage_Core_Controller_Front_Action $transactionSpeed = \Mage::getStoreConfig('payment/bitpay/speed'); if ($ipn->status === 'paid' || ($ipn->status === 'confirmed' && $transactionSpeed === 'high')) { - - $payment = \Mage::getModel('sales/order_payment')->setOrder($order); - - if (true === isset($payment) && false === empty($payment)) { - $payment->registerCaptureNotification($invoice->getPrice()); - $order->addPayment($payment); - + + if ($payments = $order->getPaymentsCollection()) + { + $payment = count($payments->getItems())>0 ? end($payments->getItems()) : \Mage::getModel('sales/order_payment')->setOrder($order); + } + + if (true === isset($payment) && false === empty($payment)) { + $payment->registerCaptureNotification($invoice->getPrice()); + $order->setPayment($payment); // If the customer has not already been notified by email // send the notification now that there's a new order. if (!$order->getEmailSent()) {