def test_refund(self): self.transaction.status = constants.STATUS_COMPLETED self.transaction.save() refunded({'tracking_id': self.transaction_uuid, 'pay_key': 'foo'}, {'amount': {'amount': 10, 'currency': 'USD'}}) types = [s.type for s in Transaction.objects.all()] eq_([constants.TYPE_REFUND, constants.TYPE_PAYMENT], types)
def test_refund_amount(self): self.transaction.status = constants.STATUS_COMPLETED self.transaction.save() refunded({'tracking_id': self.transaction_uuid, 'pay_key': 'foo'}, {'amount': {'amount': 10, 'currency': 'USD'}}) trans = Transaction.objects.get(type=constants.TYPE_REFUND) eq_(trans.amount, Decimal('-10')) eq_(trans.currency, 'USD')
def test_refund_already_done(self): PaypalTransaction.objects.create( type=constants.TYPE_REFUND, status=constants.STATUS_PENDING, correlation_id='asd-123', pay_key='asd-123', seller=self.paypal, amount=Decimal('-10'), currency='USD', uuid=self.transaction_uuid + 'another', related=self.transaction) eq_(refunded({'tracking_id': self.transaction_uuid}, {}), False)
def test_refund_already_done(self): Transaction.objects.create( type=constants.TYPE_REFUND, status=constants.STATUS_PENDING, uid_support='asd-123', uid_pay='asd-123', seller_product=self.product, amount=Decimal('-10'), currency='USD', provider=constants.SOURCE_PAYPAL, uuid=self.transaction_uuid + 'another', related=self.transaction) eq_(refunded({'tracking_id': self.transaction_uuid}, {}), False)
def test_refund_already_done(self): Transaction.objects.create( type=constants.TYPE_REFUND, status=constants.STATUS_PENDING, uid_support='asd-123', uid_pay='asd-123', seller_product=self.product, amount=Decimal('-10'), currency='USD', provider=constants.PROVIDER_PAYPAL, uuid=self.transaction_uuid + 'another', related=self.transaction) eq_(refunded({'tracking_id': self.transaction_uuid}, {}), False)
def test_refund_missing(self): eq_(refunded({'tracking_id': self.transaction_uuid + 'nope'}, {}), False)