@@ -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', |
@@ -287,24 +287,24 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | $this->send_product_welcome_notices( |
| 289 | 289 | $uemail, |
| 290 | - MeprTransactionsHelper::get_email_params( $transaction ), |
|
| 290 | + MeprTransactionsHelper::get_email_params($transaction), |
|
| 291 | 291 | $transaction->user() |
| 292 | 292 | ); |
| 293 | 293 | } else { |
| 294 | - $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); |
|
| 294 | + $this->send_transaction_notices($transaction, 'send_product_welcome_notices'); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // Send upgrade/downgrade notices. |
| 298 | - if ( $upgrade ) { |
|
| 299 | - $this->upgraded_sub( $transaction ); |
|
| 300 | - $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); |
|
| 301 | - } elseif ( $downgrade ) { |
|
| 302 | - $this->downgraded_sub( $transaction ); |
|
| 303 | - $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); |
|
| 298 | + if ($upgrade) { |
|
| 299 | + $this->upgraded_sub($transaction); |
|
| 300 | + $this->send_transaction_notices($transaction, 'send_upgraded_txn_notices'); |
|
| 301 | + } elseif ($downgrade) { |
|
| 302 | + $this->downgraded_sub($transaction); |
|
| 303 | + $this->send_transaction_notices($transaction, 'send_downgraded_txn_notices'); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $this->send_transaction_notices( $transaction, 'send_signup_notices' ); |
|
| 307 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 306 | + $this->send_transaction_notices($transaction, 'send_signup_notices'); |
|
| 307 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 308 | 308 | |
| 309 | 309 | return $transaction; |
| 310 | 310 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 |
| 318 | 318 | */ |
| 319 | - public function process_refund( MeprTransaction $txn ) { |
|
| 319 | + public function process_refund(MeprTransaction $txn) { |
|
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 338 | 338 | */ |
| 339 | - public function process_trial_payment( $transaction ) { |
|
| 339 | + public function process_trial_payment($transaction) { |
|
| 340 | 340 | |
| 341 | 341 | } |
| 342 | 342 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * |
| 348 | 348 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 349 | 349 | */ |
| 350 | - public function record_trial_payment( $transaction ) { |
|
| 350 | + public function record_trial_payment($transaction) { |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @param MeprTransaction $txn MemberPress transaction object. |
| 360 | 360 | */ |
| 361 | - public function process_create_subscription( $txn ) { |
|
| 361 | + public function process_create_subscription($txn) { |
|
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * |
| 380 | 380 | * @param int $sub_id Subscription ID. |
| 381 | 381 | */ |
| 382 | - public function process_update_subscription( $sub_id ) { |
|
| 382 | + public function process_update_subscription($sub_id) { |
|
| 383 | 383 | |
| 384 | 384 | } |
| 385 | 385 | |
@@ -399,21 +399,21 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 |
| 401 | 401 | */ |
| 402 | - public function process_suspend_subscription( $sub_id ) { |
|
| 403 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 402 | + public function process_suspend_subscription($sub_id) { |
|
| 403 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - $sub = new MeprSubscription( $sub_id ); |
|
| 407 | + $sub = new MeprSubscription($sub_id); |
|
| 408 | 408 | |
| 409 | - if ( MeprSubscription::$suspended_str === $sub->status ) { |
|
| 409 | + if (MeprSubscription::$suspended_str === $sub->status) { |
|
| 410 | 410 | // Subscription is already suspended. |
| 411 | 411 | return; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 414 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 415 | 415 | |
| 416 | - if ( ! $subscription ) { |
|
| 416 | + if ( ! $subscription) { |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | |
@@ -422,19 +422,19 @@ discard block |
||
| 422 | 422 | $sub->store(); |
| 423 | 423 | |
| 424 | 424 | // Send suspended subscription notices. |
| 425 | - MeprUtils::send_suspended_sub_notices( $sub ); |
|
| 425 | + MeprUtils::send_suspended_sub_notices($sub); |
|
| 426 | 426 | |
| 427 | 427 | $note = sprintf( |
| 428 | 428 | /* translators: %s: MemberPress */ |
| 429 | - __( '%s subscription on hold.', 'pronamic_ideal' ), |
|
| 430 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 429 | + __('%s subscription on hold.', 'pronamic_ideal'), |
|
| 430 | + __('MemberPress', 'pronamic_ideal') |
|
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | - $subscription->add_note( $note ); |
|
| 433 | + $subscription->add_note($note); |
|
| 434 | 434 | |
| 435 | 435 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 436 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 437 | - $subscription->set_status( Statuses::OPEN ); |
|
| 436 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 437 | + $subscription->set_status(Statuses::OPEN); |
|
| 438 | 438 | |
| 439 | 439 | $subscription->save(); |
| 440 | 440 | } |
@@ -456,21 +456,21 @@ discard block |
||
| 456 | 456 | * |
| 457 | 457 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 |
| 458 | 458 | */ |
| 459 | - public function process_resume_subscription( $sub_id ) { |
|
| 460 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 459 | + public function process_resume_subscription($sub_id) { |
|
| 460 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 461 | 461 | return; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $sub = new MeprSubscription( $sub_id ); |
|
| 464 | + $sub = new MeprSubscription($sub_id); |
|
| 465 | 465 | |
| 466 | - if ( MeprSubscription::$active_str === $sub->status ) { |
|
| 466 | + if (MeprSubscription::$active_str === $sub->status) { |
|
| 467 | 467 | // Subscription is already active. |
| 468 | 468 | return; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 471 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 472 | 472 | |
| 473 | - if ( ! $subscription ) { |
|
| 473 | + if ( ! $subscription) { |
|
| 474 | 474 | return; |
| 475 | 475 | } |
| 476 | 476 | |
@@ -481,35 +481,35 @@ discard block |
||
| 481 | 481 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. |
| 482 | 482 | $prior_txn = $sub->latest_txn(); |
| 483 | 483 | |
| 484 | - if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { |
|
| 484 | + if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) { |
|
| 485 | 485 | $txn = new MeprTransaction(); |
| 486 | 486 | $txn->subscription_id = $sub->id; |
| 487 | 487 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); |
| 488 | 488 | $txn->status = MeprTransaction::$confirmed_str; |
| 489 | 489 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 490 | 490 | $txn->response = (string) $sub; |
| 491 | - $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); |
|
| 491 | + $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59'); |
|
| 492 | 492 | |
| 493 | - $txn->set_subtotal( 0.00 ); // Just a confirmation txn. |
|
| 493 | + $txn->set_subtotal(0.00); // Just a confirmation txn. |
|
| 494 | 494 | |
| 495 | 495 | $txn->store(); |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | // Send resumed subscription notices. |
| 499 | - MeprUtils::send_resumed_sub_notices( $sub ); |
|
| 499 | + MeprUtils::send_resumed_sub_notices($sub); |
|
| 500 | 500 | |
| 501 | 501 | // Add note. |
| 502 | 502 | $note = sprintf( |
| 503 | 503 | /* translators: %s: MemberPress */ |
| 504 | - __( '%s subscription reactivated.', 'pronamic_ideal' ), |
|
| 505 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 504 | + __('%s subscription reactivated.', 'pronamic_ideal'), |
|
| 505 | + __('MemberPress', 'pronamic_ideal') |
|
| 506 | 506 | ); |
| 507 | 507 | |
| 508 | - $subscription->add_note( $note ); |
|
| 508 | + $subscription->add_note($note); |
|
| 509 | 509 | |
| 510 | 510 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 511 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 512 | - $subscription->set_status( Statuses::ACTIVE ); |
|
| 511 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 512 | + $subscription->set_status(Statuses::ACTIVE); |
|
| 513 | 513 | |
| 514 | 514 | $subscription->save(); |
| 515 | 515 | } |
@@ -531,21 +531,21 @@ discard block |
||
| 531 | 531 | * |
| 532 | 532 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 |
| 533 | 533 | */ |
| 534 | - public function process_cancel_subscription( $sub_id ) { |
|
| 535 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 534 | + public function process_cancel_subscription($sub_id) { |
|
| 535 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 536 | 536 | return; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $sub = new MeprSubscription( $sub_id ); |
|
| 539 | + $sub = new MeprSubscription($sub_id); |
|
| 540 | 540 | |
| 541 | - if ( MeprSubscription::$cancelled_str === $sub->status ) { |
|
| 541 | + if (MeprSubscription::$cancelled_str === $sub->status) { |
|
| 542 | 542 | // Subscription is already cancelled. |
| 543 | 543 | return; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id ); |
|
| 546 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id); |
|
| 547 | 547 | |
| 548 | - if ( ! $subscription ) { |
|
| 548 | + if ( ! $subscription) { |
|
| 549 | 549 | return; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -554,27 +554,27 @@ discard block |
||
| 554 | 554 | $sub->store(); |
| 555 | 555 | |
| 556 | 556 | // Expire the grace period (confirmation) if no completed payments have come through. |
| 557 | - if ( (int) $sub->txn_count <= 0 ) { |
|
| 557 | + if ((int) $sub->txn_count <= 0) { |
|
| 558 | 558 | $sub->expire_txns(); |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | $sub->limit_reached_actions(); |
| 562 | 562 | |
| 563 | 563 | // Send cancelled subscription notices. |
| 564 | - MeprUtils::send_cancelled_sub_notices( $sub ); |
|
| 564 | + MeprUtils::send_cancelled_sub_notices($sub); |
|
| 565 | 565 | |
| 566 | 566 | // Add note. |
| 567 | 567 | $note = sprintf( |
| 568 | 568 | /* translators: %s: MemberPress */ |
| 569 | - __( '%s subscription cancelled.', 'pronamic_ideal' ), |
|
| 570 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 569 | + __('%s subscription cancelled.', 'pronamic_ideal'), |
|
| 570 | + __('MemberPress', 'pronamic_ideal') |
|
| 571 | 571 | ); |
| 572 | 572 | |
| 573 | - $subscription->add_note( $note ); |
|
| 573 | + $subscription->add_note($note); |
|
| 574 | 574 | |
| 575 | 575 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 576 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 577 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 576 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 577 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 578 | 578 | |
| 579 | 579 | $subscription->save(); |
| 580 | 580 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * |
| 602 | 602 | * @param MeprTransaction $txn MemberPress transaction object. |
| 603 | 603 | */ |
| 604 | - public function process_signup_form( $txn ) { |
|
| 604 | + public function process_signup_form($txn) { |
|
| 605 | 605 | |
| 606 | 606 | } |
| 607 | 607 | |
@@ -612,28 +612,28 @@ discard block |
||
| 612 | 612 | * |
| 613 | 613 | * @param MeprTransaction $txn MemberPress transaction object. |
| 614 | 614 | */ |
| 615 | - public function payment_redirect( $txn ) { |
|
| 616 | - $txn = new MeprTransaction( $txn->id ); |
|
| 615 | + public function payment_redirect($txn) { |
|
| 616 | + $txn = new MeprTransaction($txn->id); |
|
| 617 | 617 | |
| 618 | 618 | // Gateway. |
| 619 | 619 | $config_id = $this->settings->config_id; |
| 620 | 620 | |
| 621 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 621 | + $gateway = Plugin::get_gateway($config_id); |
|
| 622 | 622 | |
| 623 | - if ( ! $gateway ) { |
|
| 623 | + if ( ! $gateway) { |
|
| 624 | 624 | return; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // Data. |
| 628 | - $data = new PaymentData( $txn ); |
|
| 628 | + $data = new PaymentData($txn); |
|
| 629 | 629 | |
| 630 | - $payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method ); |
|
| 630 | + $payment = Plugin::start($config_id, $gateway, $data, $this->payment_method); |
|
| 631 | 631 | |
| 632 | 632 | $error = $gateway->get_error(); |
| 633 | 633 | |
| 634 | - if ( ! is_wp_error( $error ) ) { |
|
| 634 | + if ( ! is_wp_error($error)) { |
|
| 635 | 635 | // Redirect. |
| 636 | - $gateway->redirect( $payment ); |
|
| 636 | + $gateway->redirect($payment); |
|
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | |
@@ -647,14 +647,14 @@ discard block |
||
| 647 | 647 | * @param MeprTransaction $txn MemberPress transaction object. |
| 648 | 648 | * @return bool |
| 649 | 649 | */ |
| 650 | - public function display_payment_page( $txn ) { |
|
| 650 | + public function display_payment_page($txn) { |
|
| 651 | 651 | // Gateway. |
| 652 | 652 | $config_id = $this->settings->config_id; |
| 653 | 653 | |
| 654 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 654 | + $gateway = Plugin::get_gateway($config_id); |
|
| 655 | 655 | |
| 656 | - if ( $gateway && '' === $gateway->get_input_html() ) { |
|
| 657 | - $this->payment_redirect( $txn ); |
|
| 656 | + if ($gateway && '' === $gateway->get_input_html()) { |
|
| 657 | + $this->payment_redirect($txn); |
|
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | |
@@ -668,18 +668,18 @@ discard block |
||
| 668 | 668 | * @param MeprTransaction $txn MemberPress transaction object. |
| 669 | 669 | * @return bool |
| 670 | 670 | */ |
| 671 | - public function process_payment_form( $txn ) { |
|
| 672 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
|
| 671 | + public function process_payment_form($txn) { |
|
| 672 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) { |
|
| 673 | 673 | return false; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // Gateway. |
| 677 | 677 | $config_id = $this->settings->config_id; |
| 678 | 678 | |
| 679 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 679 | + $gateway = Plugin::get_gateway($config_id); |
|
| 680 | 680 | |
| 681 | - if ( $gateway ) { |
|
| 682 | - $this->payment_redirect( $txn ); |
|
| 681 | + if ($gateway) { |
|
| 682 | + $this->payment_redirect($txn); |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
@@ -707,20 +707,20 @@ discard block |
||
| 707 | 707 | * @param int $product_id Product ID. |
| 708 | 708 | * @param int $txn_id Transaction ID. |
| 709 | 709 | */ |
| 710 | - public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
|
| 711 | - $product = new MeprProduct( $product_id ); |
|
| 710 | + public function display_payment_form($amount, $user, $product_id, $txn_id) { |
|
| 711 | + $product = new MeprProduct($product_id); |
|
| 712 | 712 | |
| 713 | 713 | $coupon = false; |
| 714 | 714 | |
| 715 | - $txn = new MeprTransaction( $txn_id ); |
|
| 715 | + $txn = new MeprTransaction($txn_id); |
|
| 716 | 716 | |
| 717 | 717 | // Artifically set the price of the $prd in case a coupon was used. |
| 718 | - if ( $product->price !== $amount ) { |
|
| 718 | + if ($product->price !== $amount) { |
|
| 719 | 719 | $coupon = true; |
| 720 | 720 | $product->price = $amount; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
|
| 723 | + $invoice = MeprTransactionsHelper::get_invoice($txn); |
|
| 724 | 724 | |
| 725 | 725 | echo $invoice; // WPCS: XSS ok. |
| 726 | 726 | |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | <div class="mp_wrapper mp_payment_form_wrapper"> |
| 729 | 729 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
| 730 | 730 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
| 731 | - <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
|
| 731 | + <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/> |
|
| 732 | 732 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
| 733 | 733 | |
| 734 | 734 | <div class="mepr_spacer"> </div> |
@@ -738,9 +738,9 @@ discard block |
||
| 738 | 738 | // Gateway. |
| 739 | 739 | $config_id = $this->settings->config_id; |
| 740 | 740 | |
| 741 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 741 | + $gateway = Plugin::get_gateway($config_id); |
|
| 742 | 742 | |
| 743 | - if ( $gateway ) { |
|
| 743 | + if ($gateway) { |
|
| 744 | 744 | echo $gateway->get_input_html(); // WPCS: XSS ok. |
| 745 | 745 | } |
| 746 | 746 | |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | <div class="mepr_spacer"> </div> |
| 750 | 750 | |
| 751 | - <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
|
| 752 | - <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 753 | - <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
|
| 751 | + <input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/> |
|
| 752 | + <img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 753 | + <?php MeprView::render('/shared/has_errors', get_defined_vars()); ?> |
|
| 754 | 754 | |
| 755 | 755 | <noscript> |
| 756 | 756 | <p class="mepr_nojs"> |
| 757 | - <?php esc_html_e( 'JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal' ); ?> |
|
| 757 | + <?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'); ?> |
|
| 758 | 758 | </p> |
| 759 | 759 | </noscript> |
| 760 | 760 | </form> |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * @param array $errors Array with errors. |
| 773 | 773 | * @return array |
| 774 | 774 | */ |
| 775 | - public function validate_payment_form( $errors ) { |
|
| 775 | + public function validate_payment_form($errors) { |
|
| 776 | 776 | return $errors; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -799,18 +799,18 @@ discard block |
||
| 799 | 799 | |
| 800 | 800 | ?> |
| 801 | 801 | <td> |
| 802 | - <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
|
| 802 | + <?php esc_html_e('Configuration', 'pronamic_ideal'); ?> |
|
| 803 | 803 | </td> |
| 804 | 804 | <td> |
| 805 | - <select name="<?php echo esc_attr( $name ); ?>"> |
|
| 805 | + <select name="<?php echo esc_attr($name); ?>"> |
|
| 806 | 806 | <?php |
| 807 | 807 | |
| 808 | - foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
|
| 808 | + foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) { |
|
| 809 | 809 | printf( |
| 810 | 810 | '<option value="%s" %s>%s</option>', |
| 811 | - esc_attr( $value ), |
|
| 812 | - selected( $value, $this->settings->config_id, false ), |
|
| 813 | - esc_html( $label ) |
|
| 811 | + esc_attr($value), |
|
| 812 | + selected($value, $this->settings->config_id, false), |
|
| 813 | + esc_html($label) |
|
| 814 | 814 | ); |
| 815 | 815 | } |
| 816 | 816 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | * @param array $errors Array with errors. |
| 833 | 833 | * @return array |
| 834 | 834 | */ |
| 835 | - public function validate_options_form( $errors ) { |
|
| 835 | + public function validate_options_form($errors) { |
|
| 836 | 836 | return $errors; |
| 837 | 837 | } |
| 838 | 838 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
| 858 | 858 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
| 859 | 859 | */ |
| 860 | - public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
|
| 860 | + public function display_update_account_form($sub_id, $errors = array(), $message = '') { |
|
| 861 | 861 | |
| 862 | 862 | } |
| 863 | 863 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | * @param array $errors Array with errors. |
| 871 | 871 | * @return array |
| 872 | 872 | */ |
| 873 | - public function validate_update_account_form( $errors = array() ) { |
|
| 873 | + public function validate_update_account_form($errors = array()) { |
|
| 874 | 874 | return $errors; |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param int $sub_id Subscription ID. |
| 884 | 884 | */ |
| 885 | - public function process_update_account_form( $sub_id ) { |
|
| 885 | + public function process_update_account_form($sub_id) { |
|
| 886 | 886 | |
| 887 | 887 | } |
| 888 | 888 | |