public byte[] PostData(Uri url, IPaymentPostData postData)
        {
            PostedUrl  = url;
            PostedData = postData;

            return(_response);
        }
Beispiel #2
0
        internal IPaymentResponse GetResponse(IPaymentPostData response)
        {
            PaymentPostDataValidator.Validate(Configuration, response);

            IPaymentResponse result = PaymentResponse.Create(response.Data);

            PaymentResponseValidator.Validate(Configuration, result);

            return(result);
        }
        internal static FormUrlEncodedContent ConvertPostData(IPaymentPostData postData)
        {
            KeyValuePair <string, string>[] nameValueCollection = new KeyValuePair <string, string>[3]
            {
                new KeyValuePair <string, string>("Data", postData.Data),
                new KeyValuePair <string, string>("InterfaceVersion", postData.InterfaceVersion),
                new KeyValuePair <string, string>("Seal", postData.Seal),
            };

            return(new FormUrlEncodedContent(nameValueCollection));
        }
Beispiel #4
0
        internal static NameValueCollection ConvertPostData(IPaymentPostData postData)
        {
            Debug.Assert(postData != null);

            return(new NameValueCollection
            {
                { "Data", postData.Data },
                { "Seal", postData.Seal },
                { "InterfaceVersion", postData.InterfaceVersion }
            });
        }
        public static async Task <byte[]> PostData(this HttpClient self, Uri uri, IPaymentPostData postData)
        {
            FormUrlEncodedContent content = ConvertPostData(postData);

            using (HttpResponseMessage response = await self.PostAsync(uri, content))
            {
                if (response.Content == null)
                {
                    return(await Task.FromResult <byte[]>(null));
                }

                return(await response.Content.ReadAsByteArrayAsync());
            }
        }
Beispiel #6
0
        internal string GetPaymentHtml(IHttpClient client, IPaymentRequest request)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            IPaymentPostData postData = CreatePostData(request);

            byte[] responseData = client.PostData(Configuration.Url, postData);
            if (responseData == null)
            {
                return(null);
            }

            return(Encoding.UTF8.GetString(responseData));
        }
        public static void Validate(IKassaConfiguration configuration, IPaymentPostData postData)
        {
            PaymentPostDataValidator validator = new PaymentPostDataValidator(configuration, postData);

            validator.Validate();
        }
 private PaymentPostDataValidator(IKassaConfiguration configuration, IPaymentPostData postData)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _postData      = postData ?? throw new ArgumentNullException(nameof(postData));
 }
Beispiel #9
0
        public byte[] PostData(Uri uri, IPaymentPostData postData)
        {
            NameValueCollection data = ConvertPostData(postData);

            return(UploadValues(uri, data));
        }