Skip to content

Commit

Permalink
Merge pull request #93 from magento-sparta/SUPEE-7227
Browse files Browse the repository at this point in the history
SUPEE-7227: Refund Online did not create a new transaction record in Sales > Transactions and Order view > Transactions
  • Loading branch information
Korshenko, Olexii(okorshenko) committed Nov 3, 2015
2 parents 5011ce6 + 4034577 commit 794b2a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Braintree/Model/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use \Braintree_Transaction;
use \Braintree_Result_Successful;
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Model\Order\Payment\Transaction;
use Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
use Magento\Sales\Model\Order\Payment\Transaction as PaymentTransaction;
use Magento\Payment\Model\InfoInterface;
Expand Down Expand Up @@ -636,13 +637,15 @@ public function refund(InfoInterface $payment, $amount)
}
}

// transaction should be voided if it not settled
$canVoid = ($transaction->status === \Braintree_Transaction::AUTHORIZED
|| $transaction->status === \Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT);
$result = $canVoid
? $this->braintreeTransaction->void($transactionId)
: $this->braintreeTransaction->refund($transactionId, $amount);
$this->_debug($result);
if ($result->success) {
$payment->setTransactionId($transactionId . '-' . Transaction::TYPE_REFUND);
$payment->setIsTransactionClosed(1);
} else {
throw new LocalizedException($this->errorHelper->parseBraintreeError($result));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Magento\Braintree\Model\PaymentMethod;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Sales\Model\Order\Payment\Transaction;
use \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
use Magento\Framework\Exception\LocalizedException;
use \Braintree_Result_Successful;
Expand Down Expand Up @@ -2327,6 +2328,7 @@ public function testRefund()

$this->model->refund($paymentObject, $amount);
$this->assertEquals(1, $paymentObject->getIsTransactionClosed());
$this->assertEquals($refundTransactionId . '-' .Transaction::TYPE_REFUND, $paymentObject->getTransactionId());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ public function testPrepareSummary($useAggregatedData, $mainTable, $isFilter, $g
*/
public function testGetDateRangeFirstPart($range, $customStart, $customEnd, $expectedInterval)
{
$timeZoneToReturn = date_default_timezone_get();
date_default_timezone_set('UTC');
$result = $this->collection->getDateRange($range, $customStart, $customEnd);
$interval = $result['to']->diff($result['from']);
date_default_timezone_set($timeZoneToReturn);
$intervalResult = $interval->format('%y %m %d %h:%i:%s');
$this->assertEquals($expectedInterval, $intervalResult);
}
Expand Down

0 comments on commit 794b2a5

Please sign in to comment.