|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PimpayBundle\Service; |
|
4
|
|
|
|
|
5
|
|
|
use PimpayBundle\Handler\CryptoHandlerInterface; |
|
6
|
|
|
use PimpayBundle\Model\AcceptClientParams; |
|
7
|
|
|
use PimpayBundle\Model\Address; |
|
8
|
|
|
use PimpayBundle\Model\ClientInfo; |
|
9
|
|
|
use PimpayBundle\Model\CustomTransaction; |
|
10
|
|
|
use PimpayBundle\Model\DeliveryStatusHistoryItem; |
|
11
|
|
|
use PimpayBundle\Model\F103; |
|
12
|
|
|
use PimpayBundle\Model\Order; |
|
13
|
|
|
use PimpayBundle\Model\OrderBase; |
|
14
|
|
|
use PimpayBundle\Model\OrderItem; |
|
15
|
|
|
use PimpayBundle\Model\OrderParams; |
|
16
|
|
|
use PimpayBundle\Model\OrderState; |
|
17
|
|
|
use PimpayBundle\Model\PaymentOrder; |
|
18
|
|
|
use PimpayBundle\Model\Recipient; |
|
19
|
|
|
use PimpayBundle\Model\RussianPostPayment; |
|
20
|
|
|
use PimpayBundle\Model\RussianPostPaymentInfo; |
|
21
|
|
|
use PimpayBundle\Model\RussianPostPaymentsResponse; |
|
22
|
|
|
use PimpayBundle\Model\UpsertResultItem; |
|
23
|
|
|
use PimpayBundle\Model\UpsertResultResponse; |
|
24
|
|
|
use PimpayBundle\Model\VerificationError; |
|
25
|
|
|
use PimpayBundle\Model\VerificationRow; |
|
26
|
|
|
use PimpayBundle\Model\VerificationStatusResponse; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class ApiService |
|
30
|
|
|
* @package PimpayBundle\Service |
|
31
|
|
|
*/ |
|
32
|
|
|
class ApiService |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $wsdl; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $token; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var CryptoHandlerInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
private $cryptoHandler; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var SoapClientService |
|
51
|
|
|
*/ |
|
52
|
|
|
private $soapClient; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* ApiService constructor. |
|
56
|
|
|
* @param array $params |
|
57
|
|
|
* @param CryptoHandlerInterface $cryptoHandler |
|
58
|
|
|
*/ |
|
59
|
|
|
public function __construct(array $params, CryptoHandlerInterface $cryptoHandler) |
|
60
|
|
|
{ |
|
61
|
|
|
$this->wsdl = file_get_contents(__DIR__.'/../Resources/wsdl.xml'); |
|
62
|
|
|
$this->token = $params['token']; |
|
63
|
|
|
$this->cryptoHandler = $cryptoHandler; |
|
64
|
|
|
$this->soapClient = new SoapClientService($this, 'data://text/xml;base64,'.base64_encode($this->wsdl), [ |
|
65
|
|
|
'classmap' => [ |
|
66
|
|
|
'AcceptClientParams' => AcceptClientParams::class, |
|
67
|
|
|
'ClientInfo' => ClientInfo::class, |
|
68
|
|
|
'Order' => Order::class, |
|
69
|
|
|
'OrderBase' => OrderBase::class, |
|
70
|
|
|
'OrderParams' => OrderParams::class, |
|
71
|
|
|
'DeliveryStatusHistoryItem' => DeliveryStatusHistoryItem::class, |
|
72
|
|
|
'OrderState' => OrderState::class, |
|
73
|
|
|
'OrderItem' => OrderItem::class, |
|
74
|
|
|
'Address' => Address::class, |
|
75
|
|
|
'Recipient' => Recipient::class, |
|
76
|
|
|
'F103' => F103::class, |
|
77
|
|
|
'PaymentOrder' => PaymentOrder::class, |
|
78
|
|
|
'VerificationRow' => VerificationRow::class, |
|
79
|
|
|
'CustomTransaction' => CustomTransaction::class, |
|
80
|
|
|
'VerificationStatusResponse' => VerificationStatusResponse::class, |
|
81
|
|
|
'VerificationError' => VerificationError::class, |
|
82
|
|
|
'UpsertResultResponse' => UpsertResultResponse::class, |
|
83
|
|
|
'UpsertResultItem' => UpsertResultItem::class, |
|
84
|
|
|
'RussianPostPaymentsResponse' => RussianPostPaymentsResponse::class, |
|
85
|
|
|
'RussianPostPaymentInfo' => RussianPostPaymentInfo::class, |
|
86
|
|
|
'RussianPostPayment' => RussianPostPayment::class, |
|
87
|
|
|
], |
|
88
|
|
|
] |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return CryptoHandlerInterface |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getCryptoHandler(): CryptoHandlerInterface |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->cryptoHandler; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param string $tin |
|
102
|
|
|
* @return mixed |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getClient($tin) |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->soapClient->getClient($this->token, $tin); |
|
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param AcceptClientParams $params |
|
111
|
|
|
* @return mixed |
|
112
|
|
|
*/ |
|
113
|
|
|
public function acceptClient(AcceptClientParams $params) |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->soapClient->acceptClient($this->token, $params); |
|
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @param array $orders |
|
120
|
|
|
* @return mixed |
|
121
|
|
|
*/ |
|
122
|
|
|
public function upsertOrders(array $orders) |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->soapClient->upsertOrders($this->token, $orders); |
|
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: