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 InvalidArgumentException; |
12
|
|
|
use Magento\Payment\Gateway\ConfigInterface; |
13
|
|
|
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
14
|
|
|
use Magento\Payment\Gateway\Request\BuilderInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Wallet Fetch Transaction Info Request - Transaction query data structure. |
18
|
|
|
*/ |
19
|
|
|
class WalletFetchTransactionInfoRequest implements BuilderInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
public const GETNET_PAYMENT_ID = 'payment_id'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Order State - Block Name. |
28
|
|
|
*/ |
29
|
|
|
public const ORDER_STATE = 'state'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ConfigInterface |
33
|
|
|
*/ |
34
|
|
|
protected $config; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param ConfigInterface $config |
38
|
|
|
*/ |
39
|
|
|
public function __construct( |
40
|
|
|
ConfigInterface $config |
41
|
|
|
) { |
42
|
|
|
$this->config = $config; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Build. |
47
|
|
|
* |
48
|
|
|
* @param array $buildSubject |
49
|
|
|
*/ |
50
|
|
|
public function build(array $buildSubject) |
51
|
|
|
{ |
52
|
|
|
if (!isset($buildSubject['payment']) |
53
|
|
|
|| !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
54
|
|
|
) { |
55
|
|
|
throw new InvalidArgumentException('Payment data object should be provided'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$paymentDO = $buildSubject['payment']; |
59
|
|
|
|
60
|
|
|
$payment = $paymentDO->getPayment(); |
61
|
|
|
|
62
|
|
|
$order = $payment->getOrder(); |
63
|
|
|
$payment = $paymentDO->getPayment(); |
64
|
|
|
|
65
|
|
|
return [ |
66
|
|
|
self::GETNET_PAYMENT_ID => $payment->getLastTransId(), |
67
|
|
|
self::ORDER_STATE => $order->getState(), |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|