Beispiel #1
0
 def test_get_backends_cache_works(self):
     MODIFIERS = ['shop.tests.payment.ValidMockPaymentBackend']
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         backends_pool.use_cache = True
         list_ = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list_), 1)
         list2 = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list2), 1)
         self.assertEqual(list_, list2)
Beispiel #2
0
 def test_09_get_backends_cache_works(self):
     MODIFIERS = ['shop.tests.payment.ValidMockPaymentBackend']
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         backends_pool.use_cache = True
         list = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list), 1)
         list2 = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list2), 1)
         self.assertEqual(list, list2)
Beispiel #3
0
 def get_context_data(self, **kwargs):
     """
     This overrides the context from the normal template view
     """
     ctx = super(SelectPaymentView, self).get_context_data(**kwargs)
     payment_modules_list = backends_pool.get_payment_backends_list()
     
     select = {}
     
     for backend in payment_modules_list:
         url = reverse(backend.url_namespace)
         select.update({backend.backend_name:url})
     ctx.update({'payment_options':select})
     return ctx
Beispiel #4
0
 def get_context_data(self, **kwargs):
     """
     This overrides the context from the normal template view
     """
     ctx = super(SelectPaymentView, self).get_context_data(**kwargs)
     payment_modules_list = backends_pool.get_payment_backends_list()
     
     select = {}
     
     for backend in payment_modules_list:
         url = reverse(backend.url_namespace)
         select.update({backend.backend_name:url})
     ctx.update({'payment_options':select})
     return ctx
Beispiel #5
0
 def setUp(self):
     self.save_received_data = False  # if True, leave a hard copy of the html sources received from the PSP
     self.create_fake_order()
     self.viveum_backend = backends_pool.get_payment_backends_list()[0]
     self.factory = RequestFactory()
     self.request = Mock()
     setattr(self.request, 'session', {})
     setattr(self.request, 'is_secure', lambda: False)
     user = User.objects.create(username="******", email="*****@*****.**",
         first_name="Test", last_name="Tester",
         password="******")
     setattr(self.request, 'user', user)
     self.country_usa = Country(name='USA')
     self.country_usa.save()
     self.client = Client()
     self.client.login(username='******', password='******')
     self.add_product_to_cart()
     self.checkout()
Beispiel #6
0
 def setUp(self):
     current_site = Site.objects.get(id=settings.SITE_ID)
     current_site.domain = settings.HOST_NAME
     current_site.save()
     self._create_fake_order()
     self.ipayment_backend = backends_pool.get_payment_backends_list()[0]
     self.factory = RequestFactory()
     self.request = Mock()
     setattr(self.request, 'session', {})
     setattr(self.request, 'is_secure', lambda: False)
     user = User.objects.create(username="******", email="*****@*****.**",
         first_name="Test", last_name="Tester",
         password="******")
     setattr(self.request, 'user', user)
     self.country_usa = Country(name='USA')
     self.country_usa.save()
     self.client = Client()
     self.client.login(username='******', password='******')
     self._create_cart()
     self._go_shopping()
Beispiel #7
0
    def get_context_data(self, **kwargs):
        """
        This overrides the context from the normal template view
        """
        ctx = super(ShippingBillingView, self).get_context_data(**kwargs)
        payment_modules_list = backends_pool.get_payment_backends_list()
        shipping_modules_list = backends_pool.get_shipping_backends_list()
        request = self.request

        shipping_address_form = self._get_shipping_address_form()
        billing_address_form = self._get_billing_address_form()
        billingshipping_form = self._get_billingshipping_form()
        ctx.update({
            'shipping_address':shipping_address_form,
            'billing_address':billing_address_form,
            'billing_shipping_form':billingshipping_form,
        })
        print ctx
        
        return ctx
    def get_context_data(self, **kwargs):
        """
        This overrides the context from the normal template view
        """
        ctx = super(SelectPaymentView, self).get_context_data(**kwargs)

        # Set the order status:
        order = get_order_from_request(self.request)
        order.status = Order.PAYMENT
        payment_selection.send(sender=self, order=order)

        payment_modules_list = backends_pool.get_payment_backends_list()

        select = {}

        for backend in payment_modules_list:
            url = reverse(backend.url_namespace)
            select.update({backend.backend_name: url})

        ctx.update({"payment_options": select})
        return ctx
