This commit is contained in:
emmymayo
2025-02-05 23:15:46 +01:00
commit 7269c99357
16995 changed files with 3389680 additions and 0 deletions
@@ -0,0 +1,61 @@
<?php
/**
* Interface MultiCurrencyAccountInterface
*
* @package WooCommerce\Payments\MultiCurrency\Interfaces
*/
namespace WCPay\MultiCurrency\Interfaces;
defined( 'ABSPATH' ) || exit;
interface MultiCurrencyAccountInterface {
/**
* Checks if the account is connected to the payment provider.
*
* @param bool $on_error Value to return on server error, defaults to false.
*
* @return bool True if the account is connected, false otherwise, $on_error on error.
*/
public function is_provider_connected( bool $on_error = false ): bool;
/**
* Checks if the account has been rejected, assumes the value of false on any account retrieval error.
* Returns false if the account is not connected.
*
* Note: We might want to use a more generic method to check if the account is in an enabled or
* disabled state for better compatibility between V1 and V2.
*
* @return bool True if the account is connected and rejected, false otherwise or on error.
*/
public function is_account_rejected(): bool;
/**
* Gets and caches the data for the account connected to this site.
*
* @param bool $force_refresh Forces data to be fetched from the server, rather than using the cache.
*
* @return array|bool Account data or false if failed to retrieve account data.
*/
public function get_cached_account_data( bool $force_refresh = false );
/**
* Gets the customer currencies supported for the account.
*
* @return array Currencies.
*/
public function get_account_customer_supported_currencies(): array;
/**
* Get list of countries supported by the provider.
*/
public function get_supported_countries(): array;
/**
* Get provider onboarding page url.
*
* @return string
*/
public function get_provider_onboarding_page_url(): string;
}
@@ -0,0 +1,30 @@
<?php
/**
* Interface MultiCurrencyApiClientInterface
*
* @package WooCommerce\Payments\MultiCurrency\Interfaces
*/
namespace WCPay\MultiCurrency\Interfaces;
defined( 'ABSPATH' ) || exit;
interface MultiCurrencyApiClientInterface {
/**
* Whether the API client is connected to the server.
*
* @return bool
*/
public function is_server_connected(): bool;
/**
* Get currency rates from the server.
*
* @param string $currency_from - The currency to convert from.
* @param ?array $currencies_to - An array of the currencies we want to convert into. If left empty, will get all supported currencies.
*
* @return array
*/
public function get_currency_rates( string $currency_from, $currencies_to = null ): array;
}
@@ -0,0 +1,46 @@
<?php
/**
* Interface MultiCurrencyCacheInterface
*
* @package WooCommerce\Payments\MultiCurrency\Interfaces
*/
namespace WCPay\MultiCurrency\Interfaces;
defined( 'ABSPATH' ) || exit;
interface MultiCurrencyCacheInterface {
const CURRENCIES_KEY = 'wcpay_multi_currency_cached_currencies';
/**
* Gets a value from the cache.
*
* @param string $key The key to look for.
* @param bool $force If set, return from the cache without checking for expiry.
*
* @return mixed The cache contents.
*/
public function get( string $key, bool $force = false );
/**
* Gets a value from cache or regenerates and adds it to the cache.
*
* @param string $key The options key to cache the data under.
* @param callable $generator Function/callable regenerating the missing value. If null or false is returned, it will be treated as an error.
* @param callable $validate_data Function/callable validating the data after it is retrieved from the cache. If it returns false, the cache will be refreshed.
* @param boolean $force_refresh Regenerates the cache regardless of its state if true.
* @param boolean $refreshed Is set to true if the cache has been refreshed without errors and with a non-empty value.
*
* @return mixed|null The cache contents. NULL on failure
*/
public function get_or_add( string $key, callable $generator, callable $validate_data, bool $force_refresh = false, bool &$refreshed = false );
/**
* Deletes a value from the cache.
*
* @param string $key The key to delete.
*
* @return void
*/
public function delete( string $key );
}
@@ -0,0 +1,31 @@
<?php
/**
* Interface MultiCurrencyLocalizationInterface
*
* @package WooCommerce\Payments\MultiCurrency\Interfaces
*/
namespace WCPay\MultiCurrency\Interfaces;
defined( 'ABSPATH' ) || exit;
interface MultiCurrencyLocalizationInterface {
/**
* Retrieves the currency's format from mapped data.
*
* @param string $currency_code The currency code.
*
* @return array The currency's format.
*/
public function get_currency_format( $currency_code ): array;
/**
* Returns the locale data for a country.
*
* @param string $country Country code.
*
* @return array Array with the country's locale data. Empty array if country not found.
*/
public function get_country_locale_data( $country ): array;
}
@@ -0,0 +1,34 @@
<?php
/**
* Interface MultiCurrencySettingsInterface
*
* @package WooCommerce\Payments\MultiCurrency\Interfaces
*/
namespace WCPay\MultiCurrency\Interfaces;
defined( 'ABSPATH' ) || exit;
interface MultiCurrencySettingsInterface {
/**
* Checks if dev mode is enabled.
*
* @return bool
*/
public function is_dev_mode(): bool;
/**
* Gets the plugin file path.
*
* @return string
*/
public function get_plugin_file_path(): string;
/**
* Gets the plugin version.
*
* @return string
*/
public function get_plugin_version(): string;
}