Completed
Branch BUG-10502-mijireh-check-all-pa... (d9262a)
by
unknown
60:34 queued 46:59
created
core/interfaces/EEI_Interfaces.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 
154 154
 
155 155
 
156
-    /**
157
-     * Retrieves all the pending payments on this transaction
158
-     * @return EEI_Payment[]
159
-     */
160
-    public function pending_payments();
156
+	/**
157
+	 * Retrieves all the pending payments on this transaction
158
+	 * @return EEI_Payment[]
159
+	 */
160
+	public function pending_payments();
161 161
 }
162 162
 
163 163
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 interface EEI_Attendee {
199 199
 	public function fname();
200 200
 	public function lname();
201
-    public function full_name();
201
+	public function full_name();
202 202
 	public function email();
203 203
 	public function phone();
204 204
 	public function address();
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
 	 * @param float $amount
320 320
 	 * @param string $name
321 321
 	 * @param string $description
322
-         * @param string $code
323
-         * @param boolean $add_to_existing_line_item if true and a duplicate line item with
324
-         *  the same code is found, $amount will be added onto it; otherwise will simply
325
-         *  set the taxes to match $amount
322
+	 * @param string $code
323
+	 * @param boolean $add_to_existing_line_item if true and a duplicate line item with
324
+	 *  the same code is found, $amount will be added onto it; otherwise will simply
325
+	 *  set the taxes to match $amount
326 326
 	 * @return EE_Line_Item the new tax created
327 327
 	 */
328 328
 	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
329 329
 
330
-         /**
331
-         * Makes all the line items which are children of $line_item taxable (or not).
332
-         * Does NOT save the line items
333
-         * @param EE_Line_Item $line_item
334
-         * @param boolean $taxable
335
-         * @param string $code_substring_for_whitelist if this string is part of the line item's code
336
-         *  it will be whitelisted (ie, except from becoming taxable)
337
-         */
338
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
330
+		 /**
331
+		  * Makes all the line items which are children of $line_item taxable (or not).
332
+		  * Does NOT save the line items
333
+		  * @param EE_Line_Item $line_item
334
+		  * @param boolean $taxable
335
+		  * @param string $code_substring_for_whitelist if this string is part of the line item's code
336
+		  *  it will be whitelisted (ie, except from becoming taxable)
337
+		  */
338
+		public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
339 339
 
340 340
 	/**
341 341
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
  */
366 366
 interface EEHI_Money{
367 367
 		/**
368
-	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
369
-	 * This should be used to compare floats instead of normal '==' because floats
370
-	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
371
-	 * but actually differ by 0.00000001.
372
-	 * @param float $float1
373
-	 * @param float $float2
374
-	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
375
-	 * @return boolean whether the equation is true or false
376
-	 */
368
+		 * For comparing floats. Default operator is '=', but see the $operator below for all options.
369
+		 * This should be used to compare floats instead of normal '==' because floats
370
+		 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
371
+		 * but actually differ by 0.00000001.
372
+		 * @param float $float1
373
+		 * @param float $float2
374
+		 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
375
+		 * @return boolean whether the equation is true or false
376
+		 */
377 377
 	public function compare_floats( $float1, $float2, $operator='=' );
378 378
 }
379 379
 
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -462,28 +462,28 @@
 block discarded – undo
462 462
 
463 463
 
464 464
 
465
-    /**
466
-     * Gets all payments which have not been approved
467
-     * @return \EE_Base_Class[]
468
-     */
465
+	/**
466
+	 * Gets all payments which have not been approved
467
+	 * @return \EE_Base_Class[]
468
+	 */
469 469
 	public function pending_payments()
470
-    {
471
-        return $this->get_many_related(
472
-            'Payment',
473
-            array(
474
-                array(
475
-                    'STS_ID' => EEM_Payment::status_id_pending
476
-                ),
477
-                'order_by' => array(
478
-                    'PAY_timestamp' => 'DESC'
479
-                )
480
-            )
481
-        );
482
-    }
483
-
484
-
485
-
486
-    /**
470
+	{
471
+		return $this->get_many_related(
472
+			'Payment',
473
+			array(
474
+				array(
475
+					'STS_ID' => EEM_Payment::status_id_pending
476
+				),
477
+				'order_by' => array(
478
+					'PAY_timestamp' => 'DESC'
479
+				)
480
+			)
481
+		);
482
+	}
483
+
484
+
485
+
486
+	/**
487 487
 	 * echoes $this->pretty_status()
488 488
 	 *
489 489
 	 * @param bool $show_icons
Please login to merge, or discard this patch.
modules/mijireh_payment_checker/EED_Mijireh_Payment_Checker.module.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@
 block discarded – undo
45 45
 
46 46
 
47 47
 
48
-    /**
49
-     * If the transaction has pending mijireh payments, we check with mijireh to see if they've been completed.
50
-     * @param EE_Transaction $transaction
51
-     */
48
+	/**
49
+	 * If the transaction has pending mijireh payments, we check with mijireh to see if they've been completed.
50
+	 * @param EE_Transaction $transaction
51
+	 */
52 52
 	public static function check_for_payment_update_on_transaction( $transaction ) {
53 53
 		if( $transaction instanceof EE_Transaction ) {
54 54
 			//are there pending mijireh payments on this transaction?
55 55
 			if( EEM_Payment::instance()->exists(
56
-			    array(
57
-			        array(
58
-			            'TXN_ID' => $transaction->ID(),
59
-			            'STS_ID' => EEM_Payment::status_id_pending,
60
-                        'Payment_Method.PMD_type' => 'Mijireh',
61
-                    )
62
-                )
63
-            )) {
56
+				array(
57
+					array(
58
+						'TXN_ID' => $transaction->ID(),
59
+						'STS_ID' => EEM_Payment::status_id_pending,
60
+						'Payment_Method.PMD_type' => 'Mijireh',
61
+					)
62
+				)
63
+			)) {
64 64
 				add_action(
65 65
 					'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
66 66
 					array( 'EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn' ),
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @author				Mike Nelson
20 20
  *
21 21
  */
22
-class EED_Mijireh_Payment_Checker extends EED_Module{
22
+class EED_Mijireh_Payment_Checker extends EED_Module {
23 23
 
24 24
 	/**
25 25
 	 * 	set_hooks - for hooking into EE Core, other modules, etc
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *  @return 	void
41 41
 	 */
42 42
 	public static function set_hooks_admin() {
43
-		add_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', array( 'EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction' ), 10, 1 );
43
+		add_action('AHEE__Transactions_Admin_Page__transaction_details__start', array('EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction'), 10, 1);
44 44
 	}
45 45
 
46 46
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
      * If the transaction has pending mijireh payments, we check with mijireh to see if they've been completed.
50 50
      * @param EE_Transaction $transaction
51 51
      */
52
-	public static function check_for_payment_update_on_transaction( $transaction ) {
53
-		if( $transaction instanceof EE_Transaction ) {
52
+	public static function check_for_payment_update_on_transaction($transaction) {
53
+		if ($transaction instanceof EE_Transaction) {
54 54
 			//are there pending mijireh payments on this transaction?
55
-			if( EEM_Payment::instance()->exists(
55
+			if (EEM_Payment::instance()->exists(
56 56
 			    array(
57 57
 			        array(
58 58
 			            'TXN_ID' => $transaction->ID(),
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
             )) {
64 64
 				add_action(
65 65
 					'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
66
-					array( 'EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn' ),
66
+					array('EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn'),
67 67
 					5, 2
68 68
 				);
69
-				EE_Payment_Processor::instance()->process_ipn( array(), $transaction, 'mijireh' );
69
+				EE_Payment_Processor::instance()->process_ipn(array(), $transaction, 'mijireh');
70 70
 			}
71 71
 		}
72 72
 	}
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @param EE_Registration $registration
83 83
 	 * @param array $additional_details
84 84
 	 */
85
-	public static function send_notifications_after_mijireh_ipn( $registration, $additional_details ) {
86
-		$last_payment = isset( $additional_details[ 'last_payment' ] ) ? $additional_details[ 'last_payment' ] : null;
87
-		if ( ! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved ) {
88
-			add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 );
85
+	public static function send_notifications_after_mijireh_ipn($registration, $additional_details) {
86
+		$last_payment = isset($additional_details['last_payment']) ? $additional_details['last_payment'] : null;
87
+		if ( ! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) {
88
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
89 89
 		}
90 90
 	}
91 91
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @access    public
98 98
 	 * @param WP_Query $WP_Query
99 99
 	 */
100
-	public function run( $WP_Query = null ) {
100
+	public function run($WP_Query = null) {
101 101
 	}
102 102
 }
103 103
 
Please login to merge, or discard this patch.
caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -111,45 +111,45 @@  discard block
 block discarded – undo
111 111
 			'body'=>  wp_json_encode($order)
112 112
 		);
113 113
 		$response = wp_remote_post( $this->_mijireh_api_orders_url, $args );
114
-                $problems_string = false;
114
+				$problems_string = false;
115 115
 		$this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment);
116 116
 		if( ! $response instanceof WP_Error ){
117 117
 			$response_body = json_decode($response['body']);
118 118
 			if($response_body && isset($response_body->checkout_url)){
119
-                            $payment->set_redirect_url($response_body->checkout_url);
120
-                            $payment->set_txn_id_chq_nmbr($response_body->order_number);
121
-                            $payment->set_details($response['body']);
119
+							$payment->set_redirect_url($response_body->checkout_url);
120
+							$payment->set_txn_id_chq_nmbr($response_body->order_number);
121
+							$payment->set_details($response['body']);
122 122
 			} else {
123
-                           if( is_array( $response_body ) || is_object( $response_body)){
124
-                                    $response_body_as_array = (array)$response_body;
125
-                                    foreach($response_body_as_array as $problem_parameter => $problems){
126
-                                            $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems));
127
-                                    }
128
-                            }else{
129
-                                    $problems_string = $response['body'];
130
-                            }
131
-                            if( ! $problems_string ) {
132
-                                //no message to show? wack
133
-                                if( isset( $response[ 'headers' ][ 'status' ] ) ){
134
-                                        $problems_string = $response[ 'headers' ][ 'status' ];
135
-                                }else{
136
-                                        $problems_string = __( 'No response from Mijireh', 'event_espresso' );
137
-                                }
138
-                            }
139
-                        }
123
+						   if( is_array( $response_body ) || is_object( $response_body)){
124
+									$response_body_as_array = (array)$response_body;
125
+									foreach($response_body_as_array as $problem_parameter => $problems){
126
+											$problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems));
127
+									}
128
+							}else{
129
+									$problems_string = $response['body'];
130
+							}
131
+							if( ! $problems_string ) {
132
+								//no message to show? wack
133
+								if( isset( $response[ 'headers' ][ 'status' ] ) ){
134
+										$problems_string = $response[ 'headers' ][ 'status' ];
135
+								}else{
136
+										$problems_string = __( 'No response from Mijireh', 'event_espresso' );
137
+								}
138
+							}
139
+						}
140 140
 		}else{
141
-                    $problems_string = implode( ",", $response->get_error_messages() );
141
+					$problems_string = implode( ",", $response->get_error_messages() );
142 142
 		}
143 143
                 
144
-                if( $problems_string ) {
145
-                    $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) );
146
-                    $payment->set_details( $response );
147
-                    $payment->set_redirect_url( null );
148
-                    //even though the payment's status is failed at this point anyways,
149
-                    //let's be explicit about it. The fact that the redirect url is null
150
-                    //should be enough to client code that they can't redirect the user
151
-                    $payment->set_status( $this->_pay_model->failed_status() );
152
-                }
144
+				if( $problems_string ) {
145
+					$payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) );
146
+					$payment->set_details( $response );
147
+					$payment->set_redirect_url( null );
148
+					//even though the payment's status is failed at this point anyways,
149
+					//let's be explicit about it. The fact that the redirect url is null
150
+					//should be enough to client code that they can't redirect the user
151
+					$payment->set_status( $this->_pay_model->failed_status() );
152
+				}
153 153
 		return $payment;
154 154
 	}
155 155
 
@@ -197,62 +197,62 @@  discard block
 block discarded – undo
197 197
 
198 198
 		$payment_to_return = nulll;
199 199
 		foreach( $transaction->pending_payments() as $payment){
200
-		    $payment = $this->check_payment_in_mijireh($payment);
201
-            if( ! $payment_to_return instanceof EEI_Payment
202
-                || $payment->status() === $this->_pay_model->approved_status()){
203
-                $payment_to_return = $payment;
204
-            }
205
-        }
206
-        return $payment;
200
+			$payment = $this->check_payment_in_mijireh($payment);
201
+			if( ! $payment_to_return instanceof EEI_Payment
202
+				|| $payment->status() === $this->_pay_model->approved_status()){
203
+				$payment_to_return = $payment;
204
+			}
205
+		}
206
+		return $payment;
207 207
 	}
