Пример #1
0
        MetaDataProvider(string integrator, ShoppingCartExtension shoppingCartExtension, IEnumerable <RequestHeader> additionalRequestHeaders)
        {
            ValidateAdditionalRequestHeaders(additionalRequestHeaders);

            ServerMetaInfo serverMetaInfo = new ServerMetaInfo()
            {
                PlatformIdentifier    = _platformIdentifier,
                SdkIdentifier         = SdkIdentifier,
                SdkCreator            = "OnlinePayments",
                Integrator            = integrator,
                ShoppingCartExtension = shoppingCartExtension
            };

            string        serverMetaInfoString = DefaultMarshaller.Instance.Marshal(serverMetaInfo);
            RequestHeader serverMetaInfoHeader = new RequestHeader(SERVER_META_INFO_HEADER, serverMetaInfoString.ToBase64String());

            ServerMetaDataHeaders = new List <RequestHeader> {
                serverMetaInfoHeader
            }
            .Concat(additionalRequestHeaders ?? Enumerable.Empty <RequestHeader>());;
        }
Пример #2
0
        public static void CheckWithAdditionalRequestHeader(string additionalHeaderName, bool isAllowed)
        {
            RequestHeader additionalRequestHeader = new RequestHeader(additionalHeaderName, Guid.NewGuid().ToString());

            MetaDataProviderBuilder builder = new MetaDataProviderBuilder("OnlinePayments");

            if (isAllowed)
            {
                MetaDataProvider            metaDataProvider = builder.WithAdditionalRequestHeader(additionalRequestHeader).Build();
                IEnumerable <RequestHeader> requestHeaders   = metaDataProvider.ServerMetaDataHeaders;
                Assert.AreEqual(2, requestHeaders.Count());

                RequestHeader requestHeader = requestHeaders.First();
                Assert.AreEqual("X-GCS-ServerMetaInfo", requestHeader.Name);

                requestHeader = requestHeaders.Skip(1).First();
                Assert.AreEqual(requestHeader, additionalRequestHeader);
            }
            else
            {
                Assert.That((() => builder.WithAdditionalRequestHeader(additionalRequestHeader)), Throws.ArgumentException.With.Message.Contains(additionalHeaderName));
            }
        }
Пример #3
0
 public bool Equals(RequestHeader obj)
 => (obj?.Name?.Equals(Name) ?? false) &&
 (obj?.Value?.Equals(Value) ?? false);