1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
2
|
|
|
/** |
3
|
|
|
* EES_Espresso_Txn_Page |
4
|
|
|
* |
5
|
|
|
* @package Event Espresso |
6
|
|
|
* @subpackage /shortcodes/ |
7
|
|
|
* @author Brent Christensen |
8
|
|
|
*/ |
9
|
|
|
class EES_Espresso_Txn_Page extends EES_Shortcode { |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* The transaction specified by the reg_url_link passed from the Request, or from the Session |
13
|
|
|
* @var EE_Transaction $_current_txn |
14
|
|
|
*/ |
15
|
|
|
protected $_current_txn; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The current payment method for the IPN |
19
|
|
|
* @var EE_Payment_Method $_current_pm |
20
|
|
|
*/ |
21
|
|
|
protected $_current_pm; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* set_hooks - for hooking into EE Core, modules, etc |
25
|
|
|
* |
26
|
|
|
* @access public |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public static function set_hooks() { |
30
|
|
|
add_action( 'wp_loaded', array( 'EES_Espresso_Txn_Page', 'set_definitions' ), 2 ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* set_hooks_admin - for hooking into EE Admin Core, modules, etc |
35
|
|
|
* |
36
|
|
|
* @access public |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
public static function set_hooks_admin() { |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* set_definitions |
46
|
|
|
* |
47
|
|
|
* @access public |
48
|
|
|
* @return void |
49
|
|
|
*/ |
50
|
|
|
public static function set_definitions() { |
51
|
|
|
define( 'TXN_PAGE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
52
|
|
|
define( 'TXN_PAGE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* run |
59
|
|
|
* |
60
|
|
|
* initial shortcode module setup called during "wp_loaded" hook |
61
|
|
|
* this method is primarily used for loading resources that will be required by the shortcode when it is actually processed |
62
|
|
|
* |
63
|
|
|
* @access public |
64
|
|
|
* @param WP $WP |
65
|
|
|
* @return void |
66
|
|
|
* @throws \Exception |
67
|
|
|
* @throws \EE_Error |
68
|
|
|
*/ |
69
|
|
|
public function run( WP $WP ) { |
70
|
|
|
$this->_current_txn = null; |
71
|
|
|
if ( EE_Registry::instance()->REQ->is_set('e_reg_url_link' )){ |
72
|
|
|
/** @var EEM_Transaction $EEM_Transaction */ |
73
|
|
|
$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
74
|
|
|
$this->_current_txn = $EEM_Transaction->get_transaction_from_reg_url_link(); |
75
|
|
|
} |
76
|
|
|
if ( $this->_current_txn instanceof EE_Transaction ) { |
77
|
|
|
$payment_method = null; |
78
|
|
|
$payment_method_slug = EE_Registry::instance()->REQ->get( 'ee_payment_method', null ); |
79
|
|
|
if( $payment_method_slug ) { |
80
|
|
|
$payment_method = EEM_Payment_Method::instance()->get_one_by_slug( $payment_method_slug ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if ( $payment_method instanceof EE_Payment_Method && $payment_method->is_off_site() ) { |
84
|
|
|
$gateway = $payment_method->type_obj()->get_gateway(); |
85
|
|
|
if ( |
86
|
|
|
$gateway instanceof EE_Offsite_Gateway |
87
|
|
|
&& $gateway->handle_IPN_in_this_request( |
88
|
|
|
\EE_Registry::instance()->REQ->params(), |
89
|
|
|
true |
90
|
|
|
) |
91
|
|
|
) { |
92
|
|
|
/** @type EE_Payment_Processor $payment_processor */ |
93
|
|
|
$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
94
|
|
|
$payment_processor->process_ipn( $_REQUEST, $this->_current_txn, $payment_method ); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
//allow gateways to add a filter to stop rendering the page |
98
|
|
|
if( apply_filters( 'FHEE__EES_Espresso_Txn_Page__run__exit', FALSE ) ){ |
99
|
|
|
exit; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* process_shortcode - EES_Espresso_Txn_Page |
110
|
|
|
* |
111
|
|
|
* @access public |
112
|
|
|
* @param array $attributes |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function process_shortcode( $attributes = array() ) { |
116
|
|
|
return __( 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso' ); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
|
121
|
|
|
} |
122
|
|
|
// End of file EES_Espresso_Txn_Page.shortcode.php |
123
|
|
|
// Location: /shortcodes/EES_Espresso_Txn_Page.shortcode.php |