Ejemplo n.º 1
0
    def test_pledge_payment_methods(self):
        user = BlueBottleUserFactory.create(can_pledge=False)
        staff_user = BlueBottleUserFactory.create(can_pledge=True)

        methods = get_payment_methods(country="nl", user=user)
        self.assertEqual(len(methods), 1)

        methods = get_payment_methods(country="nl", user=staff_user)
        self.assertEqual(len(methods), 2)
Ejemplo n.º 2
0
    def test_pledge_payment_methods(self):
        user = BlueBottleUserFactory.create(is_staff=False)
        staff_user = BlueBottleUserFactory.create(is_staff=True)

        methods = get_payment_methods(country="nl", user=user)
        self.assertEqual(len(methods), 1)

        methods = get_payment_methods(country="nl", user=staff_user)
        self.assertEqual(len(methods), 2)
Ejemplo n.º 3
0
    def get(self, request, *args, **kwargs):

        if 'country' in request.GET:
            country = request.GET['country']
        else :
            ip = get_ip(request)
            if ip == '127.0.0.1':
                country = 'all'
            else:
                country = get_country_code_by_ip(ip)
        methods = get_payment_methods(country, 500)
        result = {'country': country, 'results': methods}
        response = Response(result, status=status.HTTP_200_OK)
        return response
Ejemplo n.º 4
0
    def get(self, request, *args, **kwargs):
        ip = get_ip(request)
        if ip == '127.0.0.1':
            country = 'all' #get_payment_methods returns all methods when 'all' is specified
        else:
            country = get_country_by_ip(ip)

        # TODO: 1) Determine available methods based on GET params (amount).
        #       2) Re-enable country-based filtering when front-end can handle
        #          manually setting the country. For now send all methods.
        methods = get_payment_methods('all', 500)

        result = {'country': country, 'results': methods}
        response = Response(result, status=status.HTTP_200_OK)
        return response
Ejemplo n.º 5
0
    def get(self, request, *args, **kwargs):
        country = request.GET.get('country')

        if not country and not getattr(settings, 'SKIP_IP_LOOKUP', False):
            ip = get_ip(request)
            country = get_country_code_by_ip(ip)

        # Payment methods are loaded from the settings so they
        # aren't translated at run time. We need to do it manually
        methods = get_payment_methods(country=country,
                                      user=request.user,
                                      currency=request.GET.get('currency'))

        for method in methods:
            method['name'] = _(method['name'])

        result = {'country': country, 'results': methods}
        response = Response(result, status=status.HTTP_200_OK)
        return response
Ejemplo n.º 6
0
 def test_load_non_netherlands_payment_methods(self):
 	methods = get_payment_methods(country="Belgium")
 	self.assertEqual(len(methods), 1)
Ejemplo n.º 7
0
 def test_load_netherlands_payment_methods(self):
 	methods = get_payment_methods(country="Netherlands")
 	self.assertEqual(len(methods), 2)
Ejemplo n.º 8
0
 def test_load_all_payment_methods(self):
 	methods = get_payment_methods(country="all")
 	self.assertEqual(len(methods), 2)
Ejemplo n.º 9
0
    def test_load_non_dutch_euro_payment_methods(self):
        methods = get_payment_methods(currency="EUR", country='Belgium')
        self.assertEqual(len(methods), 1)

        for method in methods:
            self.assertTrue('EUR' in method['currencies'])
Ejemplo n.º 10
0
    def test_load_euro_payment_methods(self):
        methods = get_payment_methods(currency="EUR")
        self.assertEqual(len(methods), 2)

        for method in methods:
            self.assertTrue('EUR' in method['currencies'])
Ejemplo n.º 11
0
 def test_load_non_netherlands_payment_methods(self):
     methods = get_payment_methods(country="Belgium")
     self.assertEqual(len(methods), 2)
Ejemplo n.º 12
0
 def test_load_all_payment_methods(self):
     methods = get_payment_methods(country=None)
     self.assertEqual(len(methods), 3)
Ejemplo n.º 13
0
    def test_invalid_method_access_handler(self):
        user = BlueBottleUserFactory.create()

        with self.assertRaises(Exception):
            get_payment_methods(country="nl", user=user)