Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363744 )
Change subject: Use SmashPig version of Currency classes ...................................................................... Use SmashPig version of Currency classes Bug:163868 Change-Id: If9bdaa9f7128d85c13dc0b5f15c0cb7452f1aa80 --- M extension.json M gateway_common/Amount.php D gateway_common/CurrencyRates.php M gateway_common/DonationData.php D gateway_common/NationalCurrencies.php M gateway_common/gateway.adapter.php M modules/CurrencyRatesModule.php M tests/phpunit/Adapter/Amazon/AmazonTest.php 8 files changed, 9 insertions(+), 443 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/44/363744/1 diff --git a/extension.json b/extension.json index d6367ad..0c35e95 100644 --- a/extension.json +++ b/extension.json @@ -67,7 +67,6 @@ "FiscalNumber": "gateway_common/FiscalNumber.php", "ClientSideValidationHelper": "gateway_common/ClientSideValidationHelper.php", "ContributionTrackingPlusUnique": "gateway_common/ContributionTrackingPlusUnique.php", - "CurrencyRates": "gateway_common/CurrencyRates.php", "CurrencyRatesModule": "modules/CurrencyRatesModule.php", "DonationData": "gateway_common/DonationData.php", "DonationInterface": "DonationInterface.class.php", @@ -91,7 +90,6 @@ "LocalClusterPsr6Cache": "gateway_common/LocalClusterPsr6Cache.php", "LogPrefixProvider": "gateway_common/LogPrefixProvider.php", "MessageUtils": "gateway_common/MessageUtils.php", - "NationalCurrencies": "gateway_common/NationalCurrencies.php", "PaymentError": "gateway_common/PaymentError.php", "PaymentMethod": "gateway_common/PaymentMethod.php", "PaymentResult": "gateway_common/PaymentResult.php", diff --git a/gateway_common/Amount.php b/gateway_common/Amount.php index 434223c..924e2ff 100644 --- a/gateway_common/Amount.php +++ b/gateway_common/Amount.php @@ -1,5 +1,7 @@ <?php +use SmashPig\PaymentData\ReferenceData\CurrencyRates; + class Amount implements ValidationHelper { public function validate( GatewayType $adapter, $normalized, &$errors ) { diff --git a/gateway_common/CurrencyRates.php b/gateway_common/CurrencyRates.php deleted file mode 100644 index 7f20ea7..0000000 --- a/gateway_common/CurrencyRates.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -/** - * Automatically generated from make_exchange_refs.drush.inc:templates/ref_source.php.twig - * -- do not edit! -- - * Instead, run drush make-exchange-refs and look in the 'generated' folder. - */ - -class CurrencyRates { - /** - * Supplies rough (not up-to-date) conversion rates for currencies - */ - - static public $lastUpdated = '2017-01-31'; - - static public function getCurrencyRates() { - // Not rounding numbers under 1 because I don't think that's a big issue and could cause issues with the max check. - $currencyRates = array( - 'ADF' => 6.11, - 'ADP' => 155, - 'AED' => 3.67, - 'AFA' => 67, - 'AFN' => 67, - 'ALL' => 126, - 'AMD' => 486, - 'ANG' => 1.78, - 'AOA' => 165, - 'AON' => 165, - 'ARS' => 16, - 'ATS' => 13, - 'AUD' => 1.32, - 'AWG' => 1.79, - 'AZM' => 9583, - 'AZN' => 1.92, - 'BAM' => 1.82, - 'BBD' => 2, - 'BDT' => 78, - 'BEF' => 38, - 'BGL' => 1.81, - 'BGN' => 1.81, - 'BHD' => 0.37423, - 'BIF' => 1663, - 'BMD' => 0.99960000000003, - 'BND' => 1.41, - 'BOB' => 6.73, - 'BRL' => 3.13, - 'BSD' => 0.99555000000002, - 'BTN' => 68, - 'BWP' => 10, - 'BYR' => 20020, - 'BZD' => 1.96, - 'CAD' => 1.31, - 'CDF' => 1250, - 'CHF' => 0.99298000000003, - 'CLP' => 647, - 'CNY' => 6.88, - 'COP' => 2922, - 'CRC' => 537, - 'CUC' => 1, - 'CUP' => 23, - 'CVE' => 103, - 'CYP' => 0.54534900000001, - 'CZK' => 25, - 'DEM' => 1.82, - 'DJF' => 178, - 'DKK' => 6.93, - 'DOP' => 46, - 'DZD' => 109, - 'ECS' => 25589, - 'EEK' => 15, - 'EGP' => 19, - 'ESP' => 155, - 'ETB' => 22, - 'EUR' => 0.931784, - 'FIM' => 5.54, - 'FJD' => 2.05, - 'FKP' => 0.79897000000003, - 'FRF' => 6.11, - 'GBP' => 0.79918799999998, - 'GEL' => 2.69, - 'GHC' => 43112, - 'GHS' => 4.31, - 'GIP' => 0.79897000000003, - 'GMD' => 43, - 'GNF' => 9274, - 'GRD' => 318, - 'GTQ' => 7.27, - 'GYD' => 198, - 'HKD' => 7.76, - 'HNL' => 23, - 'HRK' => 6.96, - 'HTG' => 67, - 'HUF' => 289, - 'IDR' => 13316, - 'IEP' => 0.73384000000003, - 'ILS' => 3.77, - 'INR' => 68, - 'IQD' => 1160, - 'IRR' => 32364, - 'ISK' => 116, - 'ITL' => 1804, - 'JMD' => 127, - 'JOD' => 0.70624, - 'JPY' => 113, - 'KES' => 102, - 'KGS' => 69, - 'KHR' => 3959, - 'KMF' => 456, - 'KPW' => 135, - 'KRW' => 1159, - 'KWD' => 0.30433, - 'KYD' => 0.81291999999997, - 'KZT' => 322, - 'LAK' => 8028, - 'LBP' => 1485, - 'LKR' => 149, - 'LRD' => 91, - 'LSL' => 13, - 'LTL' => 3.22, - 'LUF' => 38, - 'LVL' => 0.65486200000002, - 'LYD' => 1.4, - 'MAD' => 9.96, - 'MDL' => 20, - 'MGA' => 3161, - 'MGF' => 9149, - 'MKD' => 57, - 'MMK' => 1329, - 'MNT' => 2444, - 'MOP' => 7.79, - 'MRO' => 353, - 'MTL' => 0.400015, - 'MUR' => 34, - 'MVR' => 15, - 'MWK' => 718, - 'MXN' => 21, - 'MYR' => 4.43, - 'MZM' => 70310, - 'MZN' => 70, - 'NAD' => 13, - 'NGN' => 307, - 'NIO' => 29, - 'NLG' => 2.05, - 'NOK' => 8.29, - 'NPR' => 107, - 'NZD' => 1.37, - 'OMR' => 0.38365, - 'PAB' => 1, - 'PEN' => 3.25, - 'PGK' => 3.11, - 'PHP' => 50, - 'PKR' => 104, - 'PLN' => 4.03, - 'PTE' => 187, - 'PYG' => 5648, - 'QAR' => 3.64, - 'ROL' => 41891, - 'RON' => 4.19, - 'RSD' => 115, - 'RUB' => 60, - 'RWF' => 817, - 'SAR' => 3.75, - 'SBD' => 7.64, - 'SCR' => 12, - 'SDD' => 646, - 'SDG' => 6.46, - 'SDP' => 2272, - 'SEK' => 8.8, - 'SGD' => 1.42, - 'SHP' => 0.79937099999998, - 'SIT' => 223, - 'SKK' => 28, - 'SLL' => 7418, - 'SOS' => 542, - 'SRD' => 7.45, - 'SRG' => 7447, - 'STD' => 22700, - 'SVC' => 8.51, - 'SYP' => 215, - 'SZL' => 13, - 'THB' => 35, - 'TJS' => 7.9, - 'TMM' => 17016, - 'TMT' => 3.4, - 'TND' => 2.28, - 'TOP' => 2.28, - 'TRL' => 3781090, - 'TRY' => 3.78, - 'TTD' => 6.62, - 'TWD' => 31, - 'TZS' => 2184, - 'UAH' => 27, - 'UGX' => 3541, - 'USD' => 1, - 'UYU' => 28, - 'UZS' => 3212, - 'VEB' => 9974, - 'VEF' => 9.97, - 'VND' => 22263, - 'VUV' => 106, - 'WST' => 2.55, - 'XAF' => 612, - 'XAG' => 0.0577804, - 'XAU' => 0.00083116099999998, - 'XCD' => 2.69, - 'XEU' => 0.931784, - 'XOF' => 612, - 'XPD' => 0.00132912, - 'XPF' => 111, - 'XPT' => 0.00100675, - 'YER' => 250, - 'YUN' => 115, - 'ZAR' => 13, - 'ZMK' => 5328, - 'ZWD' => 376, - ); - - return $currencyRates; - } -} diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php index 823481d..7e28df5 100644 --- a/gateway_common/DonationData.php +++ b/gateway_common/DonationData.php @@ -1,4 +1,6 @@ <?php +use SmashPig\PaymentData\ReferenceData\CurrencyRates; +use SmashPig\PaymentData\ReferenceData\NationalCurrencies; /** * DonationData diff --git a/gateway_common/NationalCurrencies.php b/gateway_common/NationalCurrencies.php deleted file mode 100644 index 430e9d5..0000000 --- a/gateway_common/NationalCurrencies.php +++ /dev/null @@ -1,221 +0,0 @@ -<?php - -class NationalCurrencies { - /** - * Retrieved from reference on Jul 6, 2012 - * http://fasteri.com/list/country-code-dialing-code-currency-timezone-of-countries.html - */ - static function getNationalCurrency( $country ) { - $country = substr( $country, 0, 2 ); - $country = strtoupper( $country ); - $nationalCurrencies = NationalCurrencies::getNationalCurrencies(); - if ( isset( $nationalCurrencies[$country] ) ) { - return $nationalCurrencies[$country]; - } - else - return NULL; - } - - static function getNationalCurrencies() { - $nationalCurrencies = array( - "AF" => "AFN", - "AX" => "EUR", - "AL" => "ALL", - "DZ" => "DZD", - "AS" => "USD", - "AD" => "EUR", - "AO" => "AOA", - "AI" => "XCD", - "AG" => "XCD", - "AR" => "ARS", - "AM" => "AMD", - "AW" => "AWG", - "AU" => "AUD", - "AT" => "EUR", - "AZ" => "AZN", - "BS" => "BSD", - "BH" => "BHD", - "BD" => "BDT", - "BB" => "BBD", - "BY" => "BYR", - "BE" => "EUR", - "BZ" => "BZD", - "BJ" => "XOF", - "BM" => "BMD", - "BT" => "BTN", - "BO" => "BOB", - "BQ" => "USD", - "BA" => "BAM", - "BW" => "BWP", - "BR" => "BRL", - "IO" => "USD", - "BN" => "BND", - "BG" => "BGN", - "BF" => "XOF", - "BI" => "BIF", - "KH" => "KHR", - "CM" => "XAF", - "CA" => "CAD", - "CV" => "CVE", - "KY" => "KYD", - "CF" => "XAF", - "TD" => "XAF", - "CL" => "CLP", - "CN" => "CNY", - "CX" => "AUD", - "CC" => "AUD", - "CO" => "COP", - "KM" => "KMF", - "CG" => "XAF", - "CD" => "CDF", - "CK" => "NZD", - "CR" => "CRC", - "CI" => "XOF", - "HR" => "HRK", - "CU" => "CUC", - "CW" => "ANG", - "CY" => "EUR", - "CZ" => "CZK", - "DK" => "DKK", - "DJ" => "DJF", - "DM" => "XCD", - "DO" => "DOP", - "TL" => "USD", - "EC" => "USD", - "EG" => "EGP", - "SV" => "SVC", - "GQ" => "XAF", - "ER" => "ERN", - "EE" => "EUR", - "ET" => "ETB", - "FK" => "FKP", - "FO" => "DKK", - "FJ" => "FJD", - "FI" => "EUR", - "FR" => "EUR", - "GF" => "EUR", - "PF" => "XPF", - "TF" => "EUR", - "GA" => "XAF", - "GM" => "GMD", - "GE" => "GEL", - "DE" => "EUR", - "GH" => "GHS", - "GI" => "GIP", - "GR" => "EUR", - "GL" => "DKK", - "GD" => "XCD", - "GP" => "EUR", - "GU" => "USD", - "GT" => "GTQ", - "GG" => "GBP", - "GN" => "GNF", - "GW" => "XOF", - "GY" => "GYD", - "HT" => "HTG", - "HN" => "HNL", - "HK" => "HKD", - "HU" => "HUF", - "IS" => "ISK", - "IN" => "INR", - "ID" => "IDR", - "IR" => "IRR", - "IQ" => "IQD", - "IE" => "EUR", - "IM" => "GBP", - "IL" => "ILS", - "IT" => "EUR", - "JM" => "JMD", - "JP" => "JPY", - "JE" => "GBP", - "JO" => "JOD", - "KZ" => "KZT", - "KE" => "KES", - "KI" => "AUD", - "KW" => "KWD", - "KG" => "KGS", - "LA" => "LAK", - "LV" => "LVL", - "LB" => "LBP", - "LS" => "LSL", - "LR" => "LRD", - "LY" => "LYD", - "LI" => "CHF", - "LT" => "EUR", - "LU" => "EUR", - "MO" => "MOP", - "MK" => "MKD", - "MG" => "MGA", - "MW" => "MWK", - "MY" => "MYR", - "MV" => "MVR", - "ML" => "XOF", - "MT" => "EUR", - "MH" => "USD", - "MQ" => "EUR", - "MR" => "MRO", - "MU" => "EUR", - "MS" => "XCD", - "MA" => "MAD", - "MX" => "MXN", - "MZ" => "MZN", - "MM" => "MMK", - "NA" => "NAD", - "NR" => "AUD", - "NP" => "NPR", - "NL" => "EUR", - "NC" => "XPF", - "NZ" => "NZD", - "NI" => "NIO", - "NE" => "XOF", - "NG" => "NGN", - "NU" => "NZD", - "NF" => "AUD", - "KP" => "KPW", - "MP" => "USD", - "NO" => "NOK", - "OM" => "OMR", - "PK" => "PKR", - "PW" => "USD", - "PS" => "ILS", - "PA" => "PAB", - "PG" => "PGK", - "PY" => "PYG", - "PE" => "PEN", - "PH" => "PHP", - "PN" => "NZD", - "PL" => "PLN", - "PT" => "EUR", - "PR" => "USD", - "QA" => "QAR", - "RE" => "NZD", - "TO" => "TOP", - "TT" => "TTD", - "TN" => "TND", - "TR" => "TRY", - "TM" => "TMT", - "TC" => "USD", - "TV" => "AUD", - "UG" => "UGX", - "UA" => "UAH", - "AE" => "AED", - "GB" => "GBP", - "US" => "USD", - "UM" => "USD", - "UY" => "UYU", - "UZ" => "UZS", - "VU" => "VUV", - "VA" => "EUR", - "VE" => "VEF", - "VN" => "VND", - "VG" => "Non", - "VI" => "USD", - "WF" => "XPF", - "EH" => "MAD", - "YE" => "YER", - "ZM" => "ZMK", - "ZW" => "BWP", - ); - return $nationalCurrencies; - } -} diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index e34988d..7ab4174 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -21,6 +21,8 @@ use MediaWiki\Session\SessionManager; use Psr\Log\LogLevel; use SmashPig\Core\UtcDate; +use SmashPig\PaymentData\ReferenceData\CurrencyRates; +use SmashPig\PaymentData\ReferenceData\NationalCurrencies; use Symfony\Component\Yaml\Parser; /** diff --git a/modules/CurrencyRatesModule.php b/modules/CurrencyRatesModule.php index 18e9c12..a133c6c 100644 --- a/modules/CurrencyRatesModule.php +++ b/modules/CurrencyRatesModule.php @@ -1,4 +1,5 @@ <?php +use SmashPig\PaymentData\ReferenceData\CurrencyRates; /** * Dynamically generate the javascript currency rates @@ -20,4 +21,4 @@ public function enableModuleContentVersion() { return true; } -} \ No newline at end of file +} diff --git a/tests/phpunit/Adapter/Amazon/AmazonTest.php b/tests/phpunit/Adapter/Amazon/AmazonTest.php index 3b29316..6a75838 100644 --- a/tests/phpunit/Adapter/Amazon/AmazonTest.php +++ b/tests/phpunit/Adapter/Amazon/AmazonTest.php @@ -14,6 +14,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +use SmashPig\PaymentData\ReferenceData\CurrencyRates; use SmashPig\PaymentProviders\Amazon\Tests\AmazonTestConfiguration; use SmashPig\Tests\TestingContext; -- To view, visit https://gerrit.wikimedia.org/r/363744 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If9bdaa9f7128d85c13dc0b5f15c0cb7452f1aa80 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits