Skip to content

Commit d37da65

Browse files
author
Viktor Tymchynskyi
committed
Merge remote-tracking branch 'origin/MAGETWO-43948' into MPI-BUGFIXES
2 parents de98026 + 2b11567 commit d37da65

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use \Braintree_Transaction;
1212
use \Braintree_Result_Successful;
1313
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Sales\Model\Order\Payment\Transaction;
1415
use Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
1516
use Magento\Sales\Model\Order\Payment\Transaction as PaymentTransaction;
1617
use Magento\Payment\Model\InfoInterface;
@@ -648,13 +649,15 @@ public function refund(InfoInterface $payment, $amount)
648649
}
649650
}
650651

652+
// transaction should be voided if it not settled
651653
$canVoid = ($transaction->status === \Braintree_Transaction::AUTHORIZED
652654
|| $transaction->status === \Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT);
653655
$result = $canVoid
654656
? $this->braintreeTransaction->void($transactionId)
655657
: $this->braintreeTransaction->refund($transactionId, $amount);
656658
$this->_debug($this->_convertObjToArray($result));
657659
if ($result->success) {
660+
$payment->setTransactionId($transactionId . '-' . Transaction::TYPE_REFUND);
658661
$payment->setIsTransactionClosed(true);
659662
} else {
660663
throw new LocalizedException($this->errorHelper->parseBraintreeError($result));

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Braintree\Model\PaymentMethod;
1010
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
11+
use Magento\Sales\Model\Order\Payment\Transaction;
1112
use \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use \Braintree_Result_Successful;
@@ -2378,6 +2379,7 @@ public function testRefund()
23782379

23792380
$this->model->refund($paymentObject, $amount);
23802381
$this->assertEquals(1, $paymentObject->getIsTransactionClosed());
2382+
$this->assertEquals($refundTransactionId . '-' .Transaction::TYPE_REFUND, $paymentObject->getTransactionId());
23812383
}
23822384

23832385
/**

app/code/Magento/Braintree/view/adminhtml/templates/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
133133
</div>
134134
</fieldset>
135135
<?php endif; ?>
136-
<?php if($_useVault): ?>
136+
<?php if($useVault): ?>
137137
<fieldset class="admin__fieldset hide_if_token_selected">
138138
<div id="<?php /* @noEscape */ echo $code; ?>_store_in_vault_div" style="text-align:left;" class="">
139139
<input type="checkbox" title="<?php echo $block->escapeHtml(__('Save this card for future use')); ?>"

app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $storedCards = $block->getCurrentCustomerStoredCards();
1919
<?php endif; ?>
2020
</div>
2121
<?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
22-
<?php if (count($_storedCards)): ?>
22+
<?php if (count($storedCards)): ?>
2323
<table class="data-table" id="my-quotes-table">
2424
<col width="1" />
2525
<col width="1" />

0 commit comments

Comments
 (0)