1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See COPYING.txt for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Gateway\Response; |
10
|
|
|
|
11
|
|
|
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
|
|
|
|
12
|
|
|
use Magento\Payment\Gateway\Response\HandlerInterface; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class AcceptPaymentHandler - Deals reading responses for payment authorization accepted. |
16
|
|
|
*/ |
17
|
|
|
class AcceptPaymentHandler implements HandlerInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @const TXN ID |
21
|
|
|
*/ |
22
|
|
|
const TXN_ID = 'TXN_ID'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Handles. |
26
|
|
|
* |
27
|
|
|
* @param array $handlingSubject |
28
|
|
|
* @param array $response |
29
|
|
|
*/ |
30
|
|
|
public function handle(array $handlingSubject, array $response) |
31
|
|
|
{ |
32
|
|
|
if (!isset($handlingSubject['payment']) |
33
|
|
|
|| !$handlingSubject['payment'] instanceof PaymentDataObjectInterface |
34
|
|
|
) { |
35
|
|
|
throw new \InvalidArgumentException('Payment data object should be provided'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if ($response['RESULT_CODE']) { |
39
|
|
|
$paymentDO = $handlingSubject['payment']; |
40
|
|
|
|
41
|
|
|
$payment = $paymentDO->getPayment(); |
42
|
|
|
|
43
|
|
|
$order = $payment->getOrder(); |
44
|
|
|
$amount = $order->getBaseGrandTotal(); |
45
|
|
|
$baseAmount = $order->getGrandTotal(); |
46
|
|
|
|
47
|
|
|
$payment->registerAuthorizationNotification($amount); |
48
|
|
|
$payment->registerCaptureNotification($amount); |
49
|
|
|
$payment->setIsTransactionApproved(true); |
50
|
|
|
$payment->setIsTransactionDenied(false); |
51
|
|
|
$payment->setIsInProcess(true); |
52
|
|
|
$payment->setIsTransactionClosed(true); |
53
|
|
|
|
54
|
|
|
$payment->setAmountAuthorized($amount); |
55
|
|
|
$payment->setBaseAmountAuthorized($baseAmount); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths