|
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 FetchTransactionInfoHandler - Handles reading responses to query transaction status. |
|
16
|
|
|
*/ |
|
17
|
|
|
class FetchTransactionInfoHandler implements HandlerInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @const ACCEPT PAID |
|
21
|
|
|
*/ |
|
22
|
|
|
const ACCEPT_PAID = 'PAID'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @const ACCEPT PAID ALTERNATIVE |
|
26
|
|
|
*/ |
|
27
|
|
|
const ACCEPT_PAID_ALTERNATIVE = 'AUTHORIZED'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @const ACCEPT PAID |
|
31
|
|
|
*/ |
|
32
|
|
|
const DENNY_PAID = 'NOT_PAID'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @const DENNY PAID ALTERNATIVE |
|
36
|
|
|
*/ |
|
37
|
|
|
const DENNY_PAID_ALTERNATIVE = 'CANCELLED'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Handles. |
|
41
|
|
|
* |
|
42
|
|
|
* @param array $handlingSubject |
|
43
|
|
|
* @param array $response |
|
44
|
|
|
*/ |
|
45
|
|
|
public function handle(array $handlingSubject, array $response) |
|
46
|
|
|
{ |
|
47
|
|
|
if (!isset($handlingSubject['payment']) |
|
48
|
|
|
|| !$handlingSubject['payment'] instanceof PaymentDataObjectInterface |
|
49
|
|
|
) { |
|
50
|
|
|
throw new \InvalidArgumentException('Payment data object should be provided'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$paymentDO = $handlingSubject['payment']; |
|
54
|
|
|
|
|
55
|
|
|
$payment = $paymentDO->getPayment(); |
|
56
|
|
|
|
|
57
|
|
|
$order = $payment->getOrder(); |
|
58
|
|
|
|
|
59
|
|
|
if ($response['STATUS'] === self::ACCEPT_PAID || $response['STATUS'] === self::ACCEPT_PAID_ALTERNATIVE) { |
|
60
|
|
|
$amount = $order->getBaseGrandTotal(); |
|
61
|
|
|
$baseAmount = $order->getGrandTotal(); |
|
62
|
|
|
$payment->registerAuthorizationNotification($amount); |
|
63
|
|
|
$payment->registerCaptureNotification($amount); |
|
64
|
|
|
$payment->setIsTransactionApproved(true); |
|
65
|
|
|
$payment->setIsTransactionDenied(false); |
|
66
|
|
|
$payment->setIsInProcess(true); |
|
67
|
|
|
$payment->setIsTransactionClosed(true); |
|
68
|
|
|
$payment->setAmountAuthorized($amount); |
|
69
|
|
|
$payment->setBaseAmountAuthorized($baseAmount); |
|
70
|
|
|
/** Pog dado ao erro 13466 */ |
|
71
|
|
|
$comment = __('Your payment has been successfully received.'); |
|
|
|
|
|
|
72
|
|
|
$history = $order->addStatusHistoryComment($comment); |
|
73
|
|
|
$history->setIsVisibleOnFront(1); |
|
74
|
|
|
$history->setIsCustomerNotified(1); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if ($response['STATUS'] === self::DENNY_PAID || $response['STATUS'] === self::DENNY_PAID_ALTERNATIVE) { |
|
78
|
|
|
$payment->setIsTransactionApproved(false); |
|
79
|
|
|
$payment->setIsTransactionDenied(true); |
|
80
|
|
|
$payment->setIsInProcess(true); |
|
81
|
|
|
$payment->setIsTransactionClosed(true); |
|
82
|
|
|
$payment->setShouldCloseParentTransaction(true); |
|
83
|
|
|
/** Pog dado ao erro 13466 */ |
|
84
|
|
|
$comment = $response['CANCELLATION_DETAILS_CUSTOMER']; |
|
85
|
|
|
$history = $order->addStatusHistoryComment($comment); |
|
86
|
|
|
$history->setIsVisibleOnFront(1); |
|
87
|
|
|
$history->setIsCustomerNotified(1); |
|
88
|
|
|
$comment = $response['CANCELLATION_DETAILS_ADMIN']; |
|
89
|
|
|
$history = $order->addStatusHistoryComment($comment); |
|
90
|
|
|
$history->setIsVisibleOnFront(0); |
|
91
|
|
|
$history->setIsCustomerNotified(0); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
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