def computed_signature(self): """ Compute the signature on the fly """ from mock import Mock from systempay.facade import Facade from django.http import QueryDict request = Mock() request.POST = QueryDict(self.raw_request) facade = Facade() form = facade.get_return_form_populated_with_request(request) return facade.gateway.compute_signature(form)
def handle_ipn(self, request, **kwargs): """ Complete payment with PayPal - this calls the 'DoExpressCheckout' method to capture the money from the initial transaction. """ txn = None try: txn = Facade().handle_request(request) order = Order.objects.get(number=txn.order_number) # Record payment source source_type, is_created = SourceType.objects.get_or_create( code='systempay') if txn.operation_type == SystemPayTransaction.OPERATION_TYPE_DEBIT: source = Source(source_type=source_type, currency=txn.currency, amount_allocated=D(0), amount_debited=txn.amount, order=order) source.save() elif txn.operation_type == SystemPayTransaction.OPERATION_TYPE_CREDIT: source = Source(source_type=source_type, currency=txn.currency, amount_allocated=D(0), amount_refunded=txn.amount, order=order) source.save() else: raise PaymentError( _("Unknown operation type '%(operation_type)s'") % {'operation_type': txn.operation_type}) except SystemPayError, inst: logger.error(inst.message) raise PaymentError(inst.message)
def setUp(self): self.order = self.create_mock_order() self.facade = Facade()
def get(self, *args, **kwargs): # record the request order = self.get_object() form = self.get_form() Facade().record_submit_txn(order.number, order.total_incl_tax, form) return super(SecureRedirectView, self).get(*args, **kwargs)
def get_form(self): if self._form is not None: return self._form order = self.get_object() self._form = Facade().get_submit_form_populated_with_order(order) return self._form