public void AuthorizeApiCall() { string uniqueReferenceId = GenerateRandomUniqueString(); AuthorizeRequest authRequestParameters = new AuthorizeRequest(); authRequestParameters.WithAmazonOrderReferenceId(Session["amazonOrderReferenceId"].ToString()) .WithAmount(decimal.Parse(Session["amount"].ToString())) .WithCurrencyCode(Regions.currencyCode.USD) .WithAuthorizationReferenceId(uniqueReferenceId) .WithTransactionTimeout(0) .WithCaptureNow(true) .WithSellerAuthorizationNote("Note"); AuthorizeResponse authResponse = client.Authorize(authRequestParameters); // Authorize was not a success Get the Error code and the Error message if (!authResponse.GetSuccess()) { string errorCode = authResponse.GetErrorCode(); string errorMessage = authResponse.GetErrorMessage(); authorize.InnerHtml = authResponse.GetJson(); } else { amazonAuthorizationId = authResponse.GetAuthorizationId(); captureNow = authResponse.GetCaptureNow(); // If captureNow was true then the capture has already happened. save the capture id(s). if (captureNow) { amazonCaptureIdList = authResponse.GetCaptureIdList(); } authorize.InnerHtml = authResponse.GetJson(); } }
public IActionResult ConfirmAndAuthorize() { var session = _httpContextAccessor.HttpContext.Session; var orderReferenceId = session.Get <string>(AmazonOrderReferenceId); var amount = session.Get <decimal>(AmazonOrderAmount); var getRequestParameters = new ConfirmOrderReferenceRequest(); getRequestParameters.WithAmazonOrderReferenceId(orderReferenceId); var response = (IResponse)AmazonClient.ConfirmOrderReference(getRequestParameters); if (response.GetSuccess()) { var uniqueReferenceId = GenerateRandomUniqueString(); var currencyCode = (Regions.currencyCode)Enum.Parse(typeof(Regions.currencyCode), _config.CurrencyCode); AuthorizeRequest authRequestParameters = new AuthorizeRequest(); authRequestParameters.WithAmazonOrderReferenceId(orderReferenceId) .WithAmount(amount) .WithCurrencyCode(currencyCode) .WithAuthorizationReferenceId(uniqueReferenceId) .WithTransactionTimeout(0) .WithCaptureNow(true) .WithSellerAuthorizationNote("Note"); response = AmazonClient.Authorize(authRequestParameters); var orderDetails = AmazonClient.GetOrderReferenceDetails(new GetOrderReferenceDetailsRequest() .WithAmazonOrderReferenceId(orderReferenceId)); var jsonString = new StringBuilder(response.GetJson()); //jsonString.AppendLine(orderDetails.GetJson()); //jsonString.AppendLine("}"); var data = JsonConvert.DeserializeObject <dynamic>(jsonString.ToString()); return(Json(data)); } return(Json(JsonConvert.DeserializeObject <dynamic>(response.GetJson()))); }
public void AuthorizeApiCall() { string uniqueReferenceId = GenerateRandomUniqueString(); AuthorizeRequest authRequestParameters = new AuthorizeRequest(); authRequestParameters.WithAmazonOrderReferenceId(Session["amazonOrderReferenceId"].ToString()) .WithAmount(decimal.Parse(Session["amount"].ToString())) .WithCurrencyCode(Regions.currencyCode.USD) .WithAuthorizationReferenceId(uniqueReferenceId) .WithTransactionTimeout(0) .WithCaptureNow(true) .WithSellerAuthorizationNote("Note"); AuthorizeResponse authResponse = client.Authorize(authRequestParameters); // Authorize was not a success Get the Error code and the Error message if (!authResponse.GetSuccess()) { string errorCode = authResponse.GetErrorCode(); string errorMessage = authResponse.GetErrorMessage(); authorize.InnerHtml = authResponse.GetJson(); } else { amazonAuthorizationId = authResponse.GetAuthorizationId(); captureNow = authResponse.GetCaptureNow(); // If captureNow was true then the capture has already happened. save the capture id(s). if (captureNow) { amazonCaptureIdList = authResponse.GetCaptureIdList(); } authorize.InnerHtml = authResponse.GetJson(); } }