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 $transactionReference = '1234567890'; |
22
|
|
|
private $transactionId = '843145'; |
23
|
|
|
private $amount = '8.69'; |
24
|
|
|
private $currency = 'USD'; |
25
|
|
|
private $testMode = true; |
26
|
|
|
private $status = 'completed'; |
|
|
|
|
27
|
|
|
private $fee = '0.00'; |
28
|
|
|
private $payer_first_name = 'FirstName'; |
29
|
|
|
private $payer_last_name = 'LastName'; |
30
|
|
|
private $payer_email = '[email protected]'; |
31
|
|
|
private $datetime = '2017-09-20 16:07:50'; |
32
|
|
|
|
33
|
|
|
public function setUp() |
34
|
|
|
{ |
35
|
|
|
parent::setUp(); |
36
|
|
|
|
37
|
|
|
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
38
|
|
|
$this->request->initialize([ |
39
|
|
|
'purse' => $this->purse, |
40
|
|
|
'secret' => $this->secret, |
|
|
|
|
41
|
|
|
'testMode' => $this->testMode, |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testSuccess() |
46
|
|
|
{ |
47
|
|
|
$response = new CompletePurchaseResponse($this->request, [ |
48
|
|
|
'ok_item_1_name' => $this->description, |
49
|
|
|
'ok_receiver' => $this->purse, |
50
|
|
|
'ok_txn_gross' => $this->amount, |
51
|
|
|
'ok_txn_datetime' => $this->datetime, |
52
|
|
|
'ok_invoice' => $this->transactionId, |
53
|
|
|
'ok_txn_id' => $this->transactionReference, |
54
|
|
|
'ok_txn_status' => $this->status, |
55
|
|
|
'ok_txn_currency' => $this->currency, |
56
|
|
|
'ok_txn_fee' => $this->fee, |
57
|
|
|
'ok_payer_first_name' => $this->payer_first_name, |
58
|
|
|
'ok_payer_last_name' => $this->payer_last_name, |
59
|
|
|
'ok_payer_email' => $this->payer_email, |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
$this->assertTrue($response->isSuccessful()); |
63
|
|
|
$this->assertNull($response->getMessage()); |
64
|
|
|
$this->assertNull($response->getCode()); |
65
|
|
|
$this->assertSame($this->amount, $response->getAmount()); |
66
|
|
|
$this->assertSame($this->description, $response->getDescription()); |
67
|
|
|
$this->assertSame($this->purse, $response->getPurse()); |
68
|
|
|
$this->assertSame($this->currency, $response->getCurrency()); |
69
|
|
|
$this->assertSame($this->transactionId, $response->getTransactionId()); |
70
|
|
|
$this->assertSame($this->transactionReference, $response->getTransactionReference()); |
71
|
|
|
$this->assertSame($this->fee, $response->getFee()); |
72
|
|
|
$this->assertEquals(new \DateTime($this->datetime), $response->getTime()); |
73
|
|
|
$this->assertSame($this->payer_first_name . ' ' . $this->payer_last_name . ' / ' . $this->payer_email, $response->getPayer()); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|