Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Refund description update & API response bug fix
Browse files Browse the repository at this point in the history
Added checking for isset 'status' element at API reponse.
Modified refund title to contain same value as order ID
  • Loading branch information
piotrjozwiak committed Jan 22, 2018
1 parent ae4bd1b commit 7694f69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Controller/tpaycards/CardPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ private function processNewCardPayment($orderId, $additionalPaymentInformation)
->setCustomerToken($this->tpay->getCustomerId($orderId), $result['cli_auth'], $result['card'],
$additionalPaymentInformation['card_vendor']);
}
return (int)$result[ResponseFields::RESULT] === 1 && $result[ResponseFields::STATUS] === 'correct' ?
return (int)$result[ResponseFields::RESULT] === 1 && isset($result[ResponseFields::STATUS])
&& $result[ResponseFields::STATUS] === 'correct' ?
$this->_redirect(static::SUCCESS_PATH) :
$this->trySaleAgain($localData, $orderId, $saveCard);
}
Expand Down
7 changes: 4 additions & 3 deletions Controller/tpaycards/CardRefunds.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace tpaycom\magento2cards\Controller\tpaycards;

use Magento\Payment\Model\InfoInterface;
use Magento\Sales\Model\Order\Payment;
use tpaycom\magento2cards\lib\CardAPI;
use Magento\Framework\Validator\Exception;

Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct(
}

/**
* @param InfoInterface $payment
* @param Payment $payment
* @param double $amount
* @return bool
* @throws Exception
Expand All @@ -45,7 +45,8 @@ public function makeRefund($payment, $amount)
$tpayApi = new CardAPI($this->apiKey, $this->apiPass, $this->verificationCode, $this->hashType);
$transactionId = $payment->getParentTransactionId();

$result = $tpayApi->refund($transactionId, 'Zamówienie ' . $payment->getParentId(), $amount);
$result = $tpayApi->refund($transactionId, 'Zwrot do zamówienia ' . $payment->getOrder()->getRealOrderId(),
$amount);

if ((int)$result['result'] === 1 && isset($result['status']) && $result['status'] === 'correct') {
return $result['sale_auth'];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tpaycom/magento2cards",
"description": "tpay.com card payments module",
"type": "magento2-module",
"version": "1.2.9",
"version": "1.3.0",
"license": [
"OSL-3.0"
],
Expand Down

0 comments on commit 7694f69

Please sign in to comment.