Example #1
0
        public void RefundCharge_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;
            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.Refunded);
        }
        public void GetCharge_Success()
        {
            _createChargeRequest.CardDetails = _workingCard;

            Charge createChargeResponse = _service.CreateCharge(_createChargeRequest).Content;

            GetChargeRequest chargeRequest = new GetChargeRequest();

            chargeRequest.ChargeId = createChargeResponse.Id;

            Charge getChargeResponse = _service.GetCharge(chargeRequest).Content;

            Assert.AreEqual(createChargeResponse.Id, getChargeResponse.Id);
        }