Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Controller_Orders::validate_selected_gateway( string $gateway_id, obj $plan )
Validate a gateway can be used to process the current action / transaction
Description Description
Parameters Parameters
- $gateway_id
-
(string) (Required) gateway's id
- $plan
-
(obj) (Required) instance of the LLMS_Access_Plan related to the action/transaction
Return Return
(mixed) WP_Error or LLMS_Payment_Gateway subclass
Source Source
File: includes/controllers/class.llms.controller.orders.php
private function validate_selected_gateway( $gateway_id, $plan ) { $gateway = LLMS()->payment_gateways()->get_gateway_by_id( $gateway_id ); $err = new WP_Error(); // valid gateway if ( is_subclass_of( $gateway, 'LLMS_Payment_Gateway' ) ) { // gateway not enabled if ( 'manual' !== $gateway->get_id() && ! $gateway->is_enabled() ) { return $err->add( 'gateway-error', __( 'The selected payment gateway is not currently enabled.', 'lifterlms' ) ); // it's a recurring plan and the gateway doesn't support recurring } elseif ( $plan->is_recurring() && ! $gateway->supports( 'recurring_payments' ) ) { return $err->add( 'gateway-error', sprintf( __( '%s does not support recurring payments and cannot process this transaction.', 'lifterlms' ), $gateway->get_title() ) ); // not recurring and the gateway doesn't support single payments } elseif ( ! $plan->is_recurring() && ! $gateway->supports( 'single_payments' ) ) { return $err->add( 'gateway-error', sprintf( __( '%s does not support single payments and cannot process this transaction.', 'lifterlms' ), $gateway->get_title() ) ); } } else { return $err->add( 'invalid-gateway', __( 'An invalid payment method was selected.', 'lifterlms' ) ); } return $gateway; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.10.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: