Esempio n. 1
0
        public async Task InitPayment_SpecifiedRequestEncodingAndReturnType_Succeeds(
            HttpRequestEncodingType encodingType, InitPaymentResponseType responseType)
        {
            var connection = new Connection(PlatronClient.PlatronUrl, SettingsStorage.Credentials, encodingType);
            var client     = new PlatronClient(connection);
            // To find out what really happens enable proxy (thru fiddler)
            // and use custom connection over http to watch plain requests
            //.EnableProxy(new WebProxy("http://localhost:8888", false));

            var initPayment = new InitPaymentRequest(1.Rub(), "Money first");

            initPayment.InTestMode();
            initPayment.OrderId = Guid.NewGuid().ToString("N");

            switch (responseType)
            {
            case InitPaymentResponseType.RedirectLink:
                var response = await client.InitPaymentAsync(initPayment);

                Assert.NotNull(response);
                break;

            case InitPaymentResponseType.HtmlForm:
                var html = await client.InitPaymentAsHtmlAsync(initPayment);

                Assert.NotNull(html);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(responseType), responseType, null);
            }
        }
        public HttpRequestEncoder(IXmlPipeline xmlPipeline,
            HttpRequestEncodingType encodingType = HttpRequestEncodingType.PostWithXml)
        {
            Ensure.ArgumentNotNull(xmlPipeline, "xmlPipeline");

            _xmlPipeline = xmlPipeline;
            EncodingType = encodingType;
        }
Esempio n. 3
0
        public HttpRequestEncoder(IXmlPipeline xmlPipeline,
                                  HttpRequestEncodingType encodingType = HttpRequestEncodingType.PostWithXml)
        {
            Ensure.ArgumentNotNull(xmlPipeline, "xmlPipeline");

            _xmlPipeline = xmlPipeline;
            EncodingType = encodingType;
        }
 public PlatronClient(Credentials credentials, TimeSpan timeout, HttpRequestEncodingType httpRequestEncodingType = HttpRequestEncodingType.Get)
     : this(new Connection(PlatronUrl, credentials, timeout, httpRequestEncodingType))
 {
 }
        public async Task InitPayment_SpecifiedRequestEncodingAndReturnType_Succeeds(
            HttpRequestEncodingType encodingType, InitPaymentResponseType responseType)
        {
            var connection = new Connection(PlatronClient.PlatronUrl, SettingsStorage.Credentials, encodingType);
            var client = new PlatronClient(connection);
            // To find out what really happens enable proxy (thru fiddler)
            // and use custom connection over http to watch plain requests
            //.EnableProxy(new WebProxy("http://localhost:8888", false));

            var initPayment = new InitPaymentRequest(1.Rur(), "Money first");
            initPayment.InTestMode();
            initPayment.OrderId = Guid.NewGuid().ToString("N");

            switch (responseType)
            {
                case InitPaymentResponseType.RedirectLink:
                    var response = await client.InitPaymentAsync(initPayment);
                    Assert.NotNull(response);
                    break;
                case InitPaymentResponseType.HtmlForm:
                    var html = await client.InitPaymentAsHtmlAsync(initPayment);
                    Assert.NotNull(html);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(responseType), responseType, null);
            }
        }
Esempio n. 6
0
        public Connection(Uri baseAddress, Credentials credentials, TimeSpan timeout, IXmlPipeline xmlPipeline, HttpRequestEncodingType httpRequestEncodingType = HttpRequestEncodingType.PostWithXml)
        {
            Ensure.ArgumentNotNull(baseAddress, "baseAddress");
            Ensure.ArgumentNotNull(credentials, "credentials");
            Ensure.ArgumentNotNull(xmlPipeline, "xmlPipeline");

            if (!baseAddress.IsAbsoluteUri)
            {
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture, "The base address '{0}' must be an absolute URI",
                                        baseAddress), nameof(baseAddress));
            }

            _xmlPipeline        = xmlPipeline;
            _authenticator      = new Authenticator(credentials, xmlPipeline);
            _httpRequestEncoder = new HttpRequestEncoder(xmlPipeline, httpRequestEncodingType);

            _httpClient = new HttpClient
            {
                BaseAddress = baseAddress,
                Timeout     = timeout
            };

            BaseAddress = baseAddress;
            Callback    = new CallbackResponder(_authenticator, _xmlPipeline);
        }
Esempio n. 7
0
 public Connection(Uri baseAddress, Credentials credentials, TimeSpan timeout, HttpRequestEncodingType httpRequestEncodingType = HttpRequestEncodingType.PostWithXml)
     : this(baseAddress, credentials, timeout, new XmlPipeline(), httpRequestEncodingType)
 {
 }
Esempio n. 8
0
 public PlatronClient(Credentials credentials, TimeSpan timeout, HttpRequestEncodingType httpRequestEncodingType = HttpRequestEncodingType.Get)
     : this(new Connection(PlatronUrl, credentials, timeout, httpRequestEncodingType))
 {
 }