public void CaptureCharge_Success() { _createChargeRequest.CardDetails = _workingCard; Charge createChargeResponse = _service.CreateCharge(_createChargeRequest).Content; Assert.IsTrue(createChargeResponse.State == ChargeState.Authorized); CaptureChargeRequest captureRequest = new CaptureChargeRequest(); captureRequest.ChargeId = createChargeResponse.Id; captureRequest.Amount = createChargeResponse.Amount; CaptureChargeResponse captureResponse = _service.CaptureCharge(captureRequest).Content; Assert.AreEqual(createChargeResponse.Id, captureResponse.ChargeId); Assert.AreEqual(createChargeResponse.Amount, captureResponse.ChargeAmount); Assert.IsTrue(captureResponse.State == ChargeState.Captured); GetChargeRequest getChargeRequest = new GetChargeRequest(); getChargeRequest.ChargeId = captureRequest.ChargeId; Charge charge = _service.GetCharge(getChargeRequest).Content; Assert.AreEqual(charge.CapturedAmount, captureResponse.CapturedAmount); Assert.IsTrue(charge.State == ChargeState.Captured); }
public void GetCharge_NotFound() { GetChargeRequest chargeRequest = new GetChargeRequest(); chargeRequest.ChargeId = "not_found_id"; ApiResponse <Charge> getChargeResponse = _service.GetCharge(chargeRequest); Assert.IsTrue(getChargeResponse.IsError); Assert.IsTrue(getChargeResponse.Error.Type == ErrorType.Request); Assert.AreEqual(string.Format("Couldn't find Charge with 'id'={0}.", chargeRequest.ChargeId), getChargeResponse.Error.Message); Assert.AreEqual(ErrorCode.NotFound, getChargeResponse.Error.Code); }
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); }
public ApiResponse <Charge> GetCharge(GetChargeRequest request) { ApiResponse <Charge> response = SendApiRequest <GetChargeRequest, Charge>(request); return(response); }