|
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
|
|
|
* @package EndelWar\GestPayWS |
|
22
|
|
|
*/ |
|
23
|
|
|
class WSCryptDecrypt |
|
24
|
|
|
{ |
|
25
|
|
|
private $soapClient; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param \SoapClient $soapClient |
|
29
|
|
|
*/ |
|
30
|
4 |
|
public function __construct(\SoapClient $soapClient) |
|
31
|
|
|
{ |
|
32
|
4 |
|
$this->soapClient = $soapClient; |
|
33
|
4 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param EncryptParameter $parameters |
|
37
|
|
|
* @return EncryptResponse |
|
38
|
|
|
*/ |
|
39
|
2 |
|
public function encrypt(EncryptParameter $parameters) |
|
40
|
|
|
{ |
|
41
|
2 |
|
if (!$parameters->areAllMandatoryParametersSet()) { |
|
42
|
1 |
|
throw new \InvalidArgumentException('Missing parameter'); |
|
43
|
|
|
} |
|
44
|
1 |
|
$soapResponse = $this->soapClient->Encrypt($parameters); |
|
45
|
1 |
|
$encryptResponse = new EncryptResponse($soapResponse); |
|
46
|
|
|
|
|
47
|
1 |
|
return $encryptResponse; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param DecryptParameter $parameters |
|
52
|
|
|
* @return DecryptResponse |
|
53
|
|
|
*/ |
|
54
|
2 |
|
public function decrypt(DecryptParameter $parameters) |
|
55
|
|
|
{ |
|
56
|
2 |
|
if (!$parameters->areAllMandatoryParametersSet()) { |
|
57
|
1 |
|
throw new \InvalidArgumentException('Missing parameter'); |
|
58
|
|
|
} |
|
59
|
1 |
|
$soapResponse = $this->soapClient->Decrypt($parameters); |
|
60
|
1 |
|
$decryptResponse = new DecryptResponse($soapResponse); |
|
61
|
|
|
|
|
62
|
1 |
|
return $decryptResponse; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|