1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Getnet\PaymentMagento\Gateway\Request; |
10
|
|
|
|
11
|
|
|
use Getnet\PaymentMagento\Gateway\Config\Config; |
12
|
|
|
use Getnet\PaymentMagento\Gateway\Config\ConfigBoleto; |
13
|
|
|
use Getnet\PaymentMagento\Gateway\Data\Order\OrderAdapterFactory; |
|
|
|
|
14
|
|
|
use Getnet\PaymentMagento\Gateway\SubjectReader; |
15
|
|
|
use InvalidArgumentException; |
16
|
|
|
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
17
|
|
|
use Magento\Payment\Gateway\Request\BuilderInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Boleto Payment Data Request - Payment data structure for boleto. |
21
|
|
|
*/ |
22
|
|
|
class BoletoPaymentDataRequest implements BuilderInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Method - Block Name. |
26
|
|
|
*/ |
27
|
|
|
public const METHOD = 'boleto'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Installment count - Number of payment installments. |
31
|
|
|
*/ |
32
|
|
|
public const DOCUMENT_NUMBER = 'document_number'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Boleto expiration date - Due date. |
36
|
|
|
*/ |
37
|
|
|
public const BOLETO_EXPIRATION_DATE = 'expiration_date'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Boleto Instruction - Block name. |
41
|
|
|
*/ |
42
|
|
|
public const BOLETO_INSTRUCTION = 'instructions'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var SubjectReader |
46
|
|
|
*/ |
47
|
|
|
protected $subjectReader; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var Config |
51
|
|
|
*/ |
52
|
|
|
protected $config; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var ConfigBoleto |
56
|
|
|
*/ |
57
|
|
|
protected $configBoleto; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param SubjectReader $subjectReader |
61
|
|
|
* @param Config $config |
62
|
|
|
* @param ConfigBoleto $configBoleto |
63
|
|
|
*/ |
64
|
|
|
public function __construct( |
65
|
|
|
SubjectReader $subjectReader, |
66
|
|
|
Config $config, |
67
|
|
|
ConfigBoleto $configBoleto |
68
|
|
|
) { |
69
|
|
|
$this->subjectReader = $subjectReader; |
70
|
|
|
$this->config = $config; |
71
|
|
|
$this->configBoleto = $configBoleto; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Build. |
76
|
|
|
* |
77
|
|
|
* @param array $buildSubject |
78
|
|
|
*/ |
79
|
|
|
public function build(array $buildSubject) |
80
|
|
|
{ |
81
|
|
|
if (!isset($buildSubject['payment']) |
82
|
|
|
|| !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
83
|
|
|
) { |
84
|
|
|
throw new InvalidArgumentException('Payment data object should be provided'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$paymentDO = $buildSubject['payment']; |
88
|
|
|
$order = $paymentDO->getOrder(); |
89
|
|
|
$storeId = $order->getStoreId(); |
90
|
|
|
$result = $this->getDataPaymetBoleto($order, $storeId); |
91
|
|
|
|
92
|
|
|
return $result; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Data for Boleto. |
97
|
|
|
* |
98
|
|
|
* @param OrderAdapterFactory $order |
99
|
|
|
* @param int $storeId |
100
|
|
|
* |
101
|
|
|
* @return array |
102
|
|
|
*/ |
103
|
|
|
public function getDataPaymetBoleto($order, $storeId) |
104
|
|
|
{ |
105
|
|
|
$instruction = []; |
106
|
|
|
$instruction[self::METHOD] = [ |
107
|
|
|
self::DOCUMENT_NUMBER => $order->getOrderIncrementId(), |
108
|
|
|
self::BOLETO_INSTRUCTION => $this->configBoleto->getInstructionLine($storeId), |
109
|
|
|
self::BOLETO_EXPIRATION_DATE => $this->configBoleto->getExpiration($storeId), |
110
|
|
|
]; |
111
|
|
|
|
112
|
|
|
return $instruction; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
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