Browse files

Cast the amount to string before comparing with the result.

Since we bascially do not care if the amount for the payment is given
as a string or int, we cast the amount to a string before we compare
it to the string we got back from Mollie.
  • Loading branch information...
1 parent adeb816 commit c762b53eadc2b0099f2046c848b9f95326f3e9fb Mark van Lent committed Apr 4, 2012
Showing with 13 additions and 1 deletion.
  1. +1 −1 collective/mollie/
  2. +12 −0 collective/mollie/tests/
@@ -103,7 +103,7 @@ def request_payment(self, partner_id, bank_id, amount, message, report_url,
data['profile_key'] = profile_key
answer = self._call_mollie(data)
order = answer.get('order')
- if order.get('amount') != amount:
+ if order.get('amount') != str(amount):
raise ValueError('The amount for the payment is incorrect.')
if order.get('currency') != 'EUR':
raise ValueError('The currency for the payment is incorrect.')
@@ -107,6 +107,18 @@ def side_effect(*args, **kwargs):
self.partner_id, self.bank_id, self.amount, self.message,
self.report_url, self.return_url)
+ def test_payment_request_amount_int(self):
+ """Check that the amount can also be an int."""
+ def side_effect(*args, **kwargs):
+ return mock_do_request('request_payment_good.xml')
+ self.ideal._do_request = MagicMock(
+ side_effect=side_effect)
+ transaction_id, url = self.ideal.request_payment(
+ self.partner_id, self.bank_id, int(self.amount), self.message,
+ self.report_url, self.return_url)
+ # The fact that no error was raised proves that the amount was correct.
+ self.assertTrue(transaction_id == '482d599bbcc7795727650330ad65fe9b')
def test_payment_request_wrong_currency(self):
"""Check payment request with wrong currency in answer"""
def side_effect(*args, **kwargs):

0 comments on commit c762b53

Please sign in to comment.