Beispiel #1
0
    def handle_payment(self, order_number, total, **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=kwargs['shipping_address'])

        # We're not using 3rd-man by default
        bankcard = kwargs['bankcard_form'].bankcard
        datacash_ref = facade.pre_authorise(order_number, total.incl_tax,
                                            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)
Beispiel #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 ahd handled)
        facade = Facade()
        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)
Beispiel #3
0
 def setUp(self):
     self.facade = Facade()