|
1
|
|
|
<?php namespace Ogone\Tests\FlexCheckout; |
|
2
|
|
|
|
|
3
|
|
|
use GuzzleHttp\Client; |
|
4
|
|
|
use Ogone\FlexCheckout\FlexCheckoutPaymentRequest; |
|
5
|
|
|
use Ogone\FlexCheckout\Alias; |
|
6
|
|
|
|
|
7
|
|
|
use Ogone\FlexCheckout\FlexCheckoutPaymentResponse; |
|
8
|
|
|
use Ogone\HashAlgorithm; |
|
9
|
|
|
use Ogone\Passphrase; |
|
10
|
|
|
use Ogone\ShaComposer\AllParametersShaComposer; |
|
11
|
|
|
use Ogone\ShaComposer\ShaComposer; |
|
12
|
|
|
use TestCase; |
|
13
|
|
|
|
|
14
|
|
|
class FlexCheckoutPaymentResponseTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
private $configuration; |
|
17
|
|
|
|
|
18
|
|
|
public function testResponse() |
|
19
|
|
|
{ |
|
20
|
|
|
$parameters = [ |
|
21
|
|
|
"Alias_AliasId" => "4", |
|
22
|
|
|
"Card_Bin" => "411111", |
|
23
|
|
|
"Card_Brand" => "VISA", |
|
24
|
|
|
"Card_CardNumber" => "XXXXXXXXXXXX1111", |
|
25
|
|
|
"Card_CardHolderName" => "Holder Test", |
|
26
|
|
|
"Card_Cvc" => "XXX", |
|
27
|
|
|
"Card_ExpiryDate" => "0319", |
|
28
|
|
|
"Alias_NCError" => "0", |
|
29
|
|
|
"Alias_NCErrorCardNo" => "0", |
|
30
|
|
|
"Alias_NCErrorCN" => "0", |
|
31
|
|
|
"Alias_NCErrorCVC" => "0", |
|
32
|
|
|
"Alias_NCErrorED" => "0", |
|
33
|
|
|
"Alias_OrderId" => "4422", |
|
34
|
|
|
"Alias_Status" => "2", |
|
35
|
|
|
"SHASign" => "BD9F63BC7FA689E690957DDA1C6E8BDD4A5F1A5F", |
|
36
|
|
|
]; |
|
37
|
|
|
|
|
38
|
|
|
$sha = new FakeShaComposer; |
|
39
|
|
|
$flex = new FlexCheckoutPaymentResponse($parameters); |
|
40
|
|
|
$flex->isValid($sha); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return AllParametersShaComposer |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function getShaComposer() |
|
47
|
|
|
{ |
|
48
|
|
|
$ogone_config = config("ogone"); |
|
49
|
|
|
|
|
50
|
|
|
$this->configuration = [ |
|
51
|
|
|
'sha_in' => $ogone_config["sha_in"], |
|
52
|
|
|
'sha_out' => $ogone_config["sha_out"], |
|
53
|
|
|
'psp_id' => $ogone_config["psp_id"], |
|
54
|
|
|
'user_id' => $ogone_config["user_id"], |
|
55
|
|
|
'password' => $ogone_config["password"], |
|
56
|
|
|
'url_payment' => $ogone_config["url_payment"], |
|
57
|
|
|
'url_maintenance' => $ogone_config["url_maintenance"], |
|
58
|
|
|
]; |
|
59
|
|
|
|
|
60
|
|
|
$passphrase = new Passphrase($this->configuration['sha_out']); |
|
61
|
|
|
$hash_algoritm = new HashAlgorithm(HashAlgorithm::HASH_SHA1); |
|
62
|
|
|
$shaComposer = new AllParametersShaComposer($passphrase, $hash_algoritm); |
|
63
|
|
|
return $shaComposer; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
class FakeShaComposer implements ShaComposer |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
const FAKESHASTRING = 'foo'; |
|
70
|
|
|
|
|
71
|
|
|
public function compose(array $responseParameters) |
|
72
|
|
|
{ |
|
73
|
|
|
return self::FAKESHASTRING; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.