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, LLMS_Access_Plan $plan )
Validate a gateway can be used to process the current action / transaction.
Parameters Parameters
- $gateway_id
-
(string) (Required) Gateway's id.
- $plan
-
(LLMS_Access_Plan) (Required) Instance of the LLMS_Access_Plan related to the action/transaction.
Return Return
(WP_Error|LLMS_Payment_Gateway) 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' ) ) { // Translators: %s = The gateway display name. 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' ) ) { // Translators: %s = The gateway display name. 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. |