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\OldPurchaseRequest; |
15
|
|
|
use Omnipay\InterKassa\Message\PurchaseRequest; |
16
|
|
|
|
17
|
|
|
class OldPurchaseResponseTest extends PurchaseResponseTest |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var OldPurchaseRequest |
21
|
|
|
*/ |
22
|
|
|
protected $request; |
23
|
|
|
|
24
|
|
|
protected $purse = '887ac1234c1eeee1488b156b'; |
25
|
|
|
protected $secret = 'Zp2zfdSJzbS61L32'; |
26
|
|
|
protected $returnUrl = 'https://www.example.com/success'; |
27
|
|
|
protected $cancelUrl = 'https://www.example.com/failure'; |
28
|
|
|
protected $notifyUrl = 'https://www.example.com/notify'; |
29
|
|
|
protected $description = 'Test Transaction long description'; |
30
|
|
|
protected $transactionId = 'ID_123456'; |
31
|
|
|
protected $amount = '14.65'; |
32
|
|
|
protected $currency = 'USD'; |
33
|
|
|
protected $sign = 'C5sYWKMUZF1SDPTAGosZntOLC8Q2WWNvxx4bwy/gIwc='; |
34
|
|
|
|
35
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
parent::setUp(); |
38
|
|
|
|
39
|
|
|
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
|
|
|
|
40
|
|
|
$this->request->initialize([ |
41
|
|
|
'purse' => $this->purse, |
42
|
|
|
'secret' => $this->secret, |
43
|
|
|
'returnUrl' => $this->returnUrl, |
44
|
|
|
'cancelUrl' => $this->cancelUrl, |
45
|
|
|
'notifyUrl' => $this->notifyUrl, |
46
|
|
|
'description' => $this->description, |
47
|
|
|
'transactionId' => $this->transactionId, |
48
|
|
|
'amount' => $this->amount, |
49
|
|
|
'currency' => $this->currency, |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testSuccess() |
54
|
|
|
{ |
55
|
|
|
/** @var PurchaseResponse $response */ |
56
|
|
|
$response = $this->request->send(); |
57
|
|
|
|
58
|
|
|
$this->assertFalse($response->isSuccessful()); |
59
|
|
|
$this->assertTrue($response->isRedirect()); |
60
|
|
|
$this->assertNull($response->getCode()); |
61
|
|
|
$this->assertNull($response->getMessage()); |
62
|
|
|
|
63
|
|
|
$this->assertSame('POST', $response->getRedirectMethod()); |
64
|
|
|
$this->assertSame([ |
65
|
|
|
'ik_co_id' => $this->purse, |
66
|
|
|
'ik_am' => $this->amount, |
67
|
|
|
'ik_pm_no' => $this->transactionId, |
68
|
|
|
'ik_desc' => $this->description, |
69
|
|
|
'ik_cur' => $this->currency, |
70
|
|
|
'ik_pnd_u' => $this->returnUrl, |
71
|
|
|
'ik_suc_u' => $this->returnUrl, |
72
|
|
|
'ik_fal_u' => $this->cancelUrl, |
73
|
|
|
'ik_ia_u' => $this->notifyUrl, |
74
|
|
|
'ik_sign' => $this->sign, |
75
|
|
|
], $response->getRedirectData()); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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.