Ejemplo n.º 1
0
        /// <summary>
        /// Resource /{merchantId}/products/{paymentProductId}
        /// <a href="https://developer.globalcollect.com/documentation/api/server/#__merchantId__products__paymentProductId__get">Get payment product</a>
        /// </summary>
        /// <param name="paymentProductId">int?</param>
        /// <param name="query">GetProductParams</param>
        /// <param name="context">CallContext</param>
        /// <returns>PaymentProductResponse</returns>
        /// <exception cref="ValidationException">if the request was not correct and couldn't be processed (HTTP status code BadRequest)</exception>
        /// <exception cref="AuthorizationException">if the request was not allowed (HTTP status code Forbidden)</exception>
        /// <exception cref="IdempotenceException">if an idempotent request caused a conflict (HTTP status code Conflict)</exception>
        /// <exception cref="ReferenceException">if an object was attempted to be referenced that doesn't exist or has been removed,
        ///            or there was a conflict (HTTP status code NotFound, Conflict or Gone)</exception>
        /// <exception cref="GlobalCollectException">if something went wrong at the GlobalCollect platform,
        ///            the GlobalCollect platform was unable to process a message from a downstream partner/acquirer,
        ///            or the service that you're trying to reach is temporary unavailable (HTTP status code InternalServerError, BadGateway or ServiceUnavailable)</exception>
        /// <exception cref="ApiException">if the GlobalCollect platform returned any other error</exception>
        public async Task <PaymentProductResponse> Get(int?paymentProductId, GetProductParams query, CallContext context = null)
        {
            IDictionary <string, string> pathContext = new Dictionary <string, string>();

            pathContext.Add("paymentProductId", paymentProductId.ToString());
            string uri = InstantiateUri("/{apiVersion}/{merchantId}/products/{paymentProductId}", pathContext);

            try
            {
                return(await _communicator.Get <PaymentProductResponse>(
                           uri,
                           ClientHeaders,
                           query,
                           context));
            }
            catch (ResponseException e)
            {
                object errorObject;
                switch (e.StatusCode)
                {
                default:
                    errorObject = _communicator.Marshaller.Unmarshal <ErrorResponse>(e.Body);
                    break;
                }
                throw CreateException(e.StatusCode, e.Body, errorObject, context);
            }
        }
Ejemplo n.º 2
0
        public async void Example()
        {
#pragma warning disable 0168
            using (Client client = GetClient())
            {
                GetProductParams query = new GetProductParams();
                query.Amount       = 1000L;
                query.IsRecurring  = true;
                query.CountryCode  = "US";
                query.Locale       = "en_US";
                query.CurrencyCode = "USD";
                query.AddHide("fields");

                PaymentProductResponse response = await client.Merchant("merchantId").Products().Get(1, query);
            }
#pragma warning restore 0168
        }
Ejemplo n.º 3
0
        public void TestToRequestParameters()
        {
            var lParams   = new GetProductParams();
            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));
        }