@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // Set the name of this gateway. |
| 57 | 57 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13. |
| 58 | - $this->name = __( 'Pronamic', 'pronamic_ideal' ); |
|
| 58 | + $this->name = __('Pronamic', 'pronamic_ideal'); |
|
| 59 | 59 | |
| 60 | - if ( ! empty( $this->payment_method ) ) { |
|
| 61 | - $this->name = PaymentMethods::get_name( $this->payment_method ); |
|
| 60 | + if ( ! empty($this->payment_method)) { |
|
| 61 | + $this->name = PaymentMethods::get_name($this->payment_method); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Set the default settings. |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param array $settings MemberPress gateway settings array. |
| 82 | 82 | */ |
| 83 | - public function load( $settings ) { |
|
| 83 | + public function load($settings) { |
|
| 84 | 84 | $this->settings = (object) $settings; |
| 85 | 85 | |
| 86 | 86 | $this->set_defaults(); |
@@ -97,19 +97,19 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return mixed |
| 99 | 99 | */ |
| 100 | - public function send_transaction_notices( $transaction, $method ) { |
|
| 100 | + public function send_transaction_notices($transaction, $method) { |
|
| 101 | 101 | $class = 'MeprUtils'; |
| 102 | 102 | |
| 103 | - if ( ! Core_Util::class_method_exists( $class, $method ) ) { |
|
| 103 | + if ( ! Core_Util::class_method_exists($class, $method)) { |
|
| 104 | 104 | $class = $this; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) { |
|
| 107 | + if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) { |
|
| 108 | 108 | // `send_product_welcome_notices` is called from `send_signup_notices` in newer versions. |
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return call_user_func( array( $class, $method ), $transaction ); |
|
| 112 | + return call_user_func(array($class, $method), $transaction); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73 |
| 138 | 138 | */ |
| 139 | 139 | protected function set_defaults() { |
| 140 | - if ( ! isset( $this->settings ) ) { |
|
| 140 | + if ( ! isset($this->settings)) { |
|
| 141 | 141 | $this->settings = array(); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122 |
| 177 | 177 | */ |
| 178 | - public function process_payment( $txn ) { |
|
| 178 | + public function process_payment($txn) { |
|
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $subscription = $transaction->subscription(); |
| 194 | 194 | |
| 195 | - if ( $subscription ) { |
|
| 196 | - if ( MeprSubscription::$active_str !== $subscription->status ) { |
|
| 195 | + if ($subscription) { |
|
| 196 | + if (MeprSubscription::$active_str !== $subscription->status) { |
|
| 197 | 197 | $subscription->status = MeprSubscription::$active_str; |
| 198 | 198 | $subscription->store(); |
| 199 | 199 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $subscription->limit_payment_cycles(); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 204 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 205 | 205 | |
| 206 | 206 | return $transaction; |
| 207 | 207 | } |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | // Expire associated transactions for subscription. |
| 222 | 222 | $subscription = $transaction->subscription(); |
| 223 | 223 | |
| 224 | - if ( $subscription ) { |
|
| 224 | + if ($subscription) { |
|
| 225 | 225 | $subscription->expire_txns(); |
| 226 | 226 | $subscription->store(); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $this->send_transaction_notices( $transaction, 'send_failed_txn_notices' ); |
|
| 229 | + $this->send_transaction_notices($transaction, 'send_failed_txn_notices'); |
|
| 230 | 230 | |
| 231 | 231 | return $transaction; |
| 232 | 232 | } |
@@ -250,17 +250,17 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $subscription = $transaction->subscription(); |
| 252 | 252 | |
| 253 | - if ( $subscription ) { |
|
| 253 | + if ($subscription) { |
|
| 254 | 254 | $subscription->status = MeprSubscription::$active_str; |
| 255 | 255 | $subscription->created_at = $transaction->created_at; |
| 256 | 256 | $subscription->store(); |
| 257 | 257 | |
| 258 | 258 | // Set subscription first transaction id meta. |
| 259 | - $pronamic_subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription->first_txn_id ); |
|
| 259 | + $pronamic_subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription->first_txn_id); |
|
| 260 | 260 | |
| 261 | - if ( $pronamic_subscription ) { |
|
| 261 | + if ($pronamic_subscription) { |
|
| 262 | 262 | // Store MemberPress subscription id to be able to cancel subscription on delete. |
| 263 | - $pronamic_subscription->set_meta( 'memberpress_subscription_id', $subscription->id ); |
|
| 263 | + $pronamic_subscription->set_meta('memberpress_subscription_id', $subscription->id); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619 |
| 273 | 273 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51 |
| 274 | 274 | */ |
| 275 | - $reflection = new ReflectionClass( 'MeprBaseRealGateway' ); |
|
| 275 | + $reflection = new ReflectionClass('MeprBaseRealGateway'); |
|
| 276 | 276 | |
| 277 | - if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) { |
|
| 277 | + if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) { |
|
| 278 | 278 | $uemail = MeprEmailFactory::fetch( |
| 279 | 279 | 'MeprUserProductWelcomeEmail', |
| 280 | 280 | 'MeprBaseProductEmail', |
@@ -292,24 +292,24 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | $this->send_product_welcome_notices( |
| 294 | 294 | $uemail, |
| 295 | - MeprTransactionsHelper::get_email_params( $transaction ), |
|
| 295 | + MeprTransactionsHelper::get_email_params($transaction), |
|
| 296 | 296 | $transaction->user() |
| 297 | 297 | ); |
| 298 | 298 | } else { |
| 299 | - $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); |
|
| 299 | + $this->send_transaction_notices($transaction, 'send_product_welcome_notices'); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Send upgrade/downgrade notices. |
| 303 | - if ( $upgrade ) { |
|
| 304 | - $this->upgraded_sub( $transaction ); |
|
| 305 | - $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); |
|
| 306 | - } elseif ( $downgrade ) { |
|
| 307 | - $this->downgraded_sub( $transaction ); |
|
| 308 | - $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); |
|
| 303 | + if ($upgrade) { |
|
| 304 | + $this->upgraded_sub($transaction); |
|
| 305 | + $this->send_transaction_notices($transaction, 'send_upgraded_txn_notices'); |
|
| 306 | + } elseif ($downgrade) { |
|
| 307 | + $this->downgraded_sub($transaction); |
|
| 308 | + $this->send_transaction_notices($transaction, 'send_downgraded_txn_notices'); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $this->send_transaction_notices( $transaction, 'send_signup_notices' ); |
|
| 312 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 311 | + $this->send_transaction_notices($transaction, 'send_signup_notices'); |
|
| 312 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 313 | 313 | |
| 314 | 314 | return $transaction; |
| 315 | 315 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 |
| 323 | 323 | */ |
| 324 | - public function process_refund( MeprTransaction $txn ) { |
|
| 324 | + public function process_refund(MeprTransaction $txn) { |
|
| 325 | 325 | |
| 326 | 326 | } |
| 327 | 327 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * |
| 342 | 342 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 343 | 343 | */ |
| 344 | - public function process_trial_payment( $transaction ) { |
|
| 344 | + public function process_trial_payment($transaction) { |
|
| 345 | 345 | |
| 346 | 346 | } |
| 347 | 347 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 354 | 354 | */ |
| 355 | - public function record_trial_payment( $transaction ) { |
|
| 355 | + public function record_trial_payment($transaction) { |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @param MeprTransaction $txn MemberPress transaction object. |
| 365 | 365 | */ |
| 366 | - public function process_create_subscription( $txn ) { |
|
| 366 | + public function process_create_subscription($txn) { |
|
| 367 | 367 | |
| 368 | 368 | } |
| 369 | 369 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @param int $sub_id Subscription ID. |
| 386 | 386 | */ |
| 387 | - public function process_update_subscription( $sub_id ) { |
|
| 387 | + public function process_update_subscription($sub_id) { |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 |
| 406 | 406 | */ |
| 407 | - public function process_suspend_subscription( $sub_id ) { |
|
| 408 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 407 | + public function process_suspend_subscription($sub_id) { |
|
| 408 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 409 | 409 | return; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $sub = new MeprSubscription( $sub_id ); |
|
| 412 | + $sub = new MeprSubscription($sub_id); |
|
| 413 | 413 | |
| 414 | - if ( MeprSubscription::$suspended_str === $sub->status ) { |
|
| 414 | + if (MeprSubscription::$suspended_str === $sub->status) { |
|
| 415 | 415 | // Subscription is already suspended. |
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 419 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 420 | 420 | |
| 421 | - if ( ! $subscription ) { |
|
| 421 | + if ( ! $subscription) { |
|
| 422 | 422 | return; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -427,19 +427,19 @@ discard block |
||
| 427 | 427 | $sub->store(); |
| 428 | 428 | |
| 429 | 429 | // Send suspended subscription notices. |
| 430 | - MeprUtils::send_suspended_sub_notices( $sub ); |
|
| 430 | + MeprUtils::send_suspended_sub_notices($sub); |
|
| 431 | 431 | |
| 432 | 432 | $note = sprintf( |
| 433 | 433 | /* translators: %s: MemberPress */ |
| 434 | - __( '%s subscription on hold.', 'pronamic_ideal' ), |
|
| 435 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 434 | + __('%s subscription on hold.', 'pronamic_ideal'), |
|
| 435 | + __('MemberPress', 'pronamic_ideal') |
|
| 436 | 436 | ); |
| 437 | 437 | |
| 438 | - $subscription->add_note( $note ); |
|
| 438 | + $subscription->add_note($note); |
|
| 439 | 439 | |
| 440 | 440 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 441 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 442 | - $subscription->set_status( Statuses::OPEN ); |
|
| 441 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 442 | + $subscription->set_status(Statuses::OPEN); |
|
| 443 | 443 | |
| 444 | 444 | $subscription->save(); |
| 445 | 445 | } |
@@ -461,21 +461,21 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 |
| 463 | 463 | */ |
| 464 | - public function process_resume_subscription( $sub_id ) { |
|
| 465 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 464 | + public function process_resume_subscription($sub_id) { |
|
| 465 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - $sub = new MeprSubscription( $sub_id ); |
|
| 469 | + $sub = new MeprSubscription($sub_id); |
|
| 470 | 470 | |
| 471 | - if ( MeprSubscription::$active_str === $sub->status ) { |
|
| 471 | + if (MeprSubscription::$active_str === $sub->status) { |
|
| 472 | 472 | // Subscription is already active. |
| 473 | 473 | return; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 476 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 477 | 477 | |
| 478 | - if ( ! $subscription ) { |
|
| 478 | + if ( ! $subscription) { |
|
| 479 | 479 | return; |
| 480 | 480 | } |
| 481 | 481 | |
@@ -486,35 +486,35 @@ discard block |
||
| 486 | 486 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. |
| 487 | 487 | $prior_txn = $sub->latest_txn(); |
| 488 | 488 | |
| 489 | - if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { |
|
| 489 | + if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) { |
|
| 490 | 490 | $txn = new MeprTransaction(); |
| 491 | 491 | $txn->subscription_id = $sub->id; |
| 492 | 492 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); |
| 493 | 493 | $txn->status = MeprTransaction::$confirmed_str; |
| 494 | 494 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 495 | 495 | $txn->response = (string) $sub; |
| 496 | - $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); |
|
| 496 | + $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59'); |
|
| 497 | 497 | |
| 498 | - $txn->set_subtotal( 0.00 ); // Just a confirmation txn. |
|
| 498 | + $txn->set_subtotal(0.00); // Just a confirmation txn. |
|
| 499 | 499 | |
| 500 | 500 | $txn->store(); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // Send resumed subscription notices. |
| 504 | - MeprUtils::send_resumed_sub_notices( $sub ); |
|
| 504 | + MeprUtils::send_resumed_sub_notices($sub); |
|
| 505 | 505 | |
| 506 | 506 | // Add note. |
| 507 | 507 | $note = sprintf( |
| 508 | 508 | /* translators: %s: MemberPress */ |
| 509 | - __( '%s subscription reactivated.', 'pronamic_ideal' ), |
|
| 510 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 509 | + __('%s subscription reactivated.', 'pronamic_ideal'), |
|
| 510 | + __('MemberPress', 'pronamic_ideal') |
|
| 511 | 511 | ); |
| 512 | 512 | |
| 513 | - $subscription->add_note( $note ); |
|
| 513 | + $subscription->add_note($note); |
|
| 514 | 514 | |
| 515 | 515 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 516 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 517 | - $subscription->set_status( Statuses::ACTIVE ); |
|
| 516 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 517 | + $subscription->set_status(Statuses::ACTIVE); |
|
| 518 | 518 | |
| 519 | 519 | $subscription->save(); |
| 520 | 520 | } |
@@ -536,21 +536,21 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 |
| 538 | 538 | */ |
| 539 | - public function process_cancel_subscription( $sub_id ) { |
|
| 540 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 539 | + public function process_cancel_subscription($sub_id) { |
|
| 540 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 541 | 541 | return; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - $sub = new MeprSubscription( $sub_id ); |
|
| 544 | + $sub = new MeprSubscription($sub_id); |
|
| 545 | 545 | |
| 546 | - if ( MeprSubscription::$cancelled_str === $sub->status ) { |
|
| 546 | + if (MeprSubscription::$cancelled_str === $sub->status) { |
|
| 547 | 547 | // Subscription is already cancelled. |
| 548 | 548 | return; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 551 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 552 | 552 | |
| 553 | - if ( ! $subscription ) { |
|
| 553 | + if ( ! $subscription) { |
|
| 554 | 554 | return; |
| 555 | 555 | } |
| 556 | 556 | |
@@ -559,27 +559,27 @@ discard block |
||
| 559 | 559 | $sub->store(); |
| 560 | 560 | |
| 561 | 561 | // Expire the grace period (confirmation) if no completed payments have come through. |
| 562 | - if ( (int) $sub->txn_count <= 0 ) { |
|
| 562 | + if ((int) $sub->txn_count <= 0) { |
|
| 563 | 563 | $sub->expire_txns(); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | $sub->limit_reached_actions(); |
| 567 | 567 | |
| 568 | 568 | // Send cancelled subscription notices. |
| 569 | - MeprUtils::send_cancelled_sub_notices( $sub ); |
|
| 569 | + MeprUtils::send_cancelled_sub_notices($sub); |
|
| 570 | 570 | |
| 571 | 571 | // Add note. |
| 572 | 572 | $note = sprintf( |
| 573 | 573 | /* translators: %s: MemberPress */ |
| 574 | - __( '%s subscription cancelled.', 'pronamic_ideal' ), |
|
| 575 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 574 | + __('%s subscription cancelled.', 'pronamic_ideal'), |
|
| 575 | + __('MemberPress', 'pronamic_ideal') |
|
| 576 | 576 | ); |
| 577 | 577 | |
| 578 | - $subscription->add_note( $note ); |
|
| 578 | + $subscription->add_note($note); |
|
| 579 | 579 | |
| 580 | 580 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 581 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 582 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 581 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 582 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 583 | 583 | |
| 584 | 584 | $subscription->save(); |
| 585 | 585 | } |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | * |
| 607 | 607 | * @param MeprTransaction $txn MemberPress transaction object. |
| 608 | 608 | */ |
| 609 | - public function process_signup_form( $txn ) { |
|
| 609 | + public function process_signup_form($txn) { |
|
| 610 | 610 | |
| 611 | 611 | } |
| 612 | 612 | |
@@ -617,28 +617,28 @@ discard block |
||
| 617 | 617 | * |
| 618 | 618 | * @param MeprTransaction $txn MemberPress transaction object. |
| 619 | 619 | */ |
| 620 | - public function payment_redirect( $txn ) { |
|
| 621 | - $txn = new MeprTransaction( $txn->id ); |
|
| 620 | + public function payment_redirect($txn) { |
|
| 621 | + $txn = new MeprTransaction($txn->id); |
|
| 622 | 622 | |
| 623 | 623 | // Gateway. |
| 624 | 624 | $config_id = $this->settings->config_id; |
| 625 | 625 | |
| 626 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 626 | + $gateway = Plugin::get_gateway($config_id); |
|
| 627 | 627 | |
| 628 | - if ( ! $gateway ) { |
|
| 628 | + if ( ! $gateway) { |
|
| 629 | 629 | return; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Data. |
| 633 | - $data = new PaymentData( $txn ); |
|
| 633 | + $data = new PaymentData($txn); |
|
| 634 | 634 | |
| 635 | - $payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method ); |
|
| 635 | + $payment = Plugin::start($config_id, $gateway, $data, $this->payment_method); |
|
| 636 | 636 | |
| 637 | 637 | $error = $gateway->get_error(); |
| 638 | 638 | |
| 639 | - if ( ! is_wp_error( $error ) ) { |
|
| 639 | + if ( ! is_wp_error($error)) { |
|
| 640 | 640 | // Redirect. |
| 641 | - $gateway->redirect( $payment ); |
|
| 641 | + $gateway->redirect($payment); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
@@ -651,14 +651,14 @@ discard block |
||
| 651 | 651 | * |
| 652 | 652 | * @param MeprTransaction $txn MemberPress transaction object. |
| 653 | 653 | */ |
| 654 | - public function display_payment_page( $txn ) { |
|
| 654 | + public function display_payment_page($txn) { |
|
| 655 | 655 | // Gateway. |
| 656 | 656 | $config_id = $this->settings->config_id; |
| 657 | 657 | |
| 658 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 658 | + $gateway = Plugin::get_gateway($config_id); |
|
| 659 | 659 | |
| 660 | - if ( $gateway && '' === $gateway->get_input_html() ) { |
|
| 661 | - $this->payment_redirect( $txn ); |
|
| 660 | + if ($gateway && '' === $gateway->get_input_html()) { |
|
| 661 | + $this->payment_redirect($txn); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | |
@@ -672,18 +672,18 @@ discard block |
||
| 672 | 672 | * @param MeprTransaction $txn MemberPress transaction object. |
| 673 | 673 | * @return bool |
| 674 | 674 | */ |
| 675 | - public function process_payment_form( $txn ) { |
|
| 676 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
|
| 675 | + public function process_payment_form($txn) { |
|
| 676 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) { |
|
| 677 | 677 | return false; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | // Gateway. |
| 681 | 681 | $config_id = $this->settings->config_id; |
| 682 | 682 | |
| 683 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 683 | + $gateway = Plugin::get_gateway($config_id); |
|
| 684 | 684 | |
| 685 | - if ( $gateway ) { |
|
| 686 | - $this->payment_redirect( $txn ); |
|
| 685 | + if ($gateway) { |
|
| 686 | + $this->payment_redirect($txn); |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
@@ -711,20 +711,20 @@ discard block |
||
| 711 | 711 | * @param int $product_id Product ID. |
| 712 | 712 | * @param int $txn_id Transaction ID. |
| 713 | 713 | */ |
| 714 | - public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
|
| 715 | - $product = new MeprProduct( $product_id ); |
|
| 714 | + public function display_payment_form($amount, $user, $product_id, $txn_id) { |
|
| 715 | + $product = new MeprProduct($product_id); |
|
| 716 | 716 | |
| 717 | 717 | $coupon = false; |
| 718 | 718 | |
| 719 | - $txn = new MeprTransaction( $txn_id ); |
|
| 719 | + $txn = new MeprTransaction($txn_id); |
|
| 720 | 720 | |
| 721 | 721 | // Artifically set the price of the $prd in case a coupon was used. |
| 722 | - if ( $product->price !== $amount ) { |
|
| 722 | + if ($product->price !== $amount) { |
|
| 723 | 723 | $coupon = true; |
| 724 | 724 | $product->price = $amount; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
|
| 727 | + $invoice = MeprTransactionsHelper::get_invoice($txn); |
|
| 728 | 728 | |
| 729 | 729 | echo $invoice; // WPCS: XSS ok. |
| 730 | 730 | |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | <div class="mp_wrapper mp_payment_form_wrapper"> |
| 733 | 733 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
| 734 | 734 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
| 735 | - <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
|
| 735 | + <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/> |
|
| 736 | 736 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
| 737 | 737 | |
| 738 | 738 | <div class="mepr_spacer"> </div> |
@@ -742,9 +742,9 @@ discard block |
||
| 742 | 742 | // Gateway. |
| 743 | 743 | $config_id = $this->settings->config_id; |
| 744 | 744 | |
| 745 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 745 | + $gateway = Plugin::get_gateway($config_id); |
|
| 746 | 746 | |
| 747 | - if ( $gateway ) { |
|
| 747 | + if ($gateway) { |
|
| 748 | 748 | echo $gateway->get_input_html(); // WPCS: XSS ok. |
| 749 | 749 | } |
| 750 | 750 | |
@@ -752,13 +752,13 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | <div class="mepr_spacer"> </div> |
| 754 | 754 | |
| 755 | - <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
|
| 756 | - <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 757 | - <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
|
| 755 | + <input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/> |
|
| 756 | + <img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 757 | + <?php MeprView::render('/shared/has_errors', get_defined_vars()); ?> |
|
| 758 | 758 | |
| 759 | 759 | <noscript> |
| 760 | 760 | <p class="mepr_nojs"> |
| 761 | - <?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 | + <?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'); ?> |
|
| 762 | 762 | </p> |
| 763 | 763 | </noscript> |
| 764 | 764 | </form> |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | * @param array $errors Array with errors. |
| 777 | 777 | * @return array |
| 778 | 778 | */ |
| 779 | - public function validate_payment_form( $errors ) { |
|
| 779 | + public function validate_payment_form($errors) { |
|
| 780 | 780 | return $errors; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -803,18 +803,18 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | ?> |
| 805 | 805 | <td> |
| 806 | - <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
|
| 806 | + <?php esc_html_e('Configuration', 'pronamic_ideal'); ?> |
|
| 807 | 807 | </td> |
| 808 | 808 | <td> |
| 809 | - <select name="<?php echo esc_attr( $name ); ?>"> |
|
| 809 | + <select name="<?php echo esc_attr($name); ?>"> |
|
| 810 | 810 | <?php |
| 811 | 811 | |
| 812 | - foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
|
| 812 | + foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) { |
|
| 813 | 813 | printf( |
| 814 | 814 | '<option value="%s" %s>%s</option>', |
| 815 | - esc_attr( $value ), |
|
| 816 | - selected( $value, $this->settings->config_id, false ), |
|
| 817 | - esc_html( $label ) |
|
| 815 | + esc_attr($value), |
|
| 816 | + selected($value, $this->settings->config_id, false), |
|
| 817 | + esc_html($label) |
|
| 818 | 818 | ); |
| 819 | 819 | } |
| 820 | 820 | |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | * @param array $errors Array with errors. |
| 837 | 837 | * @return array |
| 838 | 838 | */ |
| 839 | - public function validate_options_form( $errors ) { |
|
| 839 | + public function validate_options_form($errors) { |
|
| 840 | 840 | return $errors; |
| 841 | 841 | } |
| 842 | 842 | |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
| 862 | 862 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
| 863 | 863 | */ |
| 864 | - public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
|
| 864 | + public function display_update_account_form($sub_id, $errors = array(), $message = '') { |
|
| 865 | 865 | |
| 866 | 866 | } |
| 867 | 867 | |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @param array $errors Array with errors. |
| 875 | 875 | * @return array |
| 876 | 876 | */ |
| 877 | - public function validate_update_account_form( $errors = array() ) { |
|
| 877 | + public function validate_update_account_form($errors = array()) { |
|
| 878 | 878 | return $errors; |
| 879 | 879 | } |
| 880 | 880 | |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | * |
| 887 | 887 | * @param int $sub_id Subscription ID. |
| 888 | 888 | */ |
| 889 | - public function process_update_account_form( $sub_id ) { |
|
| 889 | + public function process_update_account_form($sub_id) { |
|
| 890 | 890 | |
| 891 | 891 | } |
| 892 | 892 | |