Open Journal Systems
3.3.0
lib/vendor/omnipay/paypal/src/Message/RestResponse.php
1
<?php
6
namespace
Omnipay\PayPal\Message
;
7
8
use
Omnipay\Common\Message\AbstractResponse
;
9
use
Omnipay\Common\Message\RequestInterface
;
10
14
class
RestResponse
extends
AbstractResponse
15
{
16
protected
$statusCode
;
17
18
public
function
__construct
(
RequestInterface
$request
,
$data
,
$statusCode
= 200)
19
{
20
parent::__construct(
$request
,
$data
);
21
$this->statusCode =
$statusCode
;
22
}
23
24
public
function
isSuccessful
()
25
{
26
return
empty($this->data[
'error'
]) && $this->
getCode
() < 400;
27
}
28
29
public
function
getTransactionReference
()
30
{
31
// This is usually correct for payments, authorizations, etc
32
if
(!empty($this->data[
'transactions'
]) && !empty($this->data[
'transactions'
][0][
'related_resources'
])) {
33
foreach
(array(
'sale'
,
'authorization'
) as $type) {
34
if
(!empty($this->data[
'transactions'
][0][
'related_resources'
][0][$type])) {
35
return
$this->data[
'transactions'
][0][
'related_resources'
][0][$type][
'id'
];
36
}
37
}
38
}
39
40
// This is a fallback, but is correct for fetch transaction and possibly others
41
if
(!empty($this->data[
'id'
])) {
42
return
$this->data[
'id'
];
43
}
44
45
return
null
;
46
}
47
48
public
function
getMessage
()
49
{
50
if
(isset($this->data[
'error_description'
])) {
51
return
$this->data[
'error_description'
];
52
}
53
54
if
(isset($this->data[
'message'
])) {
55
return
$this->data[
'message'
];
56
}
57
58
return
null
;
59
}
60
61
public
function
getCode
()
62
{
63
return
$this->statusCode
;
64
}
65
66
public
function
getCardReference
()
67
{
68
if
(isset($this->data[
'id'
])) {
69
return
$this->data[
'id'
];
70
}
71
}
72
}
Omnipay\Common\Message\RequestInterface
Definition:
lib/vendor/omnipay/common/src/Omnipay/Common/Message/RequestInterface.php:16
Omnipay\PayPal\Message\RestResponse\getTransactionReference
getTransactionReference()
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:29
Omnipay\PayPal\Message\RestResponse\__construct
__construct(RequestInterface $request, $data, $statusCode=200)
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:18
Omnipay\PayPal\Message\RestResponse\getCardReference
getCardReference()
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:66
Omnipay\Common\Message\AbstractResponse\$data
$data
Definition:
lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractResponse.php:52
Omnipay\PayPal\Message\RestResponse\$statusCode
$statusCode
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:16
Omnipay\PayPal\Message\RestResponse\isSuccessful
isSuccessful()
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:24
Omnipay\PayPal\Message\RestResponse\getMessage
getMessage()
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:48
Omnipay\PayPal\Message\RestResponse
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:14
Omnipay\Common\Message\AbstractResponse
Definition:
lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractResponse.php:31
Omnipay\Common\Message\AbstractResponse\$request
$request
Definition:
lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractResponse.php:42
Omnipay\PayPal\Message\RestResponse\getCode
getCode()
Definition:
lib/vendor/omnipay/paypal/src/Message/RestResponse.php:61
Omnipay\PayPal\Message
Definition:
lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6
plugins
paymethod
paypal
lib
vendor
omnipay
paypal
src
Message
RestResponse.php
Generated on Fri Aug 28 2020 14:53:29 for Open Journal Systems by
1.8.17