|
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\Tests\TestCase; |
|
17
|
|
|
|
|
18
|
|
|
class PurchaseResponseTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var PurchaseRequest |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $request; |
|
24
|
|
|
|
|
25
|
|
|
protected $purse = '887ac1234c1eeee1488b156b'; |
|
26
|
|
|
protected $secret = 'Zp2zfdSJzbS61L32'; |
|
27
|
|
|
protected $returnUrl = 'https://www.example.com/success'; |
|
28
|
|
|
protected $cancelUrl = 'https://www.example.com/failure'; |
|
29
|
|
|
protected $notifyUrl = 'https://www.example.com/notify'; |
|
30
|
|
|
protected $description = 'Test Transaction long description'; |
|
31
|
|
|
protected $transactionId = 'ID_123456'; |
|
32
|
|
|
protected $amount = '14.65'; |
|
33
|
|
|
protected $currency = 'USD'; |
|
34
|
|
|
protected $sign = 'ol7dNJnyA/j7qNyFYjXPPKfmUK9fbujrZw3nfSkyzy8='; |
|
35
|
|
|
protected $sci = 'https://sci.interkassa.com/'; |
|
36
|
|
|
protected $returnMethod = 'POST'; |
|
37
|
|
|
protected $successMethod = 'POST'; |
|
38
|
|
|
protected $cancelMethod = 'POST'; |
|
39
|
|
|
protected $notifyMethod = 'POST'; |
|
40
|
|
|
|
|
41
|
|
|
public function setUp() |
|
42
|
|
|
{ |
|
43
|
|
|
parent::setUp(); |
|
44
|
|
|
|
|
45
|
|
|
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
|
46
|
|
|
$this->request->initialize([ |
|
47
|
|
|
'purse' => $this->purse, |
|
48
|
|
|
'secret' => $this->secret, |
|
49
|
|
|
'returnUrl' => $this->returnUrl, |
|
50
|
|
|
'cancelUrl' => $this->cancelUrl, |
|
51
|
|
|
'notifyUrl' => $this->notifyUrl, |
|
52
|
|
|
'description' => $this->description, |
|
53
|
|
|
'transactionId' => $this->transactionId, |
|
54
|
|
|
'amount' => $this->amount, |
|
55
|
|
|
'currency' => $this->currency, |
|
56
|
|
|
'returnMethod' => $this->returnMethod, |
|
57
|
|
|
'successMethod' => $this->successMethod, |
|
58
|
|
|
'cancelMethod' => $this->cancelMethod, |
|
59
|
|
|
'notifyMethod' => $this->notifyMethod, |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testSuccess() |
|
64
|
|
|
{ |
|
65
|
|
|
/** @var PurchaseResponse $response */ |
|
66
|
|
|
$response = $this->request->send(); |
|
67
|
|
|
|
|
68
|
|
|
$this->assertFalse($response->isSuccessful()); |
|
69
|
|
|
$this->assertTrue($response->isRedirect()); |
|
70
|
|
|
$this->assertNull($response->getCode()); |
|
71
|
|
|
$this->assertNull($response->getMessage()); |
|
72
|
|
|
$this->assertSame($this->sci, $response->getRedirectUrl()); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertSame('POST', $response->getRedirectMethod()); |
|
75
|
|
|
$this->assertSame([ |
|
76
|
|
|
'ik_co_id' => $this->purse, |
|
77
|
|
|
'ik_am' => $this->amount, |
|
78
|
|
|
'ik_pm_no' => $this->transactionId, |
|
79
|
|
|
'ik_desc' => $this->description, |
|
80
|
|
|
'ik_cur' => $this->currency, |
|
81
|
|
|
'ik_pnd_u' => $this->returnUrl, |
|
82
|
|
|
'ik_pnd_m' => $this->returnMethod, |
|
83
|
|
|
'ik_suc_u' => $this->returnUrl, |
|
84
|
|
|
'ik_suc_m' => $this->successMethod, |
|
85
|
|
|
'ik_fal_u' => $this->cancelUrl, |
|
86
|
|
|
'ik_fal_m' => $this->cancelMethod, |
|
87
|
|
|
'ik_ia_u' => $this->notifyUrl, |
|
88
|
|
|
'ik_ia_m' => $this->notifyMethod, |
|
89
|
|
|
'ik_sign' => $this->sign, |
|
90
|
|
|
], $response->getRedirectData()); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|