public void TestResponseCreation(string operation, NameValueCollection responseData)
 {
     var req = new Request("hello");
     var resp = new Response(req, responseData);
     resp.ValidateSignature(AccessKeySecret);
     Assert.IsTrue(resp.IsValidSignature);
 }
Esempio n. 2
0
 public Response(Request originalRequest, NameValueCollection nameValueCollection)
 {
     OriginalRequest = originalRequest;
     Container = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
     SetOperation(OriginalRequest.GetOperation());
     SignatureKeys = GetSignatureKeys();
     AddCollection(nameValueCollection);
 }
        public void TestGetStatusLastPayment()
        {
            //Use the PaymentResponse set by SubmitPaymentRequest
            var statusRequest = new Request("status", new NameValueCollection
            {
                {"TrackingNumber", PaymentResponse.Get("TrackingNumber")}
            });

            var statusResponse = RavenApi.Send(statusRequest);
            Assert.AreEqual("Voided", statusResponse.Get("Status"));
        }
        public void TestVoidLastPayment()
        {
            //Use the PaymentResponse set by SubmitPaymentRequest
            var voidRequest = new Request("void", new NameValueCollection
            {
                {"TrackingNumber", PaymentResponse.Get("TrackingNumber")},
                {"PaymentType", PaymentResponse.Get("TrackingNumber")}
            });

            var voidResponse = RavenApi.Send(voidRequest);
            Assert.AreEqual("Voided", voidResponse.Get("Status"));
        }
Esempio n. 5
0
        public async Task<Response> SendAsync(Request request)
        {
            request.SetAccessKeyId(AccessKeyId);
            request.SetSignture(AccessKeySecret);
            var response = new Response(request, await CallWebClientProviderAsync(request));
            response.ValidateSignature(AccessKeySecret);

            if (!response.IsValidSignature)
            {
                throw new RavenInvalidSignatureException(
                    $"Invalid Signature; Response: {response.Get("Signature")} Calculated: {response.CalculatedSignature}");
            }
            return response;
        }
        public void TestRavenApi_Events_Search()
        {
            var raven = new Raven(AccessKeyId, AccessKeySecret);
            var eventsRequest = new Request("Events", new NameValueCollection
            {
                {"ReportFormat","RavenEventFile_v1.0" },
                {"StartTime", TimestampProvider.FormatTimestamp((DateTime.UtcNow).AddHours(-1)) },
                {"EndTime", TimestampProvider.FormatTimestamp(DateTime.UtcNow)},
                {"ResultFields","RoutingNumber PaymentType Currency CardNumber ApprovalCode Amount" },
            });

            var eventsResponse = raven.Send(eventsRequest);
            Assert.IsNotNull(eventsResponse.Get("Report"));
        }
        public void TestRavenApi_Payments_Search()
        {
            var raven = new Raven(AccessKeyId,AccessKeySecret);

            var paymentsRequest = new Request("Payments", new NameValueCollection
            {
                {"ReportFormat","RavenPaymentFile_v1.0" },
                {"StartTime", TimestampProvider.FormatTimestamp((DateTime.Now).AddDays(-1)) },
                {"EndTime", TimestampProvider.FormatTimestamp(DateTime.Now)},
                {"ResultFields","Currency CardNumber Amount" },
                {"RoutingNumbers","840033"},
                {"PaymentTypes","cc_debit" }
            });

            var paymentsResponse = raven.Send(paymentsRequest);
            Assert.IsNotNull(paymentsResponse.Get("Report"));
        }
 public void TestRequestSignature_MissingKey_Exception(string operation, NameValueCollection dataCollection, string missingKeys)
 {
     var req = new Request(operation, dataCollection);
     req.SetAccessKeyId(AccessKeyId);
     var rex = Assert.Throws<RavenException>(() => req.SetSignture(AccessKeySecret));
     Assert.That(rex.Message,Contains.Substring(missingKeys));
 }
        public string TestRequestSignatrureCreation(string operation, NameValueCollection dataCollection)
        {
            var req = new Request(operation,dataCollection);
            req.SetAccessKeyId(AccessKeyId);
            req.SetSignture(AccessKeySecret);

            return req.Get("signature");
        }
Esempio n. 10
0
 protected virtual NameValueCollection CallWebClientProvider(Request request)
 {
     return new WebClientProvider().Send(Endpoint + "/" + request.GetOperation().ToLower(), request.AllToNameValueCollection());
 }
Esempio n. 11
0
 /// <summary>
 /// Stubbed out to Mock the Method.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 protected virtual async Task<NameValueCollection> CallWebClientProviderAsync(Request request)
 {
     return await new WebClientProvider().SendAsync(Endpoint + "/" +request.GetOperation().ToLower(), request.AllToNameValueCollection());
     
 }
 public void TestSubmitPaymentRequest()
 {
     PaymentRequest = new Request("submit", BasePaymentData);
     PaymentResponse = RavenApi.Send(PaymentRequest);
     Assert.AreEqual("Approved", PaymentResponse.Get("Status"));
 }