208 208
 
209 209
 
210 210
 
211
-    /**
212
-     * Checks the payment's status in Mijireh for this specific payment
213
-     * @param \EEI_Payment $payment
214
-     * @return \EEI_Payment
215
-     */
211
+	/**
212
+	 * Checks the payment's status in Mijireh for this specific payment
213
+	 * @param \EEI_Payment $payment
214
+	 * @return \EEI_Payment
215
+	 */
216 216
 	public function check_payment_in_mijireh( EEI_Payment $payment ){
217
-        $request_args = array(
218
-            'headers' => array(
219
-                'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
220
-                'Accept'=>'application/json'
221
-            )
222
-        );
217
+		$request_args = array(
218
+			'headers' => array(
219
+				'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
220
+				'Accept'=>'application/json'
221
+			)
222
+		);
223 223
 
224
-        $response = wp_remote_get(
225
-            $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(),
226
-            $request_args
227
-        );
224
+		$response = wp_remote_get(
225
+			$this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(),
226
+			$request_args
227
+		);
228 228
 
229
-        $this->log(
230
-            array( 'get payment status request_args' => $request_args, 'response' => $response ),
231
-            $payment
232
-        );
233
-        // validate response
234
-        $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : '';
235
-        if( $response && $response_body ){
236
-            switch( $response_body->status ){
237
-                case 'paid':
238
-                    $payment->set_status($this->_pay_model->approved_status());
239
-                    break;
240
-                case 'pending':
241
-                    $payment->set_status($this->_pay_model->pending_status());
242
-                    break;
243
-                default:
244
-                    $payment->set_status($this->_pay_model->declined_status());
245
-            }
229
+		$this->log(
230
+			array( 'get payment status request_args' => $request_args, 'response' => $response ),
231
+			$payment
232
+		);
233
+		// validate response
234
+		$response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : '';
235
+		if( $response && $response_body ){
236
+			switch( $response_body->status ){
237
+				case 'paid':
238
+					$payment->set_status($this->_pay_model->approved_status());
239
+					break;
240
+				case 'pending':
241
+					$payment->set_status($this->_pay_model->pending_status());
242
+					break;
243
+				default:
244
+					$payment->set_status($this->_pay_model->declined_status());
245
+			}
246 246
 
247
-        } else {
248
-            $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) );
249
-            $payment->set_details( $response );
250
-            $payment->set_status( $this->_pay_model->failed_status() );
251
-        }
252
-        // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage
247
+		} else {
248
+			$payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) );
249
+			$payment->set_details( $response );
250
+			$payment->set_status( $this->_pay_model->failed_status() );
251
+		}
252
+		// the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage
253 253
 //		$payment->set_status( $this->_pay_model->pending_status() );
