def handle_payment(self, order_number, total_incl_tax, **kwargs):
        # Make request to DataCash - if there any problems (eg bankcard
        # not valid / request refused by bank) then an exception would be
        # raised and handled)
        facade = Facade()

        # Use The3rdMan - so build a dict of data to pass
        email = None
        if not self.request.user.is_authenticated():
            email = self.checkout_session.get_guest_email()
        fraud_data = the3rdman.build_data_dict(
            request=self.request,
            email=email,
            order_number=order_number,
            shipping_address=self.get_shipping_address())

        # We're not using 3rd-man by default
        datacash_ref = facade.pre_authorise(
            order_number, total_incl_tax, kwargs['bankcard'])

        # Request was successful - record the "payment source".  As this
        # request was a 'pre-auth', we set the 'amount_allocated' - if we had
        # performed an 'auth' request, then we would set 'amount_debited'.
        source_type, _ = SourceType.objects.get_or_create(name='Datacash')
        source = Source(source_type=source_type,
                        currency=settings.DATACASH_CURRENCY,
                        amount_allocated=total_incl_tax,
                        reference=datacash_ref)
        self.add_payment_source(source)

        # Also record payment event
        self.add_payment_event('pre-auth', total_incl_tax)
Esempio n. 2
0
    def handle_payment(self, order_number, total_incl_tax, **kwargs):
        # Make request to DataCash - if there any problems (eg bankcard
        # not valid / request refused by bank) then an exception would be
        # raised and handled)
        facade = Facade()

        # Use The3rdMan - so build a dict of data to pass
        email = None
        if not self.request.user.is_authenticated():
            email = self.checkout_session.get_guest_email()
        fraud_data = the3rdman.build_data_dict(
            request=self.request,
            email=email,
            order_number=order_number,
            shipping_address=self.get_shipping_address())

        # We're not using 3rd-man by default
        datacash_ref = facade.pre_authorise(order_number, total_incl_tax,
                                            kwargs['bankcard'])

        # Request was successful - record the "payment source".  As this
        # request was a 'pre-auth', we set the 'amount_allocated' - if we had
        # performed an 'auth' request, then we would set 'amount_debited'.
        source_type, _ = SourceType.objects.get_or_create(name='Datacash')
        source = Source(source_type=source_type,
                        currency=settings.DATACASH_CURRENCY,
                        amount_allocated=total_incl_tax,
                        reference=datacash_ref)
        self.add_payment_source(source)

        # Also record payment event
        self.add_payment_event('pre-auth', total_incl_tax)
Esempio n. 3
0
 def test_basket_lines_are_converted_to_xml(self):
     product = factories.create_product(price=D('12.99'))
     basket = Basket()
     basket.add_product(product)
     data = the3rdman.build_data_dict(basket=basket)
     doc = the3rdman.add_fraud_fields(**data)
     xml = doc.toxml()
     self.assertXmlElementEquals(
         xml, '3', 'The3rdMan.CustomerInformation.sales_channel')
 def test_basket_lines_are_converted_to_xml(self):
     product = factories.create_product(price=D('12.99'))
     basket = Basket()
     basket.add_product(product)
     data = the3rdman.build_data_dict(
         basket=basket)
     doc = the3rdman.add_fraud_fields(**data)
     xml = doc.toxml()
     self.assertXmlElementEquals(xml, '3',
                                 'The3rdMan.CustomerInformation.sales_channel')
    def test_basket_lines_are_converted_to_xml(self):
        product = factories.create_product(price=D("12.99"))
        basket = Basket()

        # Nasty hack to make test suite work with both Oscar 0.5 and 0.6
        try:
            from oscar.apps.partner import strategy
        except ImportError:
            pass
        else:
            basket.strategy = strategy.Default()

        basket.add_product(product)
        data = the3rdman.build_data_dict(basket=basket)
        doc = the3rdman.add_fraud_fields(**data)
        xml = doc.toxml()
        self.assertXmlElementEquals(xml, "3", "The3rdMan.CustomerInformation.sales_channel")
Esempio n. 6
0
    def test_basket_lines_are_converted_to_xml(self):
        product = factories.create_product(price=D('12.99'))
        basket = Basket()

        # Nasty hack to make test suite work with both Oscar 0.5 and 0.6
        try:
            from oscar.apps.partner import strategy
        except ImportError:
            pass
        else:
            basket.strategy = strategy.Default()

        basket.add_product(product)
        data = the3rdman.build_data_dict(basket=basket)
        doc = the3rdman.add_fraud_fields(**data)
        xml = doc.toxml()
        self.assertXmlElementEquals(
            xml, '3', 'The3rdMan.CustomerInformation.sales_channel')
 def test_includes_sales_channel(self):
     data = the3rdman.build_data_dict(request=None, user=None, order_number="1234", basket=None)
     self.assertEquals(3, data["customer_info"]["sales_channel"])
Esempio n. 8
0
 def test_includes_sales_channel(self):
     data = the3rdman.build_data_dict(request=None,
                                      user=None,
                                      order_number="1234",
                                      basket=None)
     self.assertEquals(3, data['customer_info']['sales_channel'])