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\SubjectReader; |
13
|
|
|
use InvalidArgumentException; |
14
|
|
|
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
15
|
|
|
use Magento\Payment\Gateway\Request\BuilderInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Seller Id Data Request - Seller Id structure. |
19
|
|
|
*/ |
20
|
|
|
class SellerIdDataRequest implements BuilderInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Store Id block name. |
24
|
|
|
*/ |
25
|
|
|
public const STORE_ID = 'store_id'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Seller Id block name. |
29
|
|
|
*/ |
30
|
|
|
public const SELLER_ID = 'seller_id'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var SubjectReader |
34
|
|
|
*/ |
35
|
|
|
protected $subjectReader; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var Config |
39
|
|
|
*/ |
40
|
|
|
protected $config; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param SubjectReader $subjectReader |
44
|
|
|
* @param Config $config |
45
|
|
|
*/ |
46
|
|
|
public function __construct( |
47
|
|
|
SubjectReader $subjectReader, |
48
|
|
|
Config $config |
49
|
|
|
) { |
50
|
|
|
$this->subjectReader = $subjectReader; |
51
|
|
|
$this->config = $config; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Build. |
56
|
|
|
* |
57
|
|
|
* @param array $buildSubject |
58
|
|
|
*/ |
59
|
|
|
public function build(array $buildSubject): array |
60
|
|
|
{ |
61
|
|
|
if (!isset($buildSubject['payment']) |
62
|
|
|
|| !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
63
|
|
|
) { |
64
|
|
|
throw new InvalidArgumentException('Payment data object should be provided'); |
65
|
|
|
} |
66
|
|
|
$paymentDO = $buildSubject['payment']; |
67
|
|
|
$order = $paymentDO->getOrder(); |
68
|
|
|
$storeId = $order->getStoreId(); |
69
|
|
|
|
70
|
|
|
return [ |
71
|
|
|
self::STORE_ID => $storeId, |
72
|
|
|
self::SELLER_ID => $this->config->getMerchantGatewaySellerId($storeId), |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|