|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* eCoin driver for Omnipay PHP payment library |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/omnipay-ecoin |
|
7
|
|
|
* @package omnipay-ecoin |
|
8
|
|
|
* @license MIT |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Omnipay\eCoin\Message; |
|
13
|
|
|
|
|
14
|
|
|
use Omnipay\Tests\TestCase; |
|
15
|
|
|
|
|
16
|
|
|
class CompletePurchaseResponseTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
private $request; |
|
19
|
|
|
|
|
20
|
|
|
private $purse = 'ec12345'; |
|
21
|
|
|
private $secret = '22SAD#-78G8sdf$88'; |
|
22
|
|
|
private $hash = 'fbbc3a665048e3f4aa001dd212b82588'; |
|
23
|
|
|
private $description = 'Test Transaction long description'; |
|
24
|
|
|
private $transactionId = '1SD672345A890sd'; |
|
25
|
|
|
private $transactionReference = 'sdfa1SD672345A8'; |
|
26
|
|
|
private $timestamp = '1454331086'; |
|
27
|
|
|
private $payer = 'ec54321'; |
|
28
|
|
|
private $amount = '1465.01'; |
|
29
|
|
|
private $currency = 'USD'; |
|
30
|
|
|
private $testMode = false; |
|
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 testInvalidHashException() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class); |
|
47
|
|
|
$this->expectExceptionMessage('Invalid hash'); |
|
48
|
|
|
new CompletePurchaseResponse($this->request, [ |
|
49
|
|
|
'description' => $this->description, |
|
50
|
|
|
]); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testSuccess() |
|
54
|
|
|
{ |
|
55
|
|
|
$response = new CompletePurchaseResponse($this->request, [ |
|
56
|
|
|
'ECM_HASH' => $this->hash, |
|
57
|
|
|
'ECM_PURCH_DESC' => $this->description, |
|
58
|
|
|
'ECM_PAYER_ID' => $this->payer, |
|
59
|
|
|
'ECM_PAYEE_ID' => $this->purse, |
|
60
|
|
|
'ECM_PAYMENT_AMOUNT' => $this->amount, |
|
61
|
|
|
'ECM_ITEM_COST' => $this->amount, |
|
62
|
|
|
'ECM_TRANS_DATE' => $this->timestamp, |
|
63
|
|
|
'ECM_INV_NO' => $this->transactionId, |
|
64
|
|
|
'ECM_TRANS_ID' => $this->transactionReference, |
|
65
|
|
|
]); |
|
66
|
|
|
|
|
67
|
|
|
$this->assertTrue($response->isSuccessful()); |
|
68
|
|
|
$this->assertFalse($response->getTestMode()); |
|
69
|
|
|
$this->assertNull($response->getMessage()); |
|
70
|
|
|
$this->assertNull($response->getCode()); |
|
71
|
|
|
$this->assertSame($this->transactionId, $response->getTransactionId()); |
|
72
|
|
|
$this->assertSame($this->transactionReference, $response->getTransactionReference()); |
|
73
|
|
|
$this->assertSame($this->amount, $response->getAmount()); |
|
74
|
|
|
$this->assertSame($this->payer, $response->getPayer()); |
|
75
|
|
|
$this->assertSame($this->hash, $response->getHash()); |
|
76
|
|
|
$this->assertSame($this->currency, $response->getCurrency()); |
|
77
|
|
|
$this->assertSame('2016-02-01T12:51:26+00:00', $response->getTime()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|