1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Paystation\Message; |
4
|
|
|
|
5
|
|
|
use DOMDocument; |
6
|
|
|
use Omnipay\Common\Exception\InvalidResponseException; |
7
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
8
|
|
|
use Omnipay\Common\Message\RedirectResponseInterface; |
9
|
|
|
use Omnipay\Paystation\Message\PurchaseRequest; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Paystation Response |
13
|
|
|
*/ |
14
|
|
|
class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface |
15
|
|
|
{ |
16
|
|
|
|
17
|
4 |
|
public function __construct(PurchaseRequest $request, $data) |
18
|
|
|
{ |
19
|
4 |
|
$this->request = $request; |
20
|
|
|
|
21
|
4 |
|
$responseDom = new DOMDocument; |
22
|
4 |
|
$responseDom->loadXML($data); |
23
|
4 |
|
$this->data = simplexml_import_dom($responseDom); |
24
|
|
|
|
25
|
4 |
|
if (!isset($this->data->PaystationTransactionID)) { |
26
|
1 |
|
throw new InvalidResponseException; |
27
|
|
|
} |
28
|
3 |
|
} |
29
|
|
|
|
30
|
3 |
|
public function isPending() |
31
|
|
|
{ |
32
|
3 |
|
return false; |
33
|
|
|
} |
34
|
|
|
|
35
|
3 |
|
public function isSuccessful() |
36
|
|
|
{ |
37
|
3 |
|
return false; |
38
|
|
|
} |
39
|
|
|
|
40
|
3 |
|
public function isRedirect() |
41
|
|
|
{ |
42
|
3 |
|
return isset($this->data->DigitalOrder); |
43
|
|
|
} |
44
|
|
|
|
45
|
2 |
|
public function getTransactionReference() |
46
|
|
|
{ |
47
|
2 |
|
return isset($this->data->PaystationTransactionID) ? (string)$this->data->PaystationTransactionID : null; |
48
|
|
|
} |
49
|
|
|
|
50
|
3 |
|
public function getMessage() |
51
|
|
|
{ |
52
|
3 |
|
return isset($this->data->em) ? (string)$this->data->em : null; |
53
|
|
|
} |
54
|
|
|
|
55
|
3 |
|
public function getCode() |
56
|
|
|
{ |
57
|
3 |
|
return isset($this->data->ec) ? (string)$this->data->ec : null; |
58
|
|
|
} |
59
|
|
|
|
60
|
1 |
|
public function getRedirectMethod() |
61
|
|
|
{ |
62
|
1 |
|
return 'GET'; |
63
|
|
|
} |
64
|
|
|
|
65
|
2 |
|
public function getRedirectUrl() |
66
|
|
|
{ |
67
|
2 |
|
if ($this->isRedirect()) { |
68
|
1 |
|
return (string)$this->data->DigitalOrder; |
69
|
|
|
} |
70
|
1 |
|
} |
71
|
|
|
|
72
|
1 |
|
public function getRedirectData() |
73
|
|
|
{ |
74
|
1 |
|
return null; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|