Completed
Branch FET-9608-locate-template-actio... (245c03)
by
unknown
765:31 queued 745:56
created

EES_Espresso_Txn_Page::run()   D

Complexity

Conditions 9
Paths 26

Size

Total Lines 36
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
rs 4.909
cc 9
eloc 21
nc 26
nop 1
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
/**
3
 * Event Espresso
4
 *
5
 * Event Registration and Management Plugin for WordPress
6
 *
7
 * @ package			Event Espresso
8
 * @ author			Seth Shoultes
9
 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
 * @ link					http://www.eventespresso.com
12
 * @ version		 	4.0
13
 *
14
 * ------------------------------------------------------------------------
15
 *
16
 * EES_Espresso_Txn_Page
17
 *
18
 * @package			Event Espresso
19
 * @subpackage	/shortcodes/
20
 * @author				Brent Christensen
21
 *
22
 * ------------------------------------------------------------------------
23
 */
24
class EES_Espresso_Txn_Page  extends EES_Shortcode {
25
26
	/**
27
	 * The transaction specified by the reg_url_link passed from the Request, or from the Session
28
	 * @var EE_Transaction $_current_txn
29
	 */
30
	protected $_current_txn = NULL;
31
32
	/**
33
	 * The current payment method for the IPN
34
	 * @var EE_Payment_Method $_current_pm
35
	 */
36
	protected $_current_pm = NULL;
37
38
	/**
39
	 * 	set_hooks - for hooking into EE Core, modules, etc
40
	 *
41
	 *  @access 	public
42
	 *  @return 	void
43
	 */
44
	public static function set_hooks() {
45
		add_action( 'wp_loaded', array( 'EES_Espresso_Txn_Page', 'set_definitions' ), 2 );
46
	}
47
48
	/**
49
	 * 	set_hooks_admin - for hooking into EE Admin Core, modules, etc
50
	 *
51
	 *  @access 	public
52
	 *  @return 	void
53
	 */
54
	public static function set_hooks_admin() {
55
	}
56
57
58
59
	/**
60
	 * 	set_definitions
61
	 *
62
	 *  @access 	public
63
	 *  @return 	void
64
	 */
65
	public static function set_definitions() {
66
		define( 'TXN_PAGE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
67
		define( 'TXN_PAGE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
68
	}
69
70
71
72
	/**
73
	 * 	run - initial shortcode module setup called during "wp_loaded" hook
74
	 * 	this method is primarily used for loading resources that will be required by the shortcode when it is actually processed
75
	 *
76
	 *  @access 	public
77
	 *  @param 	 WP $WP
78
	 *  @return 	void
79
	 */
80
	public function run( WP $WP ) {
81
		if ( EE_Registry::instance()->REQ->is_set('e_reg_url_link' )){
82
			$this->_current_txn = EE_Registry::instance()->load_model( 'Transaction' )->get_transaction_from_reg_url_link();
0 ignored issues
show
Bug introduced by
The method get_transaction_from_reg_url_link cannot be called on \EE_Registry::instance()...ad_model('Transaction') (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
83
		} else {
84
			$this->_current_txn = null;
85
		}
86
		if ( $this->_current_txn instanceof EE_Transaction ) {
87
			//EE_Registry::instance()->load_helper( 'Debug_Tools' );
88
			//EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $this->_current_txn ), true, 	'EE_Transaction: ' . $this->_current_txn->ID() );
89
			$payment_method = null;
90
			$payment_method_slug = EE_Registry::instance()->REQ->get( 'ee_payment_method', null );
91
			if( $payment_method_slug ) {
92
				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug( $payment_method_slug );
93
			}
94
95
			if ( $payment_method instanceof EE_Payment_Method && $payment_method->is_off_site() ) {
96
				$gateway = $payment_method->type_obj()->get_gateway();
97
				if (
98
					$gateway instanceof EE_Offsite_Gateway
99
				    && $gateway->handle_IPN_in_this_request(
100
						\EE_Registry::instance()->REQ->params(),
101
						true
102
					)
103
				) {
104
					/** @type EE_Payment_Processor $payment_processor */
105
					$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
106
					$payment_processor->process_ipn( $_REQUEST, $this->_current_txn, $payment_method );
107
				}
108
			}
109
			//allow gateways to add a filter to stop rendering the page
110
			if( apply_filters( 'FHEE__EES_Espresso_Txn_Page__run__exit', FALSE ) ){
111
				exit;
112
			}
113
		}
114
115
	}
116
117
118
119
120
	/**
121
	 * 	process_shortcode - EES_Espresso_Txn_Page
122
	 *
123
	 *  @access 	public
124
	 *  @param		array 	$attributes
125
	 *  @return 	string
126
	 */
127
	public function process_shortcode( $attributes = array() ) {
128
		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' );
129
	}
130
131
132
133
}
134
// End of file EES_Espresso_Txn_Page.shortcode.php
135
// Location: /shortcodes/EES_Espresso_Txn_Page.shortcode.php