def setUp(self):
     self.user = UserFactory()
     self.source = AccountFactory(primary_user=None, credit_limit=None)
     self.destination = AccountFactory(primary_user=None)
     self.transfer = facade.transfer(self.source, self.destination,
                                     D('100'), user=self.user,
                                     description="Give money to customer")
     self.reverse = facade.reverse(self.transfer, self.user,
                                   description="Oops! Return money")
Beispiel #2
0
 def setUp(self):
     self.user = UserFactory()
     self.source = AccountFactory(primary_user=None, credit_limit=None)
     self.destination = AccountFactory(primary_user=None)
     self.transfer = facade.transfer(self.source, self.destination,
                                     D('100'), user=self.user,
                                     description="Give money to customer")
     self.reverse = facade.reverse(self.transfer, self.user,
                                   description="Oops! Return money")
Beispiel #3
0
 def valid_payload(self, payload):
     to_reverse = get_object_or_404(Transfer,
                                    reference=self.kwargs['reference'])
     if not to_reverse.source.is_active():
         raise ValidationError(errors.ACCOUNT_INACTIVE)
     merchant_reference = payload.get('merchant_reference', None)
     try:
         transfer = facade.reverse(to_reverse,
                                   merchant_reference=merchant_reference)
     except exceptions.AccountException as e:
         return self.forbidden(code=errors.CANNOT_CREATE_TRANSFER,
                               msg=e.message)
     return self.created(
         reverse('transfer', kwargs={'reference': transfer.reference}),
         transfer.as_dict())
 def valid_payload(self, payload):
     to_reverse = get_object_or_404(Transfer,
                                    reference=self.kwargs['reference'])
     if not to_reverse.source.is_active():
         raise ValidationError(errors.ACCOUNT_INACTIVE)
     merchant_reference = payload.get('merchant_reference', None)
     try:
         transfer = facade.reverse(to_reverse,
                                   merchant_reference=merchant_reference)
     except exceptions.AccountException as e:
         return self.forbidden(
             code=errors.CANNOT_CREATE_TRANSFER,
             msg=e.message)
     return self.created(
         reverse('transfer', kwargs={'reference': transfer.reference}),
         transfer.as_dict())