Beispiel #1
0
        public void TestToRequestParameters()
        {
            var lParams   = new GetPaymentProductParams();
            var paramList = new List <RequestParam>();

            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.Amount = 1000L;
            paramList.Add(new RequestParam("amount", "1000"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.CountryCode = "NL";
            paramList.Add(new RequestParam("countryCode", "NL"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.CurrencyCode = "EUR";
            paramList.Add(new RequestParam("currencyCode", "EUR"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.IsRecurring = true;
            paramList.Add(new RequestParam("isRecurring", "true"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.Locale = "nl_NL";
            paramList.Add(new RequestParam("locale", "nl_NL"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.AddHide("fields");
            paramList.Add(new RequestParam("hide", "fields"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.AddHide("accountsOnFile");
            paramList.Add(new RequestParam("hide", "accountsOnFile"));
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));

            lParams.Amount = null;
            paramList.RemoveAt(0);
            Assert.That(lParams.ToRequestParameters(), Is.EquivalentTo(paramList));
        }
Beispiel #2
0
        /// <inheritdoc/>
        public async Task <PaymentProduct> GetPaymentProduct(int?paymentProductId, GetPaymentProductParams query, CallContext context = null)
        {
            IDictionary <string, string> pathContext = new Dictionary <string, string>
            {
                { "paymentProductId", paymentProductId.ToString() }
            };
            string uri = InstantiateUri("/v2/{merchantId}/products/{paymentProductId}", pathContext);

            try
            {
                return(await _communicator.Get <PaymentProduct>(
                           uri,
                           ClientHeaders,
                           query,
                           context)
                       .ConfigureAwait(false));
            }
            catch (ResponseException e)
            {
                object errorObject = _communicator.Unmarshal <ErrorResponse>(e.Body);
                throw CreateException(e.StatusCode, e.Body, errorObject, context);
            }
        }