|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\exceptions; |
|
3
|
|
|
|
|
4
|
|
|
if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5
|
|
|
exit('No direct script access allowed'); |
|
6
|
|
|
} |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class IPNException |
|
12
|
|
|
* Exception for describing any problems relating to how an IPN was received. |
|
13
|
|
|
* These should generally be thrown by children of EE_Gateway children when an Instant Payment Notification |
|
14
|
|
|
* can't be handled because it somehow contains invalid data, or we are in an invalid state to handle it. |
|
15
|
|
|
* (Eg, duplicates IPNs, or when we're unable to verify the IPN is from the trusted source, |
|
16
|
|
|
* |
|
17
|
|
|
* @package Event Espresso |
|
18
|
|
|
* @author Michael Nelson |
|
19
|
|
|
* @since $VID:$ |
|
20
|
|
|
*/ |
|
21
|
|
|
class IpnException extends \LogicException |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
const DUPLICATE = 1; |
|
25
|
|
|
|
|
26
|
|
|
const UNABLE_TO_VALIDATE = 2; |
|
27
|
|
|
|
|
28
|
|
|
const UNSUPPORTED = 3; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var \EE_Payment |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $payment; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var mixed IPN data, usually an array or object |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $ipn_data; |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function __construct( |
|
43
|
|
|
$message, |
|
44
|
|
|
$code = 0, |
|
45
|
|
|
\Exception $previous = null, |
|
46
|
|
|
\EE_Payment $payment = null, |
|
47
|
|
|
$ipn_data = array() |
|
48
|
|
|
) { |
|
49
|
|
|
parent::__construct($message, $code, $previous); |
|
50
|
|
|
$this->payment = $payment; |
|
51
|
|
|
$this->ipn_data = $ipn_data; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Gets the payment associated with this IPN, if known |
|
58
|
|
|
* |
|
59
|
|
|
* @return \EE_Payment |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getPayment() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->payment; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array) |
|
70
|
|
|
* |
|
71
|
|
|
* @return array |
|
72
|
|
|
* @throws \EE_Error |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getPaymentProperties() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Returns an array, object, or string, however, the IPN data was received |
|
83
|
|
|
* |
|
84
|
|
|
* @return mixed |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getIpnData() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->ipn_data; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
} |