Exemplo n.º 1
0
        public ActionResult GetSetOrderReference(string amazonOrderReferenceId, string amount, string addressConsentToken = "")
        {
            try
            {
                SetOrderReferenceDetailsRequest setRequestParameters = new SetOrderReferenceDetailsRequest();
                setRequestParameters.WithAmazonOrderReferenceId(amazonOrderReferenceId)
                .WithAmount(decimal.Parse(amount))
                .WithCurrencyCode(Regions.currencyCode.USD)
                .WithSellerNote("Note");

                OrderReferenceDetailsResponse setResponse = client.SetOrderReferenceDetails(setRequestParameters);
                if (!setResponse.GetSuccess())
                {
                    //apiResponse["setOrderReferenceDetailsResponse"] = "SetOrderReferenceDetails API call Failed" + Environment.NewLine + setResponse.GetJson();
                    apiResponse["setOrderReferenceDetailsResponse"] = "0";
                }
                else
                {
                    apiResponse["setOrderReferenceDetailsResponse"] = setResponse.GetJson();
                };
                System.Web.HttpContext.Current.Session.Add("amazonOrderReferenceId", amazonOrderReferenceId);
                System.Web.HttpContext.Current.Session.Add("amount", amount);
                return(Json(apiResponse));
            }
            catch (Exception ex)
            {
                return(Json(apiResponse));
            }
        }
        public static void GetOrderReferenceDetailsApiCall(string amazonOrderReferenceId, string addressConsentToken = null)
        {
            GetOrderReferenceDetailsRequest getRequestParameters = new GetOrderReferenceDetailsRequest();

            getRequestParameters.WithAmazonOrderReferenceId(amazonOrderReferenceId)
            .WithaddressConsentToken(null);

            OrderReferenceDetailsResponse getOrderReferenceDetailsResponse = client.GetOrderReferenceDetails(getRequestParameters);

            // IResponse is an interface method for common response methods for each response class
            IResponse interfaceresp = (IResponse)getOrderReferenceDetailsResponse;

            apiResponse["getOrderReferenceDetailsResponse"] = JObject.Parse(getOrderReferenceDetailsResponse.GetJson()).ToString();
        }
        public static void SetOrderReferenceDetailsApiCall(string amazonOrderReferenceId, string amount)
        {
            SetOrderReferenceDetailsRequest setRequestParameters = new SetOrderReferenceDetailsRequest();

            setRequestParameters.WithAmazonOrderReferenceId(amazonOrderReferenceId)
            .WithAmount(decimal.Parse(amount))
            .WithCurrencyCode(Regions.currencyCode.USD)
            .WithSellerNote("Note");

            OrderReferenceDetailsResponse setResponse = client.SetOrderReferenceDetails(setRequestParameters);

            if (!setResponse.GetSuccess())
            {
                apiResponse["setOrderReferenceDetailsResponse"] = "SetOrderReferenceDetails API call Failed" + Environment.NewLine + setResponse.GetJson();
            }
            else
            {
                apiResponse["setOrderReferenceDetailsResponse"] = setResponse.GetJson();
            }
        }
Exemplo n.º 4
0
        public IActionResult GetDetails(string orderReferenceId, string amount, string addressConsentToken = null)
        {
            var currencyCode = (Regions.currencyCode)Enum.Parse(typeof(Regions.currencyCode), _config.CurrencyCode);
            var amountValue  = decimal.Parse(amount, CultureInfo.InvariantCulture);


            SetOrderReferenceDetailsRequest setRequestParameters = new SetOrderReferenceDetailsRequest();

            setRequestParameters.WithAmazonOrderReferenceId(orderReferenceId)
            .WithAmount(amountValue)
            .WithCurrencyCode(currencyCode)
            .WithSellerNote("testzahlung")
            .WithStoreName("AmzonPaymentSamply by Roman Wienicke")
            .WithCustomInformation($"{DateTime.Now}")
            .WithSellerOrderId($"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}")
            .WithSellerNote("Note");
            var setResponse = AmazonClient.SetOrderReferenceDetails(setRequestParameters);

            var response = setResponse.GetJson();

            if (setResponse.GetSuccess())
            {
                var session = _httpContextAccessor.HttpContext.Session;
                session.Set(AmazonOrderReferenceId, orderReferenceId);
                session.Set(AmazonOrderAmount, amountValue);

                GetOrderReferenceDetailsRequest getRequestParameters = new GetOrderReferenceDetailsRequest();
                getRequestParameters
                .WithAccessToken(addressConsentToken)
                .WithAmazonOrderReferenceId(orderReferenceId);

                OrderReferenceDetailsResponse getOrderReferenceDetailsResponse = AmazonClient.GetOrderReferenceDetails(getRequestParameters);
                response = getOrderReferenceDetailsResponse.GetJson();
            }

            return(Json(response));
        }