254
-        return $payment;
255
-    }
254
+		return $payment;
255
+	}
256 256
 
257 257
 }
258 258
 
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Mike Nelson
9 9
  *
10 10
  */
11
-class EEG_Mijireh extends EE_Offsite_Gateway{
11
+class EEG_Mijireh extends EE_Offsite_Gateway {
12 12
 
13 13
 	protected $_access_key;
14 14
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 		$primary_attendee = $primary_registrant->attendee();
38 38
 		$items = array();
39 39
 		//if we're are charging for the full amount, show the normal line items
40
-		if( $this->_can_easily_itemize_transaction_for( $payment )){
40
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
41 41
 			$total_line_item = $transaction->total_line_item();
42 42
 			$tax_total = $total_line_item->get_total_tax();
43
-			foreach($total_line_item->get_items() as $line_item){
43
+			foreach ($total_line_item->get_items() as $line_item) {
44 44
 				$items[] = array(
45 45
 					'name'=>apply_filters(
46 46
 						'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name',
47
-						$this->_format_line_item_name( $line_item, $payment ),
47
+						$this->_format_line_item_name($line_item, $payment),
48 48
 						$line_item,
49 49
 						$payment,
50 50
 						$primary_registrant
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 					'quantity'=>$line_item->quantity()
55 55
 				);
56 56
 			}
57
-		}else{//its a partial payment
57
+		} else {//its a partial payment
58 58
 			$tax_total = 0;
59 59
 			//partial payment, so just add 1 item
60 60
 			$items[] = array(
61 61
 				'name'=> apply_filters(
62 62
 					'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name',
63
-					$this->_format_partial_payment_line_item_name( $payment ),
63
+					$this->_format_partial_payment_line_item_name($payment),
64 64
 					$payment,
65 65
 					$primary_registrant
66 66
 				),
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 		$order = array(
73 73
 			'total'=>$this->format_currency($payment->amount()),
74 74
 			'return_url'=>$return_url,
75
-			'items'=>$this->_prepare_for_mijireh( $items ),
75
+			'items'=>$this->_prepare_for_mijireh($items),
76 76
 			'email'=>$primary_attendee->email(),
77 77
 			'first_name'=>$primary_attendee->fname(),
78 78
 			'last_name'=>$primary_attendee->lname(),
79 79
 			'tax'=>$this->format_currency($tax_total),
80 80
 			'partner_id'=>'ee');
81 81
 		//setup address?
82
-		if(		$primary_attendee->address()  &&
83
-				$primary_attendee->city()  &&
84
-				$primary_attendee->state_ID()  &&
85
-				$primary_attendee->country_ID()  &&
86
-				$primary_attendee->zip()  ){
82
+		if ($primary_attendee->address() &&
83
+				$primary_attendee->city() &&
84
+				$primary_attendee->state_ID() &&
85
+				$primary_attendee->country_ID() &&
86
+				$primary_attendee->zip()) {
87 87
 			$shipping_address = array(
88 88
 				'first_name'=>$primary_attendee->fname(),
89 89
 				'last_name'=>$primary_attendee->lname(),
@@ -93,62 +93,62 @@  discard block
 block discarded – undo
93 93
 				'zip_code' => $primary_attendee->zip(),
94 94
 				'country' => $primary_attendee->country_ID()
95 95
 			);
96
-			if( $primary_attendee->address2() ){
97
-				$shipping_address[ 'apt_suite' ] = $primary_attendee->address2();
96
+			if ($primary_attendee->address2()) {
97
+				$shipping_address['apt_suite'] = $primary_attendee->address2();
98 98
 			}
99
-			if( $primary_attendee->phone() ){
100
-				$shipping_address[ 'phone' ] = $primary_attendee->phone();
99
+			if ($primary_attendee->phone()) {
100
+				$shipping_address['phone'] = $primary_attendee->phone();
101 101
 			}
102
-			$order[ 'shipping_address' ] = $shipping_address;
102
+			$order['shipping_address'] = $shipping_address;
103 103
 		}
104
-		$order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant );
105
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) );
104
+		$order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant);
105
+		do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)));
106 106
 		$args = array(
107 107
 			'headers' => array(
108
-				'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
108
+				'Authorization' => 'Basic '.base64_encode($this->_access_key.':'),
109 109
 				'Accept'=>'application/json'
110 110
 			),
111 111
 			'body'=>  wp_json_encode($order)
112 112
 		);
113
-		$response = wp_remote_post( $this->_mijireh_api_orders_url, $args );
113
+		$response = wp_remote_post($this->_mijireh_api_orders_url, $args);
114 114
                 $problems_string = false;
115
-		$this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment);
116
-		if( ! $response instanceof WP_Error ){
115
+		$this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment);
116
+		if ( ! $response instanceof WP_Error) {
117 117
 			$response_body = json_decode($response['body']);
118
-			if($response_body && isset($response_body->checkout_url)){
118
+			if ($response_body && isset($response_body->checkout_url)) {
119 119
                             $payment->set_redirect_url($response_body->checkout_url);
120 120
                             $payment->set_txn_id_chq_nmbr($response_body->order_number);
121 121
                             $payment->set_details($response['body']);
122 122
 			} else {
123
-                           if( is_array( $response_body ) || is_object( $response_body)){
124
-                                    $response_body_as_array = (array)$response_body;
125
-                                    foreach($response_body_as_array as $problem_parameter => $problems){
126
-                                            $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems));
123
+                           if (is_array($response_body) || is_object($response_body)) {
124
+                                    $response_body_as_array = (array) $response_body;
125
+                                    foreach ($response_body_as_array as $problem_parameter => $problems) {
126
+                                            $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems));
127 127
                                     }
128
-                            }else{
128
+                            } else {
129 129
                                     $problems_string = $response['body'];
130 130
                             }
131
-                            if( ! $problems_string ) {
131
+                            if ( ! $problems_string) {
132 132
                                 //no message to show? wack
133
-                                if( isset( $response[ 'headers' ][ 'status' ] ) ){
134
-                                        $problems_string = $response[ 'headers' ][ 'status' ];
135
-                                }else{
136
-                                        $problems_string = __( 'No response from Mijireh', 'event_espresso' );
133
+                                if (isset($response['headers']['status'])) {
134
+                                        $problems_string = $response['headers']['status'];
135
+                                } else {
136
+                                        $problems_string = __('No response from Mijireh', 'event_espresso');
137 137
                                 }
138 138
                             }
139 139
                         }
140
-		}else{
141
-                    $problems_string = implode( ",", $response->get_error_messages() );
140
+		} else {
141
+                    $problems_string = implode(",", $response->get_error_messages());
142 142
 		}
143 143
                 
144
-                if( $problems_string ) {
145
-                    $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) );
146
-                    $payment->set_details( $response );
147
-                    $payment->set_redirect_url( null );
144
+                if ($problems_string) {
145
+                    $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string));
146
+                    $payment->set_details($response);
147
+                    $payment->set_redirect_url(null);
148 148
                     //even though the payment's status is failed at this point anyways,
149 149
                     //let's be explicit about it. The fact that the redirect url is null
150 150
                     //should be enough to client code that they can't redirect the user
151
-                    $payment->set_status( $this->_pay_model->failed_status() );
151
+                    $payment->set_status($this->_pay_model->failed_status());
152 152
                 }
153 153
 		return $payment;
154 154
 	}
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 	 * @param mixed $data
162 162
 	 * @return mixed same type as $data
163 163
 	 */
164
-	private function _prepare_for_mijireh( $data ){
165
-		if( is_array( $data ) ){
164
+	private function _prepare_for_mijireh($data) {
165
+		if (is_array($data)) {
166 166
 			$prepared_data = array();
167
-			foreach($data as $key => $datum ){
168
-				$prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum );
167
+			foreach ($data as $key => $datum) {
168
+				$prepared_data[$key] = $this->_prepare_for_mijireh($datum);
169 169
 			}
170 170
 			return $prepared_data;
171
-		}elseif(is_string( $data ) ){
172
-			return str_replace( '%', 'percent', $data );
173
-		}else{
171
+		}elseif (is_string($data)) {
172
+			return str_replace('%', 'percent', $data);
173
+		} else {
174 174
 			return $data;
175 175
 		}
176 176
 	}
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 
192 192
 		$payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL;
193 193
 
194
-		if ( ! $payment instanceof EEI_Payment ){
195
-			throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) );
194
+		if ( ! $payment instanceof EEI_Payment) {
195
+			throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID()));
196 196
 		}
