llms_can_gateway_be_used_for_plan( string $gateway_id, LLMS_Access_Plan $plan )
Determine if a gateway can be used for a give LLMS_Access_Plan.
Description Description
Parameters Parameters
- $gateway_id
-
(string) (Required) LLMS_Payment_Gateway ID.
- $plan
-
(LLMS_Access_Plan) (Required) The access plan.
Return Return
(WP_Error|bool) WP_Error on error, true on success
Source Source
File: includes/functions/llms.functions.order.php
function llms_can_gateway_be_used_for_plan( $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() ) { $err->add( 'gateway-error', __( 'The selected payment gateway is not currently enabled.', 'lifterlms' ) ); return $err; // it's a recurring plan and the gateway doesn't support recurring } elseif ( $plan->is_recurring() && ! $gateway->supports( 'recurring_payments' ) ) { $err->add( 'gateway-error', sprintf( __( '%s does not support recurring payments and cannot process this transaction.', 'lifterlms' ), $gateway->get_title() ) ); return $err; // not recurring and the gateway doesn't support single payments } elseif ( ! $plan->is_recurring() && ! $gateway->supports( 'single_payments' ) ) { $err->add( 'gateway-error', sprintf( __( '%s does not support single payments and cannot process this transaction.', 'lifterlms' ), $gateway->get_title() ) ); return $err; } } else { $err->add( 'invalid-gateway', __( 'An invalid payment method was selected.', 'lifterlms' ) ); return $err; } return apply_filters( 'llms_can_gateway_be_used_for_plan', true, $gateway_id, $plan ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.29.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: