Completed
Pull Request — master (#1233)
by
unknown
09:46
created
core/domain/services/admin/ajax/ThankYouPageIpnMonitor.php 2 patches
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -22,239 +22,239 @@
 block discarded – undo
22 22
 class ThankYouPageIpnMonitor
23 23
 {
24 24
 
25
-    /**
26
-     * @var string $heartbeat
27
-     */
28
-    private $heartbeat;
25
+	/**
26
+	 * @var string $heartbeat
27
+	 */
28
+	private $heartbeat;
29 29
 
30
-    /**
31
-     * @var EED_Thank_You_Page $thank_you_page
32
-     */
33
-    private $thank_you_page;
30
+	/**
31
+	 * @var EED_Thank_You_Page $thank_you_page
32
+	 */
33
+	private $thank_you_page;
34 34
 
35
-    /**
36
-     * @var EE_Transaction $transaction
37
-     */
38
-    private $transaction;
35
+	/**
36
+	 * @var EE_Transaction $transaction
37
+	 */
38
+	private $transaction;
39 39
 
40 40
 
41
-    /**
42
-     * EventEditorHeartbeat constructor.
43
-     */
44
-    public function __construct()
45
-    {
46
-        $this->heartbeat = WordpressHeartbeat::RESPONSE_KEY_THANK_YOU_PAGE;
47
-        add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 3);
48
-        add_filter('heartbeat_nopriv_received', array($this, 'heartbeatResponse'), 10, 3);
49
-    }
41
+	/**
42
+	 * EventEditorHeartbeat constructor.
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$this->heartbeat = WordpressHeartbeat::RESPONSE_KEY_THANK_YOU_PAGE;
47
+		add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 3);
48
+		add_filter('heartbeat_nopriv_received', array($this, 'heartbeatResponse'), 10, 3);
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * thank_you_page_IPN_monitor
54
-     * this basically just pulls the TXN based on the reg_url_link sent from the server,
55
-     * then checks that the TXN status is not failed, and that no other errors have been generated.
56
-     * it also calculates the IPN wait time since the Thank You page was first loaded
57
-     *
58
-     * @param array $response
59
-     * @param array $data
60
-     * @return array
61
-     * @throws EE_Error
62
-     * @throws InvalidArgumentException
63
-     * @throws InvalidDataTypeException
64
-     * @throws InvalidInterfaceException
65
-     * @throws ReflectionException
66
-     */
67
-    public function heartbeatResponse($response = array(), $data = array())
68
-    {
69
-        // does this heartbeat contain our data ?
70
-        if (! isset($data[ $this->heartbeat ])) {
71
-            return $response;
72
-        }
73
-        // check for reg_url_link in the incoming heartbeat data
74
-        if (! isset($data[ $this->heartbeat ]['e_reg_url_link'])) {
75
-            $response[ $this->heartbeat ] = array(
76
-                'errors' => ! empty($notices['errors'])
77
-                    ? $notices['errors']
78
-                    : __(
79
-                        'No transaction information could be retrieved because the registration URL link is missing or invalid.',
80
-                        'event_espresso'
81
-                    ),
82
-            );
83
-            return $response;
84
-        }
85
-        // kk heartbeat has our data
86
-        $response = $this->initializeThankYouPageAndTransaction($response, $data);
87
-        // if something went wrong...
88
-        if (isset($response[ $this->heartbeat ]['errors'])) {
89
-            return $response;
90
-        }
91
-        // grab transient of Transaction's status
92
-        $txn_status = isset($data[ $this->heartbeat ]['txn_status'])
93
-            ? $data[ $this->heartbeat ]['txn_status']
94
-            : null;
95
-        $response = $this->getTransactionDetails($txn_status, $response, $data);
96
-        // no payment data yet?
97
-        if (isset($response[ $this->heartbeat ]['still_waiting'])) {
98
-            return $response;
99
-        }
100
-        // TXN is happening so let's get the payments now
101
-        // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
102
-        $since = isset($data[ $this->heartbeat ]['get_payments_since'])
103
-            ? $data[ $this->heartbeat ]['get_payments_since']
104
-            : 0;
105
-        return $this->paymentDetails($response, $since);
106
-    }
52
+	/**
53
+	 * thank_you_page_IPN_monitor
54
+	 * this basically just pulls the TXN based on the reg_url_link sent from the server,
55
+	 * then checks that the TXN status is not failed, and that no other errors have been generated.
56
+	 * it also calculates the IPN wait time since the Thank You page was first loaded
57
+	 *
58
+	 * @param array $response
59
+	 * @param array $data
60
+	 * @return array
61
+	 * @throws EE_Error
62
+	 * @throws InvalidArgumentException
63
+	 * @throws InvalidDataTypeException
64
+	 * @throws InvalidInterfaceException
65
+	 * @throws ReflectionException
66
+	 */
67
+	public function heartbeatResponse($response = array(), $data = array())
68
+	{
69
+		// does this heartbeat contain our data ?
70
+		if (! isset($data[ $this->heartbeat ])) {
71
+			return $response;
72
+		}
73
+		// check for reg_url_link in the incoming heartbeat data
74
+		if (! isset($data[ $this->heartbeat ]['e_reg_url_link'])) {
75
+			$response[ $this->heartbeat ] = array(
76
+				'errors' => ! empty($notices['errors'])
77
+					? $notices['errors']
78
+					: __(
79
+						'No transaction information could be retrieved because the registration URL link is missing or invalid.',
80
+						'event_espresso'
81
+					),
82
+			);
83
+			return $response;
84
+		}
85
+		// kk heartbeat has our data
86
+		$response = $this->initializeThankYouPageAndTransaction($response, $data);
87
+		// if something went wrong...
88
+		if (isset($response[ $this->heartbeat ]['errors'])) {
89
+			return $response;
90
+		}
91
+		// grab transient of Transaction's status
92
+		$txn_status = isset($data[ $this->heartbeat ]['txn_status'])
93
+			? $data[ $this->heartbeat ]['txn_status']
94
+			: null;
95
+		$response = $this->getTransactionDetails($txn_status, $response, $data);
96
+		// no payment data yet?
97
+		if (isset($response[ $this->heartbeat ]['still_waiting'])) {
98
+			return $response;
99
+		}
100
+		// TXN is happening so let's get the payments now
101
+		// if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
102
+		$since = isset($data[ $this->heartbeat ]['get_payments_since'])
103
+			? $data[ $this->heartbeat ]['get_payments_since']
104
+			: 0;
105
+		return $this->paymentDetails($response, $since);
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * @param array $response
111
-     * @param array $data
112
-     * @return array
113
-     * @throws EE_Error
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidInterfaceException
117
-     */
118
-    private function initializeThankYouPageAndTransaction($response, $data)
119
-    {
120
-        require_once EE_MODULES . 'thank_you_page/EED_Thank_You_Page.module.php';
121
-        // set_definitions, instantiate the thank you page class, and get the ball rolling
122
-        EED_Thank_You_Page::set_definitions();
123
-        $this->thank_you_page = EED_Thank_You_Page::instance();
124
-        $this->thank_you_page->set_reg_url_link($data[ $this->heartbeat ]['e_reg_url_link']);
125
-        $this->thank_you_page->init();
126
-        // get TXN
127
-        $transaction = $this->thank_you_page->get_txn();
128
-        // no TXN? then get out
129
-        if (! $transaction instanceof EE_Transaction) {
130
-            $notices = EE_Error::get_notices();
131
-            $response[ $this->heartbeat ] = array(
132
-                'errors' => ! empty($notices['errors'])
133
-                    ? $notices['errors']
134
-                    : sprintf(
135
-                        __(
136
-                            'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
137
-                            'event_espresso'
138
-                        ),
139
-                        __LINE__
140
-                    ),
141
-            );
142
-            return $response;
143
-        }
144
-        $this->transaction = $transaction;
145
-        return $response;
146
-    }
109
+	/**
110
+	 * @param array $response
111
+	 * @param array $data
112
+	 * @return array
113
+	 * @throws EE_Error
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidInterfaceException
117
+	 */
118
+	private function initializeThankYouPageAndTransaction($response, $data)
119
+	{
120
+		require_once EE_MODULES . 'thank_you_page/EED_Thank_You_Page.module.php';
121
+		// set_definitions, instantiate the thank you page class, and get the ball rolling
122
+		EED_Thank_You_Page::set_definitions();
123
+		$this->thank_you_page = EED_Thank_You_Page::instance();
124
+		$this->thank_you_page->set_reg_url_link($data[ $this->heartbeat ]['e_reg_url_link']);
125
+		$this->thank_you_page->init();
126
+		// get TXN
127
+		$transaction = $this->thank_you_page->get_txn();
128
+		// no TXN? then get out
129
+		if (! $transaction instanceof EE_Transaction) {
130
+			$notices = EE_Error::get_notices();
131
+			$response[ $this->heartbeat ] = array(
132
+				'errors' => ! empty($notices['errors'])
133
+					? $notices['errors']
134
+					: sprintf(
135
+						__(
136
+							'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
137
+							'event_espresso'
138
+						),
139
+						__LINE__
140
+					),
141
+			);
142
+			return $response;
143
+		}
144
+		$this->transaction = $transaction;
145
+		return $response;
146
+	}
147 147
 
148 148
 
149
-    /**
150
-     * @param string $txn_status
151
-     * @param array  $response
152
-     * @param array  $data
153
-     * @return array
154
-     * @throws EE_Error
155
-     * @throws InvalidArgumentException
156
-     * @throws InvalidDataTypeException
157
-     * @throws InvalidInterfaceException
158
-     * @throws ReflectionException
159
-     */
160
-    private function getTransactionDetails($txn_status, $response, $data)
161
-    {
162
-        // has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
163
-        if ($txn_status !== $this->transaction->status_ID()) {
164
-            // switch between two possible basic outcomes
165
-            switch ($this->transaction->status_ID()) {
166
-                // TXN has been updated in some way
167
-                case EEM_Transaction::overpaid_status_code:
168
-                case EEM_Transaction::complete_status_code:
169
-                case EEM_Transaction::incomplete_status_code:
170
-                    // send updated TXN results back to client,
171
-                    return $this->setTransactionDetails($response);
172
-                // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
173
-                case EEM_Transaction::failed_status_code:
174
-                default:
175
-                    // keep on waiting...
176
-                    return $this->updateServerWaitTime($data[ $this->heartbeat ]);
177
-            }
178
-            // or is the TXN still failed (never been updated) ???
179
-        } elseif ($this->transaction->failed()) {
180
-            // keep on waiting...
181
-            return $this->updateServerWaitTime($data[ $this->heartbeat ]);
182
-        }
183
-        return $response;
184
-    }
149
+	/**
150
+	 * @param string $txn_status
151
+	 * @param array  $response
152
+	 * @param array  $data
153
+	 * @return array
154
+	 * @throws EE_Error
155
+	 * @throws InvalidArgumentException
156
+	 * @throws InvalidDataTypeException
157
+	 * @throws InvalidInterfaceException
158
+	 * @throws ReflectionException
159
+	 */
160
+	private function getTransactionDetails($txn_status, $response, $data)
161
+	{
162
+		// has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
163
+		if ($txn_status !== $this->transaction->status_ID()) {
164
+			// switch between two possible basic outcomes
165
+			switch ($this->transaction->status_ID()) {
166
+				// TXN has been updated in some way
167
+				case EEM_Transaction::overpaid_status_code:
168
+				case EEM_Transaction::complete_status_code:
169
+				case EEM_Transaction::incomplete_status_code:
170
+					// send updated TXN results back to client,
171
+					return $this->setTransactionDetails($response);
172
+				// or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
173
+				case EEM_Transaction::failed_status_code:
174
+				default:
175
+					// keep on waiting...
176
+					return $this->updateServerWaitTime($data[ $this->heartbeat ]);
177
+			}
178
+			// or is the TXN still failed (never been updated) ???
179
+		} elseif ($this->transaction->failed()) {
180
+			// keep on waiting...
181
+			return $this->updateServerWaitTime($data[ $this->heartbeat ]);
182
+		}
183
+		return $response;
184
+	}
185 185
 
186 186
 
187
-    /**
188
-     * @param array $response
189
-     * @param boolean $status_only
190
-     * @return array
191
-     * @throws EE_Error
192
-     * @throws InvalidArgumentException
193
-     * @throws InvalidDataTypeException
194
-     * @throws InvalidInterfaceException
195
-     * @throws ReflectionException
196
-     */
197
-    private function setTransactionDetails($response, $status_only = false)
198
-    {
199
-        if (! $status_only && ! isset($response[ $this->heartbeat ]['transaction_details'])) {
200
-            $response[ $this->heartbeat ]['transaction_details'] = $this->thank_you_page->get_transaction_details();
201
-        }
202
-        if (! isset($response[ $this->heartbeat ]['txn_status'])) {
203
-            $response[ $this->heartbeat ]['txn_status'] = $this->transaction->status_ID();
204
-        }
205
-        return $response;
206
-    }
187
+	/**
188
+	 * @param array $response
189
+	 * @param boolean $status_only
190
+	 * @return array
191
+	 * @throws EE_Error
192
+	 * @throws InvalidArgumentException
193
+	 * @throws InvalidDataTypeException
194
+	 * @throws InvalidInterfaceException
195
+	 * @throws ReflectionException
196
+	 */
197
+	private function setTransactionDetails($response, $status_only = false)
198
+	{
199
+		if (! $status_only && ! isset($response[ $this->heartbeat ]['transaction_details'])) {
200
+			$response[ $this->heartbeat ]['transaction_details'] = $this->thank_you_page->get_transaction_details();
201
+		}
202
+		if (! isset($response[ $this->heartbeat ]['txn_status'])) {
203
+			$response[ $this->heartbeat ]['txn_status'] = $this->transaction->status_ID();
204
+		}
205
+		return $response;
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * @param array $response
211
-     * @param int $since
212
-     * @return array
213
-     * @throws EE_Error
214
-     * @throws InvalidArgumentException
215
-     * @throws InvalidDataTypeException
216
-     * @throws InvalidInterfaceException
217
-     * @throws ReflectionException
218
-     */
219
-    private function paymentDetails($response, $since)
220
-    {
221
-        // then check for payments
222
-        $payments = $this->thank_you_page->get_txn_payments($since);
223
-        // has a payment been processed ?
224
-        if (! empty($payments) || $this->thank_you_page->isOfflinePaymentMethod()) {
225
-            if ($since) {
226
-                $response[ $this->heartbeat ]['new_payments'] = $this->thank_you_page->get_new_payments($payments);
227
-                $response = $this->setTransactionDetails($response);
228
-            } else {
229
-                $response[ $this->heartbeat ]['payment_details'] = $this->thank_you_page->get_payment_details(
230
-                    $payments
231
-                );
232
-            }
233
-            // reset time to check for payments
234
-            $response[ $this->heartbeat ]['get_payments_since'] = time();
235
-        } else {
236
-            $response[ $this->heartbeat ]['get_payments_since'] = $since;
237
-        }
238
-        return $response;
239
-    }
209
+	/**
210
+	 * @param array $response
211
+	 * @param int $since
212
+	 * @return array
213
+	 * @throws EE_Error
214
+	 * @throws InvalidArgumentException
215
+	 * @throws InvalidDataTypeException
216
+	 * @throws InvalidInterfaceException
217
+	 * @throws ReflectionException
218
+	 */
219
+	private function paymentDetails($response, $since)
220
+	{
221
+		// then check for payments
222
+		$payments = $this->thank_you_page->get_txn_payments($since);
223
+		// has a payment been processed ?
224
+		if (! empty($payments) || $this->thank_you_page->isOfflinePaymentMethod()) {
225
+			if ($since) {
226
+				$response[ $this->heartbeat ]['new_payments'] = $this->thank_you_page->get_new_payments($payments);
227
+				$response = $this->setTransactionDetails($response);
228
+			} else {
229
+				$response[ $this->heartbeat ]['payment_details'] = $this->thank_you_page->get_payment_details(
230
+					$payments
231
+				);
232
+			}
233
+			// reset time to check for payments
234
+			$response[ $this->heartbeat ]['get_payments_since'] = time();
235
+		} else {
236
+			$response[ $this->heartbeat ]['get_payments_since'] = $since;
237
+		}
238
+		return $response;
239
+	}
240 240
 
241 241
 
242
-    /**
243
-     * @param array $thank_you_page_data    thank you page portion of the incoming JSON array
244
-     *                                      from the WP heartbeat data
245
-     * @return array
246
-     * @throws EE_Error
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidDataTypeException
249
-     * @throws InvalidInterfaceException
250
-     * @throws ReflectionException
251
-     */
252
-    private function updateServerWaitTime($thank_you_page_data)
253
-    {
254
-        $response[ $this->heartbeat ]['still_waiting'] = isset($thank_you_page_data['initial_access'])
255
-            ? time() - $thank_you_page_data['initial_access']
256
-            : 0;
257
-        $response = $this->setTransactionDetails($response, true);
258
-        return $response;
259
-    }
242
+	/**
243
+	 * @param array $thank_you_page_data    thank you page portion of the incoming JSON array
244
+	 *                                      from the WP heartbeat data
245
+	 * @return array
246
+	 * @throws EE_Error
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidDataTypeException
249
+	 * @throws InvalidInterfaceException
250
+	 * @throws ReflectionException
251
+	 */
252
+	private function updateServerWaitTime($thank_you_page_data)
253
+	{
254
+		$response[ $this->heartbeat ]['still_waiting'] = isset($thank_you_page_data['initial_access'])
255
+			? time() - $thank_you_page_data['initial_access']
256
+			: 0;
257
+		$response = $this->setTransactionDetails($response, true);
258
+		return $response;
259
+	}
260 260
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
     public function heartbeatResponse($response = array(), $data = array())
68 68
     {
69 69
         // does this heartbeat contain our data ?
70
-        if (! isset($data[ $this->heartbeat ])) {
70
+        if ( ! isset($data[$this->heartbeat])) {
71 71
             return $response;
72 72
         }
73 73
         // check for reg_url_link in the incoming heartbeat data
74
-        if (! isset($data[ $this->heartbeat ]['e_reg_url_link'])) {
75
-            $response[ $this->heartbeat ] = array(
74
+        if ( ! isset($data[$this->heartbeat]['e_reg_url_link'])) {
75
+            $response[$this->heartbeat] = array(
76 76
                 'errors' => ! empty($notices['errors'])
77 77
                     ? $notices['errors']
78 78
                     : __(
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
         // kk heartbeat has our data
86 86
         $response = $this->initializeThankYouPageAndTransaction($response, $data);
87 87
         // if something went wrong...
88
-        if (isset($response[ $this->heartbeat ]['errors'])) {
88
+        if (isset($response[$this->heartbeat]['errors'])) {
89 89
             return $response;
90 90
         }
91 91
         // grab transient of Transaction's status
92
-        $txn_status = isset($data[ $this->heartbeat ]['txn_status'])
93
-            ? $data[ $this->heartbeat ]['txn_status']
92
+        $txn_status = isset($data[$this->heartbeat]['txn_status'])
93
+            ? $data[$this->heartbeat]['txn_status']
94 94
             : null;
95 95
         $response = $this->getTransactionDetails($txn_status, $response, $data);
96 96
         // no payment data yet?
97
-        if (isset($response[ $this->heartbeat ]['still_waiting'])) {
97
+        if (isset($response[$this->heartbeat]['still_waiting'])) {
98 98
             return $response;
99 99
         }
100 100
         // TXN is happening so let's get the payments now
101 101
         // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
102
-        $since = isset($data[ $this->heartbeat ]['get_payments_since'])
103
-            ? $data[ $this->heartbeat ]['get_payments_since']
102
+        $since = isset($data[$this->heartbeat]['get_payments_since'])
103
+            ? $data[$this->heartbeat]['get_payments_since']
104 104
             : 0;
105 105
         return $this->paymentDetails($response, $since);
106 106
     }
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
      */
118 118
     private function initializeThankYouPageAndTransaction($response, $data)
119 119
     {
120
-        require_once EE_MODULES . 'thank_you_page/EED_Thank_You_Page.module.php';
120
+        require_once EE_MODULES.'thank_you_page/EED_Thank_You_Page.module.php';
121 121
         // set_definitions, instantiate the thank you page class, and get the ball rolling
122 122
         EED_Thank_You_Page::set_definitions();
123 123
         $this->thank_you_page = EED_Thank_You_Page::instance();
124
-        $this->thank_you_page->set_reg_url_link($data[ $this->heartbeat ]['e_reg_url_link']);
124
+        $this->thank_you_page->set_reg_url_link($data[$this->heartbeat]['e_reg_url_link']);
125 125
         $this->thank_you_page->init();
126 126
         // get TXN
127 127
         $transaction = $this->thank_you_page->get_txn();
128 128
         // no TXN? then get out
129
-        if (! $transaction instanceof EE_Transaction) {
129
+        if ( ! $transaction instanceof EE_Transaction) {
130 130
             $notices = EE_Error::get_notices();
131
-            $response[ $this->heartbeat ] = array(
131
+            $response[$this->heartbeat] = array(
132 132
                 'errors' => ! empty($notices['errors'])
133 133
                     ? $notices['errors']
134 134
                     : sprintf(
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
                 case EEM_Transaction::failed_status_code:
174 174
                 default:
175 175
                     // keep on waiting...
176
-                    return $this->updateServerWaitTime($data[ $this->heartbeat ]);
176
+                    return $this->updateServerWaitTime($data[$this->heartbeat]);
177 177
             }
178 178
             // or is the TXN still failed (never been updated) ???
179 179
         } elseif ($this->transaction->failed()) {
180 180
             // keep on waiting...
181
-            return $this->updateServerWaitTime($data[ $this->heartbeat ]);
181
+            return $this->updateServerWaitTime($data[$this->heartbeat]);
182 182
         }
183 183
         return $response;
184 184
     }
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
      */
197 197
     private function setTransactionDetails($response, $status_only = false)
198 198
     {
199
-        if (! $status_only && ! isset($response[ $this->heartbeat ]['transaction_details'])) {
200
-            $response[ $this->heartbeat ]['transaction_details'] = $this->thank_you_page->get_transaction_details();
199
+        if ( ! $status_only && ! isset($response[$this->heartbeat]['transaction_details'])) {
200
+            $response[$this->heartbeat]['transaction_details'] = $this->thank_you_page->get_transaction_details();
201 201
         }
202
-        if (! isset($response[ $this->heartbeat ]['txn_status'])) {
203
-            $response[ $this->heartbeat ]['txn_status'] = $this->transaction->status_ID();
202
+        if ( ! isset($response[$this->heartbeat]['txn_status'])) {
203
+            $response[$this->heartbeat]['txn_status'] = $this->transaction->status_ID();
204 204
         }
205 205
         return $response;
206 206
     }
@@ -221,19 +221,19 @@  discard block
 block discarded – undo
221 221
         // then check for payments
222 222
         $payments = $this->thank_you_page->get_txn_payments($since);
223 223
         // has a payment been processed ?
224
-        if (! empty($payments) || $this->thank_you_page->isOfflinePaymentMethod()) {
224
+        if ( ! empty($payments) || $this->thank_you_page->isOfflinePaymentMethod()) {
225 225
             if ($since) {
226
-                $response[ $this->heartbeat ]['new_payments'] = $this->thank_you_page->get_new_payments($payments);
226
+                $response[$this->heartbeat]['new_payments'] = $this->thank_you_page->get_new_payments($payments);
227 227
                 $response = $this->setTransactionDetails($response);
228 228
             } else {
229
-                $response[ $this->heartbeat ]['payment_details'] = $this->thank_you_page->get_payment_details(
229
+                $response[$this->heartbeat]['payment_details'] = $this->thank_you_page->get_payment_details(
230 230
                     $payments
231 231
                 );
232 232
             }
233 233
             // reset time to check for payments
234
-            $response[ $this->heartbeat ]['get_payments_since'] = time();
234
+            $response[$this->heartbeat]['get_payments_since'] = time();
235 235
         } else {
236
-            $response[ $this->heartbeat ]['get_payments_since'] = $since;
236
+            $response[$this->heartbeat]['get_payments_since'] = $since;
237 237
         }
238 238
         return $response;
239 239
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     private function updateServerWaitTime($thank_you_page_data)
253 253
     {
254
-        $response[ $this->heartbeat ]['still_waiting'] = isset($thank_you_page_data['initial_access'])
254
+        $response[$this->heartbeat]['still_waiting'] = isset($thank_you_page_data['initial_access'])
255 255
             ? time() - $thank_you_page_data['initial_access']
256 256
             : 0;
257 257
         $response = $this->setTransactionDetails($response, true);
Please login to merge, or discard this patch.
core/domain/services/admin/ajax/WordpressHeartbeat.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -17,52 +17,52 @@
 block discarded – undo
17 17
 class WordpressHeartbeat
18 18
 {
19 19
 
20
-    const RESPONSE_KEY_THANK_YOU_PAGE = 'espresso_thank_you_page';
20
+	const RESPONSE_KEY_THANK_YOU_PAGE = 'espresso_thank_you_page';
21 21
 
22
-    /**
23
-     * @var LoaderInterface $loader
24
-     */
25
-    protected $loader;
22
+	/**
23
+	 * @var LoaderInterface $loader
24
+	 */
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var RequestInterface $request
29
-     */
30
-    protected $request;
27
+	/**
28
+	 * @var RequestInterface $request
29
+	 */
30
+	protected $request;
31 31
 
32 32
 
33
-    /**
34
-     * WordpressHeartbeat constructor.
35
-     *
36
-     * @param LoaderInterface  $loader
37
-     * @param RequestInterface $request
38
-     */
39
-    public function __construct(
40
-        LoaderInterface $loader,
41
-        RequestInterface $request
42
-    ) {
43
-        $this->loader = $loader;
44
-        $this->request = $request;
45
-        do_action('AHEE__EventEspresso_core_domain_services_admin_ajax_WordpressHeartbeat__constructor', $this);
46
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'resolveRoutes'));
47
-    }
33
+	/**
34
+	 * WordpressHeartbeat constructor.
35
+	 *
36
+	 * @param LoaderInterface  $loader
37
+	 * @param RequestInterface $request
38
+	 */
39
+	public function __construct(
40
+		LoaderInterface $loader,
41
+		RequestInterface $request
42
+	) {
43
+		$this->loader = $loader;
44
+		$this->request = $request;
45
+		do_action('AHEE__EventEspresso_core_domain_services_admin_ajax_WordpressHeartbeat__constructor', $this);
46
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'resolveRoutes'));
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @since 4.9.76.p
52
-     * @throws InvalidClassException
53
-     */
54
-    public function resolveRoutes()
55
-    {
56
-        $screenID = $this->request->getRequestParam('screen_id');
57
-        $heartbeat_data = $this->request->getRequestParam('data', []);
58
-        if ($screenID === 'espresso_events') {
59
-            $this->loader->getShared(
60
-                'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat'
61
-            );
62
-        } elseif ($screenID === 'front' && ! empty($heartbeat_data[ self::RESPONSE_KEY_THANK_YOU_PAGE ])) {
63
-            $this->loader->getShared(
64
-                'EventEspresso\core\domain\services\admin\ajax\ThankYouPageIpnMonitor'
65
-            );
66
-        }
67
-    }
50
+	/**
51
+	 * @since 4.9.76.p
52
+	 * @throws InvalidClassException
53
+	 */
54
+	public function resolveRoutes()
55
+	{
56
+		$screenID = $this->request->getRequestParam('screen_id');
57
+		$heartbeat_data = $this->request->getRequestParam('data', []);
58
+		if ($screenID === 'espresso_events') {
59
+			$this->loader->getShared(
60
+				'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat'
61
+			);
62
+		} elseif ($screenID === 'front' && ! empty($heartbeat_data[ self::RESPONSE_KEY_THANK_YOU_PAGE ])) {
63
+			$this->loader->getShared(
64
+				'EventEspresso\core\domain\services\admin\ajax\ThankYouPageIpnMonitor'
65
+			);
66
+		}
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
             $this->loader->getShared(
60 60
                 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat'
61 61
             );
62
-        } elseif ($screenID === 'front' && ! empty($heartbeat_data[ self::RESPONSE_KEY_THANK_YOU_PAGE ])) {
62
+        } elseif ($screenID === 'front' && ! empty($heartbeat_data[self::RESPONSE_KEY_THANK_YOU_PAGE])) {
63 63
             $this->loader->getShared(
64 64
                 'EventEspresso\core\domain\services\admin\ajax\ThankYouPageIpnMonitor'
65 65
             );
Please login to merge, or discard this patch.