Beispiel #9
0
def _get_billing_backends():
    billing_backends = backends_pool.get_payment_backends_list()
    return tuple([(x.url_namespace, x.backend_name) for x in billing_backends])
Beispiel #10
0
def get_billing_backends_choices():
    billing_backends = backends_pool.get_payment_backends_list()
    return tuple([(x.url_namespace, getattr(x, 'backend_verbose_name', x.backend_name)) for x in billing_backends])
Beispiel #11
0
 def test_05_get_backends_from_empty_pool(self):
     self.create_fixtures()
     MODIFIERS = []
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list), 0)
Beispiel #12
0
 def test_04_get_backends_from_pool(self):
     self.create_fixtures()
     MODIFIERS = ['shop.tests.payment.ValidMockPaymentBackend']
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list), 1)
Beispiel #13
0
def get_billing_backends_choices():
    billing_backends = backends_pool.get_payment_backends_list()
    return tuple([(x.url_namespace, x.backend_name) for x in billing_backends])
Beispiel #14
0
#-*- coding: utf-8 -*-
"""
Loop over payment backends defined in settings.SHOP_PAYMENT_BACKENDS and add
their URLs to the payment namespace. eg:
http://www.example.com/shop/pay/paypal
http://www.example.com/shop/pay/pay-on-delivery
...
"""
from django.conf.urls import patterns, include
from shop.backends_pool import backends_pool


urlpatterns = patterns('')

# For every backend defined in the backend pool, load all the URLs it defines
# in its get_urls() method.
for backend in backends_pool.get_payment_backends_list():
    regexp = '^%s/' % backend.url_namespace
    urls = backend.get_urls()
    pattern = patterns('',
        (regexp, include(backend.get_urls()))
    )

    urlpatterns = pattern + urlpatterns
Beispiel #15
0
 def get_billing_backends_choices(self):
     billing_backends = backends_pool.get_payment_backends_list()
     return tuple([(x.url_namespace,
                    getattr(x, 'backend_verbose_name', x.backend_name))
                   for x in billing_backends])
Beispiel #16
0
#-*- coding: utf-8 -*-
"""
Loop over payment backends defined in settings.SHOP_PAYMENT_BACKENDS and add 
their URLs to the payment namespace. eg:
http://www.example.com/shop/pay/paypal
http://www.example.com/shop/pay/pay-on-delivery
...
"""
from django.conf.urls.defaults import patterns, include
from shop.backends_pool import backends_pool

urlpatterns = patterns('')

# For every backend defined in the backend pool, load all the URLs it defines
# in its get_urls() method.
for backend in backends_pool.get_payment_backends_list():
    regexp = "^%s/" % backend.url_namespace
    urls = backend.get_urls()
    patterns = patterns('', (regexp, include(backend.get_urls())))
    urlpatterns = patterns + urlpatterns
Beispiel #17
0
 def test_get_backends_from_empty_pool(self):
     MODIFIERS = []
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list_ = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list_), 0)
Beispiel #18
0
 def test_get_backends_from_empty_pool(self):
     MODIFIERS = []
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list_ = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list_), 0)
Beispiel #19
0
 def test_get_backends_from_pool(self):
     MODIFIERS = ['shop.tests.payment.ValidMockPaymentBackend']
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list_ = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list_), 1)
Beispiel #20
0
 def test_05_get_backends_from_empty_pool(self):
     self.create_fixtures()
     MODIFIERS = []
     with SettingsOverride(SHOP_PAYMENT_BACKENDS=MODIFIERS):
         list = backends_pool.get_payment_backends_list()
         self.assertEqual(len(list), 0)