|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* OKPAY driver for Omnipay PHP payment library. |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/omnipay-okpay |
|
6
|
|
|
* @package omnipay-okpay |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Omnipay\OKPAY\Message; |
|
12
|
|
|
|
|
13
|
|
|
use Omnipay\Tests\TestCase; |
|
14
|
|
|
|
|
15
|
|
|
class CompletePurchaseResponseTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
private $request; |
|
18
|
|
|
|
|
19
|
|
|
private $purse = '[email protected]'; |
|
20
|
|
|
private $description = 'sDf#$Sdf#$%'; |
|
21
|
|
|
private $transactionId = 1234567890; |
|
22
|
|
|
private $amount = '8.69'; |
|
23
|
|
|
private $currency = 'USD'; |
|
24
|
|
|
private $testMode = true; |
|
25
|
|
|
private $status = 'completed'; |
|
|
|
|
|
|
26
|
|
|
private $fee = '0.00'; |
|
27
|
|
|
private $payer_first_name = 'FirstName'; |
|
28
|
|
|
private $payer_last_name = 'LastName'; |
|
29
|
|
|
private $payer_email = '[email protected]'; |
|
30
|
|
|
private $datetime = '2017-09-20 16:07:50'; |
|
31
|
|
|
|
|
32
|
|
|
public function setUp() |
|
33
|
|
|
{ |
|
34
|
|
|
parent::setUp(); |
|
35
|
|
|
|
|
36
|
|
|
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
|
37
|
|
|
$this->request->initialize([ |
|
38
|
|
|
'purse' => $this->purse, |
|
39
|
|
|
'secret' => $this->secret, |
|
|
|
|
|
|
40
|
|
|
'testMode' => $this->testMode, |
|
41
|
|
|
]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testSuccess() |
|
45
|
|
|
{ |
|
46
|
|
|
$response = new CompletePurchaseResponse($this->request, [ |
|
47
|
|
|
'ok_item_1_name' => $this->description, |
|
48
|
|
|
'ok_receiver' => $this->purse, |
|
49
|
|
|
'ok_txn_gross' => $this->amount, |
|
50
|
|
|
'ok_txn_datetime' => $this->datetime, |
|
51
|
|
|
'ok_txn_id' => $this->transactionId, |
|
52
|
|
|
'ok_txn_status' => $this->status, |
|
53
|
|
|
'ok_txn_currency' => $this->currency, |
|
54
|
|
|
'ok_txn_fee' => $this->fee, |
|
55
|
|
|
'ok_payer_first_name' => $this->payer_first_name, |
|
56
|
|
|
'ok_payer_last_name' => $this->payer_last_name, |
|
57
|
|
|
'ok_payer_email' => $this->payer_email, |
|
58
|
|
|
]); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertTrue($response->isSuccessful()); |
|
61
|
|
|
$this->assertNull($response->getMessage()); |
|
62
|
|
|
$this->assertNull($response->getCode()); |
|
63
|
|
|
$this->assertSame($this->amount, $response->getAmount()); |
|
64
|
|
|
$this->assertSame($this->description, $response->getDescription()); |
|
65
|
|
|
$this->assertSame($this->purse, $response->getPurse()); |
|
66
|
|
|
$this->assertSame($this->currency, $response->getCurrency()); |
|
67
|
|
|
$this->assertSame($this->transactionId, $response->getTransactionId()); |
|
68
|
|
|
$this->assertSame($this->fee, $response->getFee()); |
|
69
|
|
|
$this->assertEquals(new \DateTime($this->datetime), $response->getTime()); |
|
70
|
|
|
$this->assertSame($this->payer_first_name . ' ' . $this->payer_last_name . ' / ' . $this->payer_email, $response->getPayer()); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|