public void When_I_void_an_auth_with_an_amount_too_large_Then_it_should_return_throw_RequestDeclinedException_async()
        {
            _auth = _cardService.Authorize(_auth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(_auth.MerchantRefNum())
                                                 .Amount(1000000) //Amount voided > authorized amount
                                                 .AuthorizationId(_auth.Id())
                                                 .Build();

            Assert.ThrowsAsync <Paysafe.Common.RequestDeclinedException>(async() => await _cardService.ReverseAuthAsync(authReversal));
        }
        public async Task When_I_partially_void_an_auth_Then_it_should_return_a_valid_response_async()
        {
            _auth = _cardService.Authorize(_auth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(_auth.MerchantRefNum())
                                                 .Amount(111) //Amount voided < authorized amount
                                                 .AuthorizationId(_auth.Id())
                                                 .Build();

            AuthorizationReversal response = await _cardService.ReverseAuthAsync(authReversal);

            Assert.That(response.Status(), Is.EqualTo("COMPLETED"));
        }
        public void When_I_void_an_auth_Then_it_should_return_a_valid_response_sync()
        {
            _auth = _cardService.Authorize(_auth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(_auth.MerchantRefNum())
                                                 .Amount(6666) // Amount voided == authorized amount
                                                 .AuthorizationId(_auth.Id())
                                                 .Build();

            AuthorizationReversal response = _cardService.ReverseAuth(authReversal);

            Assert.That(response.Status(), Is.EqualTo("COMPLETED"));
        }
        public void When_I_void_a_settled_auth_Then_it_should_return_throw_RequestDeclinedException_async()
        {
            var service     = SampleFactory.CreateSampleCardPaymentService();
            var settledAuth = SampleFactory.CreateSampleSettledAuthorization();

            settledAuth = service.Authorize(settledAuth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(settledAuth.MerchantRefNum())
                                                 .Amount(6666) //Amount voided == authorized amount
                                                 .AuthorizationId(settledAuth.Id())
                                                 .Build();

            Assert.ThrowsAsync <Paysafe.Common.RequestDeclinedException>(async() => await service.ReverseAuthAsync(authReversal));
        }
        public void When_I_lookup_a_reversal_using_a_reversal_id_Then_it_should_return_a_valid_reversal_sync()
        {
            _auth = _cardService.Authorize(_auth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(_auth.MerchantRefNum())
                                                 .Amount(6666)
                                                 .AuthorizationId(_auth.Id())
                                                 .Build();

            authReversal = _cardService.ReverseAuth(authReversal);

            AuthorizationReversal returnedReversal = _cardService.Get(new AuthorizationReversal(authReversal.Id()));

            Assert.That(returnedReversal.Status(), Is.EqualTo("COMPLETED"));
            Assert.That(AuthorizationReversalsAreEquivalent(authReversal, returnedReversal));
        }
        public async Task When_I_lookup_a_reversal_using_a_merchant_refNum_Then_it_should_return_a_valid_reversal_async()
        {
            _auth = await _cardService.AuthorizeAsync(_auth);

            AuthorizationReversal authReversal = AuthorizationReversal.Builder()
                                                 .MerchantRefNum(_auth.MerchantRefNum())
                                                 .Amount(6666)
                                                 .AuthorizationId(_auth.Id())
                                                 .Build();

            authReversal = await _cardService.ReverseAuthAsync(authReversal);

            Pagerator <AuthorizationReversal> authReversals = await _cardService.GetAuthReversalsAsync(AuthorizationReversal.Builder()
                                                                                                       .MerchantRefNum(authReversal.MerchantRefNum())
                                                                                                       .Build());


            var authRevList = authReversals.GetResults();

            Assert.That(authRevList.Count, Is.EqualTo(1));
            Assert.That(AuthorizationReversalsAreEquivalent(authReversal, authRevList[0]));
        }