api_client = $api_client; if ( WC_Payments_Features::should_use_stripe_billing() ) { add_filter( 'woocommerce_subscriptions_minimum_processable_recurring_amount', [ $this, 'get_minimum_recurring_amount' ], 10, 2 ); } } /** * Gets the minimum WC Pay Subscription recurring amount that can be transacted in a given currency. * * @param int|bool $minimum_amount The minimum amount that can be processed in recurring transactions. Can be an int (the minimum amount) or false if no minimum exists. * @param string $currency_code The currency to fetch the minimum amount in. * * @return float The minimum recurring amount. */ public function get_minimum_recurring_amount( $minimum_amount, $currency_code ) { $transient_key = self::MINIMUM_RECURRING_AMOUNT_TRANSIENT_KEY . "_$currency_code"; // Enforce uppercase. $transient_key = strtoupper( $transient_key ); // Minimum amount is purposefully immediately overwritten. The calling function passes a default value which we must receive. $minimum_amount = get_transient( $transient_key ); if ( false === $minimum_amount ) { try { $minimum_amount = $this->api_client->get_currency_minimum_recurring_amount( $currency_code ); } catch ( \WCPay\Exceptions\API_Exception $exception ) { // Currency not supported or other API error. $minimum_amount = 0; } set_transient( $transient_key, $minimum_amount, self::MINIMUM_RECURRING_AMOUNTS_TRANSIENT_EXPIRATION ); } return WC_Payments_Utils::interpret_stripe_amount( (int) $minimum_amount, strtolower( $currency_code ) ); } }