jenkins-bot has submitted this change and it was merged.
Change subject: Move Worldpay currencies to config
......................................................................
Move Worldpay currencies to config
And add a config accessor to GatewayType interface.
Change-Id: I1f2e521d9c37f57c66d2eaedc823e88584871e23
---
M gateway_common/GatewayType.php
M gateway_common/gateway.adapter.php
M worldpay_gateway/WorldpayCurrency.php
A worldpay_gateway/config/currencies.yaml
M worldpay_gateway/worldpay.adapter.php
5 files changed, 144 insertions(+), 134 deletions(-)
Approvals:
Awight: Looks good to me, approved
jenkins-bot: Verified
diff --git a/gateway_common/GatewayType.php b/gateway_common/GatewayType.php
index 4857e05..9560858 100644
--- a/gateway_common/GatewayType.php
+++ b/gateway_common/GatewayType.php
@@ -378,4 +378,11 @@
* @return string
*/
function token_getSaltedSessionToken();
+
+ /**
+ * Get settings loaded from adapter's config directory
+ * @param string|null $key setting to retrieve, or null for all
+ * @return mixed the setting requested, or the config array
+ */
+ public function getConfig( $key = null );
}
diff --git a/gateway_common/gateway.adapter.php
b/gateway_common/gateway.adapter.php
index 115ad65..faa35fc 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -310,6 +310,16 @@
}
}
+ public function getConfig( $key = null ) {
+ if ( $key === null ) {
+ return $this->config;
+ }
+ if ( array_key_exists( $key, $this->config ) ) {
+ return $this->config[$key];
+ }
+ return null;
+ }
+
// For legacy support.
// TODO replace with access to config structure
public function definePaymentMethods() {
diff --git a/worldpay_gateway/WorldpayCurrency.php
b/worldpay_gateway/WorldpayCurrency.php
index ce553b8..86612f5 100644
--- a/worldpay_gateway/WorldpayCurrency.php
+++ b/worldpay_gateway/WorldpayCurrency.php
@@ -3,8 +3,9 @@
class WorldpayCurrency implements StagingHelper {
public function stage( GatewayType $adapter, $unstagedData,
&$stagedData ) {
$currency = $unstagedData['currency_code'];
- if ( array_key_exists( $currency,
WorldpayAdapter::$CURRENCY_CODES ) ) {
- $stagedData['iso_currency_id'] =
WorldpayAdapter::$CURRENCY_CODES[$currency];
+ $codes = $adapter->getConfig( 'currencies' );
+ if ( array_key_exists( $currency, $codes ) ) {
+ $stagedData['iso_currency_id'] = $codes[$currency];
}
}
}
diff --git a/worldpay_gateway/config/currencies.yaml
b/worldpay_gateway/config/currencies.yaml
new file mode 100644
index 0000000..fd1e9ca
--- /dev/null
+++ b/worldpay_gateway/config/currencies.yaml
@@ -0,0 +1,123 @@
+# ISO Currency code letters to numbers (from appendix B of the
+# integration manual). These are also apparently all the currencies
+# that Worldpay can support.
+AED: 784
+ALL: 8
+ANG: 532
+ARS: 32
+AUD: 36
+AWG: 533
+AZN: 944
+BAM: 977
+BBD: 52
+BDT: 50
+BGN: 975
+BHD: 48
+BMD: 60
+BND: 96
+BOB: 68
+BRL: 986
+BSD: 44
+BWP: 72
+BZD: 84
+CAD: 124
+CHF: 756
+CLP: 152
+CNY: 156
+COP: 170
+CRC: 188
+CUP: 192
+CZK: 203
+DJF: 262
+DKK: 208
+DOP: 214
+DZD: 12
+EGP: 818
+ERN: 232
+ETB: 230
+EUR: 978
+FJD: 242
+GBP: 826
+GEL: 981
+GIP: 292
+GTQ: 320
+GYD: 328
+HKD: 344
+HNL: 340
+HRK: 191
+HTG: 332
+HUF: 348
+IDR: 360
+ILS: 376
+INR: 356
+IQD: 368
+JMD: 388
+JOD: 400
+JPY: 392
+KES: 404
+KHR: 116
+KRW: 410
+KWD: 414
+KYD: 136
+KZT: 398
+LBP: 422
+LKR: 144
+LSL: 426
+LTL: 440
+LVL: 428
+MAD: 504
+MKD: 807
+MNT: 496
+MOP: 446
+MRO: 478
+MUR: 480
+MVR: 462
+MWK: 454
+MXN: 484
+MYR: 458
+MZN: 943
+NAD: 516
+NGN: 566
+NIO: 558
+NOK: 578
+NPR: 524
+NZD: 554
+OMR: 512
+PAB: 590
+PEN: 604
+PGK: 598
+PHP: 608
+PKR: 586
+PLN: 985
+PYG: 600
+QAR: 634
+RON: 946
+RSD: 941
+RUB: 643
+RWF: 646
+SAR: 682
+SCR: 690
+SEK: 752
+SGD: 702
+SLL: 694
+SVC: 222
+SYP: 760
+SZL: 748
+THB: 764
+TND: 788
+TRY: 949
+TTD: 780
+TWD: 901
+TZS: 834
+UAH: 980
+USD: 840
+UYU: 858
+UZS: 860
+VEF: 937
+XAF: 950
+XCD: 951
+XOF: 952
+XPF: 953
+YER: 886
+ZAR: 710
+ZMK: 894
diff --git a/worldpay_gateway/worldpay.adapter.php
b/worldpay_gateway/worldpay.adapter.php
index 3851771..85d8800 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -34,137 +34,6 @@
'OTTResultURL'
);
-
- /**
- * @var string[] ISO Currency code letters to numbers (from appendix B
of the
- * integration manual). These are also apparently all the currencies
that
- * Worldpay can support.
- *
- * TODO: move to reference data
- */
- public static $CURRENCY_CODES = array(
- 'AED' => 784,
- 'ALL' => 8,
- 'ANG' => 532,
- 'ARS' => 32,
- 'AUD' => 36,
- 'AWG' => 533,
- 'AZN' => 944,
- 'BAM' => 977,
- 'BBD' => 52,
- 'BDT' => 50,
- 'BGN' => 975,
- 'BHD' => 48,
- 'BMD' => 60,
- 'BND' => 96,
- 'BOB' => 68,
- 'BRL' => 986,
- 'BSD' => 44,
- 'BWP' => 72,
- 'BZD' => 84,
- 'CAD' => 124,
- 'CHF' => 756,
- 'CLP' => 152,
- 'CNY' => 156,
- 'COP' => 170,
- 'CRC' => 188,
- 'CUP' => 192,
- 'CZK' => 203,
- 'DJF' => 262,
- 'DKK' => 208,
- 'DOP' => 214,
- 'DZD' => 12,
- 'EGP' => 818,
- 'ERN' => 232,
- 'ETB' => 230,
- 'EUR' => 978,
- 'FJD' => 242,
- 'GBP' => 826,
- 'GEL' => 981,
- 'GIP' => 292,
- 'GTQ' => 320,
- 'GYD' => 328,
- 'HKD' => 344,
- 'HNL' => 340,
- 'HRK' => 191,
- 'HTG' => 332,
- 'HUF' => 348,
- 'IDR' => 360,
- 'ILS' => 376,
- 'INR' => 356,
- 'IQD' => 368,
- 'JMD' => 388,
- 'JOD' => 400,
- 'JPY' => 392,
- 'KES' => 404,
- 'KHR' => 116,
- 'KRW' => 410,
- 'KWD' => 414,
- 'KYD' => 136,
- 'KZT' => 398,
- 'LBP' => 422,
- 'LKR' => 144,
- 'LSL' => 426,
- 'LTL' => 440,
- 'LVL' => 428,
- 'MAD' => 504,
- 'MKD' => 807,
- 'MNT' => 496,
- 'MOP' => 446,
- 'MRO' => 478,
- 'MUR' => 480,
- 'MVR' => 462,
- 'MWK' => 454,
- 'MXN' => 484,
- 'MYR' => 458,
- 'MZN' => 943,
- 'NAD' => 516,
- 'NGN' => 566,
- 'NIO' => 558,
- 'NOK' => 578,
- 'NPR' => 524,
- 'NZD' => 554,
- 'OMR' => 512,
- 'PAB' => 590,
- 'PEN' => 604,
- 'PGK' => 598,
- 'PHP' => 608,
- 'PKR' => 586,
- 'PLN' => 985,
- 'PYG' => 600,
- 'QAR' => 634,
- 'RON' => 946,
- 'RSD' => 941,
- 'RUB' => 643,
- 'RWF' => 646,
- 'SAR' => 682,
- 'SCR' => 690,
- 'SEK' => 752,
- 'SGD' => 702,
- 'SLL' => 694,
- 'SVC' => 222,
- 'SYP' => 760,
- 'SZL' => 748,
- 'THB' => 764,
- 'TND' => 788,
- 'TRY' => 949,
- 'TTD' => 780,
- 'TWD' => 901,
- 'TZS' => 834,
- 'UAH' => 980,
- 'USD' => 840,
- 'UYU' => 858,
- 'UZS' => 860,
- 'VEF' => 937,
- 'XAF' => 950,
- 'XCD' => 951,
- 'XOF' => 952,
- 'XPF' => 953,
- 'YER' => 886,
- 'ZAR' => 710,
- 'ZMK' => 894,
- );
-
public function __construct( $options = array ( ) ) {
parent::__construct( $options );
}
@@ -300,7 +169,7 @@
}
public function getCurrencies( $options = array() ) {
- return array_keys( self::$CURRENCY_CODES );
+ return array_keys( $this->config['currencies'] );
}
function defineTransactions() {
--
To view, visit https://gerrit.wikimedia.org/r/281043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1f2e521d9c37f57c66d2eaedc823e88584871e23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits