Merge pull request #130 from rafaldr91/master

IPN creates second invoice in database issue fix
This commit is contained in:
Pieter Poorthuis 2018-02-22 14:48:37 +01:00 committed by GitHub
commit 9a33a88b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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()) {