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\Paystation\Message\CompletePurchaseRequest; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Paystation Complete Purchase Response |
12
|
|
|
*/ |
13
|
|
|
class CompletePurchaseResponse extends AbstractResponse |
14
|
|
|
{ |
15
|
|
|
use HasCardFields; |
16
|
6 |
|
|
17
|
|
|
public function __construct(CompletePurchaseRequest $request, $data) |
18
|
6 |
|
{ |
19
|
|
|
$this->lookupField = 'LookupResponse'; |
20
|
6 |
|
$this->request = $request; |
21
|
6 |
|
|
22
|
6 |
|
$responseDom = new DOMDocument; |
23
|
|
|
$responseDom->loadXML($data); |
24
|
6 |
|
$this->data = simplexml_import_dom($responseDom); |
25
|
2 |
|
|
26
|
1 |
|
if (!isset($this->data->LookupResponse)) { |
27
|
|
|
if (isset($this->data->LookupStatus->LookupMessage)) { |
28
|
1 |
|
throw new InvalidResponseException($this->data->LookupStatus->LookupMessage); |
29
|
|
|
} else { |
30
|
|
|
throw new InvalidResponseException; |
31
|
4 |
|
} |
32
|
|
|
} |
33
|
2 |
|
} |
34
|
|
|
|
35
|
2 |
|
public function isPending() |
36
|
|
|
{ |
37
|
|
|
return false; |
38
|
4 |
|
} |
39
|
|
|
|
40
|
4 |
|
public function isSuccessful() |
41
|
|
|
{ |
42
|
|
|
return $this->getCode() === "0"; |
43
|
4 |
|
} |
44
|
|
|
|
45
|
4 |
|
public function getTransactionReference() |
46
|
2 |
|
{ |
47
|
|
|
if (isset($this->data->LookupResponse) && isset($this->data->LookupResponse->PaystationTransactionID)) { |
48
|
2 |
|
return (string)$this->data->LookupResponse->PaystationTransactionID; |
49
|
|
|
} |
50
|
4 |
|
} |
51
|
|
|
|
52
|
4 |
|
public function getCode() |
53
|
2 |
|
{ |
54
|
|
|
if (isset($this->data->LookupResponse->PaystationErrorCode)) { |
55
|
2 |
|
return (string)$this->data->LookupResponse->PaystationErrorCode; |
56
|
|
|
} |
57
|
4 |
|
} |
58
|
|
|
|
59
|
4 |
|
public function getMessage() |
60
|
2 |
|
{ |
61
|
|
|
if (isset($this->data->LookupResponse->PaystationErrorMessage)) { |
62
|
2 |
|
return (string)$this->data->LookupResponse->PaystationErrorMessage; |
63
|
1 |
|
} |
64
|
|
|
if (isset($this->data->LookupStatus->LookupMessage)) { |
65
|
1 |
|
return (string)$this->data->LookupStatus->LookupMessage; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|