1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\WindcaveHpp\Message; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Exception\InvalidResponseException; |
6
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
7
|
|
|
use Omnipay\Common\Message\RequestInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Windcave HPP Complete Purchase Response |
11
|
|
|
*/ |
12
|
|
|
class CompletePurchaseResponse extends AbstractResponse { |
13
|
|
|
/** |
14
|
|
|
* Constructor |
15
|
|
|
* |
16
|
|
|
* @param RequestInterface $request the initiating request. |
17
|
|
|
* @param mixed $data |
18
|
|
|
* |
19
|
|
|
* @throws InvalidResponseException If merchant data or order number is missing, or signature does not match |
20
|
|
|
*/ |
21
|
|
|
public function __construct(RequestInterface $request, $data) { |
22
|
|
|
parent::__construct($request, $data); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function isSuccessful() { |
26
|
|
|
$transaction = $this->getTransactionResult(); |
27
|
|
|
|
28
|
|
|
return ( |
29
|
|
|
$transaction && |
30
|
|
|
($transaction['authorised'] ?? false) && |
31
|
|
|
(strtoupper($transaction['responseText'] ?? '')) === 'APPROVED' |
32
|
|
|
) ?? false; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function getTransactionResult() { |
36
|
|
|
return $this->getData()['transactions'][0] ?? []; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getTransactionId() { |
40
|
|
|
return $this->getTransactionResult()['merchantReference'] ?? ''; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getTransactionReference() { |
44
|
|
|
return $this->getTransactionResult()['id'] ?? ''; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getTransactionType() { |
48
|
|
|
return $this->getTransactionResult()['type'] ?? ''; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getMessage() { |
52
|
|
|
return $this->getResponseText() ?? ''; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getResponseText() { |
56
|
|
|
$transaction = $this->getTransactionResult(); |
57
|
|
|
|
58
|
|
|
return $transaction['responseText'] ?? ''; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getSessionId() { |
62
|
|
|
return $this->getTransactionResult()['sessionId'] ?? ''; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getCard() { |
66
|
|
|
return $this->getTransactionResult()['card'] ?? ''; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getCardNumber() { |
70
|
|
|
return $this->getCard()['cardNumber'] ?? ''; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function cardHolderName() { |
74
|
|
|
return $this->getCard()['cardHolderName'] ?? ''; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getCardExpiry() { |
78
|
|
|
return ($this->getCard()['dateExpiryMonth'] ?? '') . '/' . ($this->getCard()['dateExpiryYear'] ?? ''); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getCardType() { |
82
|
|
|
return $this->getCard()['type'] ?? ''; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|