Exemplo n.º 1
0
 def handle_payment(self, order_number, total_incl_tax, **kwargs):
     # Make submission to PayPal.
     try:
         # Using authorization here (two-stage model).  You could use sale to
         # perform the auth and capture in one step.  The choice is dependent
         # on your business model.
         facade.authorize(order_number,
                          total_incl_tax,
                          kwargs['bankcard'],
                          kwargs['billing_address'])
     except facade.NotApproved, e:
         # Submission failed
         raise exceptions.UnableToTakePayment(e.message)
Exemplo n.º 2
0
    def handle_payment(self, order_number, total_incl_tax, **kwargs):
        """ Make submission to PayPal """
        # Using authorization here (two-stage model).  You could use sale to
        # perform the auth and capture in one step.  The choice is dependent
        # on your business model.
        facade.authorize(order_number,
                         total_incl_tax,
                         kwargs['bankcard'],
                         kwargs['billing_address'])

        # Record payment source and event
        source_type, is_created = models.SourceType.objects.get_or_create(name='PayPal')
        source = models.Source(source_type=source_type,
                               currency='GBP',
                               amount_allocated=total_incl_tax)
        self.add_payment_source(source)
        self.add_payment_event('Authorised', total_incl_tax)
Exemplo n.º 3
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 by the parent PaymentDetail view)
        #facade = Facade()
        bankcard = kwargs['bankcard_form'].bankcard
        paypal_ref = authorize(
            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='PayPal')
        source = source_type.sources.model(
            source_type=source_type,
            currency=total.currency,
            amount_allocated=total.incl_tax,
            reference=paypal_ref)
        self.add_payment_source(source)

        # Also record payment event
        self.add_payment_event(
            'pre-auth', total.incl_tax, reference=paypal_ref)
 def authorize(self):
     return facade.authorize('1234', D('10.00'), self.card)
 def authorize(self):
     return facade.authorize('1234', D('10.00'), self.card)