hooks(); } } /** * @return Gateway[] Keyed by gateway ID. */ public static function all() { if ( null === self::$gateways ) { self::$gateways = array(); $gateways = apply_filters( 'postfee_gateways', array( new Gateway_Stripe(), new Gateway_PayPal(), new Gateway_WooCommerce() ) ); foreach ( $gateways as $gateway ) { if ( $gateway instanceof Gateway ) { self::$gateways[ $gateway->id() ] = $gateway; } } } return self::$gateways; } public static function get( $id ) { $gateways = self::all(); return isset( $gateways[ $id ] ) ? $gateways[ $id ] : null; } /** * Gateways the site owner switched on that are ready to take this plan. */ public static function for_plan( $plan ) { $enabled = (array) postfee_setting( 'gateways', array() ); $list = array(); foreach ( self::all() as $id => $gateway ) { if ( in_array( $id, $enabled, true ) && $gateway->is_available() && $gateway->supports( $plan ) ) { $list[ $id ] = $gateway; } } return $list; } }