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\Util as Core_Util; |
||
| 26 | use Pronamic\WordPress\Pay\Payments\Payment; |
||
| 27 | use Pronamic\WordPress\Pay\Plugin; |
||
| 28 | use Pronamic\WordPress\Pay\Extensions\MemberPress\Pronamic; |
||
| 29 | use Pronamic\WordPress\Pay\Extensions\MemberPress\MemberPress; |
||
| 30 | use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus; |
||
| 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_transaction is correct as $transaction->maybe_cancel_old_sub() targeting MeprTransaction::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_subscription is correct as $subscription->maybe_cancel_old_sub() targeting MeprSubscription::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( SubscriptionStatus::CANCELLED, SubscriptionStatus::COMPLETED ), true ) ) { |
||
| 465 | $subscription->set_status( SubscriptionStatus::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( SubscriptionStatus::CANCELLED, SubscriptionStatus::COMPLETED ), true ) ) { |
||
| 540 | $subscription->set_status( SubscriptionStatus::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( SubscriptionStatus::CANCELLED, SubscriptionStatus::COMPLETED ), true ) ) { |
||
| 605 | $subscription->set_status( SubscriptionStatus::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
$gateway is correct as Pronamic\WordPress\Pay\P...get_gateway($config_id) targeting Pronamic\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 | $error = null; |
||
| 662 | |||
| 663 | try { |
||
| 664 | $payment = Plugin::start_payment( $payment ); |
||
| 665 | } catch ( \Exception $e ) { |
||
| 666 | $error = $e; |
||
| 667 | |||
| 668 | // @todo What to do? |
||
| 669 | } |
||
| 670 | |||
| 671 | /* |
||
| 672 | * Update transaction subtotal. |
||
| 673 | * |
||
| 674 | * Notes: |
||
| 675 | * - MemberPress also uses trial amount for prorated upgrade/downgrade |
||
| 676 | * - Not updated BEFORE payment start, as transaction total amount is used for subscription amount. |
||
| 677 | */ |
||
| 678 | $subscription = $txn->subscription(); |
||
| 679 | |||
| 680 | if ( $subscription && $subscription->in_trial() ) { |
||
| 681 | $txn->set_subtotal( $subscription->trial_amount ); |
||
| 682 | $txn->store(); |
||
| 683 | } |
||
| 684 | |||
| 685 | if ( ! ( $error instanceof \Exception ) ) { |
||
| 686 | // Redirect. |
||
| 687 | $gateway->redirect( $payment ); |
||
| 688 | } |
||
| 689 | } |
||
| 690 | |||
| 691 | /** |
||
| 692 | * Display payment page. |
||
| 693 | * |
||
| 694 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L219-223 |
||
| 695 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L290 |
||
| 696 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L775-L850 |
||
| 697 | * |
||
| 698 | * @param MeprTransaction $txn MemberPress transaction object. |
||
| 699 | */ |
||
| 700 | public function display_payment_page( $txn ) { |
||
| 701 | // Gateway. |
||
| 702 | $config_id = $this->settings->config_id; |
||
| 703 | |||
| 704 | $gateway = Plugin::get_gateway( $config_id ); |
||
|
0 ignored issues
–
show
Are you sure the assignment to
$gateway is correct as Pronamic\WordPress\Pay\P...get_gateway($config_id) targeting Pronamic\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...
|
|||
| 705 | |||
| 706 | if ( $gateway && '' === $gateway->get_input_html() ) { |
||
| 707 | $this->payment_redirect( $txn ); |
||
| 708 | } |
||
| 709 | } |
||
| 710 | |||
| 711 | /** |
||
| 712 | * Process payment form. |
||
| 713 | * |
||
| 714 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L239-289 |
||
| 715 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L336 |
||
| 716 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L1011 |
||
| 717 | * |
||
| 718 | * @param MeprTransaction $txn MemberPress transaction object. |
||
| 719 | * @return bool |
||
| 720 | */ |
||
| 721 | public function process_payment_form( $txn ) { |
||
| 722 | if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
||
| 723 | return false; |
||
| 724 | } |
||
| 725 | |||
| 726 | // Gateway. |
||
| 727 | $config_id = $this->settings->config_id; |
||
| 728 | |||
| 729 | $gateway = Plugin::get_gateway( $config_id ); |
||
|
0 ignored issues
–
show
Are you sure the assignment to
$gateway is correct as Pronamic\WordPress\Pay\P...get_gateway($config_id) targeting Pronamic\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...
|
|||
| 730 | |||
| 731 | if ( $gateway ) { |
||
| 732 | $this->payment_redirect( $txn ); |
||
| 733 | } |
||
| 734 | } |
||
| 735 | |||
| 736 | /** |
||
| 737 | * Enqueue payment form scripts. |
||
| 738 | * |
||
| 739 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L219-223 |
||
| 740 | */ |
||
| 741 | public function enqueue_payment_form_scripts() { |
||
| 742 | |||
| 743 | } |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Display payment form. |
||
| 747 | * |
||
| 748 | * This spits out html for the payment form on the registration / payment |
||
| 749 | * page for the user to fill out for payment. |
||
| 750 | * |
||
| 751 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L230-233 |
||
| 752 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L248-L251 |
||
| 753 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L318 |
||
| 754 | * |
||
| 755 | * @param float $amount Transaction amount to create a payment form for. |
||
| 756 | * @param MeprUser $user MemberPress user object. |
||
| 757 | * @param int $product_id Product ID. |
||
| 758 | * @param int $txn_id Transaction ID. |
||
| 759 | */ |
||
| 760 | public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
||
| 761 | $product = new MeprProduct( $product_id ); |
||
| 762 | |||
| 763 | $coupon = false; |
||
| 764 | |||
| 765 | $txn = new MeprTransaction( $txn_id ); |
||
| 766 | |||
| 767 | // Artifically set the price of the $prd in case a coupon was used. |
||
| 768 | if ( $product->price !== $amount ) { |
||
| 769 | $coupon = true; |
||
| 770 | $product->price = $amount; |
||
| 771 | } |
||
| 772 | |||
| 773 | $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
||
| 774 | |||
| 775 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
||
| 776 | echo $invoice; |
||
| 777 | |||
| 778 | ?> |
||
| 779 | <div class="mp_wrapper mp_payment_form_wrapper"> |
||
| 780 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
||
| 781 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
||
| 782 | <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
||
| 783 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
||
| 784 | |||
| 785 | <div class="mepr_spacer"> </div> |
||
| 786 | |||
| 787 | <?php |
||
| 788 | |||
| 789 | // Gateway. |
||
| 790 | $config_id = $this->settings->config_id; |
||
| 791 | |||
| 792 | $gateway = Plugin::get_gateway( $config_id ); |
||
|
0 ignored issues
–
show
Are you sure the assignment to
$gateway is correct as Pronamic\WordPress\Pay\P...get_gateway($config_id) targeting Pronamic\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...
|
|||
| 793 | |||
| 794 | if ( $gateway ) { |
||
| 795 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
||
| 796 | echo $gateway->get_input_html(); |
||
| 797 | } |
||
| 798 | |||
| 799 | ?> |
||
| 800 | |||
| 801 | <div class="mepr_spacer"> </div> |
||
| 802 | |||
| 803 | <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
||
| 804 | <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
||
| 805 | <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
||
| 806 | |||
| 807 | <noscript> |
||
| 808 | <p class="mepr_nojs"> |
||
| 809 | <?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' ); ?> |
||
| 810 | </p> |
||
| 811 | </noscript> |
||
| 812 | </form> |
||
| 813 | </div> |
||
| 814 | <?php |
||
| 815 | } |
||
| 816 | |||
| 817 | /** |
||
| 818 | * Validate payment form. |
||
| 819 | * |
||
| 820 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L235-236 |
||
| 821 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprCheckoutCtrl.php#L330 |
||
| 822 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseGateway.php#L253-L254 |
||
| 823 | * |
||
| 824 | * @param array $errors Array with errors. |
||
| 825 | * @return array |
||
| 826 | */ |
||
| 827 | public function validate_payment_form( $errors ) { |
||
| 828 | return $errors; |
||
| 829 | } |
||
| 830 | |||
| 831 | /** |
||
| 832 | * Display options form. |
||
| 833 | * |
||
| 834 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L291-292 |
||
| 835 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/gateways/MeprAuthorizeGateway.php#L1027-1037 |
||
| 836 | */ |
||
| 837 | public function display_options_form() { |
||
| 838 | $mepr_options = MeprOptions::fetch(); |
||
| 839 | |||
| 840 | ?> |
||
| 841 | <table> |
||
| 842 | <tr> |
||
| 843 | <?php |
||
| 844 | |||
| 845 | $name = sprintf( |
||
| 846 | '%s[%s][%s]', |
||
| 847 | $mepr_options->integrations_str, |
||
| 848 | $this->id, |
||
| 849 | 'config_id' |
||
| 850 | ); |
||
| 851 | |||
| 852 | ?> |
||
| 853 | <td> |
||
| 854 | <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
||
| 855 | </td> |
||
| 856 | <td> |
||
| 857 | <select name="<?php echo esc_attr( $name ); ?>"> |
||
| 858 | <?php |
||
| 859 | |||
| 860 | foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
||
| 861 | printf( |
||
| 862 | '<option value="%s" %s>%s</option>', |
||
| 863 | esc_attr( $value ), |
||
| 864 | selected( $value, $this->settings->config_id, false ), |
||
| 865 | esc_html( $label ) |
||
| 866 | ); |
||
| 867 | } |
||
| 868 | |||
| 869 | ?> |
||
| 870 | </select> |
||
| 871 | </td> |
||
| 872 | </tr> |
||
| 873 | </table> |
||
| 874 | <?php |
||
| 875 | } |
||
| 876 | |||
| 877 | /** |
||
| 878 | * Validate options form. |
||
| 879 | * |
||
| 880 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L294-295 |
||
| 881 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprPayPalGateway.php#L909-L924 |
||
| 882 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/models/MeprOptions.php#L416-L423 |
||
| 883 | * |
||
| 884 | * @param array $errors Array with errors. |
||
| 885 | * @return array |
||
| 886 | */ |
||
| 887 | public function validate_options_form( $errors ) { |
||
| 888 | return $errors; |
||
| 889 | } |
||
| 890 | |||
| 891 | /** |
||
| 892 | * Enqueue user account scripts. |
||
| 893 | * |
||
| 894 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L297-302 |
||
| 895 | */ |
||
| 896 | public function enqueue_user_account_scripts() { |
||
| 897 | |||
| 898 | } |
||
| 899 | |||
| 900 | /** |
||
| 901 | * Display update account form. |
||
| 902 | * |
||
| 903 | * @param int $sub_id Subscription ID. |
||
| 904 | * @param array $errors Array with errors. |
||
| 905 | * @param string $message Update message. |
||
| 906 | * |
||
| 907 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L365-366 |
||
| 908 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/lib/MeprBaseStaticGateway.php#L160-L161 |
||
| 909 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
||
| 910 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
||
| 911 | */ |
||
| 912 | public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
||
| 913 | |||
| 914 | } |
||
| 915 | |||
| 916 | /** |
||
| 917 | * Validate update account form. |
||
| 918 | * |
||
| 919 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L368-369 |
||
| 920 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1170-L1173 |
||
| 921 | * |
||
| 922 | * @param array $errors Array with errors. |
||
| 923 | * @return array |
||
| 924 | */ |
||
| 925 | public function validate_update_account_form( $errors = array() ) { |
||
| 926 | return $errors; |
||
| 927 | } |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Process update account form. |
||
| 931 | * |
||
| 932 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L371-372 |
||
| 933 | * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1175-L1181 |
||
| 934 | * |
||
| 935 | * @param int $sub_id Subscription ID. |
||
| 936 | */ |
||
| 937 | public function process_update_account_form( $sub_id ) { |
||
| 938 | |||
| 939 | } |
||
| 940 | |||
| 941 | /** |
||
| 942 | * Is test mode. |
||
| 943 | * |
||
| 944 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L374-375 |
||
| 945 | * |
||
| 946 | * @return boolean |
||
| 947 | */ |
||
| 948 | public function is_test_mode() { |
||
| 949 | return false; |
||
| 950 | } |
||
| 951 | |||
| 952 | /** |
||
| 953 | * Force SSL. |
||
| 954 | * |
||
| 955 | * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L377-378 |
||
| 956 | * |
||
| 957 | * @return boolean |
||
| 958 | */ |
||
| 959 | public function force_ssl() { |
||
| 960 | return false; |
||
| 961 | } |
||
| 962 | } |
||
| 963 |
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.