Ejemplo n.º 1
0
        public void RefundCharge_Partially_Success()
        {
            _createChargeRequest.CardDetails = _workingCard;
            _createChargeRequest.Capture     = true;

            ApiResponse <Charge> response = _chargeService.CreateCharge(_createChargeRequest);

            Assert.IsTrue(!string.IsNullOrEmpty(response.Content.Id));
            Assert.IsTrue(response.Content.State == ChargeState.Captured);

            RefundChargeRequest refundRequest = new RefundChargeRequest();

            refundRequest.ChargeId = response.Content.Id;
            refundRequest.Amount   = response.Content.CapturedAmount - 200;
            refundRequest.Reason   = RefundReason.RequestedByCustomer;

            ApiResponse <Refund> refundResponse = _refundService.RefundCharge(refundRequest);

            Charge charge = _chargeService.GetCharge(new GetChargeRequest()
            {
                ChargeId = response.Content.Id
            }).Content;

            Assert.IsTrue(!string.IsNullOrEmpty(refundResponse.Content.Id));
            Assert.IsTrue(charge.State == ChargeState.PartiallyRefunded);
        }
Ejemplo n.º 2
0
        public void ListRefundsOfCharge_Success()
        {
            _createChargeRequest.CardDetails = _workingCard;
            _createChargeRequest.Capture     = true;
            _createChargeRequest.Amount      = 10000;

            ApiResponse <Charge> response = _chargeService.CreateCharge(_createChargeRequest);

            RefundChargeRequest refundRequest = new RefundChargeRequest();

            refundRequest.ChargeId = response.Content.Id;
            refundRequest.Amount   = 100;

            ApiResponse <Refund> refundResponse = _refundService.RefundCharge(refundRequest);

            _refundService.RefundCharge(refundRequest);
            _refundService.RefundCharge(refundRequest);

            PagedApiResponse <Refund> apiResponse = _refundService.ListRefundsForCharge(new ListRefundsForChargeRequest()
            {
                ChargeId = refundRequest.ChargeId
            });

            Assert.IsTrue(apiResponse.Content.Count == 3);
        }
Ejemplo n.º 3
0
        public async Task <Charge> RefundChargeAsync(long chargeId, RefundChargeRequest refundChargeRequest)
        {
            ValidateModel(refundChargeRequest);

            var response = await PostAsJsonAsync($"/charges/{chargeId}/refund", JsonConvert.SerializeObject(refundChargeRequest)).ConfigureAwait(false);

            return(JsonConvert.DeserializeObject <ChargeResponse>(
                       await response.Content.ReadAsStringAsync().ConfigureAwait(false)).Charge);
        }
        public ApiResponse <Refund> RefundCharge(RefundChargeRequest request)
        {
            ApiResponse <Refund> response = SendApiRequest <RefundChargeRequest, Refund>(request);

            return(response);
        }