Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -1726,6 +1726,24 @@ |
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | /** |
| 1730 | + * Floor the amount |
| 1731 | + * |
| 1732 | + * Some amounts for GlobalCollect cannot have cents. We will not round up. |
| 1733 | + * |
| 1734 | + * For example: JPY 1000.05 get changed to 100005. This need to be 100000. |
| 1735 | + * For example: JPY 1000.95 get changed to 100095. This need to be 100000. |
| 1736 | + * |
| 1737 | + * |
| 1738 | + * @param string $value |
| 1739 | + */ |
| 1740 | + protected function floorAmount( $value ) { |
| 1741 | + |
| 1742 | + $value = substr( $value, 0, -2 ) . '00'; |
| 1743 | + |
| 1744 | + return $value; |
| 1745 | + } |
| 1746 | + |
| 1747 | + /** |
1730 | 1748 | * Stage: amount |
1731 | 1749 | * |
1732 | 1750 | * @param string $type request|response |
— | — | @@ -1733,7 +1751,20 @@ |
1734 | 1752 | protected function stage_amount( $type = 'request' ) { |
1735 | 1753 | switch ( $type ) { |
1736 | 1754 | case 'request': |
| 1755 | + |
| 1756 | + $floor = false; |
| 1757 | + |
| 1758 | + if ( $this->staged_data['currency_code'] == 'JPY' ) { |
| 1759 | + $floor = true; |
| 1760 | + } |
| 1761 | + |
1737 | 1762 | $this->staged_data['amount'] = $this->staged_data['amount'] * 100; |
| 1763 | + |
| 1764 | + // Floor if required |
| 1765 | + if ( $floor ) { |
| 1766 | + $this->staged_data['amount'] = $this->floorAmount( $this->staged_data['amount'] ); |
| 1767 | + } |
| 1768 | + |
1738 | 1769 | break; |
1739 | 1770 | case 'response': |
1740 | 1771 | $this->staged_data['amount'] = $this->staged_data['amount'] / 100; |