1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the GestPayWS library. |
5
|
|
|
* |
6
|
|
|
* (c) Manuel Dalla Lana <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace EndelWar\GestPayWS; |
13
|
|
|
|
14
|
|
|
use EndelWar\GestPayWS\Parameter\DecryptParameter; |
15
|
|
|
use EndelWar\GestPayWS\Parameter\EncryptParameter; |
16
|
|
|
use EndelWar\GestPayWS\Response\DecryptResponse; |
17
|
|
|
use EndelWar\GestPayWS\Response\EncryptResponse; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class WSCryptDecrypt |
21
|
|
|
*/ |
22
|
|
|
class WSCryptDecrypt |
23
|
|
|
{ |
24
|
|
|
private $soapClient; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param \SoapClient $soapClient |
28
|
|
|
*/ |
29
|
|
|
public function __construct(\SoapClient $soapClient) |
30
|
|
|
{ |
31
|
|
|
$this->soapClient = $soapClient; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param EncryptParameter $parameters |
36
|
|
|
* @throws \Exception |
37
|
|
|
* @throws \InvalidArgumentException |
38
|
|
|
* @return EncryptResponse |
39
|
|
|
*/ |
40
|
|
|
public function encrypt(EncryptParameter $parameters) |
41
|
|
|
{ |
42
|
|
|
if (!$parameters->areAllMandatoryParametersSet()) { |
43
|
|
|
throw new \InvalidArgumentException('Missing parameter'); |
44
|
|
|
} |
45
|
|
|
$soapResponse = $this->soapClient->Encrypt($parameters); |
46
|
|
|
|
47
|
|
|
return new EncryptResponse($soapResponse); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param DecryptParameter $parameters |
52
|
|
|
* @throws \Exception |
53
|
|
|
* @throws \InvalidArgumentException |
54
|
|
|
* @return DecryptResponse |
55
|
|
|
*/ |
56
|
|
|
public function decrypt(DecryptParameter $parameters) |
57
|
|
|
{ |
58
|
|
|
if (!$parameters->areAllMandatoryParametersSet()) { |
59
|
|
|
throw new \InvalidArgumentException('Missing parameter'); |
60
|
|
|
} |
61
|
|
|
$soapResponse = $this->soapClient->Decrypt($parameters); |
62
|
|
|
|
63
|
|
|
return new DecryptResponse($soapResponse); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|