|
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\OldCompletePurchaseRequest; |
|
15
|
|
|
use Omnipay\InterKassa\Message\OldCompletePurchaseResponse; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request as HttpRequest; |
|
17
|
|
|
|
|
18
|
|
|
class OldCompletePurchaseResponseTest extends CompletePurchaseResponseTest |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var OldCompletePurchaseResponse |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $request; |
|
24
|
|
|
|
|
25
|
|
|
protected $purse = '62B97027-5260-1442-CF1A-7BDC16454400'; |
|
26
|
|
|
protected $sign = 'RtCUy16yl+8c3YidodCa7GC5j0BlI9Y0N5N6oUMLriI='; |
|
27
|
|
|
protected $currency = null; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param array $options |
|
31
|
|
|
* @return OldCompletePurchaseRequest |
|
32
|
|
|
*/ |
|
33
|
|
|
public function createRequest($options = []) |
|
34
|
|
|
{ |
|
35
|
|
|
$httpRequest = new HttpRequest([], array_merge([ |
|
36
|
|
|
'ik_shop_id' => $this->purse, |
|
37
|
|
|
'ik_payment_id' => $this->transactionId, |
|
38
|
|
|
'ik_payment_desc' => $this->description, |
|
39
|
|
|
'ik_payment_amount' => $this->amount, |
|
40
|
|
|
'ik_payment_timestamp' => $this->time, |
|
41
|
|
|
'ik_sign_hash' => $this->sign, |
|
42
|
|
|
'ik_payment_state' => $this->state, |
|
43
|
|
|
'ik_trans_id' => $this->invoiceId, |
|
44
|
|
|
'ik_paysystem_alias' => $this->payway, |
|
45
|
|
|
|
|
46
|
|
|
], $options)); |
|
47
|
|
|
|
|
48
|
|
|
$request = new OldCompletePurchaseRequest($this->getHttpClient(), $httpRequest); |
|
49
|
|
|
$request->initialize([ |
|
50
|
|
|
'secret' => $this->secret, |
|
51
|
|
|
]); |
|
52
|
|
|
|
|
53
|
|
|
return $request; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testSignException() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Failed to validate signature'); |
|
59
|
|
|
$this->createRequest(['ik_wtf' => ':)'])->send(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testStateException() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'The payment was not success'); |
|
65
|
|
|
$this->createRequest(['ik_payment_state' => 'fail', 'ik_sign_hash' => '2+Wv5Qna6e+BIhRrykWZ46RJ5sVeEnMdVfPUMxa8tVc='])->send(); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|