1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* InterKassa driver for the Omnipay PHP payment processing library |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/omnipay-interkassa |
7
|
|
|
* @package omnipay-interkassa |
8
|
|
|
* @license MIT |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Omnipay\InterKassa\Tests\Message; |
13
|
|
|
|
14
|
|
|
use Omnipay\InterKassa\Message\PurchaseRequest; |
15
|
|
|
use Omnipay\InterKassa\Message\PurchaseResponse; |
16
|
|
|
use Omnipay\InterKassa\Stubs\PurchaseResponseStub; |
17
|
|
|
use Omnipay\Tests\TestCase; |
18
|
|
|
|
19
|
|
|
class PurchaseResponseTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var PurchaseRequest |
23
|
|
|
*/ |
24
|
|
|
protected $request; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var PurchaseResponseStub |
28
|
|
|
*/ |
29
|
|
|
private $stub; |
30
|
|
|
|
31
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
parent::setUp(); |
34
|
|
|
|
35
|
|
|
$this->stub = new PurchaseResponseStub(); |
36
|
|
|
$stub = $this->stub; |
37
|
|
|
|
38
|
|
|
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
39
|
|
|
$this->request->initialize([ |
40
|
|
|
'purse' => $stub->purse, |
41
|
|
|
'signAlgorithm' => $stub->signAlgorithm, |
42
|
|
|
'signKey' => $stub->signKey, |
43
|
|
|
'testKey' => $stub->testKey, |
44
|
|
|
'returnUrl' => $stub->returnUrl, |
45
|
|
|
'cancelUrl' => $stub->cancelUrl, |
46
|
|
|
'notifyUrl' => $stub->notifyUrl, |
47
|
|
|
'description' => $stub->description, |
48
|
|
|
'transactionId' => $stub->transactionId, |
49
|
|
|
'amount' => $stub->amount, |
50
|
|
|
'currency' => $stub->currency, |
51
|
|
|
'returnMethod' => $stub->returnMethod, |
52
|
|
|
'successMethod' => $stub->successMethod, |
53
|
|
|
'cancelMethod' => $stub->cancelMethod, |
54
|
|
|
'notifyMethod' => $stub->notifyMethod, |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testSuccess() |
59
|
|
|
{ |
60
|
|
|
/** @var PurchaseResponse $response */ |
61
|
|
|
$response = $this->request->send(); |
62
|
|
|
$stub = $this->stub; |
63
|
|
|
|
64
|
|
|
$this->assertFalse($response->isSuccessful()); |
65
|
|
|
$this->assertTrue($response->isRedirect()); |
66
|
|
|
$this->assertNull($response->getCode()); |
67
|
|
|
$this->assertNull($response->getMessage()); |
68
|
|
|
$this->assertSame($stub->sci, $response->getRedirectUrl()); |
69
|
|
|
|
70
|
|
|
$this->assertSame('POST', $response->getRedirectMethod()); |
71
|
|
|
$this->assertSame([ |
72
|
|
|
'ik_co_id' => $stub->purse, |
73
|
|
|
'ik_am' => $stub->amount, |
74
|
|
|
'ik_pm_no' => $stub->transactionId, |
75
|
|
|
'ik_desc' => $stub->description, |
76
|
|
|
'ik_cur' => $stub->currency, |
77
|
|
|
'ik_pnd_u' => $stub->returnUrl, |
78
|
|
|
'ik_pnd_m' => $stub->returnMethod, |
79
|
|
|
'ik_suc_u' => $stub->returnUrl, |
80
|
|
|
'ik_suc_m' => $stub->successMethod, |
81
|
|
|
'ik_fal_u' => $stub->cancelUrl, |
82
|
|
|
'ik_fal_m' => $stub->cancelMethod, |
83
|
|
|
'ik_ia_u' => $stub->notifyUrl, |
84
|
|
|
'ik_ia_m' => $stub->notifyMethod, |
85
|
|
|
'ik_sign' => $stub->sign, |
86
|
|
|
], $response->getRedirectData()); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.