@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | // Set the name of this gateway. |
| 58 | 58 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13. |
| 59 | - $this->name = __( 'Pronamic', 'pronamic_ideal' ); |
|
| 59 | + $this->name = __('Pronamic', 'pronamic_ideal'); |
|
| 60 | 60 | |
| 61 | - if ( ! empty( $this->payment_method ) ) { |
|
| 62 | - $this->name = PaymentMethods::get_name( $this->payment_method ); |
|
| 61 | + if ( ! empty($this->payment_method)) { |
|
| 62 | + $this->name = PaymentMethods::get_name($this->payment_method); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Set the default settings. |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @param array $settings MemberPress gateway settings array. |
| 83 | 83 | */ |
| 84 | - public function load( $settings ) { |
|
| 84 | + public function load($settings) { |
|
| 85 | 85 | $this->settings = (object) $settings; |
| 86 | 86 | |
| 87 | 87 | $this->set_defaults(); |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return mixed |
| 100 | 100 | */ |
| 101 | - public function send_transaction_notices( $transaction, $method ) { |
|
| 101 | + public function send_transaction_notices($transaction, $method) { |
|
| 102 | 102 | $class = 'MeprUtils'; |
| 103 | 103 | |
| 104 | - if ( ! Core_Util::class_method_exists( $class, $method ) ) { |
|
| 104 | + if ( ! Core_Util::class_method_exists($class, $method)) { |
|
| 105 | 105 | $class = $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) { |
|
| 108 | + if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) { |
|
| 109 | 109 | // `send_product_welcome_notices` is called from `send_signup_notices` in newer versions. |
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return call_user_func( array( $class, $method ), $transaction ); |
|
| 113 | + return call_user_func(array($class, $method), $transaction); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73 |
| 139 | 139 | */ |
| 140 | 140 | protected function set_defaults() { |
| 141 | - if ( ! isset( $this->settings ) ) { |
|
| 141 | + if ( ! isset($this->settings)) { |
|
| 142 | 142 | $this->settings = array(); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122 |
| 178 | 178 | */ |
| 179 | - public function process_payment( $txn ) { |
|
| 179 | + public function process_payment($txn) { |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | $subscription = $transaction->subscription(); |
| 197 | 197 | |
| 198 | - if ( $subscription ) { |
|
| 199 | - if ( MeprSubscription::$active_str !== $subscription->status ) { |
|
| 198 | + if ($subscription) { |
|
| 199 | + if (MeprSubscription::$active_str !== $subscription->status) { |
|
| 200 | 200 | $subscription->status = MeprSubscription::$active_str; |
| 201 | 201 | $subscription->store(); |
| 202 | 202 | } |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | // Expire subscription confirmations. |
| 205 | 205 | $mepr_db = new MeprDb(); |
| 206 | 206 | |
| 207 | - $wpdb->query( $wpdb->prepare( |
|
| 207 | + $wpdb->query($wpdb->prepare( |
|
| 208 | 208 | "UPDATE $mepr_db->transactions SET expires_at = created_at WHERE subscription_id = %d AND txn_type = %s", |
| 209 | 209 | $subscription->id, |
| 210 | 210 | MeprTransaction::$subscription_confirmation_str |
| 211 | - ) ); |
|
| 211 | + )); |
|
| 212 | 212 | |
| 213 | 213 | $subscription->limit_payment_cycles(); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 216 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 217 | 217 | |
| 218 | 218 | return $transaction; |
| 219 | 219 | } |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | // Expire associated transactions for subscription. |
| 234 | 234 | $subscription = $transaction->subscription(); |
| 235 | 235 | |
| 236 | - if ( $subscription ) { |
|
| 236 | + if ($subscription) { |
|
| 237 | 237 | $subscription->expire_txns(); |
| 238 | 238 | $subscription->store(); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $this->send_transaction_notices( $transaction, 'send_failed_txn_notices' ); |
|
| 241 | + $this->send_transaction_notices($transaction, 'send_failed_txn_notices'); |
|
| 242 | 242 | |
| 243 | 243 | return $transaction; |
| 244 | 244 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $subscription = $transaction->subscription(); |
| 264 | 264 | |
| 265 | - if ( $subscription ) { |
|
| 265 | + if ($subscription) { |
|
| 266 | 266 | $subscription->status = MeprSubscription::$active_str; |
| 267 | 267 | $subscription->created_at = $transaction->created_at; |
| 268 | 268 | $subscription->store(); |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619 |
| 277 | 277 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51 |
| 278 | 278 | */ |
| 279 | - $reflection = new ReflectionClass( 'MeprBaseRealGateway' ); |
|
| 279 | + $reflection = new ReflectionClass('MeprBaseRealGateway'); |
|
| 280 | 280 | |
| 281 | - if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) { |
|
| 281 | + if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) { |
|
| 282 | 282 | $uemail = MeprEmailFactory::fetch( |
| 283 | 283 | 'MeprUserProductWelcomeEmail', |
| 284 | 284 | 'MeprBaseProductEmail', |
@@ -296,24 +296,24 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | $this->send_product_welcome_notices( |
| 298 | 298 | $uemail, |
| 299 | - MeprTransactionsHelper::get_email_params( $transaction ), |
|
| 299 | + MeprTransactionsHelper::get_email_params($transaction), |
|
| 300 | 300 | $transaction->user() |
| 301 | 301 | ); |
| 302 | 302 | } else { |
| 303 | - $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); |
|
| 303 | + $this->send_transaction_notices($transaction, 'send_product_welcome_notices'); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Send upgrade/downgrade notices. |
| 307 | - if ( $upgrade ) { |
|
| 308 | - $this->upgraded_sub( $transaction ); |
|
| 309 | - $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); |
|
| 310 | - } elseif ( $downgrade ) { |
|
| 311 | - $this->downgraded_sub( $transaction ); |
|
| 312 | - $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); |
|
| 307 | + if ($upgrade) { |
|
| 308 | + $this->upgraded_sub($transaction); |
|
| 309 | + $this->send_transaction_notices($transaction, 'send_upgraded_txn_notices'); |
|
| 310 | + } elseif ($downgrade) { |
|
| 311 | + $this->downgraded_sub($transaction); |
|
| 312 | + $this->send_transaction_notices($transaction, 'send_downgraded_txn_notices'); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $this->send_transaction_notices( $transaction, 'send_signup_notices' ); |
|
| 316 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 315 | + $this->send_transaction_notices($transaction, 'send_signup_notices'); |
|
| 316 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 317 | 317 | |
| 318 | 318 | return $transaction; |
| 319 | 319 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 |
| 327 | 327 | */ |
| 328 | - public function process_refund( MeprTransaction $txn ) { |
|
| 328 | + public function process_refund(MeprTransaction $txn) { |
|
| 329 | 329 | |
| 330 | 330 | } |
| 331 | 331 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 347 | 347 | */ |
| 348 | - public function process_trial_payment( $transaction ) { |
|
| 348 | + public function process_trial_payment($transaction) { |
|
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 358 | 358 | */ |
| 359 | - public function record_trial_payment( $transaction ) { |
|
| 359 | + public function record_trial_payment($transaction) { |
|
| 360 | 360 | |
| 361 | 361 | } |
| 362 | 362 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * |
| 368 | 368 | * @param MeprTransaction $txn MemberPress transaction object. |
| 369 | 369 | */ |
| 370 | - public function process_create_subscription( $txn ) { |
|
| 370 | + public function process_create_subscription($txn) { |
|
| 371 | 371 | |
| 372 | 372 | } |
| 373 | 373 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @param int $sub_id Subscription ID. |
| 390 | 390 | */ |
| 391 | - public function process_update_subscription( $sub_id ) { |
|
| 391 | + public function process_update_subscription($sub_id) { |
|
| 392 | 392 | |
| 393 | 393 | } |
| 394 | 394 | |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 |
| 410 | 410 | */ |
| 411 | - public function process_suspend_subscription( $sub_id ) { |
|
| 412 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 411 | + public function process_suspend_subscription($sub_id) { |
|
| 412 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 413 | 413 | return; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - $sub = new MeprSubscription( $sub_id ); |
|
| 416 | + $sub = new MeprSubscription($sub_id); |
|
| 417 | 417 | |
| 418 | - if ( MeprSubscription::$suspended_str === $sub->status ) { |
|
| 418 | + if (MeprSubscription::$suspended_str === $sub->status) { |
|
| 419 | 419 | // Subscription is already suspended. |
| 420 | 420 | return; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 423 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 424 | 424 | |
| 425 | - if ( ! $subscription ) { |
|
| 425 | + if ( ! $subscription) { |
|
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -431,19 +431,19 @@ discard block |
||
| 431 | 431 | $sub->store(); |
| 432 | 432 | |
| 433 | 433 | // Send suspended subscription notices. |
| 434 | - MeprUtils::send_suspended_sub_notices( $sub ); |
|
| 434 | + MeprUtils::send_suspended_sub_notices($sub); |
|
| 435 | 435 | |
| 436 | 436 | $note = sprintf( |
| 437 | 437 | /* translators: %s: MemberPress */ |
| 438 | - __( '%s subscription on hold.', 'pronamic_ideal' ), |
|
| 439 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 438 | + __('%s subscription on hold.', 'pronamic_ideal'), |
|
| 439 | + __('MemberPress', 'pronamic_ideal') |
|
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | - $subscription->add_note( $note ); |
|
| 442 | + $subscription->add_note($note); |
|
| 443 | 443 | |
| 444 | 444 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 445 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 446 | - $subscription->set_status( Statuses::OPEN ); |
|
| 445 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 446 | + $subscription->set_status(Statuses::OPEN); |
|
| 447 | 447 | |
| 448 | 448 | $subscription->save(); |
| 449 | 449 | } |
@@ -465,21 +465,21 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 |
| 467 | 467 | */ |
| 468 | - public function process_resume_subscription( $sub_id ) { |
|
| 469 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 468 | + public function process_resume_subscription($sub_id) { |
|
| 469 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 470 | 470 | return; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $sub = new MeprSubscription( $sub_id ); |
|
| 473 | + $sub = new MeprSubscription($sub_id); |
|
| 474 | 474 | |
| 475 | - if ( MeprSubscription::$active_str === $sub->status ) { |
|
| 475 | + if (MeprSubscription::$active_str === $sub->status) { |
|
| 476 | 476 | // Subscription is already active. |
| 477 | 477 | return; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 480 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 481 | 481 | |
| 482 | - if ( ! $subscription ) { |
|
| 482 | + if ( ! $subscription) { |
|
| 483 | 483 | return; |
| 484 | 484 | } |
| 485 | 485 | |
@@ -490,35 +490,35 @@ discard block |
||
| 490 | 490 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. |
| 491 | 491 | $prior_txn = $sub->latest_txn(); |
| 492 | 492 | |
| 493 | - if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { |
|
| 493 | + if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) { |
|
| 494 | 494 | $txn = new MeprTransaction(); |
| 495 | 495 | $txn->subscription_id = $sub->id; |
| 496 | 496 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); |
| 497 | 497 | $txn->status = MeprTransaction::$confirmed_str; |
| 498 | 498 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 499 | 499 | $txn->response = (string) $sub; |
| 500 | - $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); |
|
| 500 | + $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59'); |
|
| 501 | 501 | |
| 502 | - $txn->set_subtotal( 0.00 ); // Just a confirmation txn. |
|
| 502 | + $txn->set_subtotal(0.00); // Just a confirmation txn. |
|
| 503 | 503 | |
| 504 | 504 | $txn->store(); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | // Send resumed subscription notices. |
| 508 | - MeprUtils::send_resumed_sub_notices( $sub ); |
|
| 508 | + MeprUtils::send_resumed_sub_notices($sub); |
|
| 509 | 509 | |
| 510 | 510 | // Add note. |
| 511 | 511 | $note = sprintf( |
| 512 | 512 | /* translators: %s: MemberPress */ |
| 513 | - __( '%s subscription reactivated.', 'pronamic_ideal' ), |
|
| 514 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 513 | + __('%s subscription reactivated.', 'pronamic_ideal'), |
|
| 514 | + __('MemberPress', 'pronamic_ideal') |
|
| 515 | 515 | ); |
| 516 | 516 | |
| 517 | - $subscription->add_note( $note ); |
|
| 517 | + $subscription->add_note($note); |
|
| 518 | 518 | |
| 519 | 519 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 520 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 521 | - $subscription->set_status( Statuses::ACTIVE ); |
|
| 520 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 521 | + $subscription->set_status(Statuses::ACTIVE); |
|
| 522 | 522 | |
| 523 | 523 | $subscription->save(); |
| 524 | 524 | } |
@@ -540,21 +540,21 @@ discard block |
||
| 540 | 540 | * |
| 541 | 541 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 |
| 542 | 542 | */ |
| 543 | - public function process_cancel_subscription( $sub_id ) { |
|
| 544 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 543 | + public function process_cancel_subscription($sub_id) { |
|
| 544 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 545 | 545 | return; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $sub = new MeprSubscription( $sub_id ); |
|
| 548 | + $sub = new MeprSubscription($sub_id); |
|
| 549 | 549 | |
| 550 | - if ( MeprSubscription::$cancelled_str === $sub->status ) { |
|
| 550 | + if (MeprSubscription::$cancelled_str === $sub->status) { |
|
| 551 | 551 | // Subscription is already cancelled. |
| 552 | 552 | return; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 555 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 556 | 556 | |
| 557 | - if ( ! $subscription ) { |
|
| 557 | + if ( ! $subscription) { |
|
| 558 | 558 | return; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -563,27 +563,27 @@ discard block |
||
| 563 | 563 | $sub->store(); |
| 564 | 564 | |
| 565 | 565 | // Expire the grace period (confirmation) if no completed payments have come through. |
| 566 | - if ( (int) $sub->txn_count <= 0 ) { |
|
| 566 | + if ((int) $sub->txn_count <= 0) { |
|
| 567 | 567 | $sub->expire_txns(); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | $sub->limit_reached_actions(); |
| 571 | 571 | |
| 572 | 572 | // Send cancelled subscription notices. |
| 573 | - MeprUtils::send_cancelled_sub_notices( $sub ); |
|
| 573 | + MeprUtils::send_cancelled_sub_notices($sub); |
|
| 574 | 574 | |
| 575 | 575 | // Add note. |
| 576 | 576 | $note = sprintf( |
| 577 | 577 | /* translators: %s: MemberPress */ |
| 578 | - __( '%s subscription cancelled.', 'pronamic_ideal' ), |
|
| 579 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 578 | + __('%s subscription cancelled.', 'pronamic_ideal'), |
|
| 579 | + __('MemberPress', 'pronamic_ideal') |
|
| 580 | 580 | ); |
| 581 | 581 | |
| 582 | - $subscription->add_note( $note ); |
|
| 582 | + $subscription->add_note($note); |
|
| 583 | 583 | |
| 584 | 584 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 585 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 586 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 585 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 586 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 587 | 587 | |
| 588 | 588 | $subscription->save(); |
| 589 | 589 | } |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @param MeprTransaction $txn MemberPress transaction object. |
| 612 | 612 | */ |
| 613 | - public function process_signup_form( $txn ) { |
|
| 613 | + public function process_signup_form($txn) { |
|
| 614 | 614 | |
| 615 | 615 | } |
| 616 | 616 | |
@@ -621,28 +621,28 @@ discard block |
||
| 621 | 621 | * |
| 622 | 622 | * @param MeprTransaction $txn MemberPress transaction object. |
| 623 | 623 | */ |
| 624 | - public function payment_redirect( $txn ) { |
|
| 625 | - $txn = new MeprTransaction( $txn->id ); |
|
| 624 | + public function payment_redirect($txn) { |
|
| 625 | + $txn = new MeprTransaction($txn->id); |
|
| 626 | 626 | |
| 627 | 627 | // Gateway. |
| 628 | 628 | $config_id = $this->settings->config_id; |
| 629 | 629 | |
| 630 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 630 | + $gateway = Plugin::get_gateway($config_id); |
|
| 631 | 631 | |
| 632 | - if ( ! $gateway ) { |
|
| 632 | + if ( ! $gateway) { |
|
| 633 | 633 | return; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // Data. |
| 637 | - $data = new PaymentData( $txn, $this ); |
|
| 637 | + $data = new PaymentData($txn, $this); |
|
| 638 | 638 | |
| 639 | - $payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method ); |
|
| 639 | + $payment = Plugin::start($config_id, $gateway, $data, $this->payment_method); |
|
| 640 | 640 | |
| 641 | 641 | $error = $gateway->get_error(); |
| 642 | 642 | |
| 643 | - if ( ! is_wp_error( $error ) ) { |
|
| 643 | + if ( ! is_wp_error($error)) { |
|
| 644 | 644 | // Redirect. |
| 645 | - $gateway->redirect( $payment ); |
|
| 645 | + $gateway->redirect($payment); |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
@@ -655,14 +655,14 @@ discard block |
||
| 655 | 655 | * |
| 656 | 656 | * @param MeprTransaction $txn MemberPress transaction object. |
| 657 | 657 | */ |
| 658 | - public function display_payment_page( $txn ) { |
|
| 658 | + public function display_payment_page($txn) { |
|
| 659 | 659 | // Gateway. |
| 660 | 660 | $config_id = $this->settings->config_id; |
| 661 | 661 | |
| 662 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 662 | + $gateway = Plugin::get_gateway($config_id); |
|
| 663 | 663 | |
| 664 | - if ( $gateway && '' === $gateway->get_input_html() ) { |
|
| 665 | - $this->payment_redirect( $txn ); |
|
| 664 | + if ($gateway && '' === $gateway->get_input_html()) { |
|
| 665 | + $this->payment_redirect($txn); |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | * @param MeprTransaction $txn MemberPress transaction object. |
| 677 | 677 | * @return bool |
| 678 | 678 | */ |
| 679 | - public function process_payment_form( $txn ) { |
|
| 680 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
|
| 679 | + public function process_payment_form($txn) { |
|
| 680 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) { |
|
| 681 | 681 | return false; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | // Gateway. |
| 685 | 685 | $config_id = $this->settings->config_id; |
| 686 | 686 | |
| 687 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 687 | + $gateway = Plugin::get_gateway($config_id); |
|
| 688 | 688 | |
| 689 | - if ( $gateway ) { |
|
| 690 | - $this->payment_redirect( $txn ); |
|
| 689 | + if ($gateway) { |
|
| 690 | + $this->payment_redirect($txn); |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
@@ -715,20 +715,20 @@ discard block |
||
| 715 | 715 | * @param int $product_id Product ID. |
| 716 | 716 | * @param int $txn_id Transaction ID. |
| 717 | 717 | */ |
| 718 | - public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
|
| 719 | - $product = new MeprProduct( $product_id ); |
|
| 718 | + public function display_payment_form($amount, $user, $product_id, $txn_id) { |
|
| 719 | + $product = new MeprProduct($product_id); |
|
| 720 | 720 | |
| 721 | 721 | $coupon = false; |
| 722 | 722 | |
| 723 | - $txn = new MeprTransaction( $txn_id ); |
|
| 723 | + $txn = new MeprTransaction($txn_id); |
|
| 724 | 724 | |
| 725 | 725 | // Artifically set the price of the $prd in case a coupon was used. |
| 726 | - if ( $product->price !== $amount ) { |
|
| 726 | + if ($product->price !== $amount) { |
|
| 727 | 727 | $coupon = true; |
| 728 | 728 | $product->price = $amount; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
|
| 731 | + $invoice = MeprTransactionsHelper::get_invoice($txn); |
|
| 732 | 732 | |
| 733 | 733 | echo $invoice; // WPCS: XSS ok. |
| 734 | 734 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | <div class="mp_wrapper mp_payment_form_wrapper"> |
| 737 | 737 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
| 738 | 738 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
| 739 | - <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
|
| 739 | + <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/> |
|
| 740 | 740 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
| 741 | 741 | |
| 742 | 742 | <div class="mepr_spacer"> </div> |
@@ -746,9 +746,9 @@ discard block |
||
| 746 | 746 | // Gateway. |
| 747 | 747 | $config_id = $this->settings->config_id; |
| 748 | 748 | |
| 749 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 749 | + $gateway = Plugin::get_gateway($config_id); |
|
| 750 | 750 | |
| 751 | - if ( $gateway ) { |
|
| 751 | + if ($gateway) { |
|
| 752 | 752 | echo $gateway->get_input_html(); // WPCS: XSS ok. |
| 753 | 753 | } |
| 754 | 754 | |
@@ -756,13 +756,13 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | <div class="mepr_spacer"> </div> |
| 758 | 758 | |
| 759 | - <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
|
| 760 | - <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 761 | - <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
|
| 759 | + <input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/> |
|
| 760 | + <img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 761 | + <?php MeprView::render('/shared/has_errors', get_defined_vars()); ?> |
|
| 762 | 762 | |
| 763 | 763 | <noscript> |
| 764 | 764 | <p class="mepr_nojs"> |
| 765 | - <?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' ); ?> |
|
| 765 | + <?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'); ?> |
|
| 766 | 766 | </p> |
| 767 | 767 | </noscript> |
| 768 | 768 | </form> |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @param array $errors Array with errors. |
| 781 | 781 | * @return array |
| 782 | 782 | */ |
| 783 | - public function validate_payment_form( $errors ) { |
|
| 783 | + public function validate_payment_form($errors) { |
|
| 784 | 784 | return $errors; |
| 785 | 785 | } |
| 786 | 786 | |
@@ -807,18 +807,18 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | ?> |
| 809 | 809 | <td> |
| 810 | - <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
|
| 810 | + <?php esc_html_e('Configuration', 'pronamic_ideal'); ?> |
|
| 811 | 811 | </td> |
| 812 | 812 | <td> |
| 813 | - <select name="<?php echo esc_attr( $name ); ?>"> |
|
| 813 | + <select name="<?php echo esc_attr($name); ?>"> |
|
| 814 | 814 | <?php |
| 815 | 815 | |
| 816 | - foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
|
| 816 | + foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) { |
|
| 817 | 817 | printf( |
| 818 | 818 | '<option value="%s" %s>%s</option>', |
| 819 | - esc_attr( $value ), |
|
| 820 | - selected( $value, $this->settings->config_id, false ), |
|
| 821 | - esc_html( $label ) |
|
| 819 | + esc_attr($value), |
|
| 820 | + selected($value, $this->settings->config_id, false), |
|
| 821 | + esc_html($label) |
|
| 822 | 822 | ); |
| 823 | 823 | } |
| 824 | 824 | |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | * @param array $errors Array with errors. |
| 841 | 841 | * @return array |
| 842 | 842 | */ |
| 843 | - public function validate_options_form( $errors ) { |
|
| 843 | + public function validate_options_form($errors) { |
|
| 844 | 844 | return $errors; |
| 845 | 845 | } |
| 846 | 846 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
| 866 | 866 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
| 867 | 867 | */ |
| 868 | - public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
|
| 868 | + public function display_update_account_form($sub_id, $errors = array(), $message = '') { |
|
| 869 | 869 | |
| 870 | 870 | } |
| 871 | 871 | |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | * @param array $errors Array with errors. |
| 879 | 879 | * @return array |
| 880 | 880 | */ |
| 881 | - public function validate_update_account_form( $errors = array() ) { |
|
| 881 | + public function validate_update_account_form($errors = array()) { |
|
| 882 | 882 | return $errors; |
| 883 | 883 | } |
| 884 | 884 | |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @param int $sub_id Subscription ID. |
| 892 | 892 | */ |
| 893 | - public function process_update_account_form( $sub_id ) { |
|
| 893 | + public function process_update_account_form($sub_id) { |
|
| 894 | 894 | |
| 895 | 895 | } |
| 896 | 896 | |
@@ -47,22 +47,22 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function __construct() { |
| 49 | 49 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprGatewayFactory.php#L48-50 |
| 50 | - add_filter( 'mepr-gateway-paths', array( $this, 'gateway_paths' ) ); |
|
| 51 | - add_filter( 'mepr_recurring_subscriptions_table_joins', array( $this, 'subscriptions_table_joins_nested_query_fix' ) ); |
|
| 50 | + add_filter('mepr-gateway-paths', array($this, 'gateway_paths')); |
|
| 51 | + add_filter('mepr_recurring_subscriptions_table_joins', array($this, 'subscriptions_table_joins_nested_query_fix')); |
|
| 52 | 52 | |
| 53 | - add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( __CLASS__, 'redirect_url' ), 10, 2 ); |
|
| 54 | - add_action( 'pronamic_payment_status_update_' . self::SLUG, array( __CLASS__, 'status_update' ), 10, 1 ); |
|
| 53 | + add_filter('pronamic_payment_redirect_url_' . self::SLUG, array(__CLASS__, 'redirect_url'), 10, 2); |
|
| 54 | + add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 1); |
|
| 55 | 55 | |
| 56 | - add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( __CLASS__, 'source_text' ), 10, 2 ); |
|
| 57 | - add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( __CLASS__, 'source_description' ), 10, 2 ); |
|
| 58 | - add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( __CLASS__, 'source_url' ), 10, 2 ); |
|
| 59 | - add_filter( 'pronamic_subscription_source_text_' . self::SLUG, array( __CLASS__, 'subscription_source_text' ), 10, 2 ); |
|
| 60 | - add_filter( 'pronamic_subscription_source_description_' . self::SLUG, array( __CLASS__, 'subscription_source_description' ), 10, 2 ); |
|
| 61 | - add_filter( 'pronamic_subscription_source_url_' . self::SLUG, array( __CLASS__, 'subscription_source_url' ), 10, 2 ); |
|
| 56 | + add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2); |
|
| 57 | + add_filter('pronamic_payment_source_description_' . self::SLUG, array(__CLASS__, 'source_description'), 10, 2); |
|
| 58 | + add_filter('pronamic_payment_source_url_' . self::SLUG, array(__CLASS__, 'source_url'), 10, 2); |
|
| 59 | + add_filter('pronamic_subscription_source_text_' . self::SLUG, array(__CLASS__, 'subscription_source_text'), 10, 2); |
|
| 60 | + add_filter('pronamic_subscription_source_description_' . self::SLUG, array(__CLASS__, 'subscription_source_description'), 10, 2); |
|
| 61 | + add_filter('pronamic_subscription_source_url_' . self::SLUG, array(__CLASS__, 'subscription_source_url'), 10, 2); |
|
| 62 | 62 | |
| 63 | - add_action( 'mepr_subscription_pre_delete', array( $this, 'subscription_pre_delete' ), 10, 1 ); |
|
| 63 | + add_action('mepr_subscription_pre_delete', array($this, 'subscription_pre_delete'), 10, 1); |
|
| 64 | 64 | |
| 65 | - add_action( 'mepr_subscription_transition_status', array( $this, 'memberpress_subscription_transition_status' ), 10, 3 ); |
|
| 65 | + add_action('mepr_subscription_transition_status', array($this, 'memberpress_subscription_transition_status'), 10, 3); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param array $paths Array with gateway paths. |
| 74 | 74 | * @return array |
| 75 | 75 | */ |
| 76 | - public function gateway_paths( $paths ) { |
|
| 77 | - $paths[] = dirname( __FILE__ ) . '/../gateways/'; |
|
| 76 | + public function gateway_paths($paths) { |
|
| 77 | + $paths[] = dirname(__FILE__) . '/../gateways/'; |
|
| 78 | 78 | |
| 79 | 79 | return $paths; |
| 80 | 80 | } |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| 90 | - public function subscriptions_table_joins_nested_query_fix( $joins ) { |
|
| 91 | - if ( ! is_array( $joins ) ) { |
|
| 90 | + public function subscriptions_table_joins_nested_query_fix($joins) { |
|
| 91 | + if ( ! is_array($joins)) { |
|
| 92 | 92 | return $joins; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Loop joins. |
| 96 | - foreach ( $joins as &$join ) { |
|
| 96 | + foreach ($joins as &$join) { |
|
| 97 | 97 | // Determine if fix needs to be applied. |
| 98 | - if ( ! strpos( $join, 'expiring_txn' ) && ! strpos( $join, 't2.subscription_id=sub.id' ) ) { |
|
| 98 | + if ( ! strpos($join, 'expiring_txn') && ! strpos($join, 't2.subscription_id=sub.id')) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | $join = str_replace( |
| 111 | 111 | ' AS t', |
| 112 | - sprintf( ' AS t, %s AS sub', $mepr_db->subscriptions ), |
|
| 112 | + sprintf(' AS t, %s AS sub', $mepr_db->subscriptions), |
|
| 113 | 113 | $join |
| 114 | 114 | ); |
| 115 | 115 | } |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | - public static function redirect_url( $url, Payment $payment ) { |
|
| 130 | + public static function redirect_url($url, Payment $payment) { |
|
| 131 | 131 | global $transaction; |
| 132 | 132 | |
| 133 | 133 | $transaction_id = $payment->get_source_id(); |
| 134 | 134 | |
| 135 | - $transaction = new MeprTransaction( $transaction_id ); |
|
| 135 | + $transaction = new MeprTransaction($transaction_id); |
|
| 136 | 136 | |
| 137 | - switch ( $payment->get_status() ) { |
|
| 137 | + switch ($payment->get_status()) { |
|
| 138 | 138 | case Statuses::CANCELLED: |
| 139 | 139 | case Statuses::EXPIRED: |
| 140 | 140 | case Statuses::FAILURE: |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | array( |
| 145 | 145 | 'action' => 'payment_form', |
| 146 | 146 | 'txn' => $transaction->trans_num, |
| 147 | - '_wpnonce' => wp_create_nonce( 'mepr_payment_form' ), |
|
| 147 | + '_wpnonce' => wp_create_nonce('mepr_payment_form'), |
|
| 148 | 148 | ), |
| 149 | 149 | $product->url() |
| 150 | 150 | ); |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782 |
| 155 | 155 | $mepr_options = MeprOptions::fetch(); |
| 156 | 156 | |
| 157 | - $product = new MeprProduct( $transaction->product_id ); |
|
| 158 | - $sanitized_title = sanitize_title( $product->post_title ); |
|
| 157 | + $product = new MeprProduct($transaction->product_id); |
|
| 158 | + $sanitized_title = sanitize_title($product->post_title); |
|
| 159 | 159 | |
| 160 | 160 | $args = array( |
| 161 | 161 | 'membership_id' => $product->ID, |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | 'trans_num' => $transaction->trans_num, |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | - $url = $mepr_options->thankyou_page_url( http_build_query( $args ) ); |
|
| 166 | + $url = $mepr_options->thankyou_page_url(http_build_query($args)); |
|
| 167 | 167 | |
| 168 | 168 | break; |
| 169 | 169 | case Statuses::OPEN: |
@@ -181,26 +181,26 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @param Payment $payment The payment whose status is updated. |
| 183 | 183 | */ |
| 184 | - public static function status_update( Payment $payment ) { |
|
| 184 | + public static function status_update(Payment $payment) { |
|
| 185 | 185 | $transaction_id = $payment->get_source_id(); |
| 186 | 186 | |
| 187 | - $transaction = new MeprTransaction( $transaction_id ); |
|
| 187 | + $transaction = new MeprTransaction($transaction_id); |
|
| 188 | 188 | |
| 189 | - if ( $payment->get_recurring() ) { |
|
| 189 | + if ($payment->get_recurring()) { |
|
| 190 | 190 | $subscription = $transaction->subscription(); |
| 191 | 191 | |
| 192 | - if ( empty( $subscription ) || empty( $subscription->id ) ) { |
|
| 192 | + if (empty($subscription) || empty($subscription->id)) { |
|
| 193 | 193 | $subscription_id = $payment->get_subscription()->get_source_id(); |
| 194 | 194 | |
| 195 | - $subscription = new MeprSubscription( $subscription_id ); |
|
| 195 | + $subscription = new MeprSubscription($subscription_id); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Same source ID and first transaction ID for recurring payment means we need to add a new transaction. |
| 199 | - if ( $payment->get_source_id() === $subscription->id ) { |
|
| 199 | + if ($payment->get_source_id() === $subscription->id) { |
|
| 200 | 200 | // First transaction. |
| 201 | 201 | $first_txn = $subscription->first_txn(); |
| 202 | 202 | |
| 203 | - if ( false === $first_txn || ! ( $first_txn instanceof MeprTransaction ) ) { |
|
| 203 | + if (false === $first_txn || ! ($first_txn instanceof MeprTransaction)) { |
|
| 204 | 204 | $first_txn = new MeprTransaction(); |
| 205 | 205 | $first_txn->user_id = $subscription->user_id; |
| 206 | 206 | $first_txn->product_id = $subscription->product_id; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | // Transaction number. |
| 212 | 212 | $trans_num = $payment->get_transaction_id(); |
| 213 | 213 | |
| 214 | - if ( empty( $trans_num ) ) { |
|
| 214 | + if (empty($trans_num)) { |
|
| 215 | 215 | $trans_num = uniqid(); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -227,16 +227,16 @@ discard block |
||
| 227 | 227 | $transaction->status = MeprTransaction::$pending_str; |
| 228 | 228 | $transaction->subscription_id = $subscription->id; |
| 229 | 229 | |
| 230 | - $transaction->set_gross( $payment->get_amount()->get_amount() ); |
|
| 230 | + $transaction->set_gross($payment->get_amount()->get_amount()); |
|
| 231 | 231 | |
| 232 | 232 | $transaction->store(); |
| 233 | 233 | |
| 234 | 234 | // Set source ID. |
| 235 | - $payment->set_meta( 'source_id', $transaction->id ); |
|
| 235 | + $payment->set_meta('source_id', $transaction->id); |
|
| 236 | 236 | |
| 237 | 237 | $payment->source_id = $transaction->id; |
| 238 | 238 | |
| 239 | - if ( MeprSubscription::$active_str === $subscription->status ) { |
|
| 239 | + if (MeprSubscription::$active_str === $subscription->status) { |
|
| 240 | 240 | // New transaction and subscription confirmation. |
| 241 | 241 | $subscription_confirmation = new MeprTransaction(); |
| 242 | 242 | $subscription_confirmation->created_at = $payment->post->post_date_gmt; |
@@ -248,26 +248,26 @@ discard block |
||
| 248 | 248 | $subscription_confirmation->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 249 | 249 | $subscription_confirmation->status = MeprTransaction::$confirmed_str; |
| 250 | 250 | $subscription_confirmation->subscription_id = $subscription->id; |
| 251 | - $subscription_confirmation->expires_at = MeprUtils::ts_to_mysql_date( strtotime( $payment->post->post_date_gmt ) + MeprUtils::days( 15 ), 'Y-m-d 23:59:59' ); |
|
| 251 | + $subscription_confirmation->expires_at = MeprUtils::ts_to_mysql_date(strtotime($payment->post->post_date_gmt) + MeprUtils::days(15), 'Y-m-d 23:59:59'); |
|
| 252 | 252 | |
| 253 | - $subscription_confirmation->set_subtotal( 0.00 ); |
|
| 253 | + $subscription_confirmation->set_subtotal(0.00); |
|
| 254 | 254 | |
| 255 | 255 | $subscription_confirmation->store(); |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $should_update = ! MemberPress::transaction_has_status( $transaction, array( |
|
| 260 | + $should_update = ! MemberPress::transaction_has_status($transaction, array( |
|
| 261 | 261 | MeprTransaction::$failed_str, |
| 262 | 262 | MeprTransaction::$complete_str, |
| 263 | - ) ); |
|
| 263 | + )); |
|
| 264 | 264 | |
| 265 | - if ( $should_update ) { |
|
| 265 | + if ($should_update) { |
|
| 266 | 266 | $gateway = new Gateway(); |
| 267 | 267 | |
| 268 | 268 | $gateway->mp_txn = $transaction; |
| 269 | 269 | |
| 270 | - switch ( $payment->get_status() ) { |
|
| 270 | + switch ($payment->get_status()) { |
|
| 271 | 271 | case Statuses::CANCELLED: |
| 272 | 272 | case Statuses::EXPIRED: |
| 273 | 273 | case Statuses::FAILURE: |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | break; |
| 277 | 277 | case Statuses::SUCCESS: |
| 278 | - if ( $payment->get_recurring() ) { |
|
| 278 | + if ($payment->get_recurring()) { |
|
| 279 | 279 | $gateway->record_subscription_payment(); |
| 280 | 280 | } else { |
| 281 | 281 | $gateway->record_payment(); |
@@ -294,25 +294,25 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @param int $subscription_id MemberPress subscription id. |
| 296 | 296 | */ |
| 297 | - public function subscription_pre_delete( $subscription_id ) { |
|
| 298 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription_id ); |
|
| 297 | + public function subscription_pre_delete($subscription_id) { |
|
| 298 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription_id); |
|
| 299 | 299 | |
| 300 | - if ( ! $subscription ) { |
|
| 300 | + if ( ! $subscription) { |
|
| 301 | 301 | return; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Add note. |
| 305 | 305 | $note = sprintf( |
| 306 | 306 | /* translators: %s: MemberPress */ |
| 307 | - __( '%s subscription deleted.', 'pronamic_ideal' ), |
|
| 308 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 307 | + __('%s subscription deleted.', 'pronamic_ideal'), |
|
| 308 | + __('MemberPress', 'pronamic_ideal') |
|
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | - $subscription->add_note( $note ); |
|
| 311 | + $subscription->add_note($note); |
|
| 312 | 312 | |
| 313 | 313 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 314 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 315 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 314 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 315 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 316 | 316 | |
| 317 | 317 | $subscription->save(); |
| 318 | 318 | } |
@@ -326,18 +326,18 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @return string |
| 328 | 328 | */ |
| 329 | - public static function source_text( $text, Payment $payment ) { |
|
| 330 | - $text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />'; |
|
| 329 | + public static function source_text($text, Payment $payment) { |
|
| 330 | + $text = __('MemberPress', 'pronamic_ideal') . '<br />'; |
|
| 331 | 331 | |
| 332 | 332 | $text .= sprintf( |
| 333 | 333 | '<a href="%s">%s</a>', |
| 334 | - add_query_arg( array( |
|
| 334 | + add_query_arg(array( |
|
| 335 | 335 | 'page' => 'memberpress-trans', |
| 336 | 336 | 'action' => 'edit', |
| 337 | 337 | 'id' => $payment->source_id, |
| 338 | - ), admin_url( 'admin.php' ) ), |
|
| 338 | + ), admin_url('admin.php')), |
|
| 339 | 339 | /* translators: %s: payment source id */ |
| 340 | - sprintf( __( 'Transaction %s', 'pronamic_ideal' ), $payment->source_id ) |
|
| 340 | + sprintf(__('Transaction %s', 'pronamic_ideal'), $payment->source_id) |
|
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | 343 | return $text; |
@@ -351,17 +351,17 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @return string |
| 353 | 353 | */ |
| 354 | - public static function subscription_source_text( $text, Subscription $subscription ) { |
|
| 355 | - $text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />'; |
|
| 354 | + public static function subscription_source_text($text, Subscription $subscription) { |
|
| 355 | + $text = __('MemberPress', 'pronamic_ideal') . '<br />'; |
|
| 356 | 356 | |
| 357 | 357 | $text .= sprintf( |
| 358 | 358 | '<a href="%s">%s</a>', |
| 359 | - add_query_arg( array( |
|
| 359 | + add_query_arg(array( |
|
| 360 | 360 | 'page' => 'memberpress-subscriptions', |
| 361 | 361 | 'subscription' => $subscription->source_id, |
| 362 | - ), admin_url( 'admin.php' ) ), |
|
| 362 | + ), admin_url('admin.php')), |
|
| 363 | 363 | /* translators: %s: payment source id */ |
| 364 | - sprintf( __( 'Subscription %s', 'pronamic_ideal' ), $subscription->source_id ) |
|
| 364 | + sprintf(__('Subscription %s', 'pronamic_ideal'), $subscription->source_id) |
|
| 365 | 365 | ); |
| 366 | 366 | |
| 367 | 367 | return $text; |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @return string |
| 377 | 377 | */ |
| 378 | - public static function source_description( $description, Payment $payment ) { |
|
| 379 | - return __( 'MemberPress Transaction', 'pronamic_ideal' ); |
|
| 378 | + public static function source_description($description, Payment $payment) { |
|
| 379 | + return __('MemberPress Transaction', 'pronamic_ideal'); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | * |
| 388 | 388 | * @return string |
| 389 | 389 | */ |
| 390 | - public static function subscription_source_description( $description, Subscription $subscription ) { |
|
| 391 | - return __( 'MemberPress Subscription', 'pronamic_ideal' ); |
|
| 390 | + public static function subscription_source_description($description, Subscription $subscription) { |
|
| 391 | + return __('MemberPress Subscription', 'pronamic_ideal'); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @return string |
| 401 | 401 | */ |
| 402 | - public static function source_url( $url, Payment $payment ) { |
|
| 403 | - $url = add_query_arg( array( |
|
| 402 | + public static function source_url($url, Payment $payment) { |
|
| 403 | + $url = add_query_arg(array( |
|
| 404 | 404 | 'page' => 'memberpress-trans', |
| 405 | 405 | 'action' => 'edit', |
| 406 | 406 | 'id' => $payment->source_id, |
| 407 | - ), admin_url( 'admin.php' ) ); |
|
| 407 | + ), admin_url('admin.php')); |
|
| 408 | 408 | |
| 409 | 409 | return $url; |
| 410 | 410 | } |
@@ -417,11 +417,11 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @return string |
| 419 | 419 | */ |
| 420 | - public static function subscription_source_url( $url, Subscription $subscription ) { |
|
| 421 | - $url = add_query_arg( array( |
|
| 420 | + public static function subscription_source_url($url, Subscription $subscription) { |
|
| 421 | + $url = add_query_arg(array( |
|
| 422 | 422 | 'page' => 'memberpress-subscriptions', |
| 423 | 423 | 'subscription' => $subscription->source_id, |
| 424 | - ), admin_url( 'admin.php' ) ); |
|
| 424 | + ), admin_url('admin.php')); |
|
| 425 | 425 | |
| 426 | 426 | return $url; |
| 427 | 427 | } |
@@ -437,16 +437,16 @@ discard block |
||
| 437 | 437 | * @param string $status_new New status identifier. |
| 438 | 438 | * @param MeprSubscription $memberpress_subscription MemberPress subscription object. |
| 439 | 439 | */ |
| 440 | - public function memberpress_subscription_transition_status( $status_old, $status_new, $memberpress_subscription ) { |
|
| 441 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $memberpress_subscription->id ); |
|
| 440 | + public function memberpress_subscription_transition_status($status_old, $status_new, $memberpress_subscription) { |
|
| 441 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $memberpress_subscription->id); |
|
| 442 | 442 | |
| 443 | - if ( empty( $subscription ) ) { |
|
| 443 | + if (empty($subscription)) { |
|
| 444 | 444 | return; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $status = SubscriptionStatuses::transform( $status_new ); |
|
| 447 | + $status = SubscriptionStatuses::transform($status_new); |
|
| 448 | 448 | |
| 449 | - $subscription->set_status( $status ); |
|
| 449 | + $subscription->set_status($status); |
|
| 450 | 450 | |
| 451 | 451 | $subscription->save(); |
| 452 | 452 | } |