 wp-pay-extensions    /
                    memberpress
                      wp-pay-extensions    /
                    memberpress
                
                            | 1 | <?php | ||
| 2 | /** | ||
| 3 | * Gateway | ||
| 4 | * | ||
| 5 | * @author Pronamic <[email protected]> | ||
| 6 | * @copyright 2005-2019 Pronamic | ||
| 7 | * @license GPL-3.0-or-later | ||
| 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress | ||
| 9 | */ | ||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Extensions\MemberPress\Gateways; | ||
| 12 | |||
| 13 | use MeprBaseRealGateway; | ||
| 14 | use MeprDb; | ||
| 15 | use MeprEmailFactory; | ||
| 16 | use MeprOptions; | ||
| 17 | use MeprProduct; | ||
| 18 | use MeprSubscription; | ||
| 19 | use MeprTransaction; | ||
| 20 | use MeprTransactionsHelper; | ||
| 21 | use MeprUser; | ||
| 22 | use MeprUtils; | ||
| 23 | use MeprView; | ||
| 24 | use Pronamic\WordPress\Pay\Core\PaymentMethods; | ||
| 25 | use Pronamic\WordPress\Pay\Core\Statuses; | ||
| 26 | use Pronamic\WordPress\Pay\Core\Util as Core_Util; | ||
| 27 | use Pronamic\WordPress\Pay\Payments\Payment; | ||
| 28 | use Pronamic\WordPress\Pay\Plugin; | ||
| 29 | use Pronamic\WordPress\Pay\Extensions\MemberPress\Pronamic; | ||
| 30 | use Pronamic\WordPress\Pay\Extensions\MemberPress\MemberPress; | ||
| 31 | use ReflectionClass; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * WordPress pay MemberPress gateway | ||
| 35 | * | ||
| 36 | * @author Remco Tolsma | ||
| 37 | * @version 2.0.4 | ||
| 38 | * @since 1.0.0 | ||
| 39 | */ | ||
| 40 | class Gateway extends MeprBaseRealGateway { | ||
| 41 | /** | ||
| 42 | * Payment method. | ||
| 43 | * | ||
| 44 | * @var string | ||
| 45 | */ | ||
| 46 | protected $payment_method; | ||
| 47 | |||
| 48 | /** | ||
| 49 | * MemberPress transaction. | ||
| 50 | * | ||
| 51 | * @var MeprTransaction | ||
| 52 | */ | ||
| 53 | public $mp_txn; | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Pronamic payment. | ||
| 57 | * | ||
| 58 | * @var Payment | ||
| 59 | */ | ||
| 60 | public $pronamic_payment; | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Constructs and initialize iDEAL gateway. | ||
| 64 | */ | ||
| 65 | 	public function __construct() { | ||
| 66 | // Set the name of this gateway. | ||
| 67 | // @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13. | ||
| 68 | $this->name = __( 'Pronamic', 'pronamic_ideal' ); | ||
| 69 | |||
| 70 | 		if ( ! empty( $this->payment_method ) ) { | ||
| 71 | $this->name = sprintf( | ||
| 72 | /* translators: %s: payment method name */ | ||
| 73 | __( 'Pronamic - %s', 'pronamic_ideal' ), | ||
| 74 | PaymentMethods::get_name( $this->payment_method ) | ||
| 75 | ); | ||
| 76 | } | ||
| 77 | |||
| 78 | // Set the default settings. | ||
| 79 | // @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73. | ||
| 80 | $this->set_defaults(); | ||
| 81 | |||
| 82 | // Set the capabilities of this gateway. | ||
| 83 | // @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L36-37. | ||
| 84 | $this->capabilities = array(); | ||
| 85 | |||
| 86 | // Setup the notification actions for this gateway. | ||
| 87 | $this->notifiers = array(); | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Load the specified settings. | ||
| 92 | * | ||
| 93 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L69-70 | ||
| 94 | * | ||
| 95 | * @param array $settings MemberPress gateway settings array. | ||
| 96 | */ | ||
| 97 | 	public function load( $settings ) { | ||
| 98 | $this->settings = (object) $settings; | ||
| 99 | |||
| 100 | $this->set_defaults(); | ||
| 101 | } | ||
| 102 | |||
| 103 | /** | ||
| 104 | * Custom helper function to send transaction notices. | ||
| 105 | * | ||
| 106 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprUtils.php#L1333-L1351 | ||
| 107 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/models/MeprTransaction.php | ||
| 108 | * | ||
| 109 | * @param MeprTransaction $transaction MemberPress transaction object. | ||
| 110 | * @param string $method PHP function name to call. | ||
| 111 | * | ||
| 112 | * @return mixed | ||
| 113 | */ | ||
| 114 | 	public function send_transaction_notices( $transaction, $method ) { | ||
| 115 | $class = 'MeprUtils'; | ||
| 116 | |||
| 117 | 		if ( ! Core_Util::class_method_exists( $class, $method ) ) { | ||
| 118 | $class = $this; | ||
| 119 | } | ||
| 120 | |||
| 121 | 		if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) { | ||
| 122 | // `send_product_welcome_notices` is called from `send_signup_notices` in newer versions. | ||
| 123 | return; | ||
| 124 | } | ||
| 125 | |||
| 126 | return call_user_func( array( $class, $method ), $transaction ); | ||
| 127 | } | ||
| 128 | |||
| 129 | /** | ||
| 130 | * Get icon function (this is not a MemberPress function). | ||
| 131 | * | ||
| 132 | * @since 1.0.2 | ||
| 133 | * @return string | ||
| 134 | */ | ||
| 135 | 	protected function get_icon() { | ||
| 136 | return ''; | ||
| 137 | } | ||
| 138 | |||
| 139 | /** | ||
| 140 | * Get class alias name. | ||
| 141 | * | ||
| 142 | * @return string | ||
| 143 | */ | ||
| 144 | 	public function get_alias() { | ||
| 145 | return 'MeprPronamicGateway'; | ||
| 146 | } | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Set the default settings. | ||
| 150 | * | ||
| 151 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73 | ||
| 152 | */ | ||
| 153 | 	protected function set_defaults() { | ||
| 154 | 		if ( ! isset( $this->settings ) ) { | ||
| 155 | $this->settings = array(); | ||
| 156 | } | ||
| 157 | |||
| 158 | $this->settings = (object) array_merge( | ||
| 159 | array( | ||
| 160 | 'gateway' => $this->get_alias(), | ||
| 161 | 'id' => $this->generate_id(), | ||
| 162 | 'label' => '', | ||
| 163 | 'use_label' => true, | ||
| 164 | 'icon' => $this->get_icon(), | ||
| 165 | 'use_icon' => true, | ||
| 166 | 'desc' => '', | ||
| 167 | 'use_desc' => true, | ||
| 168 | 'config_id' => '', | ||
| 169 | 'email' => '', | ||
| 170 | 'sandbox' => false, | ||
| 171 | 'debug' => false, | ||
| 172 | ), | ||
| 173 | (array) $this->settings | ||
| 174 | ); | ||
| 175 | |||
| 176 | $this->id = $this->settings->id; | ||
| 177 | $this->label = $this->settings->label; | ||
| 178 | $this->use_label = $this->settings->use_label; | ||
| 179 | $this->icon = $this->settings->icon; | ||
| 180 | $this->use_icon = $this->settings->use_icon; | ||
| 181 | $this->desc = $this->settings->desc; | ||
| 182 | $this->use_desc = $this->settings->use_desc; | ||
| 183 | } | ||
| 184 | |||
| 185 | /** | ||
| 186 | * Process payment. | ||
| 187 | * | ||
| 188 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 189 | * | ||
| 190 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122 | ||
| 191 | */ | ||
| 192 | 	public function process_payment( $txn ) { | ||
| 193 | |||
| 194 | } | ||
| 195 | |||
| 196 | /** | ||
| 197 | * Record subscription payment. | ||
| 198 | * | ||
| 199 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L140-145 | ||
| 200 | */ | ||
| 201 | 	public function record_subscription_payment() { | ||
| 202 | $transaction = $this->mp_txn; | ||
| 203 | |||
| 204 | $transaction->status = MeprTransaction::$complete_str; | ||
| 205 | $transaction->store(); | ||
| 206 | |||
| 207 | $subscription = $transaction->subscription(); | ||
| 208 | |||
| 209 | 		if ( $subscription ) { | ||
| 210 | 			if ( MeprSubscription::$active_str !== $subscription->status ) { | ||
| 211 | $subscription->status = MeprSubscription::$active_str; | ||
| 212 | $subscription->store(); | ||
| 213 | } | ||
| 214 | |||
| 215 | $subscription->expire_confirmation_txn(); | ||
| 216 | |||
| 217 | $subscription->limit_payment_cycles(); | ||
| 218 | } | ||
| 219 | |||
| 220 | $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); | ||
| 221 | |||
| 222 | return $transaction; | ||
| 223 | } | ||
| 224 | |||
| 225 | /** | ||
| 226 | * Record payment failure. | ||
| 227 | * | ||
| 228 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L147-148 | ||
| 229 | */ | ||
| 230 | 	public function record_payment_failure() { | ||
| 231 | $transaction = $this->mp_txn; | ||
| 232 | |||
| 233 | // @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L50. | ||
| 234 | $transaction->status = MeprTransaction::$failed_str; | ||
| 235 | $transaction->store(); | ||
| 236 | |||
| 237 | // Expire associated subscription transactions for non-recurring payments. | ||
| 238 | 		if ( ! ( isset( $this->pronamic_payment ) && $this->pronamic_payment->get_recurring() ) ) { | ||
| 0 ignored issues–
                            show | |||
| 239 | $subscription = $transaction->subscription(); | ||
| 240 | |||
| 241 | 			if ( $subscription ) { | ||
| 242 | $subscription->expire_txns(); | ||
| 243 | $subscription->store(); | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | $this->send_transaction_notices( $transaction, 'send_failed_txn_notices' ); | ||
| 248 | |||
| 249 | return $transaction; | ||
| 250 | } | ||
| 251 | |||
| 252 | /** | ||
| 253 | * Record payment. | ||
| 254 | * | ||
| 255 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L124-129 | ||
| 256 | */ | ||
| 257 | 	public function record_payment() { | ||
| 258 | $transaction = $this->mp_txn; | ||
| 259 | |||
| 260 | $transaction->status = MeprTransaction::$complete_str; | ||
| 261 | |||
| 262 | // This will only work before maybe_cancel_old_sub is run. | ||
| 263 | $upgrade = $transaction->is_upgrade(); | ||
| 264 | $downgrade = $transaction->is_downgrade(); | ||
| 265 | |||
| 266 | $event_transaction = $transaction->maybe_cancel_old_sub(); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $event_transactionis correct as$transaction->maybe_cancel_old_sub()targetingMeprTransaction::maybe_cancel_old_sub()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 267 | |||
| 268 | $subscription = $transaction->subscription(); | ||
| 269 | |||
| 270 | 		if ( $subscription ) { | ||
| 271 | $event_subscription = $subscription->maybe_cancel_old_sub(); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $event_subscriptionis correct as$subscription->maybe_cancel_old_sub()targetingMeprSubscription::maybe_cancel_old_sub()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 272 | |||
| 273 | $subscription->status = MeprSubscription::$active_str; | ||
| 274 | $subscription->created_at = $transaction->created_at; | ||
| 275 | $subscription->store(); | ||
| 276 | |||
| 277 | 			if ( false === $event_transaction && false !== $event_subscription ) { | ||
| 278 | $event_transaction = $event_subscription; | ||
| 279 | } | ||
| 280 | } | ||
| 281 | |||
| 282 | $transaction->store(); | ||
| 283 | |||
| 284 | /* | ||
| 285 | * For some reasons the `send_product_welcome_notices` function accepts 1 or 3 arguments. We are not sure | ||
| 286 | * if this is a difference in the 'Business' and 'Developer' edition or between version `1.2.4` and `1.2.7`. | ||
| 287 | * | ||
| 288 | * @link https://github.com/wp-premium/memberpress-developer/blob/1.2.4/app/lib/MeprBaseGateway.php#L596-L612 | ||
| 289 | * @link https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619 | ||
| 290 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51 | ||
| 291 | */ | ||
| 292 | $reflection = new ReflectionClass( 'MeprBaseRealGateway' ); | ||
| 293 | |||
| 294 | 		if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) { | ||
| 295 | $uemail = MeprEmailFactory::fetch( | ||
| 296 | 'MeprUserProductWelcomeEmail', | ||
| 297 | 'MeprBaseProductEmail', | ||
| 298 | array( | ||
| 299 | array( | ||
| 300 | 'product_id' => $transaction->product_id, | ||
| 301 | ), | ||
| 302 | ) | ||
| 303 | ); | ||
| 304 | |||
| 305 | /** | ||
| 306 | * The `send_product_welcome_notices` method is only available in earlier version of MemberPress. | ||
| 307 | * | ||
| 308 | * @scrutinizer ignore-call | ||
| 309 | */ | ||
| 310 | $this->send_product_welcome_notices( | ||
| 311 | $uemail, | ||
| 312 | MeprTransactionsHelper::get_email_params( $transaction ), | ||
| 313 | $transaction->user() | ||
| 314 | ); | ||
| 315 | 		} else { | ||
| 316 | $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); | ||
| 317 | } | ||
| 318 | |||
| 319 | // Send upgrade/downgrade notices. | ||
| 320 | $product = $transaction->product(); | ||
| 321 | |||
| 322 | 		if ( 'lifetime' === $product->period_type ) { | ||
| 323 | 			if ( $upgrade ) { | ||
| 324 | $this->upgraded_sub( $transaction, $event_transaction ); | ||
| 325 | $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); | ||
| 326 | 			} elseif ( $downgrade ) { | ||
| 327 | $this->downgraded_sub( $transaction, $event_transaction ); | ||
| 328 | $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); | ||
| 329 | 			} else { | ||
| 330 | $this->new_sub( $transaction ); | ||
| 331 | } | ||
| 332 | } | ||
| 333 | |||
| 334 | $this->send_transaction_notices( $transaction, 'send_signup_notices' ); | ||
| 335 | $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); | ||
| 336 | |||
| 337 | return $transaction; | ||
| 338 | } | ||
| 339 | |||
| 340 | /** | ||
| 341 | * Process refund. | ||
| 342 | * | ||
| 343 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 344 | * | ||
| 345 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 | ||
| 346 | */ | ||
| 347 | 	public function process_refund( MeprTransaction $txn ) { | ||
| 348 | |||
| 349 | } | ||
| 350 | |||
| 351 | /** | ||
| 352 | * Record refund. | ||
| 353 | * | ||
| 354 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L135-138 | ||
| 355 | */ | ||
| 356 | 	public function record_refund() { | ||
| 357 | |||
| 358 | } | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Process trial payment. | ||
| 362 | * | ||
| 363 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L150-157 | ||
| 364 | * | ||
| 365 | * @param MeprTransaction $transaction MemberPress transaction object. | ||
| 366 | */ | ||
| 367 | 	public function process_trial_payment( $transaction ) { | ||
| 368 | |||
| 369 | } | ||
| 370 | |||
| 371 | /** | ||
| 372 | * Reord trial payment. | ||
| 373 | * | ||
| 374 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L159-161 | ||
| 375 | * | ||
| 376 | * @param MeprTransaction $transaction MemberPress transaction object. | ||
| 377 | */ | ||
| 378 | 	public function record_trial_payment( $transaction ) { | ||
| 379 | |||
| 380 | } | ||
| 381 | |||
| 382 | /** | ||
| 383 | * Process create subscription. | ||
| 384 | * | ||
| 385 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L163-167 | ||
| 386 | * | ||
| 387 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 388 | */ | ||
| 389 | 	public function process_create_subscription( $txn ) { | ||
| 390 | |||
| 391 | } | ||
| 392 | |||
| 393 | /** | ||
| 394 | * Record create subscription. | ||
| 395 | * | ||
| 396 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L169-174 | ||
| 397 | */ | ||
| 398 | 	public function record_create_subscription() { | ||
| 399 | |||
| 400 | } | ||
| 401 | |||
| 402 | /** | ||
| 403 | * Process update subscription. | ||
| 404 | * | ||
| 405 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L176 | ||
| 406 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L194 | ||
| 407 | * | ||
| 408 | * @param int $sub_id Subscription ID. | ||
| 409 | */ | ||
| 410 | 	public function process_update_subscription( $sub_id ) { | ||
| 411 | |||
| 412 | } | ||
| 413 | |||
| 414 | /** | ||
| 415 | * Record update subscription. | ||
| 416 | * | ||
| 417 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L178-182 | ||
| 418 | */ | ||
| 419 | 	public function record_update_subscription() { | ||
| 420 | |||
| 421 | } | ||
| 422 | |||
| 423 | /** | ||
| 424 | * Process suspend subscription. | ||
| 425 | * | ||
| 426 | * @param int $sub_id Subscription id. | ||
| 427 | * | ||
| 428 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 | ||
| 429 | */ | ||
| 430 | 	public function process_suspend_subscription( $sub_id ) { | ||
| 431 | 		if ( ! MeprSubscription::exists( $sub_id ) ) { | ||
| 432 | return; | ||
| 433 | } | ||
| 434 | |||
| 435 | $sub = new MeprSubscription( $sub_id ); | ||
| 436 | |||
| 437 | 		if ( MeprSubscription::$suspended_str === $sub->status ) { | ||
| 438 | // Subscription is already suspended. | ||
| 439 | return; | ||
| 440 | } | ||
| 441 | |||
| 442 | $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); | ||
| 443 | |||
| 444 | 		if ( ! $subscription ) { | ||
| 445 | return; | ||
| 446 | } | ||
| 447 | |||
| 448 | $sub->status = MeprSubscription::$suspended_str; | ||
| 449 | |||
| 450 | $sub->store(); | ||
| 451 | |||
| 452 | // Send suspended subscription notices. | ||
| 453 | MeprUtils::send_suspended_sub_notices( $sub ); | ||
| 454 | |||
| 455 | $note = sprintf( | ||
| 456 | /* translators: %s: MemberPress */ | ||
| 457 | __( '%s subscription on hold.', 'pronamic_ideal' ), | ||
| 458 | __( 'MemberPress', 'pronamic_ideal' ) | ||
| 459 | ); | ||
| 460 | |||
| 461 | $subscription->add_note( $note ); | ||
| 462 | |||
| 463 | // The status of canceled or completed subscriptions will not be changed automatically. | ||
| 464 | 		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { | ||
| 465 | $subscription->set_status( Statuses::ON_HOLD ); | ||
| 466 | |||
| 467 | $subscription->save(); | ||
| 468 | } | ||
| 469 | } | ||
| 470 | |||
| 471 | /** | ||
| 472 | * Record suspend subscription. | ||
| 473 | * | ||
| 474 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L188-191 | ||
| 475 | */ | ||
| 476 | 	public function record_suspend_subscription() { | ||
| 477 | |||
| 478 | } | ||
| 479 | |||
| 480 | /** | ||
| 481 | * Process resume subscription. | ||
| 482 | * | ||
| 483 | * @param int $sub_id Subscription id. | ||
| 484 | * | ||
| 485 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 | ||
| 486 | */ | ||
| 487 | 	public function process_resume_subscription( $sub_id ) { | ||
| 488 | 		if ( ! MeprSubscription::exists( $sub_id ) ) { | ||
| 489 | return; | ||
| 490 | } | ||
| 491 | |||
| 492 | $sub = new MeprSubscription( $sub_id ); | ||
| 493 | |||
| 494 | 		if ( MeprSubscription::$active_str === $sub->status ) { | ||
| 495 | // Subscription is already active. | ||
| 496 | return; | ||
| 497 | } | ||
| 498 | |||
| 499 | $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); | ||
| 500 | |||
| 501 | 		if ( ! $subscription ) { | ||
| 502 | return; | ||
| 503 | } | ||
| 504 | |||
| 505 | $sub->status = MeprSubscription::$active_str; | ||
| 506 | |||
| 507 | $sub->store(); | ||
| 508 | |||
| 509 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. | ||
| 510 | $prior_txn = $sub->latest_txn(); | ||
| 511 | |||
| 512 | 		if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { | ||
| 513 | $txn = new MeprTransaction(); | ||
| 514 | $txn->subscription_id = $sub->id; | ||
| 515 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); | ||
| 516 | $txn->status = MeprTransaction::$confirmed_str; | ||
| 517 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; | ||
| 518 | $txn->response = (string) $sub; | ||
| 519 | $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); | ||
| 520 | |||
| 521 | $txn->set_subtotal( 0.00 ); // Just a confirmation txn. | ||
| 522 | |||
| 523 | $txn->store(); | ||
| 524 | } | ||
| 525 | |||
| 526 | // Send resumed subscription notices. | ||
| 527 | MeprUtils::send_resumed_sub_notices( $sub ); | ||
| 528 | |||
| 529 | // Add note. | ||
| 530 | $note = sprintf( | ||
| 531 | /* translators: %s: MemberPress */ | ||
| 532 | __( '%s subscription reactivated.', 'pronamic_ideal' ), | ||
| 533 | __( 'MemberPress', 'pronamic_ideal' ) | ||
| 534 | ); | ||
| 535 | |||
| 536 | $subscription->add_note( $note ); | ||
| 537 | |||
| 538 | // The status of canceled or completed subscriptions will not be changed automatically. | ||
| 539 | 		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { | ||
| 540 | $subscription->set_status( Statuses::ACTIVE ); | ||
| 541 | |||
| 542 | $subscription->save(); | ||
| 543 | } | ||
| 544 | } | ||
| 545 | |||
| 546 | /** | ||
| 547 | * Record resume subscription. | ||
| 548 | * | ||
| 549 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L197-201 | ||
| 550 | */ | ||
| 551 | 	public function record_resume_subscription() { | ||
| 552 | |||
| 553 | } | ||
| 554 | |||
| 555 | /** | ||
| 556 | * Process cancel subscription. | ||
| 557 | * | ||
| 558 | * @param int $sub_id Subscription id. | ||
| 559 | * | ||
| 560 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 | ||
| 561 | */ | ||
| 562 | 	public function process_cancel_subscription( $sub_id ) { | ||
| 563 | 		if ( ! MeprSubscription::exists( $sub_id ) ) { | ||
| 564 | return; | ||
| 565 | } | ||
| 566 | |||
| 567 | $sub = new MeprSubscription( $sub_id ); | ||
| 568 | |||
| 569 | 		if ( MeprSubscription::$cancelled_str === $sub->status ) { | ||
| 570 | // Subscription is already cancelled. | ||
| 571 | return; | ||
| 572 | } | ||
| 573 | |||
| 574 | $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); | ||
| 575 | |||
| 576 | 		if ( ! $subscription ) { | ||
| 577 | return; | ||
| 578 | } | ||
| 579 | |||
| 580 | $sub->status = MeprSubscription::$cancelled_str; | ||
| 581 | |||
| 582 | $sub->store(); | ||
| 583 | |||
| 584 | // Expire the grace period (confirmation) if no completed payments have come through. | ||
| 585 | 		if ( (int) $sub->txn_count <= 0 ) { | ||
| 586 | $sub->expire_txns(); | ||
| 587 | } | ||
| 588 | |||
| 589 | $sub->limit_reached_actions(); | ||
| 590 | |||
| 591 | // Send cancelled subscription notices. | ||
| 592 | MeprUtils::send_cancelled_sub_notices( $sub ); | ||
| 593 | |||
| 594 | // Add note. | ||
| 595 | $note = sprintf( | ||
| 596 | /* translators: %s: MemberPress */ | ||
| 597 | __( '%s subscription cancelled.', 'pronamic_ideal' ), | ||
| 598 | __( 'MemberPress', 'pronamic_ideal' ) | ||
| 599 | ); | ||
| 600 | |||
| 601 | $subscription->add_note( $note ); | ||
| 602 | |||
| 603 | // The status of canceled or completed subscriptions will not be changed automatically. | ||
| 604 | 		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { | ||
| 605 | $subscription->set_status( Statuses::CANCELLED ); | ||
| 606 | |||
| 607 | $subscription->save(); | ||
| 608 | } | ||
| 609 | } | ||
| 610 | |||
| 611 | /** | ||
| 612 | * Record cancel subscription. | ||
| 613 | * | ||
| 614 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L208-212 | ||
| 615 | */ | ||
| 616 | 	public function record_cancel_subscription() { | ||
| 617 | |||
| 618 | } | ||
| 619 | |||
| 620 | /** | ||
| 621 | * Process signup form. | ||
| 622 | * | ||
| 623 | * Gets called when the signup form is posted used for running any payment | ||
| 624 | * method specific actions when processing the customer signup form. | ||
| 625 | * | ||
| 626 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L214-217 | ||
| 627 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L262 | ||
| 628 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L232-L235 | ||
| 629 | * | ||
| 630 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 631 | */ | ||
| 632 | 	public function process_signup_form( $txn ) { | ||
| 633 | |||
| 634 | } | ||
| 635 | |||
| 636 | /** | ||
| 637 | * Payment redirect. | ||
| 638 | * | ||
| 639 | * @since 1.0.2 | ||
| 640 | * | ||
| 641 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 642 | */ | ||
| 643 | 	public function payment_redirect( $txn ) { | ||
| 644 | $txn = new MeprTransaction( $txn->id ); | ||
| 645 | |||
| 646 | // Gateway. | ||
| 647 | $config_id = $this->settings->config_id; | ||
| 648 | |||
| 649 | $gateway = Plugin::get_gateway( $config_id ); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $gatewayis correct asPronamic\WordPress\Pay\P...get_gateway($config_id)targetingPronamic\WordPress\Pay\Plugin::get_gateway()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 650 | |||
| 651 | 		if ( ! $gateway ) { | ||
| 652 | return; | ||
| 653 | } | ||
| 654 | |||
| 655 | // Create Pronamic payment. | ||
| 656 | $payment = Pronamic::get_payment( $txn ); | ||
| 657 | |||
| 658 | $payment->config_id = $this->settings->config_id; | ||
| 659 | $payment->method = $this->payment_method; | ||
| 660 | |||
| 661 | $payment = Plugin::start_payment( $payment ); | ||
| 662 | |||
| 663 | /* | ||
| 664 | * Update transaction subtotal. | ||
| 665 | * | ||
| 666 | * Notes: | ||
| 667 | * - MemberPress also uses trial amount for prorated upgrade/downgrade | ||
| 668 | * - Not updated BEFORE payment start, as transaction total amount is used for subscription amount. | ||
| 669 | */ | ||
| 670 | $subscription = $txn->subscription(); | ||
| 671 | |||
| 672 | 		if ( $subscription && $subscription->in_trial() ) { | ||
| 673 | $txn->set_subtotal( $subscription->trial_amount ); | ||
| 674 | $txn->store(); | ||
| 675 | } | ||
| 676 | |||
| 677 | $error = $gateway->get_error(); | ||
| 678 | |||
| 679 | 		if ( ! is_wp_error( $error ) ) { | ||
| 680 | // Redirect. | ||
| 681 | $gateway->redirect( $payment ); | ||
| 682 | } | ||
| 683 | } | ||
| 684 | |||
| 685 | /** | ||
| 686 | * Display payment page. | ||
| 687 | * | ||
| 688 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L219-223 | ||
| 689 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L290 | ||
| 690 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L775-L850 | ||
| 691 | * | ||
| 692 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 693 | */ | ||
| 694 | 	public function display_payment_page( $txn ) { | ||
| 695 | // Gateway. | ||
| 696 | $config_id = $this->settings->config_id; | ||
| 697 | |||
| 698 | $gateway = Plugin::get_gateway( $config_id ); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $gatewayis correct asPronamic\WordPress\Pay\P...get_gateway($config_id)targetingPronamic\WordPress\Pay\Plugin::get_gateway()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 699 | |||
| 700 | 		if ( $gateway && '' === $gateway->get_input_html() ) { | ||
| 701 | $this->payment_redirect( $txn ); | ||
| 702 | } | ||
| 703 | } | ||
| 704 | |||
| 705 | /** | ||
| 706 | * Process payment form. | ||
| 707 | * | ||
| 708 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L239-289 | ||
| 709 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L336 | ||
| 710 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L1011 | ||
| 711 | * | ||
| 712 | * @param MeprTransaction $txn MemberPress transaction object. | ||
| 713 | * @return bool | ||
| 714 | */ | ||
| 715 | 	public function process_payment_form( $txn ) { | ||
| 716 | 		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { | ||
| 717 | return false; | ||
| 718 | } | ||
| 719 | |||
| 720 | // Gateway. | ||
| 721 | $config_id = $this->settings->config_id; | ||
| 722 | |||
| 723 | $gateway = Plugin::get_gateway( $config_id ); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $gatewayis correct asPronamic\WordPress\Pay\P...get_gateway($config_id)targetingPronamic\WordPress\Pay\Plugin::get_gateway()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 724 | |||
| 725 | 		if ( $gateway ) { | ||
| 726 | $this->payment_redirect( $txn ); | ||
| 727 | } | ||
| 728 | } | ||
| 729 | |||
| 730 | /** | ||
| 731 | * Enqueue payment form scripts. | ||
| 732 | * | ||
| 733 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L219-223 | ||
| 734 | */ | ||
| 735 | 	public function enqueue_payment_form_scripts() { | ||
| 736 | |||
| 737 | } | ||
| 738 | |||
| 739 | /** | ||
| 740 | * Display payment form. | ||
| 741 | * | ||
| 742 | * This spits out html for the payment form on the registration / payment | ||
| 743 | * page for the user to fill out for payment. | ||
| 744 | * | ||
| 745 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L230-233 | ||
| 746 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L248-L251 | ||
| 747 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L318 | ||
| 748 | * | ||
| 749 | * @param float $amount Transaction amount to create a payment form for. | ||
| 750 | * @param MeprUser $user MemberPress user object. | ||
| 751 | * @param int $product_id Product ID. | ||
| 752 | * @param int $txn_id Transaction ID. | ||
| 753 | */ | ||
| 754 | 	public function display_payment_form( $amount, $user, $product_id, $txn_id ) { | ||
| 755 | $product = new MeprProduct( $product_id ); | ||
| 756 | |||
| 757 | $coupon = false; | ||
| 758 | |||
| 759 | $txn = new MeprTransaction( $txn_id ); | ||
| 760 | |||
| 761 | // Artifically set the price of the $prd in case a coupon was used. | ||
| 762 | 		if ( $product->price !== $amount ) { | ||
| 763 | $coupon = true; | ||
| 764 | $product->price = $amount; | ||
| 765 | } | ||
| 766 | |||
| 767 | $invoice = MeprTransactionsHelper::get_invoice( $txn ); | ||
| 768 | |||
| 769 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
| 770 | echo $invoice; | ||
| 771 | |||
| 772 | ?> | ||
| 773 | <div class="mp_wrapper mp_payment_form_wrapper"> | ||
| 774 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> | ||
| 775 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> | ||
| 776 | <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> | ||
| 777 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> | ||
| 778 | |||
| 779 | <div class="mepr_spacer"> </div> | ||
| 780 | |||
| 781 | <?php | ||
| 782 | |||
| 783 | // Gateway. | ||
| 784 | $config_id = $this->settings->config_id; | ||
| 785 | |||
| 786 | $gateway = Plugin::get_gateway( $config_id ); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $gatewayis correct asPronamic\WordPress\Pay\P...get_gateway($config_id)targetingPronamic\WordPress\Pay\Plugin::get_gateway()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 787 | |||
| 788 | 				if ( $gateway ) { | ||
| 789 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
| 790 | echo $gateway->get_input_html(); | ||
| 791 | } | ||
| 792 | |||
| 793 | ?> | ||
| 794 | |||
| 795 | <div class="mepr_spacer"> </div> | ||
| 796 | |||
| 797 | <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> | ||
| 798 | <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> | ||
| 799 | <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> | ||
| 800 | |||
| 801 | <noscript> | ||
| 802 | <p class="mepr_nojs"> | ||
| 803 | <?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' ); ?> | ||
| 804 | </p> | ||
| 805 | </noscript> | ||
| 806 | </form> | ||
| 807 | </div> | ||
| 808 | <?php | ||
| 809 | } | ||
| 810 | |||
| 811 | /** | ||
| 812 | * Validate payment form. | ||
| 813 | * | ||
| 814 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L235-236 | ||
| 815 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L330 | ||
| 816 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L253-L254 | ||
| 817 | * | ||
| 818 | * @param array $errors Array with errors. | ||
| 819 | * @return array | ||
| 820 | */ | ||
| 821 | 	public function validate_payment_form( $errors ) { | ||
| 822 | return $errors; | ||
| 823 | } | ||
| 824 | |||
| 825 | /** | ||
| 826 | * Display options form. | ||
| 827 | * | ||
| 828 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L291-292 | ||
| 829 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/gateways/MeprAuthorizeGateway.php#L1027-1037 | ||
| 830 | */ | ||
| 831 | 	public function display_options_form() { | ||
| 832 | $mepr_options = MeprOptions::fetch(); | ||
| 833 | |||
| 834 | ?> | ||
| 835 | <table> | ||
| 836 | <tr> | ||
| 837 | <?php | ||
| 838 | |||
| 839 | $name = sprintf( | ||
| 840 | '%s[%s][%s]', | ||
| 841 | $mepr_options->integrations_str, | ||
| 842 | $this->id, | ||
| 843 | 'config_id' | ||
| 844 | ); | ||
| 845 | |||
| 846 | ?> | ||
| 847 | <td> | ||
| 848 | <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> | ||
| 849 | </td> | ||
| 850 | <td> | ||
| 851 | <select name="<?php echo esc_attr( $name ); ?>"> | ||
| 852 | <?php | ||
| 853 | |||
| 854 | 						foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { | ||
| 855 | printf( | ||
| 856 | '<option value="%s" %s>%s</option>', | ||
| 857 | esc_attr( $value ), | ||
| 858 | selected( $value, $this->settings->config_id, false ), | ||
| 859 | esc_html( $label ) | ||
| 860 | ); | ||
| 861 | } | ||
| 862 | |||
| 863 | ?> | ||
| 864 | </select> | ||
| 865 | </td> | ||
| 866 | </tr> | ||
| 867 | </table> | ||
| 868 | <?php | ||
| 869 | } | ||
| 870 | |||
| 871 | /** | ||
| 872 | * Validate options form. | ||
| 873 | * | ||
| 874 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L294-295 | ||
| 875 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L909-L924 | ||
| 876 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/models/MeprOptions.php#L416-L423 | ||
| 877 | * | ||
| 878 | * @param array $errors Array with errors. | ||
| 879 | * @return array | ||
| 880 | */ | ||
| 881 | 	public function validate_options_form( $errors ) { | ||
| 882 | return $errors; | ||
| 883 | } | ||
| 884 | |||
| 885 | /** | ||
| 886 | * Enqueue user account scripts. | ||
| 887 | * | ||
| 888 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L297-302 | ||
| 889 | */ | ||
| 890 | 	public function enqueue_user_account_scripts() { | ||
| 891 | |||
| 892 | } | ||
| 893 | |||
| 894 | /** | ||
| 895 | * Display update account form. | ||
| 896 | * | ||
| 897 | * @param int $sub_id Subscription ID. | ||
| 898 | * @param array $errors Array with errors. | ||
| 899 | * @param string $message Update message. | ||
| 900 | * | ||
| 901 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L365-366 | ||
| 902 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseStaticGateway.php#L160-L161 | ||
| 903 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 | ||
| 904 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 | ||
| 905 | */ | ||
| 906 | 	public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { | ||
| 907 | |||
| 908 | } | ||
| 909 | |||
| 910 | /** | ||
| 911 | * Validate update account form. | ||
| 912 | * | ||
| 913 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L368-369 | ||
| 914 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1170-L1173 | ||
| 915 | * | ||
| 916 | * @param array $errors Array with errors. | ||
| 917 | * @return array | ||
| 918 | */ | ||
| 919 | 	public function validate_update_account_form( $errors = array() ) { | ||
| 920 | return $errors; | ||
| 921 | } | ||
| 922 | |||
| 923 | /** | ||
| 924 | * Process update account form. | ||
| 925 | * | ||
| 926 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L371-372 | ||
| 927 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1175-L1181 | ||
| 928 | * | ||
| 929 | * @param int $sub_id Subscription ID. | ||
| 930 | */ | ||
| 931 | 	public function process_update_account_form( $sub_id ) { | ||
| 932 | |||
| 933 | } | ||
| 934 | |||
| 935 | /** | ||
| 936 | * Is test mode. | ||
| 937 | * | ||
| 938 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L374-375 | ||
| 939 | * | ||
| 940 | * @return boolean | ||
| 941 | */ | ||
| 942 | 	public function is_test_mode() { | ||
| 943 | return false; | ||
| 944 | } | ||
| 945 | |||
| 946 | /** | ||
| 947 | * Force SSL. | ||
| 948 | * | ||
| 949 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L377-378 | ||
| 950 | * | ||
| 951 | * @return boolean | ||
| 952 | */ | ||
| 953 | 	public function force_ssl() { | ||
| 954 | return false; | ||
| 955 | } | ||
| 956 | } | ||
| 957 | 
 
                                
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.