@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | protected function get_icon() { |
| 33 | - return plugins_url( 'images/sepa-sofort/icon-24x24.png', Plugin::$file ); |
|
| 33 | + return plugins_url('images/sepa-sofort/icon-24x24.png', Plugin::$file); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | protected function get_icon() { |
| 33 | - return plugins_url( 'images/paypal/icon-32x32.png', Plugin::$file ); |
|
| 33 | + return plugins_url('images/paypal/icon-32x32.png', Plugin::$file); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | protected function get_icon() { |
| 33 | - return plugins_url( 'images/sepa-ideal/icon-24x24.png', Plugin::$file ); |
|
| 33 | + return plugins_url('images/sepa-ideal/icon-24x24.png', Plugin::$file); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | protected function get_icon() { |
| 33 | - return plugins_url( 'images/sepa-bancontact/icon-24x24.png', Plugin::$file ); |
|
| 33 | + return plugins_url('images/sepa-bancontact/icon-24x24.png', Plugin::$file); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | protected function get_icon() { |
| 33 | - return plugins_url( 'images/ideal/icon-32x32.png', Plugin::$file ); |
|
| 33 | + return plugins_url('images/ideal/icon-32x32.png', Plugin::$file); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // Set the name of this gateway. |
| 56 | 56 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13. |
| 57 | - $this->name = __( 'Pronamic', 'pronamic_ideal' ); |
|
| 57 | + $this->name = __('Pronamic', 'pronamic_ideal'); |
|
| 58 | 58 | |
| 59 | - if ( ! empty( $this->payment_method ) ) { |
|
| 60 | - $this->name = PaymentMethods::get_name( $this->payment_method ); |
|
| 59 | + if ( ! empty($this->payment_method)) { |
|
| 60 | + $this->name = PaymentMethods::get_name($this->payment_method); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Set the default settings. |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param array $settings MemberPress gateway settings array. |
| 81 | 81 | */ |
| 82 | - public function load( $settings ) { |
|
| 82 | + public function load($settings) { |
|
| 83 | 83 | $this->settings = (object) $settings; |
| 84 | 84 | |
| 85 | 85 | $this->set_defaults(); |
@@ -96,19 +96,19 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return mixed |
| 98 | 98 | */ |
| 99 | - public function send_transaction_notices( $transaction, $method ) { |
|
| 99 | + public function send_transaction_notices($transaction, $method) { |
|
| 100 | 100 | $class = 'MeprUtils'; |
| 101 | 101 | |
| 102 | - if ( ! Core_Util::class_method_exists( $class, $method ) ) { |
|
| 102 | + if ( ! Core_Util::class_method_exists($class, $method)) { |
|
| 103 | 103 | $class = $this; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) { |
|
| 106 | + if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) { |
|
| 107 | 107 | // `send_product_welcome_notices` is called from `send_signup_notices` in newer versions. |
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return call_user_func( array( $class, $method ), $transaction ); |
|
| 111 | + return call_user_func(array($class, $method), $transaction); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73 |
| 137 | 137 | */ |
| 138 | 138 | protected function set_defaults() { |
| 139 | - if ( ! isset( $this->settings ) ) { |
|
| 139 | + if ( ! isset($this->settings)) { |
|
| 140 | 140 | $this->settings = array(); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122 |
| 176 | 176 | */ |
| 177 | - public function process_payment( $txn ) { |
|
| 177 | + public function process_payment($txn) { |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $subscription = $transaction->subscription(); |
| 193 | 193 | |
| 194 | - if ( $subscription ) { |
|
| 195 | - if ( MeprSubscription::$active_str !== $subscription->status ) { |
|
| 194 | + if ($subscription) { |
|
| 195 | + if (MeprSubscription::$active_str !== $subscription->status) { |
|
| 196 | 196 | $subscription->status = MeprSubscription::$active_str; |
| 197 | 197 | $subscription->store(); |
| 198 | 198 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $subscription->limit_payment_cycles(); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 203 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 204 | 204 | |
| 205 | 205 | return $transaction; |
| 206 | 206 | } |
@@ -220,12 +220,12 @@ discard block |
||
| 220 | 220 | // Expire associated transactions for subscription. |
| 221 | 221 | $subscription = $transaction->subscription(); |
| 222 | 222 | |
| 223 | - if ( $subscription ) { |
|
| 223 | + if ($subscription) { |
|
| 224 | 224 | $subscription->expire_txns(); |
| 225 | 225 | $subscription->store(); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $this->send_transaction_notices( $transaction, 'send_failed_txn_notices' ); |
|
| 228 | + $this->send_transaction_notices($transaction, 'send_failed_txn_notices'); |
|
| 229 | 229 | |
| 230 | 230 | return $transaction; |
| 231 | 231 | } |
@@ -249,17 +249,17 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $subscription = $transaction->subscription(); |
| 251 | 251 | |
| 252 | - if ( $subscription ) { |
|
| 252 | + if ($subscription) { |
|
| 253 | 253 | $subscription->status = MeprSubscription::$active_str; |
| 254 | 254 | $subscription->created_at = $transaction->created_at; |
| 255 | 255 | $subscription->store(); |
| 256 | 256 | |
| 257 | 257 | // Set subscription first transaction id meta. |
| 258 | - $pronamic_subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription->first_txn_id ); |
|
| 258 | + $pronamic_subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription->first_txn_id); |
|
| 259 | 259 | |
| 260 | - if ( $pronamic_subscription ) { |
|
| 260 | + if ($pronamic_subscription) { |
|
| 261 | 261 | // Store MemberPress subscription id to be able to cancel subscription on delete. |
| 262 | - $pronamic_subscription->set_meta( 'memberpress_subscription_id', $subscription->id ); |
|
| 262 | + $pronamic_subscription->set_meta('memberpress_subscription_id', $subscription->id); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619 |
| 272 | 272 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51 |
| 273 | 273 | */ |
| 274 | - $reflection = new ReflectionClass( 'MeprBaseRealGateway' ); |
|
| 274 | + $reflection = new ReflectionClass('MeprBaseRealGateway'); |
|
| 275 | 275 | |
| 276 | - if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) { |
|
| 276 | + if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) { |
|
| 277 | 277 | $uemail = MeprEmailFactory::fetch( |
| 278 | 278 | 'MeprUserProductWelcomeEmail', |
| 279 | 279 | 'MeprBaseProductEmail', |
@@ -286,24 +286,24 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $this->send_product_welcome_notices( |
| 288 | 288 | $uemail, |
| 289 | - MeprTransactionsHelper::get_email_params( $transaction ), |
|
| 289 | + MeprTransactionsHelper::get_email_params($transaction), |
|
| 290 | 290 | $transaction->user() |
| 291 | 291 | ); |
| 292 | 292 | } else { |
| 293 | - $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); |
|
| 293 | + $this->send_transaction_notices($transaction, 'send_product_welcome_notices'); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Send upgrade/downgrade notices. |
| 297 | - if ( $upgrade ) { |
|
| 298 | - $this->upgraded_sub( $transaction ); |
|
| 299 | - $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); |
|
| 300 | - } elseif ( $downgrade ) { |
|
| 301 | - $this->downgraded_sub( $transaction ); |
|
| 302 | - $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); |
|
| 297 | + if ($upgrade) { |
|
| 298 | + $this->upgraded_sub($transaction); |
|
| 299 | + $this->send_transaction_notices($transaction, 'send_upgraded_txn_notices'); |
|
| 300 | + } elseif ($downgrade) { |
|
| 301 | + $this->downgraded_sub($transaction); |
|
| 302 | + $this->send_transaction_notices($transaction, 'send_downgraded_txn_notices'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $this->send_transaction_notices( $transaction, 'send_signup_notices' ); |
|
| 306 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 305 | + $this->send_transaction_notices($transaction, 'send_signup_notices'); |
|
| 306 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 307 | 307 | |
| 308 | 308 | return $transaction; |
| 309 | 309 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 |
| 317 | 317 | */ |
| 318 | - public function process_refund( MeprTransaction $txn ) { |
|
| 318 | + public function process_refund(MeprTransaction $txn) { |
|
| 319 | 319 | |
| 320 | 320 | } |
| 321 | 321 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 337 | 337 | */ |
| 338 | - public function process_trial_payment( $transaction ) { |
|
| 338 | + public function process_trial_payment($transaction) { |
|
| 339 | 339 | |
| 340 | 340 | } |
| 341 | 341 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 348 | 348 | */ |
| 349 | - public function record_trial_payment( $transaction ) { |
|
| 349 | + public function record_trial_payment($transaction) { |
|
| 350 | 350 | |
| 351 | 351 | } |
| 352 | 352 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @param MeprTransaction $txn MemberPress transaction object. |
| 359 | 359 | */ |
| 360 | - public function process_create_subscription( $txn ) { |
|
| 360 | + public function process_create_subscription($txn) { |
|
| 361 | 361 | |
| 362 | 362 | } |
| 363 | 363 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * |
| 379 | 379 | * @param int $sub_id Subscription ID. |
| 380 | 380 | */ |
| 381 | - public function process_update_subscription( $sub_id ) { |
|
| 381 | + public function process_update_subscription($sub_id) { |
|
| 382 | 382 | |
| 383 | 383 | } |
| 384 | 384 | |
@@ -398,21 +398,21 @@ discard block |
||
| 398 | 398 | * |
| 399 | 399 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 |
| 400 | 400 | */ |
| 401 | - public function process_suspend_subscription( $sub_id ) { |
|
| 402 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 401 | + public function process_suspend_subscription($sub_id) { |
|
| 402 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 403 | 403 | return; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $sub = new MeprSubscription( $sub_id ); |
|
| 406 | + $sub = new MeprSubscription($sub_id); |
|
| 407 | 407 | |
| 408 | - if ( MeprSubscription::$suspended_str === $sub->status ) { |
|
| 408 | + if (MeprSubscription::$suspended_str === $sub->status) { |
|
| 409 | 409 | // Subscription is already suspended. |
| 410 | 410 | return; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 413 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 414 | 414 | |
| 415 | - if ( ! $subscription ) { |
|
| 415 | + if ( ! $subscription) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -421,19 +421,19 @@ discard block |
||
| 421 | 421 | $sub->store(); |
| 422 | 422 | |
| 423 | 423 | // Send suspended subscription notices. |
| 424 | - MeprUtils::send_suspended_sub_notices( $sub ); |
|
| 424 | + MeprUtils::send_suspended_sub_notices($sub); |
|
| 425 | 425 | |
| 426 | 426 | $note = sprintf( |
| 427 | 427 | /* translators: %s: MemberPress */ |
| 428 | - __( '%s subscription on hold.', 'pronamic_ideal' ), |
|
| 429 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 428 | + __('%s subscription on hold.', 'pronamic_ideal'), |
|
| 429 | + __('MemberPress', 'pronamic_ideal') |
|
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | - $subscription->add_note( $note ); |
|
| 432 | + $subscription->add_note($note); |
|
| 433 | 433 | |
| 434 | 434 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 435 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 436 | - $subscription->set_status( Statuses::OPEN ); |
|
| 435 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 436 | + $subscription->set_status(Statuses::OPEN); |
|
| 437 | 437 | |
| 438 | 438 | $subscription->save(); |
| 439 | 439 | } |
@@ -455,21 +455,21 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 |
| 457 | 457 | */ |
| 458 | - public function process_resume_subscription( $sub_id ) { |
|
| 459 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 458 | + public function process_resume_subscription($sub_id) { |
|
| 459 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - $sub = new MeprSubscription( $sub_id ); |
|
| 463 | + $sub = new MeprSubscription($sub_id); |
|
| 464 | 464 | |
| 465 | - if ( MeprSubscription::$active_str === $sub->status ) { |
|
| 465 | + if (MeprSubscription::$active_str === $sub->status) { |
|
| 466 | 466 | // Subscription is already active. |
| 467 | 467 | return; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 470 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 471 | 471 | |
| 472 | - if ( ! $subscription ) { |
|
| 472 | + if ( ! $subscription) { |
|
| 473 | 473 | return; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -480,35 +480,35 @@ discard block |
||
| 480 | 480 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. |
| 481 | 481 | $prior_txn = $sub->latest_txn(); |
| 482 | 482 | |
| 483 | - if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { |
|
| 483 | + if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) { |
|
| 484 | 484 | $txn = new MeprTransaction(); |
| 485 | 485 | $txn->subscription_id = $sub->id; |
| 486 | 486 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); |
| 487 | 487 | $txn->status = MeprTransaction::$confirmed_str; |
| 488 | 488 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 489 | 489 | $txn->response = (string) $sub; |
| 490 | - $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); |
|
| 490 | + $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59'); |
|
| 491 | 491 | |
| 492 | - $txn->set_subtotal( 0.00 ); // Just a confirmation txn. |
|
| 492 | + $txn->set_subtotal(0.00); // Just a confirmation txn. |
|
| 493 | 493 | |
| 494 | 494 | $txn->store(); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // Send resumed subscription notices. |
| 498 | - MeprUtils::send_resumed_sub_notices( $sub ); |
|
| 498 | + MeprUtils::send_resumed_sub_notices($sub); |
|
| 499 | 499 | |
| 500 | 500 | // Add note. |
| 501 | 501 | $note = sprintf( |
| 502 | 502 | /* translators: %s: MemberPress */ |
| 503 | - __( '%s subscription reactivated.', 'pronamic_ideal' ), |
|
| 504 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 503 | + __('%s subscription reactivated.', 'pronamic_ideal'), |
|
| 504 | + __('MemberPress', 'pronamic_ideal') |
|
| 505 | 505 | ); |
| 506 | 506 | |
| 507 | - $subscription->add_note( $note ); |
|
| 507 | + $subscription->add_note($note); |
|
| 508 | 508 | |
| 509 | 509 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 510 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 511 | - $subscription->set_status( Statuses::ACTIVE ); |
|
| 510 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 511 | + $subscription->set_status(Statuses::ACTIVE); |
|
| 512 | 512 | |
| 513 | 513 | $subscription->save(); |
| 514 | 514 | } |
@@ -530,21 +530,21 @@ discard block |
||
| 530 | 530 | * |
| 531 | 531 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 |
| 532 | 532 | */ |
| 533 | - public function process_cancel_subscription( $sub_id ) { |
|
| 534 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 533 | + public function process_cancel_subscription($sub_id) { |
|
| 534 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 535 | 535 | return; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | - $sub = new MeprSubscription( $sub_id ); |
|
| 538 | + $sub = new MeprSubscription($sub_id); |
|
| 539 | 539 | |
| 540 | - if ( MeprSubscription::$cancelled_str === $sub->status ) { |
|
| 540 | + if (MeprSubscription::$cancelled_str === $sub->status) { |
|
| 541 | 541 | // Subscription is already cancelled. |
| 542 | 542 | return; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 545 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 546 | 546 | |
| 547 | - if ( ! $subscription ) { |
|
| 547 | + if ( ! $subscription) { |
|
| 548 | 548 | return; |
| 549 | 549 | } |
| 550 | 550 | |
@@ -553,27 +553,27 @@ discard block |
||
| 553 | 553 | $sub->store(); |
| 554 | 554 | |
| 555 | 555 | // Expire the grace period (confirmation) if no completed payments have come through. |
| 556 | - if ( (int) $sub->txn_count <= 0 ) { |
|
| 556 | + if ((int) $sub->txn_count <= 0) { |
|
| 557 | 557 | $sub->expire_txns(); |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | $sub->limit_reached_actions(); |
| 561 | 561 | |
| 562 | 562 | // Send cancelled subscription notices. |
| 563 | - MeprUtils::send_cancelled_sub_notices( $sub ); |
|
| 563 | + MeprUtils::send_cancelled_sub_notices($sub); |
|
| 564 | 564 | |
| 565 | 565 | // Add note. |
| 566 | 566 | $note = sprintf( |
| 567 | 567 | /* translators: %s: MemberPress */ |
| 568 | - __( '%s subscription cancelled.', 'pronamic_ideal' ), |
|
| 569 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 568 | + __('%s subscription cancelled.', 'pronamic_ideal'), |
|
| 569 | + __('MemberPress', 'pronamic_ideal') |
|
| 570 | 570 | ); |
| 571 | 571 | |
| 572 | - $subscription->add_note( $note ); |
|
| 572 | + $subscription->add_note($note); |
|
| 573 | 573 | |
| 574 | 574 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 575 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 576 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 575 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 576 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 577 | 577 | |
| 578 | 578 | $subscription->save(); |
| 579 | 579 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @param MeprTransaction $txn MemberPress transaction object. |
| 602 | 602 | */ |
| 603 | - public function process_signup_form( $txn ) { |
|
| 603 | + public function process_signup_form($txn) { |
|
| 604 | 604 | |
| 605 | 605 | } |
| 606 | 606 | |
@@ -611,28 +611,28 @@ discard block |
||
| 611 | 611 | * |
| 612 | 612 | * @param MeprTransaction $txn MemberPress transaction object. |
| 613 | 613 | */ |
| 614 | - public function payment_redirect( $txn ) { |
|
| 615 | - $txn = new MeprTransaction( $txn->id ); |
|
| 614 | + public function payment_redirect($txn) { |
|
| 615 | + $txn = new MeprTransaction($txn->id); |
|
| 616 | 616 | |
| 617 | 617 | // Gateway. |
| 618 | 618 | $config_id = $this->settings->config_id; |
| 619 | 619 | |
| 620 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 620 | + $gateway = Plugin::get_gateway($config_id); |
|
| 621 | 621 | |
| 622 | - if ( ! $gateway ) { |
|
| 622 | + if ( ! $gateway) { |
|
| 623 | 623 | return; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Data. |
| 627 | - $data = new PaymentData( $txn ); |
|
| 627 | + $data = new PaymentData($txn); |
|
| 628 | 628 | |
| 629 | - $payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method ); |
|
| 629 | + $payment = Plugin::start($config_id, $gateway, $data, $this->payment_method); |
|
| 630 | 630 | |
| 631 | 631 | $error = $gateway->get_error(); |
| 632 | 632 | |
| 633 | - if ( ! is_wp_error( $error ) ) { |
|
| 633 | + if ( ! is_wp_error($error)) { |
|
| 634 | 634 | // Redirect. |
| 635 | - $gateway->redirect( $payment ); |
|
| 635 | + $gateway->redirect($payment); |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
@@ -644,18 +644,18 @@ discard block |
||
| 644 | 644 | * @param MeprTransaction $txn MemberPress transaction object. |
| 645 | 645 | * @return bool |
| 646 | 646 | */ |
| 647 | - public function display_payment_page( $txn ) { |
|
| 648 | - if ( ! $txn instanceof MeprTransaction ) { |
|
| 647 | + public function display_payment_page($txn) { |
|
| 648 | + if ( ! $txn instanceof MeprTransaction) { |
|
| 649 | 649 | return false; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | // Gateway. |
| 653 | 653 | $config_id = $this->settings->config_id; |
| 654 | 654 | |
| 655 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 655 | + $gateway = Plugin::get_gateway($config_id); |
|
| 656 | 656 | |
| 657 | - if ( $gateway && '' === $gateway->get_input_html() ) { |
|
| 658 | - $this->payment_redirect( $txn ); |
|
| 657 | + if ($gateway && '' === $gateway->get_input_html()) { |
|
| 658 | + $this->payment_redirect($txn); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |
@@ -667,22 +667,22 @@ discard block |
||
| 667 | 667 | * @param MeprTransaction $txn MemberPress transaction object. |
| 668 | 668 | * @return bool |
| 669 | 669 | */ |
| 670 | - public function process_payment_form( $txn ) { |
|
| 671 | - if ( ! $txn instanceof MeprTransaction ) { |
|
| 670 | + public function process_payment_form($txn) { |
|
| 671 | + if ( ! $txn instanceof MeprTransaction) { |
|
| 672 | 672 | return false; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
|
| 675 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) { |
|
| 676 | 676 | return false; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // Gateway. |
| 680 | 680 | $config_id = $this->settings->config_id; |
| 681 | 681 | |
| 682 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 682 | + $gateway = Plugin::get_gateway($config_id); |
|
| 683 | 683 | |
| 684 | - if ( $gateway ) { |
|
| 685 | - $this->payment_redirect( $txn ); |
|
| 684 | + if ($gateway) { |
|
| 685 | + $this->payment_redirect($txn); |
|
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | |
@@ -710,20 +710,20 @@ discard block |
||
| 710 | 710 | * @param int $product_id Product ID. |
| 711 | 711 | * @param int $txn_id Transaction ID. |
| 712 | 712 | */ |
| 713 | - public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
|
| 714 | - $product = new MeprProduct( $product_id ); |
|
| 713 | + public function display_payment_form($amount, $user, $product_id, $txn_id) { |
|
| 714 | + $product = new MeprProduct($product_id); |
|
| 715 | 715 | |
| 716 | 716 | $coupon = false; |
| 717 | 717 | |
| 718 | - $txn = new MeprTransaction( $txn_id ); |
|
| 718 | + $txn = new MeprTransaction($txn_id); |
|
| 719 | 719 | |
| 720 | 720 | // Artifically set the price of the $prd in case a coupon was used. |
| 721 | - if ( $product->price !== $amount ) { |
|
| 721 | + if ($product->price !== $amount) { |
|
| 722 | 722 | $coupon = true; |
| 723 | 723 | $product->price = $amount; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
|
| 726 | + $invoice = MeprTransactionsHelper::get_invoice($txn); |
|
| 727 | 727 | |
| 728 | 728 | echo $invoice; // WPCS: XSS ok. |
| 729 | 729 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | <div class="mp_wrapper mp_payment_form_wrapper"> |
| 732 | 732 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
| 733 | 733 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
| 734 | - <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
|
| 734 | + <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/> |
|
| 735 | 735 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
| 736 | 736 | |
| 737 | 737 | <div class="mepr_spacer"> </div> |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | // Gateway. |
| 742 | 742 | $config_id = $this->settings->config_id; |
| 743 | 743 | |
| 744 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 744 | + $gateway = Plugin::get_gateway($config_id); |
|
| 745 | 745 | |
| 746 | - if ( $gateway ) { |
|
| 746 | + if ($gateway) { |
|
| 747 | 747 | echo $gateway->get_input_html(); // WPCS: XSS ok. |
| 748 | 748 | } |
| 749 | 749 | |
@@ -751,13 +751,13 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | <div class="mepr_spacer"> </div> |
| 753 | 753 | |
| 754 | - <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
|
| 755 | - <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 756 | - <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
|
| 754 | + <input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/> |
|
| 755 | + <img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 756 | + <?php MeprView::render('/shared/has_errors', get_defined_vars()); ?> |
|
| 757 | 757 | |
| 758 | 758 | <noscript> |
| 759 | 759 | <p class="mepr_nojs"> |
| 760 | - <?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' ); ?> |
|
| 760 | + <?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'); ?> |
|
| 761 | 761 | </p> |
| 762 | 762 | </noscript> |
| 763 | 763 | </form> |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * @param array $errors Array with errors. |
| 776 | 776 | * @return array |
| 777 | 777 | */ |
| 778 | - public function validate_payment_form( $errors ) { |
|
| 778 | + public function validate_payment_form($errors) { |
|
| 779 | 779 | return $errors; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -802,18 +802,18 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | ?> |
| 804 | 804 | <td> |
| 805 | - <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
|
| 805 | + <?php esc_html_e('Configuration', 'pronamic_ideal'); ?> |
|
| 806 | 806 | </td> |
| 807 | 807 | <td> |
| 808 | - <select name="<?php echo esc_attr( $name ); ?>"> |
|
| 808 | + <select name="<?php echo esc_attr($name); ?>"> |
|
| 809 | 809 | <?php |
| 810 | 810 | |
| 811 | - foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
|
| 811 | + foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) { |
|
| 812 | 812 | printf( |
| 813 | 813 | '<option value="%s" %s>%s</option>', |
| 814 | - esc_attr( $value ), |
|
| 815 | - selected( $value, $this->settings->config_id, false ), |
|
| 816 | - esc_html( $label ) |
|
| 814 | + esc_attr($value), |
|
| 815 | + selected($value, $this->settings->config_id, false), |
|
| 816 | + esc_html($label) |
|
| 817 | 817 | ); |
| 818 | 818 | } |
| 819 | 819 | |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param array $errors Array with errors. |
| 836 | 836 | * @return array |
| 837 | 837 | */ |
| 838 | - public function validate_options_form( $errors ) { |
|
| 838 | + public function validate_options_form($errors) { |
|
| 839 | 839 | return $errors; |
| 840 | 840 | } |
| 841 | 841 | |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
| 861 | 861 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
| 862 | 862 | */ |
| 863 | - public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
|
| 863 | + public function display_update_account_form($sub_id, $errors = array(), $message = '') { |
|
| 864 | 864 | |
| 865 | 865 | } |
| 866 | 866 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | * @param array $errors Array with errors. |
| 874 | 874 | * @return array |
| 875 | 875 | */ |
| 876 | - public function validate_update_account_form( $errors = array() ) { |
|
| 876 | + public function validate_update_account_form($errors = array()) { |
|
| 877 | 877 | return $errors; |
| 878 | 878 | } |
| 879 | 879 | |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | * |
| 886 | 886 | * @param int $sub_id Subscription ID. |
| 887 | 887 | */ |
| 888 | - public function process_update_account_form( $sub_id ) { |
|
| 888 | + public function process_update_account_form($sub_id) { |
|
| 889 | 889 | |
| 890 | 890 | } |
| 891 | 891 | |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Returns true if the transaction has the specified status, false otherwise. |
| 30 | 30 | */ |
| 31 | - public static function transaction_has_status( MeprTransaction $transaction, $status ) { |
|
| 32 | - if ( is_array( $status ) ) { |
|
| 33 | - return in_array( $transaction->status, $status, true ); |
|
| 31 | + public static function transaction_has_status(MeprTransaction $transaction, $status) { |
|
| 32 | + if (is_array($status)) { |
|
| 33 | + return in_array($transaction->status, $status, true); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return ( $transaction->status === $status ); |
|
| 36 | + return ($transaction->status === $status); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | * @param MeprTransaction $txn MemberPress transaction object. |
| 50 | 50 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/models/MeprTransaction.php |
| 51 | 51 | */ |
| 52 | - public function __construct( MeprTransaction $txn ) { |
|
| 52 | + public function __construct(MeprTransaction $txn) { |
|
| 53 | 53 | parent::__construct(); |
| 54 | 54 | |
| 55 | 55 | $this->txn = $txn; |
| 56 | 56 | $this->member = $this->txn->user(); |
| 57 | - $this->recurring = ( $txn->subscription() && $txn->subscription()->txn_count > 1 ); |
|
| 57 | + $this->recurring = ($txn->subscription() && $txn->subscription()->txn_count > 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | $items = new Items(); |
| 108 | 108 | |
| 109 | 109 | $item = new Item(); |
| 110 | - $item->setNumber( $this->get_order_id() ); |
|
| 111 | - $item->setDescription( $this->get_description() ); |
|
| 112 | - $item->setPrice( $this->txn->total ); |
|
| 113 | - $item->setQuantity( 1 ); |
|
| 110 | + $item->setNumber($this->get_order_id()); |
|
| 111 | + $item->setDescription($this->get_description()); |
|
| 112 | + $item->setPrice($this->txn->total); |
|
| 113 | + $item->setQuantity(1); |
|
| 114 | 114 | |
| 115 | - $items->addItem( $item ); |
|
| 115 | + $items->addItem($item); |
|
| 116 | 116 | |
| 117 | 117 | return $items; |
| 118 | 118 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @return string |
| 138 | 138 | */ |
| 139 | 139 | public function get_email() { |
| 140 | - if ( $this->member instanceof MeprUser ) { |
|
| 140 | + if ($this->member instanceof MeprUser) { |
|
| 141 | 141 | return $this->member->user_email; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | public function get_first_name() { |
| 152 | - if ( $this->member instanceof MeprUser ) { |
|
| 152 | + if ($this->member instanceof MeprUser) { |
|
| 153 | 153 | return $this->member->first_name; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @return string |
| 162 | 162 | */ |
| 163 | 163 | public function get_last_name() { |
| 164 | - if ( $this->member instanceof MeprUser ) { |
|
| 164 | + if ($this->member instanceof MeprUser) { |
|
| 165 | 165 | return $this->member->last_name; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | 175 | public function get_customer_name() { |
| 176 | - if ( $this->member instanceof MeprUser ) { |
|
| 176 | + if ($this->member instanceof MeprUser) { |
|
| 177 | 177 | return $this->member->get_full_name(); |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $mepr_options = MeprOptions::fetch(); |
| 216 | 216 | |
| 217 | 217 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782 |
| 218 | - return $mepr_options->thankyou_page_url( 'trans_num=' . $this->txn->id ); |
|
| 218 | + return $mepr_options->thankyou_page_url('trans_num=' . $this->txn->id); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -255,36 +255,36 @@ discard block |
||
| 255 | 255 | public function get_subscription() { |
| 256 | 256 | $product = $this->txn->product(); |
| 257 | 257 | |
| 258 | - if ( $product->is_one_time_payment() ) { |
|
| 258 | + if ($product->is_one_time_payment()) { |
|
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $mp_subscription = $this->txn->subscription(); |
| 263 | 263 | |
| 264 | - if ( ! $mp_subscription ) { |
|
| 264 | + if ( ! $mp_subscription) { |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $frequency = ''; |
| 269 | 269 | |
| 270 | - if ( $mp_subscription->limit_cycles ) { |
|
| 270 | + if ($mp_subscription->limit_cycles) { |
|
| 271 | 271 | $frequency = $mp_subscription->limit_cycles; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $subscription = new Subscription(); |
| 275 | 275 | $subscription->frequency = $frequency; |
| 276 | 276 | $subscription->interval = $product->period; |
| 277 | - $subscription->interval_period = Core_Util::to_period( $product->period_type ); |
|
| 277 | + $subscription->interval_period = Core_Util::to_period($product->period_type); |
|
| 278 | 278 | $subscription->description = sprintf( |
| 279 | 279 | 'Order #%s - %s', |
| 280 | 280 | $this->get_source_id(), |
| 281 | 281 | $this->get_description() |
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | - $subscription->set_amount( new Money( |
|
| 284 | + $subscription->set_amount(new Money( |
|
| 285 | 285 | $this->txn->total, |
| 286 | 286 | $this->get_currency_alphabetic_code() |
| 287 | - ) ); |
|
| 287 | + )); |
|
| 288 | 288 | |
| 289 | 289 | return $subscription; |
| 290 | 290 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | public function get_subscription_source_id() { |
| 299 | 299 | $subscription = $this->get_subscription(); |
| 300 | 300 | |
| 301 | - if ( ! $subscription ) { |
|
| 301 | + if ( ! $subscription) { |
|
| 302 | 302 | return false; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct() { |
| 46 | 46 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprGatewayFactory.php#L48-50 |
| 47 | - add_filter( 'mepr-gateway-paths', array( $this, 'gateway_paths' ) ); |
|
| 47 | + add_filter('mepr-gateway-paths', array($this, 'gateway_paths')); |
|
| 48 | 48 | |
| 49 | - add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( __CLASS__, 'redirect_url' ), 10, 2 ); |
|
| 50 | - add_action( 'pronamic_payment_status_update_' . self::SLUG, array( __CLASS__, 'status_update' ), 10, 1 ); |
|
| 49 | + add_filter('pronamic_payment_redirect_url_' . self::SLUG, array(__CLASS__, 'redirect_url'), 10, 2); |
|
| 50 | + add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 1); |
|
| 51 | 51 | |
| 52 | - add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( __CLASS__, 'source_text' ), 10, 2 ); |
|
| 53 | - add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( __CLASS__, 'source_description' ), 10, 2 ); |
|
| 54 | - add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( __CLASS__, 'source_url' ), 10, 2 ); |
|
| 52 | + add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2); |
|
| 53 | + add_filter('pronamic_payment_source_description_' . self::SLUG, array(__CLASS__, 'source_description'), 10, 2); |
|
| 54 | + add_filter('pronamic_payment_source_url_' . self::SLUG, array(__CLASS__, 'source_url'), 10, 2); |
|
| 55 | 55 | |
| 56 | - add_action( 'mepr_subscription_pre_delete', array( $this, 'subscription_pre_delete' ), 10, 1 ); |
|
| 56 | + add_action('mepr_subscription_pre_delete', array($this, 'subscription_pre_delete'), 10, 1); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | * @param array $paths Array with gateway paths. |
| 65 | 65 | * @return array |
| 66 | 66 | */ |
| 67 | - public function gateway_paths( $paths ) { |
|
| 68 | - $paths[] = dirname( __FILE__ ) . '/../gateways/'; |
|
| 67 | + public function gateway_paths($paths) { |
|
| 68 | + $paths[] = dirname(__FILE__) . '/../gateways/'; |
|
| 69 | 69 | |
| 70 | 70 | return $paths; |
| 71 | 71 | } |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public static function redirect_url( $url, Payment $payment ) { |
|
| 83 | + public static function redirect_url($url, Payment $payment) { |
|
| 84 | 84 | global $transaction; |
| 85 | 85 | |
| 86 | 86 | $transaction_id = $payment->get_source_id(); |
| 87 | 87 | |
| 88 | - $transaction = new MeprTransaction( $transaction_id ); |
|
| 88 | + $transaction = new MeprTransaction($transaction_id); |
|
| 89 | 89 | |
| 90 | - switch ( $payment->get_status() ) { |
|
| 90 | + switch ($payment->get_status()) { |
|
| 91 | 91 | case Statuses::CANCELLED: |
| 92 | 92 | case Statuses::EXPIRED: |
| 93 | 93 | case Statuses::FAILURE: |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | array( |
| 98 | 98 | 'action' => 'payment_form', |
| 99 | 99 | 'txn' => $transaction->trans_num, |
| 100 | - '_wpnonce' => wp_create_nonce( 'mepr_payment_form' ), |
|
| 100 | + '_wpnonce' => wp_create_nonce('mepr_payment_form'), |
|
| 101 | 101 | ), |
| 102 | 102 | $product->url() |
| 103 | 103 | ); |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782 |
| 108 | 108 | $mepr_options = MeprOptions::fetch(); |
| 109 | 109 | |
| 110 | - $product = new MeprProduct( $transaction->product_id ); |
|
| 111 | - $sanitized_title = sanitize_title( $product->post_title ); |
|
| 110 | + $product = new MeprProduct($transaction->product_id); |
|
| 111 | + $sanitized_title = sanitize_title($product->post_title); |
|
| 112 | 112 | |
| 113 | 113 | $args = array( |
| 114 | 114 | 'membership_id' => $product->ID, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | 'trans_num' => $transaction->trans_num, |
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | - $url = $mepr_options->thankyou_page_url( http_build_query( $args ) ); |
|
| 119 | + $url = $mepr_options->thankyou_page_url(http_build_query($args)); |
|
| 120 | 120 | |
| 121 | 121 | break; |
| 122 | 122 | case Statuses::OPEN: |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @param Payment $payment The payment whose status is updated. |
| 136 | 136 | */ |
| 137 | - public static function status_update( Payment $payment ) { |
|
| 137 | + public static function status_update(Payment $payment) { |
|
| 138 | 138 | global $transaction; |
| 139 | 139 | |
| 140 | 140 | $transaction_id = $payment->get_source_id(); |
| 141 | 141 | |
| 142 | - $transaction = new MeprTransaction( $transaction_id ); |
|
| 142 | + $transaction = new MeprTransaction($transaction_id); |
|
| 143 | 143 | |
| 144 | - if ( $payment->get_recurring() ) { |
|
| 144 | + if ($payment->get_recurring()) { |
|
| 145 | 145 | $sub = $transaction->subscription(); |
| 146 | 146 | |
| 147 | 147 | // Same source ID and first transaction ID for recurring payment means we need to add a new transaction. |
| 148 | - if ( $payment->get_source_id() === $sub->first_txn_id ) { |
|
| 148 | + if ($payment->get_source_id() === $sub->first_txn_id) { |
|
| 149 | 149 | // First transaction. |
| 150 | 150 | $first_txn = $sub->first_txn(); |
| 151 | 151 | |
| 152 | - if ( false === $first_txn || ! ( $first_txn instanceof MeprTransaction ) ) { |
|
| 152 | + if (false === $first_txn || ! ($first_txn instanceof MeprTransaction)) { |
|
| 153 | 153 | $first_txn = new MeprTransaction(); |
| 154 | 154 | $first_txn->user_id = $sub->user_id; |
| 155 | 155 | $first_txn->product_id = $sub->product_id; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | // Transaction number. |
| 160 | 160 | $trans_num = $payment->get_transaction_id(); |
| 161 | 161 | |
| 162 | - if ( empty( $trans_num ) ) { |
|
| 162 | + if (empty($trans_num)) { |
|
| 163 | 163 | $trans_num = uniqid(); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -175,27 +175,27 @@ discard block |
||
| 175 | 175 | $txn->status = MeprTransaction::$pending_str; |
| 176 | 176 | $txn->subscription_id = $sub->id; |
| 177 | 177 | |
| 178 | - $txn->set_gross( $payment->get_amount()->get_amount() ); |
|
| 178 | + $txn->set_gross($payment->get_amount()->get_amount()); |
|
| 179 | 179 | |
| 180 | 180 | $txn->store(); |
| 181 | 181 | |
| 182 | - update_post_meta( $payment->get_id(), '_pronamic_payment_source_id', $txn->id ); |
|
| 182 | + update_post_meta($payment->get_id(), '_pronamic_payment_source_id', $txn->id); |
|
| 183 | 183 | |
| 184 | 184 | $transaction = $txn; |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $should_update = ! MemberPress::transaction_has_status( $transaction, array( |
|
| 188 | + $should_update = ! MemberPress::transaction_has_status($transaction, array( |
|
| 189 | 189 | MeprTransaction::$failed_str, |
| 190 | 190 | MeprTransaction::$complete_str, |
| 191 | - ) ); |
|
| 191 | + )); |
|
| 192 | 192 | |
| 193 | - if ( $should_update ) { |
|
| 193 | + if ($should_update) { |
|
| 194 | 194 | $gateway = new Gateway(); |
| 195 | 195 | |
| 196 | 196 | $gateway->mp_txn = $transaction; |
| 197 | 197 | |
| 198 | - switch ( $payment->get_status() ) { |
|
| 198 | + switch ($payment->get_status()) { |
|
| 199 | 199 | case Statuses::CANCELLED: |
| 200 | 200 | case Statuses::EXPIRED: |
| 201 | 201 | case Statuses::FAILURE: |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | break; |
| 205 | 205 | case Statuses::SUCCESS: |
| 206 | - if ( $payment->get_recurring() ) { |
|
| 206 | + if ($payment->get_recurring()) { |
|
| 207 | 207 | $gateway->record_subscription_payment(); |
| 208 | 208 | } else { |
| 209 | 209 | $gateway->record_payment(); |
@@ -222,25 +222,25 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param int $subscription_id MemberPress subscription id. |
| 224 | 224 | */ |
| 225 | - public function subscription_pre_delete( $subscription_id ) { |
|
| 226 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_memberpress_subscription_id', $subscription_id ); |
|
| 225 | + public function subscription_pre_delete($subscription_id) { |
|
| 226 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_memberpress_subscription_id', $subscription_id); |
|
| 227 | 227 | |
| 228 | - if ( ! $subscription ) { |
|
| 228 | + if ( ! $subscription) { |
|
| 229 | 229 | return; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Add note. |
| 233 | 233 | $note = sprintf( |
| 234 | 234 | /* translators: %s: MemberPress */ |
| 235 | - __( '%s subscription deleted.', 'pronamic_ideal' ), |
|
| 236 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 235 | + __('%s subscription deleted.', 'pronamic_ideal'), |
|
| 236 | + __('MemberPress', 'pronamic_ideal') |
|
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - $subscription->add_note( $note ); |
|
| 239 | + $subscription->add_note($note); |
|
| 240 | 240 | |
| 241 | 241 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 242 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 243 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 242 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 243 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 244 | 244 | |
| 245 | 245 | $subscription->save(); |
| 246 | 246 | } |
@@ -254,18 +254,18 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return string |
| 256 | 256 | */ |
| 257 | - public static function source_text( $text, Payment $payment ) { |
|
| 258 | - $text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />'; |
|
| 257 | + public static function source_text($text, Payment $payment) { |
|
| 258 | + $text = __('MemberPress', 'pronamic_ideal') . '<br />'; |
|
| 259 | 259 | |
| 260 | 260 | $text .= sprintf( |
| 261 | 261 | '<a href="%s">%s</a>', |
| 262 | - add_query_arg( array( |
|
| 262 | + add_query_arg(array( |
|
| 263 | 263 | 'page' => 'memberpress-trans', |
| 264 | 264 | 'action' => 'edit', |
| 265 | 265 | 'id' => $payment->source_id, |
| 266 | - ), admin_url( 'admin.php' ) ), |
|
| 266 | + ), admin_url('admin.php')), |
|
| 267 | 267 | /* translators: %s: payment source id */ |
| 268 | - sprintf( __( 'Transaction %s', 'pronamic_ideal' ), $payment->source_id ) |
|
| 268 | + sprintf(__('Transaction %s', 'pronamic_ideal'), $payment->source_id) |
|
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | 271 | return $text; |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | - public static function source_description( $description, Payment $payment ) { |
|
| 283 | - return __( 'MemberPress Transaction', 'pronamic_ideal' ); |
|
| 282 | + public static function source_description($description, Payment $payment) { |
|
| 283 | + return __('MemberPress Transaction', 'pronamic_ideal'); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return string |
| 293 | 293 | */ |
| 294 | - public static function source_url( $url, Payment $payment ) { |
|
| 295 | - $url = add_query_arg( array( |
|
| 294 | + public static function source_url($url, Payment $payment) { |
|
| 295 | + $url = add_query_arg(array( |
|
| 296 | 296 | 'page' => 'memberpress-trans', |
| 297 | 297 | 'action' => 'edit', |
| 298 | 298 | 'id' => $payment->source_id, |
| 299 | - ), admin_url( 'admin.php' ) ); |
|
| 299 | + ), admin_url('admin.php')); |
|
| 300 | 300 | |
| 301 | 301 | return $url; |
| 302 | 302 | } |