diff --git a/laterpay/__init__.py b/laterpay/__init__.py index 17f32ed..31afa7f 100644 --- a/laterpay/__init__.py +++ b/laterpay/__init__.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function -import copy import json import logging import random @@ -231,7 +230,8 @@ def _get_web_url(self, transaction_reference=None, consumable=False): - data = copy.copy(item_definition.data) + # filter out params with None value. + data = {k: v for k, v in item_definition.data.items() if v is not None} if use_jsevents: data['jsevents'] = 1 diff --git a/tests/test_client.py b/tests/test_client.py index 4ff78eb..d60db70 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -85,6 +85,15 @@ def test_transaction_reference(self): use_jsevents=True, transaction_reference='123') + def test_get_web_url_has_no_none_params(self): + # item with expiry not set. + item = ItemDefinition(1, 'EUR20', 'DE19.0', 'http://help.me/', 'title') + url = self.lp.get_add_url(item) + self.assertFalse( + 'expiry%3DNone' in url, + 'expiry url param is "None". Should be omitted.', + ) + if __name__ == '__main__': unittest.main()