1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Braintree\Business\Payment\Transaction; |
9
|
|
|
|
10
|
|
|
use Braintree\Transaction as BraintreeTransaction; |
11
|
|
|
use Generated\Shared\Transfer\BraintreeTransactionResponseTransfer; |
|
|
|
|
12
|
|
|
use SprykerEco\Zed\Braintree\BraintreeConfig; |
13
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Method\ApiConstants; |
14
|
|
|
use SprykerEco\Zed\Braintree\Persistence\BraintreeEntityManagerInterface; |
15
|
|
|
|
16
|
|
|
class ShipmentTransaction extends AbstractTransaction |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \SprykerEco\Zed\Braintree\Persistence\BraintreeEntityManagerInterface |
20
|
|
|
*/ |
21
|
|
|
protected $braintreeEntityManager; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param \SprykerEco\Zed\Braintree\BraintreeConfig $config |
25
|
|
|
* @param \SprykerEco\Zed\Braintree\Persistence\BraintreeEntityManagerInterface $braintreeEntityManager |
26
|
|
|
*/ |
27
|
|
|
public function __construct( |
28
|
|
|
BraintreeConfig $config, |
29
|
|
|
BraintreeEntityManagerInterface $braintreeEntityManager |
30
|
|
|
) { |
31
|
|
|
parent::__construct($config); |
32
|
|
|
$this->braintreeEntityManager = $braintreeEntityManager; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
protected function getTransactionType(): string |
39
|
|
|
{ |
40
|
|
|
return ApiConstants::SALE; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
protected function getTransactionCode(): string |
47
|
|
|
{ |
48
|
|
|
return ApiConstants::TRANSACTION_CODE_CAPTURE; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return \Braintree\Result\Successful|\Braintree\Result\Error|\Braintree\Transaction |
53
|
|
|
*/ |
54
|
|
|
protected function doTransaction() |
55
|
|
|
{ |
56
|
|
|
return $this->capture(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param \Braintree\Result\Error|\Braintree\Result\Successful $response |
61
|
|
|
* |
62
|
|
|
* @return \Generated\Shared\Transfer\BraintreeTransactionResponseTransfer |
63
|
|
|
*/ |
64
|
|
|
protected function afterTransaction($response): BraintreeTransactionResponseTransfer |
65
|
|
|
{ |
66
|
|
|
if ($this->isTransactionSuccessful($response)) { |
67
|
|
|
$braintreeTransactionResponseTransfer = $this->getSuccessResponseTransfer($response); |
68
|
|
|
$this->logApiResponse($braintreeTransactionResponseTransfer, $this->getIdPayment(), $response->transaction->statusHistory); |
|
|
|
|
69
|
|
|
|
70
|
|
|
$this->braintreeEntityManager->updateIsShipmentOperationValue($this->getIdPayment(), $braintreeTransactionResponseTransfer->getTransactionId(), true); |
|
|
|
|
71
|
|
|
|
72
|
|
|
return $braintreeTransactionResponseTransfer; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$braintreeTransactionResponseTransfer = $this->getErrorResponseTransfer($response); |
76
|
|
|
$this->logApiResponse($braintreeTransactionResponseTransfer, $this->getIdPayment()); |
77
|
|
|
|
78
|
|
|
return $braintreeTransactionResponseTransfer; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return \Braintree\Result\Error|\Braintree\Result\Successful |
83
|
|
|
*/ |
84
|
|
|
protected function capture() |
85
|
|
|
{ |
86
|
|
|
return BraintreeTransaction::submitForPartialSettlement( |
87
|
|
|
$this->getTransactionIdentifier(), |
88
|
|
|
$this->transactionMetaTransfer->getCaptureShipmentAmount() |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
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