https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103514
Revision: 103514
Author: jpostlethwaite
Date: 2011-11-17 22:15:00 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Fixing issue with currency JPY. The amount is floored for the last two digits.
Modified Paths:
--------------
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
Modified:
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
===================================================================
---
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-11-17 21:57:45 UTC (rev 103513)
+++
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-11-17 22:15:00 UTC (rev 103514)
@@ -1726,6 +1726,24 @@
}
/**
+ * Floor the amount
+ *
+ * Some amounts for GlobalCollect cannot have cents. We will not round
up.
+ *
+ * For example: JPY 1000.05 get changed to 100005. This need to be
100000.
+ * For example: JPY 1000.95 get changed to 100095. This need to be
100000.
+ *
+ *
+ * @param string $value
+ */
+ protected function floorAmount( $value ) {
+
+ $value = substr( $value, 0, -2 ) . '00';
+
+ return $value;
+ }
+
+ /**
* Stage: amount
*
* @param string $type request|response
@@ -1733,7 +1751,20 @@
protected function stage_amount( $type = 'request' ) {
switch ( $type ) {
case 'request':
+
+ $floor = false;
+
+ if ( $this->staged_data['currency_code'] ==
'JPY' ) {
+ $floor = true;
+ }
+
$this->staged_data['amount'] =
$this->staged_data['amount'] * 100;
+
+ // Floor if required
+ if ( $floor ) {
+ $this->staged_data['amount'] =
$this->floorAmount( $this->staged_data['amount'] );
+ }
+
break;
case 'response':
$this->staged_data['amount'] =
$this->staged_data['amount'] / 100;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs