Mwalker has submitted this change and it was merged.
Change subject: Round 1 of Japan Localization feedback changes
......................................................................
Round 1 of Japan Localization feedback changes
Change-Id: I7319346377c5263f914d549e85a9b2d9995e3324
---
M adyen_gateway/adyen.adapter.php
M gateway_common/DataValidator.php
M gateway_common/DonationData.php
M gateway_common/gateway.adapter.php
A globalcollect_gateway/forms/html/_personal-information/JP.html
M globalcollect_gateway/globalcollect.adapter.php
6 files changed, 52 insertions(+), 8 deletions(-)
Approvals:
Mwalker: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index ce3cef8..788c6cf 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -294,7 +294,7 @@
protected function stage_amount( $type = 'request' ) {
switch ( $type ) {
case 'request':
- if ( in_array(
$this->staged_data['currency_code'], $this->non_fractional_currencies ) ) {
+ if ( !DataValidator::is_fractional_currency(
$this->staged_data['currency_code'] ) ) {
$this->staged_data['amount'] = floor(
$this->staged_data['amount'] );
}
diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 9f8abff..9eedd0a 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -961,4 +961,21 @@
}
return false;
}
+
+ /**
+ * More of a validation helper function. If an amount is ever expressed
for
+ * the fractional currencies defined in this function,
+ * they should not have an associated fractional amount (so: full
integers only).
+ * @param string $currency_code The three-digit currency code.
+ * @return boolean
+ */
+ public static function is_fractional_currency( $currency_code ){
+ // these currencies cannot have cents.
+ $non_fractional_currencies = array( 'CLP', 'DJF', 'IDR', 'JPY',
'KMF', 'KRW', 'MGA', 'PYG', 'VND', 'XAF', 'XOF', 'XPF' );
+
+ if ( in_array( strtoupper( $currency_code ),
$non_fractional_currencies ) ) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index a3b10ef..98f7e0d 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -636,7 +636,9 @@
return;
}
- $this->setVal( 'amount', number_format( $this->getVal( 'amount'
), 2, '.', '' ) );
+ if ( DataValidator::is_fractional_currency( $this->getVal(
'currency_code' ) ) ){
+ $this->setVal( 'amount', number_format( $this->getVal(
'amount' ), 2, '.', '' ) );
+ }
$this->expunge( 'amountGiven' );
$this->expunge( 'amountOther' );
}
diff --git a/gateway_common/gateway.adapter.php
b/gateway_common/gateway.adapter.php
index ded564d..8058db4 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -157,8 +157,6 @@
protected $url;
protected $transactions;
- public $non_fractional_currencies = array();
-
/**
* $payment_methods will be defined by the adapter.
*
@@ -269,9 +267,7 @@
$external_data = $testData;
}
}
- // these currencies cannot have cents.
- $this->non_fractional_currencies = array( 'CLP', 'DJF', 'IDR',
'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'VND', 'XAF', 'XOF', 'XPF' );
-
+
$this->dataObj = new DonationData( get_called_class(),
self::getGlobal( 'Test' ), $external_data );
$this->setValidationErrors(
$this->getOriginalValidationErrors() );
diff --git a/globalcollect_gateway/forms/html/_personal-information/JP.html
b/globalcollect_gateway/forms/html/_personal-information/JP.html
new file mode 100644
index 0000000..22188b4
--- /dev/null
+++ b/globalcollect_gateway/forms/html/_personal-information/JP.html
@@ -0,0 +1,29 @@
+<tr>
+ <td colspan="2">
+ <h3
class="cc_header">%donate_interface-cc-form-header-personal%<img
src="@script_path/extensions/DonationInterface/gateway_forms/includes/padlock.gif"
style="vertical-align:baseline;margin-left:8px;"></h3>
+ </td>
+</tr>
+<tr>
+ <td colspan="2">
+ <input class="halfwidth" name="lname" value="@lname"
type="text" placeholder="%donate_interface-donor-lname%" id="lname"><input
class="halfwidth leftmar" name="fname" value="@fname" type="text"
placeholder="%donate_interface-donor-fname%" id="fname">
+ </td>
+</tr>
+<tr>
+ <td colspan="2">
+ <input class="fullwidth" name="emailAdd" value="@emailAdd" type="text"
title="%donate_interface-donor-email%"
placeholder="%donate_interface-donor-email%" id="emailAdd">
+ </td>
+</tr>
+<tr class="collapsingCity">
+ <td colspan="2">
+ <input class="fullwidth optional" name="city" value="@city"
type="text" title="%donate_interface-city-town%"
placeholder="%donate_interface-city-town%" id="city">
+ </td>
+</tr>
+<tr>
+ <td colspan="2">
+ <select class="txt" id="country" name="country" value="@country"
placeholder="%donate_interface-country%">
+ <option value="">%donate_interface-select-country%</option>
+ @select_country
+ </select>
+ </td>
+</tr>
+
diff --git a/globalcollect_gateway/globalcollect.adapter.php
b/globalcollect_gateway/globalcollect.adapter.php
index 9a1bda3..3537558 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -1886,7 +1886,7 @@
switch ( $type ) {
case 'request':
- if ( in_array(
$this->staged_data['currency_code'], $this->non_fractional_currencies ) ) {
+ if ( !DataValidator::is_fractional_currency(
$this->staged_data['currency_code'] ) ) {
$this->staged_data['amount'] = floor(
$this->staged_data['amount'] );
}
--
To view, visit https://gerrit.wikimedia.org/r/53178
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7319346377c5263f914d549e85a9b2d9995e3324
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Katie Horn <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits