Completed
Push — develop ( c30ec5...06c5d6 )
by Remco
07:42
created
src/PaymentData.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param MeprTransaction $txn MemberPress transaction object.
56 56
 	 */
57
-	public function __construct( MeprTransaction $txn ) {
57
+	public function __construct(MeprTransaction $txn) {
58 58
 		parent::__construct();
59 59
 
60 60
 		$this->txn       = $txn;
61 61
 		$this->member    = $this->txn->user();
62
-		$this->recurring = ( $txn->subscription() && $txn->subscription()->txn_count > 1 );
62
+		$this->recurring = ($txn->subscription() && $txn->subscription()->txn_count > 1);
63 63
 	}
64 64
 
65 65
 	/**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		$items = new Items();
118 118
 
119 119
 		$item = new Item();
120
-		$item->setNumber( $this->get_order_id() );
121
-		$item->setDescription( $this->get_description() );
122
-		$item->setPrice( $this->txn->total );
123
-		$item->setQuantity( 1 );
120
+		$item->setNumber($this->get_order_id());
121
+		$item->setDescription($this->get_description());
122
+		$item->setPrice($this->txn->total);
123
+		$item->setQuantity(1);
124 124
 
125
-		$items->addItem( $item );
125
+		$items->addItem($item);
126 126
 
127 127
 		return $items;
128 128
 	}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string
199 199
 	 */
200 200
 	public function get_address() {
201
-		return $this->member->address( 'one' );
201
+		return $this->member->address('one');
202 202
 	}
203 203
 
204 204
 	/**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function get_city() {
212
-		return $this->member->attr( 'city' );
212
+		return $this->member->attr('city');
213 213
 	}
214 214
 
215 215
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return string
221 221
 	 */
222 222
 	public function get_zip() {
223
-		return $this->member->attr( 'zip' );
223
+		return $this->member->attr('zip');
224 224
 	}
225 225
 
226 226
 	/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		$mepr_options = MeprOptions::fetch();
235 235
 
236 236
 		// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782
237
-		return $mepr_options->thankyou_page_url( 'trans_num=' . $this->txn->id );
237
+		return $mepr_options->thankyou_page_url('trans_num=' . $this->txn->id);
238 238
 	}
239 239
 
240 240
 	/**
@@ -274,36 +274,36 @@  discard block
 block discarded – undo
274 274
 	public function get_subscription() {
275 275
 		$product = $this->txn->product();
276 276
 
277
-		if ( $product->is_one_time_payment() ) {
277
+		if ($product->is_one_time_payment()) {
278 278
 			return false;
279 279
 		}
280 280
 
281 281
 		$mp_subscription = $this->txn->subscription();
282 282
 
283
-		if ( ! $mp_subscription ) {
283
+		if ( ! $mp_subscription) {
284 284
 			return false;
285 285
 		}
286 286
 
287 287
 		$frequency = '';
288 288
 
289
-		if ( $mp_subscription->limit_cycles ) {
289
+		if ($mp_subscription->limit_cycles) {
290 290
 			$frequency = $mp_subscription->limit_cycles;
291 291
 		}
292 292
 
293 293
 		$subscription                  = new Subscription();
294 294
 		$subscription->frequency       = $frequency;
295 295
 		$subscription->interval        = $product->period;
296
-		$subscription->interval_period = Core_Util::to_period( $product->period_type );
296
+		$subscription->interval_period = Core_Util::to_period($product->period_type);
297 297
 		$subscription->description     = sprintf(
298 298
 			'Order #%s - %s',
299 299
 			$this->get_source_id(),
300 300
 			$this->get_description()
301 301
 		);
302 302
 
303
-		$subscription->set_amount( new Money(
303
+		$subscription->set_amount(new Money(
304 304
 			$this->txn->total,
305 305
 			$this->get_currency_alphabetic_code()
306
-		) );
306
+		));
307 307
 
308 308
 		return $subscription;
309 309
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	public function get_subscription_source_id() {
318 318
 		$subscription = $this->get_subscription();
319 319
 
320
-		if ( ! $subscription ) {
320
+		if ( ! $subscription) {
321 321
 			return false;
322 322
 		}
323 323
 
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// Set the name of this gateway.
57 57
 		// @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13.
58
-		$this->name = __( 'Pronamic', 'pronamic_ideal' );
58
+		$this->name = __('Pronamic', 'pronamic_ideal');
59 59
 
60
-		if ( ! empty( $this->payment_method ) ) {
61
-			$this->name = PaymentMethods::get_name( $this->payment_method );
60
+		if ( ! empty($this->payment_method)) {
61
+			$this->name = PaymentMethods::get_name($this->payment_method);
62 62
 		}
63 63
 
64 64
 		// Set the default settings.
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $settings MemberPress gateway settings array.
82 82
 	 */
83
-	public function load( $settings ) {
83
+	public function load($settings) {
84 84
 		$this->settings = (object) $settings;
85 85
 
86 86
 		$this->set_defaults();
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return mixed
99 99
 	 */
100
-	public function send_transaction_notices( $transaction, $method ) {
100
+	public function send_transaction_notices($transaction, $method) {
101 101
 		$class = 'MeprUtils';
102 102
 
103
-		if ( ! Core_Util::class_method_exists( $class, $method ) ) {
103
+		if ( ! Core_Util::class_method_exists($class, $method)) {
104 104
 			$class = $this;
105 105
 		}
106 106
 
107
-		if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) {
107
+		if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) {
108 108
 			// `send_product_welcome_notices` is called from `send_signup_notices` in newer versions.
109 109
 			return;
110 110
 		}
111 111
 
112
-		return call_user_func( array( $class, $method ), $transaction );
112
+		return call_user_func(array($class, $method), $transaction);
113 113
 	}
114 114
 
115 115
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73
138 138
 	 */
139 139
 	protected function set_defaults() {
140
-		if ( ! isset( $this->settings ) ) {
140
+		if ( ! isset($this->settings)) {
141 141
 			$this->settings = array();
142 142
 		}
143 143
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122
177 177
 	 */
178
-	public function process_payment( $txn ) {
178
+	public function process_payment($txn) {
179 179
 
180 180
 	}
181 181
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$subscription = $transaction->subscription();
194 194
 
195
-		if ( $subscription ) {
196
-			if ( MeprSubscription::$active_str !== $subscription->status ) {
195
+		if ($subscription) {
196
+			if (MeprSubscription::$active_str !== $subscription->status) {
197 197
 				$subscription->status = MeprSubscription::$active_str;
198 198
 				$subscription->store();
199 199
 			}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$subscription->limit_payment_cycles();
202 202
 		}
203 203
 
204
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
204
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
205 205
 
206 206
 		return $transaction;
207 207
 	}
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 		// Expire associated transactions for subscription.
222 222
 		$subscription = $transaction->subscription();
223 223
 
224
-		if ( $subscription ) {
224
+		if ($subscription) {
225 225
 			$subscription->expire_txns();
226 226
 			$subscription->store();
227 227
 		}
228 228
 
229
-		$this->send_transaction_notices( $transaction, 'send_failed_txn_notices' );
229
+		$this->send_transaction_notices($transaction, 'send_failed_txn_notices');
230 230
 
231 231
 		return $transaction;
232 232
 	}
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
 
251 251
 		$subscription = $transaction->subscription();
252 252
 
253
-		if ( $subscription ) {
253
+		if ($subscription) {
254 254
 			$subscription->status     = MeprSubscription::$active_str;
255 255
 			$subscription->created_at = $transaction->created_at;
256 256
 			$subscription->store();
257 257
 
258 258
 			// Set subscription first transaction id meta.
259
-			$pronamic_subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription->first_txn_id );
259
+			$pronamic_subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription->first_txn_id);
260 260
 
261
-			if ( $pronamic_subscription ) {
261
+			if ($pronamic_subscription) {
262 262
 				// Store MemberPress subscription id to be able to cancel subscription on delete.
263
-				$pronamic_subscription->set_meta( 'memberpress_subscription_id', $subscription->id );
263
+				$pronamic_subscription->set_meta('memberpress_subscription_id', $subscription->id);
264 264
 			}
265 265
 		}
266 266
 
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 		 * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619
273 273
 		 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51
274 274
 		 */
275
-		$reflection = new ReflectionClass( 'MeprBaseRealGateway' );
275
+		$reflection = new ReflectionClass('MeprBaseRealGateway');
276 276
 
277
-		if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) {
277
+		if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) {
278 278
 			$uemail = MeprEmailFactory::fetch(
279 279
 				'MeprUserProductWelcomeEmail',
280 280
 				'MeprBaseProductEmail',
@@ -287,24 +287,24 @@  discard block
 block discarded – undo
287 287
 
288 288
 			$this->send_product_welcome_notices(
289 289
 				$uemail,
290
-				MeprTransactionsHelper::get_email_params( $transaction ),
290
+				MeprTransactionsHelper::get_email_params($transaction),
291 291
 				$transaction->user()
292 292
 			);
293 293
 		} else {
294
-			$this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); /** @scrutinizer ignore-call */
294
+			$this->send_transaction_notices($transaction, 'send_product_welcome_notices'); /** @scrutinizer ignore-call */
295 295
 		}
296 296
 
297 297
 		// Send upgrade/downgrade notices.
298
-		if ( $upgrade ) {
299
-			$this->upgraded_sub( $transaction );
300
-			$this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' );
301
-		} elseif ( $downgrade ) {
302
-			$this->downgraded_sub( $transaction );
303
-			$this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' );
298
+		if ($upgrade) {
299
+			$this->upgraded_sub($transaction);
300
+			$this->send_transaction_notices($transaction, 'send_upgraded_txn_notices');
301
+		} elseif ($downgrade) {
302
+			$this->downgraded_sub($transaction);
303
+			$this->send_transaction_notices($transaction, 'send_downgraded_txn_notices');
304 304
 		}
305 305
 
306
-		$this->send_transaction_notices( $transaction, 'send_signup_notices' );
307
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
306
+		$this->send_transaction_notices($transaction, 'send_signup_notices');
307
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
308 308
 
309 309
 		return $transaction;
310 310
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133
318 318
 	 */
319
-	public function process_refund( MeprTransaction $txn ) {
319
+	public function process_refund(MeprTransaction $txn) {
320 320
 
321 321
 	}
322 322
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @param MeprTransaction $transaction MemberPress transaction object.
338 338
 	 */
339
-	public function process_trial_payment( $transaction ) {
339
+	public function process_trial_payment($transaction) {
340 340
 
341 341
 	}
342 342
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @param MeprTransaction $transaction MemberPress transaction object.
349 349
 	 */
350
-	public function record_trial_payment( $transaction ) {
350
+	public function record_trial_payment($transaction) {
351 351
 
352 352
 	}
353 353
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @param MeprTransaction $txn MemberPress transaction object.
360 360
 	 */
361
-	public function process_create_subscription( $txn ) {
361
+	public function process_create_subscription($txn) {
362 362
 
363 363
 	}
364 364
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 *
380 380
 	 * @param int $sub_id Subscription ID.
381 381
 	 */
382
-	public function process_update_subscription( $sub_id ) {
382
+	public function process_update_subscription($sub_id) {
383 383
 
384 384
 	}
385 385
 
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186
401 401
 	 */
402
-	public function process_suspend_subscription( $sub_id ) {
403
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
402
+	public function process_suspend_subscription($sub_id) {
403
+		if ( ! MeprSubscription::exists($sub_id)) {
404 404
 			return;
405 405
 		}
406 406
 
407
-		$sub = new MeprSubscription( $sub_id );
407
+		$sub = new MeprSubscription($sub_id);
408 408
 
409
-		if ( MeprSubscription::$suspended_str === $sub->status ) {
409
+		if (MeprSubscription::$suspended_str === $sub->status) {
410 410
 			// Subscription is already suspended.
411 411
 			return;
412 412
 		}
413 413
 
414
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
414
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
415 415
 
416
-		if ( ! $subscription ) {
416
+		if ( ! $subscription) {
417 417
 			return;
418 418
 		}
419 419
 
@@ -422,19 +422,19 @@  discard block
 block discarded – undo
422 422
 		$sub->store();
423 423
 
424 424
 		// Send suspended subscription notices.
425
-		MeprUtils::send_suspended_sub_notices( $sub );
425
+		MeprUtils::send_suspended_sub_notices($sub);
426 426
 
427 427
 		$note = sprintf(
428 428
 			/* translators: %s: MemberPress */
429
-			__( '%s subscription on hold.', 'pronamic_ideal' ),
430
-			__( 'MemberPress', 'pronamic_ideal' )
429
+			__('%s subscription on hold.', 'pronamic_ideal'),
430
+			__('MemberPress', 'pronamic_ideal')
431 431
 		);
432 432
 
433
-		$subscription->add_note( $note );
433
+		$subscription->add_note($note);
434 434
 
435 435
 		// The status of canceled or completed subscriptions will not be changed automatically.
436
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
437
-			$subscription->set_status( Statuses::OPEN );
436
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
437
+			$subscription->set_status(Statuses::OPEN);
438 438
 
439 439
 			$subscription->save();
440 440
 		}
@@ -456,21 +456,21 @@  discard block
 block discarded – undo
456 456
 	 *
457 457
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195
458 458
 	 */
459
-	public function process_resume_subscription( $sub_id ) {
460
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
459
+	public function process_resume_subscription($sub_id) {
460
+		if ( ! MeprSubscription::exists($sub_id)) {
461 461
 			return;
462 462
 		}
463 463
 
464
-		$sub = new MeprSubscription( $sub_id );
464
+		$sub = new MeprSubscription($sub_id);
465 465
 
466
-		if ( MeprSubscription::$active_str === $sub->status ) {
466
+		if (MeprSubscription::$active_str === $sub->status) {
467 467
 			// Subscription is already active.
468 468
 			return;
469 469
 		}
470 470
 
471
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
471
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
472 472
 
473
-		if ( ! $subscription ) {
473
+		if ( ! $subscription) {
474 474
 			return;
475 475
 		}
476 476
 
@@ -481,35 +481,35 @@  discard block
 block discarded – undo
481 481
 		// Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately.
482 482
 		$prior_txn = $sub->latest_txn();
483 483
 
484
-		if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) {
484
+		if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) {
485 485
 			$txn                  = new MeprTransaction();
486 486
 			$txn->subscription_id = $sub->id;
487 487
 			$txn->trans_num       = $sub->subscr_id . '-' . uniqid();
488 488
 			$txn->status          = MeprTransaction::$confirmed_str;
489 489
 			$txn->txn_type        = MeprTransaction::$subscription_confirmation_str;
490 490
 			$txn->response        = (string) $sub;
491
-			$txn->expires_at      = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' );
491
+			$txn->expires_at      = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59');
492 492
 
493
-			$txn->set_subtotal( 0.00 ); // Just a confirmation txn.
493
+			$txn->set_subtotal(0.00); // Just a confirmation txn.
494 494
 
495 495
 			$txn->store();
496 496
 		}
497 497
 
498 498
 		// Send resumed subscription notices.
499
-		MeprUtils::send_resumed_sub_notices( $sub );
499
+		MeprUtils::send_resumed_sub_notices($sub);
500 500
 
501 501
 		// Add note.
502 502
 		$note = sprintf(
503 503
 			/* translators: %s: MemberPress */
504
-			__( '%s subscription reactivated.', 'pronamic_ideal' ),
505
-			__( 'MemberPress', 'pronamic_ideal' )
504
+			__('%s subscription reactivated.', 'pronamic_ideal'),
505
+			__('MemberPress', 'pronamic_ideal')
506 506
 		);
507 507
 
508
-		$subscription->add_note( $note );
508
+		$subscription->add_note($note);
509 509
 
510 510
 		// The status of canceled or completed subscriptions will not be changed automatically.
511
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
512
-			$subscription->set_status( Statuses::ACTIVE );
511
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
512
+			$subscription->set_status(Statuses::ACTIVE);
513 513
 
514 514
 			$subscription->save();
515 515
 		}
@@ -531,21 +531,21 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206
533 533
 	 */
534
-	public function process_cancel_subscription( $sub_id ) {
535
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
534
+	public function process_cancel_subscription($sub_id) {
535
+		if ( ! MeprSubscription::exists($sub_id)) {
536 536
 			return;
537 537
 		}
538 538
 
539
-		$sub = new MeprSubscription( $sub_id );
539
+		$sub = new MeprSubscription($sub_id);
540 540
 
541
-		if ( MeprSubscription::$cancelled_str === $sub->status ) {
541
+		if (MeprSubscription::$cancelled_str === $sub->status) {
542 542
 			// Subscription is already cancelled.
543 543
 			return;
544 544
 		}
545 545
 
546
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
546
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
547 547
 
548
-		if ( ! $subscription ) {
548
+		if ( ! $subscription) {
549 549
 			return;
550 550
 		}
551 551
 
@@ -554,27 +554,27 @@  discard block
 block discarded – undo
554 554
 		$sub->store();
555 555
 
556 556
 		// Expire the grace period (confirmation) if no completed payments have come through.
557
-		if ( (int) $sub->txn_count <= 0 ) {
557
+		if ((int) $sub->txn_count <= 0) {
558 558
 			$sub->expire_txns();
559 559
 		}
560 560
 
561 561
 		$sub->limit_reached_actions();
562 562
 
563 563
 		// Send cancelled subscription notices.
564
-		MeprUtils::send_cancelled_sub_notices( $sub );
564
+		MeprUtils::send_cancelled_sub_notices($sub);
565 565
 
566 566
 		// Add note.
567 567
 		$note = sprintf(
568 568
 			/* translators: %s: MemberPress */
569
-			__( '%s subscription cancelled.', 'pronamic_ideal' ),
570
-			__( 'MemberPress', 'pronamic_ideal' )
569
+			__('%s subscription cancelled.', 'pronamic_ideal'),
570
+			__('MemberPress', 'pronamic_ideal')
571 571
 		);
572 572
 
573
-		$subscription->add_note( $note );
573
+		$subscription->add_note($note);
574 574
 
575 575
 		// The status of canceled or completed subscriptions will not be changed automatically.
576
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
577
-			$subscription->set_status( Statuses::CANCELLED );
576
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
577
+			$subscription->set_status(Statuses::CANCELLED);
578 578
 
579 579
 			$subscription->save();
580 580
 		}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 * @param MeprTransaction $txn MemberPress transaction object.
603 603
 	 */
604
-	public function process_signup_form( $txn ) {
604
+	public function process_signup_form($txn) {
605 605
 
606 606
 	}
607 607
 
@@ -612,28 +612,28 @@  discard block
 block discarded – undo
612 612
 	 *
613 613
 	 * @param MeprTransaction $txn MemberPress transaction object.
614 614
 	 */
615
-	public function payment_redirect( $txn ) {
616
-		$txn = new MeprTransaction( $txn->id );
615
+	public function payment_redirect($txn) {
616
+		$txn = new MeprTransaction($txn->id);
617 617
 
618 618
 		// Gateway.
619 619
 		$config_id = $this->settings->config_id;
620 620
 
621
-		$gateway = Plugin::get_gateway( $config_id );
621
+		$gateway = Plugin::get_gateway($config_id);
622 622
 
623
-		if ( ! $gateway ) {
623
+		if ( ! $gateway) {
624 624
 			return;
625 625
 		}
626 626
 
627 627
 		// Data.
628
-		$data = new PaymentData( $txn );
628
+		$data = new PaymentData($txn);
629 629
 
630
-		$payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method );
630
+		$payment = Plugin::start($config_id, $gateway, $data, $this->payment_method);
631 631
 
632 632
 		$error = $gateway->get_error();
633 633
 
634
-		if ( ! is_wp_error( $error ) ) {
634
+		if ( ! is_wp_error($error)) {
635 635
 			// Redirect.
636
-			$gateway->redirect( $payment );
636
+			$gateway->redirect($payment);
637 637
 		}
638 638
 	}
639 639
 
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
 	 *
647 647
 	 * @param MeprTransaction $txn MemberPress transaction object.
648 648
 	 */
649
-	public function display_payment_page( $txn ) {
649
+	public function display_payment_page($txn) {
650 650
 		// Gateway.
651 651
 		$config_id = $this->settings->config_id;
652 652
 
653
-		$gateway = Plugin::get_gateway( $config_id );
653
+		$gateway = Plugin::get_gateway($config_id);
654 654
 
655
-		if ( $gateway && '' === $gateway->get_input_html() ) {
656
-			$this->payment_redirect( $txn );
655
+		if ($gateway && '' === $gateway->get_input_html()) {
656
+			$this->payment_redirect($txn);
657 657
 		}
658 658
 	}
659 659
 
@@ -667,18 +667,18 @@  discard block
 block discarded – undo
667 667
 	 * @param  MeprTransaction $txn MemberPress transaction object.
668 668
 	 * @return bool
669 669
 	 */
670
-	public function process_payment_form( $txn ) {
671
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) {
670
+	public function process_payment_form($txn) {
671
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) {
672 672
 			return false;
673 673
 		}
674 674
 
675 675
 		// Gateway.
676 676
 		$config_id = $this->settings->config_id;
677 677
 
678
-		$gateway = Plugin::get_gateway( $config_id );
678
+		$gateway = Plugin::get_gateway($config_id);
679 679
 
680
-		if ( $gateway ) {
681
-			$this->payment_redirect( $txn );
680
+		if ($gateway) {
681
+			$this->payment_redirect($txn);
682 682
 		}
683 683
 	}
684 684
 
@@ -706,20 +706,20 @@  discard block
 block discarded – undo
706 706
 	 * @param int      $product_id Product ID.
707 707
 	 * @param int      $txn_id     Transaction ID.
708 708
 	 */
709
-	public function display_payment_form( $amount, $user, $product_id, $txn_id ) {
710
-		$product = new MeprProduct( $product_id );
709
+	public function display_payment_form($amount, $user, $product_id, $txn_id) {
710
+		$product = new MeprProduct($product_id);
711 711
 
712 712
 		$coupon = false;
713 713
 
714
-		$txn = new MeprTransaction( $txn_id );
714
+		$txn = new MeprTransaction($txn_id);
715 715
 
716 716
 		// Artifically set the price of the $prd in case a coupon was used.
717
-		if ( $product->price !== $amount ) {
717
+		if ($product->price !== $amount) {
718 718
 			$coupon         = true;
719 719
 			$product->price = $amount;
720 720
 		}
721 721
 
722
-		$invoice = MeprTransactionsHelper::get_invoice( $txn );
722
+		$invoice = MeprTransactionsHelper::get_invoice($txn);
723 723
 
724 724
 		echo $invoice; // WPCS: XSS ok.
725 725
 
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 		<div class="mp_wrapper mp_payment_form_wrapper">
728 728
 			<form action="" method="post" id="payment-form" class="mepr-form" novalidate>
729 729
 				<input type="hidden" name="mepr_process_payment_form" value="Y"/>
730
-				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/>
730
+				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/>
731 731
 				<input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/>
732 732
 
733 733
 				<div class="mepr_spacer">&nbsp;</div>
@@ -737,9 +737,9 @@  discard block
 block discarded – undo
737 737
 				// Gateway.
738 738
 				$config_id = $this->settings->config_id;
739 739
 
740
-				$gateway = Plugin::get_gateway( $config_id );
740
+				$gateway = Plugin::get_gateway($config_id);
741 741
 
742
-				if ( $gateway ) {
742
+				if ($gateway) {
743 743
 					echo $gateway->get_input_html(); // WPCS: XSS ok.
744 744
 				}
745 745
 
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
 
748 748
 				<div class="mepr_spacer">&nbsp;</div>
749 749
 
750
-				<input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/>
751
-				<img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/>
752
-				<?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?>
750
+				<input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/>
751
+				<img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/>
752
+				<?php MeprView::render('/shared/has_errors', get_defined_vars()); ?>
753 753
 
754 754
 				<noscript>
755 755
 					<p class="mepr_nojs">
756
-						<?php esc_html_e( 'JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal' ); ?>
756
+						<?php esc_html_e('JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal'); ?>
757 757
 					</p>
758 758
 				</noscript>
759 759
 			</form>
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	 * @param array $errors Array with errors.
772 772
 	 * @return array
773 773
 	 */
774
-	public function validate_payment_form( $errors ) {
774
+	public function validate_payment_form($errors) {
775 775
 		return $errors;
776 776
 	}
777 777
 
@@ -798,18 +798,18 @@  discard block
 block discarded – undo
798 798
 
799 799
 				?>
800 800
 				<td>
801
-					<?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?>
801
+					<?php esc_html_e('Configuration', 'pronamic_ideal'); ?>
802 802
 				</td>
803 803
 				<td>
804
-					<select name="<?php echo esc_attr( $name ); ?>">
804
+					<select name="<?php echo esc_attr($name); ?>">
805 805
 						<?php
806 806
 
807
-						foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) {
807
+						foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) {
808 808
 							printf(
809 809
 								'<option value="%s" %s>%s</option>',
810
-								esc_attr( $value ),
811
-								selected( $value, $this->settings->config_id, false ),
812
-								esc_html( $label )
810
+								esc_attr($value),
811
+								selected($value, $this->settings->config_id, false),
812
+								esc_html($label)
813 813
 							);
814 814
 						}
815 815
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 	 * @param array $errors Array with errors.
832 832
 	 * @return array
833 833
 	 */
834
-	public function validate_options_form( $errors ) {
834
+	public function validate_options_form($errors) {
835 835
 		return $errors;
836 836
 	}
837 837
 
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 	 * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168
857 857
 	 * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388
858 858
 	 */
859
-	public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) {
859
+	public function display_update_account_form($sub_id, $errors = array(), $message = '') {
860 860
 
861 861
 	}
862 862
 
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 	 * @param  array $errors Array with errors.
870 870
 	 * @return array
871 871
 	 */
872
-	public function validate_update_account_form( $errors = array() ) {
872
+	public function validate_update_account_form($errors = array()) {
873 873
 		return $errors;
874 874
 	}
875 875
 
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 *
882 882
 	 * @param int $sub_id Subscription ID.
883 883
 	 */
884
-	public function process_update_account_form( $sub_id ) {
884
+	public function process_update_account_form($sub_id) {
885 885
 
886 886
 	}
887 887
 
Please login to merge, or discard this patch.