197 197
 
198 198
 		$payment_to_return = nulll;
199
-		foreach( $transaction->pending_payments() as $payment){
199
+		foreach ($transaction->pending_payments() as $payment) {
200 200
 		    $payment = $this->check_payment_in_mijireh($payment);
201
-            if( ! $payment_to_return instanceof EEI_Payment
202
-                || $payment->status() === $this->_pay_model->approved_status()){
201
+            if ( ! $payment_to_return instanceof EEI_Payment
202
+                || $payment->status() === $this->_pay_model->approved_status()) {
203 203
                 $payment_to_return = $payment;
204 204
             }
205 205
         }
@@ -213,27 +213,27 @@  discard block
 block discarded – undo
213 213
      * @param \EEI_Payment $payment
214 214
      * @return \EEI_Payment
215 215
      */
216
-	public function check_payment_in_mijireh( EEI_Payment $payment ){
216
+	public function check_payment_in_mijireh(EEI_Payment $payment) {
217 217
         $request_args = array(
218 218
             'headers' => array(
219
-                'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ),
219
+                'Authorization' => 'Basic '.base64_encode($this->_access_key.':'),
220 220
                 'Accept'=>'application/json'
221 221
             )
222 222
         );
223 223
 
224 224
         $response = wp_remote_get(
225
-            $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(),
225
+            $this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(),
226 226
             $request_args
227 227
         );
228 228
 
229 229
         $this->log(
230
-            array( 'get payment status request_args' => $request_args, 'response' => $response ),
230
+            array('get payment status request_args' => $request_args, 'response' => $response),
231 231
             $payment
232 232
         );
233 233
         // validate response
234
-        $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : '';
235
-        if( $response && $response_body ){
236
-            switch( $response_body->status ){
234
+        $response_body = isset($response['body']) ? json_decode($response['body']) : '';
235
+        if ($response && $response_body) {
236
+            switch ($response_body->status) {
237 237
                 case 'paid':
238 238
                     $payment->set_status($this->_pay_model->approved_status());
239 239
                     break;
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
             }
246 246
 
247 247
         } else {
248
-            $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) );
249
-            $payment->set_details( $response );
250
-            $payment->set_status( $this->_pay_model->failed_status() );
248
+            $payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso'));
249
+            $payment->set_details($response);
250
+            $payment->set_status($this->_pay_model->failed_status());
251 251
         }
252 252
         // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage
253 253
 //		$payment->set_status( $this->_pay_model->pending_status() );
Please login to merge, or discard this patch.