From e9fdec0a4cef817be8e2d6d7dff8f54ecf67a1d0 Mon Sep 17 00:00:00 2001 From: gitvinit Date: Sun, 5 Mar 2017 22:09:50 -0600 Subject: [PATCH] Refactored Code Refactored code to remove redundancies and implement code improvements --- AmazonPay/Client.cs | 89 ++++++------- AmazonPay/CommonRequests/Configuration.cs | 42 +++--- .../CommonRequests/GetServiceStatusRequest.cs | 17 +-- AmazonPay/Constants.cs | 8 +- AmazonPay/HttpImpl.cs | 25 ++-- AmazonPay/IClient.cs | 51 ++++--- AmazonPay/IpnHandler.cs | 122 +++++++---------- AmazonPay/NestedJsonToDictionary.cs | 9 +- .../GetProviderCreditDetailsRequest.cs | 19 +-- ...GetProviderCreditReversalDetailsRequest.cs | 19 +-- .../ReverseProviderCreditRequest.cs | 23 ++-- .../AuthorizeOnBillingAgreementRequest.cs | 41 +++--- .../CloseBillingAgreementRequest.cs | 21 ++- .../ConfirmBillingAgreementRequest.cs | 19 +-- .../CreateOrderReferenceForIdRequest.cs | 37 +++-- .../GetBillingAgreementDetailsRequest.cs | 21 ++- .../SetBillingAgreementDetailsRequest.cs | 29 ++-- .../ValidateBillingAgreementRequest.cs | 19 +-- AmazonPay/Regions.cs | 25 ++-- AmazonPay/ResponseParser.cs | 11 +- AmazonPay/Responses/AuthorizeResponse.cs | 69 +++++----- AmazonPay/Responses/BillingAddressDetails.cs | 26 ++-- .../BillingAgreementDetailsResponse.cs | 101 +++++++------- .../Responses/CancelOrderReferenceResponse.cs | 28 ++-- AmazonPay/Responses/CaptureResponse.cs | 59 ++++---- .../Responses/CloseAuthorizationResponse.cs | 28 ++-- .../CloseBillingAgreementResponse.cs | 31 ++--- .../Responses/CloseOrderReferenceResponse.cs | 28 ++-- .../ConfirmBillingAgreementResponse.cs | 30 ++--- .../ConfirmOrderReferenceResponse.cs | 28 ++-- AmazonPay/Responses/ErrorResponse.cs | 14 +- .../GetProviderCreditDetailsResponse.cs | 55 ++++---- ...etProviderCreditReversalDetailsResponse.cs | 53 ++++---- .../Responses/GetServiceStatusResponse.cs | 26 ++-- AmazonPay/Responses/IResponse.cs | 3 +- .../OrderReferenceDetailsResponse.cs | 126 +++++++++--------- AmazonPay/Responses/RefundResponse.cs | 57 ++++---- .../ValidateBillingAgreementResponse.cs | 40 +++--- AmazonPay/SanitizeData.cs | 8 +- AmazonPay/Signature.cs | 126 +++++++++--------- .../AuthorizeRequest.cs | 34 +++-- .../CancelOrderReferenceRequest.cs | 21 ++- .../StandardPaymentRequests/CaptureRequest.cs | 30 ++--- .../StandardPaymentRequests/ChargeRequest.cs | 5 +- .../CloseAuthorizationRequest.cs | 21 ++- .../CloseOrderReferenceRequest.cs | 21 ++- .../ConfirmOrderReferenceRequest.cs | 19 +-- .../GetAuthorizationDetailsRequest.cs | 19 +-- .../GetCaptureDetailsRequest.cs | 19 +-- .../GetOrderReferenceDetailsRequest.cs | 24 ++-- .../GetRefundDetailsRequest.cs | 23 ++-- .../StandardPaymentRequests/RefundRequest.cs | 30 ++--- .../SetOrderReferenceDetailsRequest.cs | 33 +++-- UnitTests/AmazonPayUnitTests.cs | 48 ++++--- 54 files changed, 871 insertions(+), 1059 deletions(-) diff --git a/AmazonPay/Client.cs b/AmazonPay/Client.cs index 90b841d..f914ed1 100644 --- a/AmazonPay/Client.cs +++ b/AmazonPay/Client.cs @@ -1,16 +1,8 @@ using System; -using System.Reflection; -using System.Web; using System.Net; using System.Text; using System.IO; -using System.Text.RegularExpressions; -using System.Security.Cryptography; -using System.Globalization; -using System.Xml.Serialization; using System.Collections.Generic; -using System.Collections; -using System.Xml; using Newtonsoft.Json; using AmazonPay.StandardPaymentRequests; using AmazonPay.Responses; @@ -27,14 +19,14 @@ namespace AmazonPay /// Makes API calls to MWS forAmazon Pay /// returns Request Object /// - public class Client : AmazonPay.IClient + public class Client : IClient { private Dictionary parameters = new Dictionary(); private string mwsTestUrl = string.Empty; private string timeStamp = string.Empty; private Signature signatureObject; - private Configuration clientConfig = null; + private readonly Configuration clientConfig; private readonly string aud = "aud"; /// @@ -92,7 +84,6 @@ public Client(Configuration clientConfig) /// public Client(string jsonFilePath) { - string json; if (!string.IsNullOrEmpty(jsonFilePath)) { if (!File.Exists(@jsonFilePath)) @@ -101,11 +92,12 @@ public Client(string jsonFilePath) } else { + string json; using (StreamReader r = new StreamReader(@jsonFilePath)) { json = r.ReadToEnd(); } - this.clientConfig = new Configuration(json); + clientConfig = new Configuration(json); } } else @@ -120,7 +112,7 @@ public Client(string jsonFilePath) /// public void SetMwsTestUrl(string url) { - this.mwsTestUrl = url; + mwsTestUrl = url; } /// @@ -129,7 +121,7 @@ public void SetMwsTestUrl(string url) /// IDictionary parameters public Dictionary GetParameters() { - return this.parameters; + return parameters; } @@ -149,6 +141,7 @@ public void SetTimeStamp(string timeStamp) /// If Provider Credit Reversal Details is present, values are set by setProviderCreditDetails /// /// + /// /// string XML response private string SetParametersAndPost(Dictionary requestParameters, IList> providerDetails = null) { @@ -158,7 +151,7 @@ private string SetParametersAndPost(Dictionary requestParameters foreach (KeyValuePair pair in requestParameters) { - if (pair.Value != null && pair.Value != "") + if (!string.IsNullOrEmpty(pair.Value)) { parameters[pair.Key] = pair.Value; } @@ -208,11 +201,11 @@ private Dictionary SetDefaultValues(Dictionary p { if (requestParameters.ContainsKey(Constants.SellerId)) { - if (requestParameters[Constants.SellerId] == null || requestParameters[Constants.SellerId].ToString().Trim() == "") + if (requestParameters[Constants.SellerId] == null || requestParameters[Constants.SellerId].Trim() == "") { - if (this.clientConfig.GetMerchantId() != null && this.clientConfig.GetMerchantId().ToString().Trim() != "") + if (clientConfig.GetMerchantId() != null && clientConfig.GetMerchantId().Trim() != "") { - parameters[Constants.SellerId] = this.clientConfig.GetMerchantId(); + parameters[Constants.SellerId] = clientConfig.GetMerchantId(); } } } @@ -221,22 +214,22 @@ private Dictionary SetDefaultValues(Dictionary p { if (param.Key.Contains("CurrencyCode")) { - if (param.Value == null || param.Value == "") + if (string.IsNullOrEmpty(param.Value)) { - if (this.clientConfig.GetCurrencyCode() != null && this.clientConfig.GetCurrencyCode().Trim() != "") + if (clientConfig.GetCurrencyCode() != null && clientConfig.GetCurrencyCode().Trim() != "") { - parameters[param.Key] = this.clientConfig.GetCurrencyCode(); + parameters[param.Key] = clientConfig.GetCurrencyCode(); } } } if (param.Key.Contains("PlatformId")) { - if (param.Value == null || param.Value.ToString() == "") + if (string.IsNullOrEmpty(param.Value)) { - if (this.clientConfig.GetPlatformId() != null && this.clientConfig.GetPlatformId().Trim() != "") + if (clientConfig.GetPlatformId() != null && clientConfig.GetPlatformId().Trim() != "") { - parameters[param.Key] = this.clientConfig.GetPlatformId(); + parameters[param.Key] = clientConfig.GetPlatformId(); } } } @@ -271,7 +264,7 @@ private Dictionary SetProviderCreditDetails(Dictionary SetProviderCreditReversalDetails(Dictionary keypair in innerDictionary) { - if (keypair.Value.ToString().Trim() != "" && keypair.Value != null) + if (keypair.Value.Trim() != "" && keypair.Value != null) { parameters[providerString + providerIndex + "." + keypair.Key] = keypair.Value; } @@ -303,7 +296,7 @@ private Dictionary SetProviderCreditReversalDetails(Dictionary SetProviderCreditReversalDetails(Dictionarystring response - json output of profile information public string GetUserInfo(string accessToken) { - string response; string profileEndpoint = GetProfileEndpointUrl(); if (string.IsNullOrEmpty(accessToken)) { throw new NullReferenceException("Access Token is a required parameter and is not set"); } - if (string.IsNullOrEmpty(this.clientConfig.GetClientId().ToString())) + if (string.IsNullOrEmpty(clientConfig.GetClientId())) { throw new NullReferenceException("client ID is a required parameter and is not set"); } @@ -332,21 +324,21 @@ public string GetUserInfo(string accessToken) string url = profileEndpoint + "/auth/o2/tokeninfo?access_token=" + System.Web.HttpUtility.UrlEncode(accessToken); HttpImpl httpRequest = new HttpImpl(clientConfig); - response = httpRequest.Get(url); + var response = httpRequest.Get(url); Dictionary data = JsonConvert.DeserializeObject>(response); // aud - The client identifier used to request the access token. The value for aud should math the LWA Client ID - this.clientConfig.GetClientId() if (data.ContainsKey(aud)) { - if (!(data[aud].Equals(this.clientConfig.GetClientId().ToString()))) // describe the aud variable nd add value into a final string + if (!(data[aud].Equals(clientConfig.GetClientId()))) // describe the aud variable nd add value into a final string { throw new InvalidDataException("The Access token entered is incorrect"); } else { url = profileEndpoint + "/user/profile"; - httpRequest = new HttpImpl(this.clientConfig); + httpRequest = new HttpImpl(clientConfig); httpRequest.setAccessToken(accessToken); httpRequest.setHttpHeader(); @@ -1262,10 +1254,10 @@ public GetProviderCreditReversalDetailsResponse ReverseProviderCredit(ReversePro /// Dictionary response public AuthorizeResponse Charge(ChargeRequest requestParameters) { - string xml, baStatus, oroStatus = string.Empty; + string xml, baStatus, oroStatus; var chargeException = new InvalidDataException(); AuthorizeResponse authorizeResponseObject = null; - bool getSuccess = false, setSuccess = false, confirmSuccess = false, authorizeSuccess = false; + bool getSuccess, setSuccess, confirmSuccess, authorizeSuccess = false; switch (requestParameters.chargeType) { @@ -1413,9 +1405,8 @@ public AuthorizeResponse Charge(ChargeRequest requestParameters) /// parametersToString private string CalculateSignatureAndParametersToString(Dictionary parameters) { - signatureObject = new Signature(this.clientConfig, Constants.PaymentsServiceVersion); - signatureObject.Logger = this.Logger; - string parametersToString = signatureObject.CalculateSignatureAndReturnParametersAsString(parameters, this.timeStamp, this.mwsTestUrl); + signatureObject = new Signature(clientConfig, Constants.PaymentsServiceVersion) { Logger = Logger }; + string parametersToString = signatureObject.CalculateSignatureAndReturnParametersAsString(parameters, timeStamp, mwsTestUrl); this.parameters = parameters; return parametersToString; @@ -1430,9 +1421,7 @@ private string Invoke(string parameters) { String responseBody = null; - /// - /// Boolean variable to check if the API call was a success - /// + //Boolean variable to check if the API call was a success bool success = false; Dictionary responseDict = new Dictionary(); @@ -1441,7 +1430,7 @@ private string Invoke(string parameters) byte[] requestData = new UTF8Encoding().GetBytes(parameters); ConfigureUserAgentHeader(); - HttpImpl httpRequest = new HttpImpl(this.clientConfig); + HttpImpl httpRequest = new HttpImpl(clientConfig); // Submit the request and read response body bool shouldRetry; @@ -1460,7 +1449,7 @@ private string Invoke(string parameters) shouldRetry = false; success = true; } - else if (System.Convert.ToBoolean(this.clientConfig.GetAutoRetryOnThrottle()) && (statusCode == 500 || statusCode == 503)) + else if (Convert.ToBoolean(clientConfig.GetAutoRetryOnThrottle()) && (statusCode == 500 || statusCode == 503)) { ++retries; if (shouldRetry) @@ -1509,15 +1498,15 @@ private void PauseOnRetry(int retries, int status) private string GetProfileEndpointUrl() { string region = string.Empty; - string profileEnvt = System.Convert.ToBoolean(this.clientConfig.GetSandbox()) ? "api.sandbox" : "api"; + string profileEnvt = Convert.ToBoolean(clientConfig.GetSandbox()) ? "api.sandbox" : "api"; string profileEndpoint = string.Empty; - if (!string.IsNullOrEmpty(this.clientConfig.GetRegion().ToString())) + if (!string.IsNullOrEmpty(clientConfig.GetRegion())) { - region = this.clientConfig.GetRegion().ToString(); + region = clientConfig.GetRegion(); if (Regions.regionMappings.ContainsKey(region)) { - profileEndpoint = "https://" + profileEnvt + "." + Regions.ProfileEndpoint[region].ToString(); + profileEndpoint = "https://" + profileEnvt + "." + Regions.ProfileEndpoint[region]; } else { @@ -1536,18 +1525,18 @@ private void ConfigureUserAgentHeader() { signatureObject.SetUserAgentHeader( Environment.OSVersion.Platform + "/" + Environment.OSVersion.Version, - ".NET/" + Environment.Version.ToString()); + ".NET/" + Environment.Version); } /// /// Helper method to log data within Client /// /// - private void LogMessage(string message, AmazonPay.SanitizeData.DataType type) + private void LogMessage(string message, SanitizeData.DataType type) { - if (this.Logger != null && this.Logger.IsDebugEnabled) + if (Logger != null && Logger.IsDebugEnabled) { - this.Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); + Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); } } } diff --git a/AmazonPay/CommonRequests/Configuration.cs b/AmazonPay/CommonRequests/Configuration.cs index 434dfe4..b8e1d61 100644 --- a/AmazonPay/CommonRequests/Configuration.cs +++ b/AmazonPay/CommonRequests/Configuration.cs @@ -1,9 +1,7 @@ using Newtonsoft.Json; using System; -using System.Collections; using System.Collections.Generic; using System.IO; -using System.Text; namespace AmazonPay.CommonRequests { @@ -17,7 +15,7 @@ public class Configuration private string secret_key; private string region; private string currency_code; - private bool sandbox = false; + private bool sandbox; private string platform_id; private string cabundle_file; private string application_name; @@ -39,7 +37,7 @@ private enum configurationKeys public Configuration() { - this.proxy_port = -1; + proxy_port = -1; } public Configuration(string json) @@ -65,7 +63,7 @@ public Configuration(string json) { // If the region is present convert it to an enum type and pass it to the WithRegion method var region = (Regions.supportedRegions)Enum.Parse(typeof(Regions.supportedRegions), pair.Value.ToLower()); - WithRegion((Enum)region); + WithRegion(region); } else { @@ -80,7 +78,7 @@ public Configuration(string json) { // If the Currency Code is present convert it to an enum type and pass it to the WithRegion method var currencyCode = (Regions.currencyCode)Enum.Parse(typeof(Regions.currencyCode), pair.Value.ToUpper()); - WithCurrencyCode((Enum)currencyCode); + WithCurrencyCode(currencyCode); } else { @@ -131,7 +129,7 @@ public Configuration WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -146,7 +144,7 @@ public Configuration WithAccessKey(string access_key) } public string GetAccessKey() { - return this.access_key; + return access_key; } /// @@ -161,7 +159,7 @@ public Configuration WithSecretKey(string secret_key) } public string GetSecretKey() { - return this.secret_key; + return secret_key; } /// @@ -176,7 +174,7 @@ public Configuration WithRegion(Enum region) } public string GetRegion() { - return this.region; + return region; } /// @@ -191,7 +189,7 @@ public Configuration WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -206,7 +204,7 @@ public Configuration WithSandbox(bool sandbox = false) } public string GetSandbox() { - return this.sandbox.ToString().ToLower(); + return sandbox.ToString().ToLower(); } /// @@ -221,7 +219,7 @@ public Configuration WithPlatformId(string platform_id) } public string GetPlatformId() { - return this.platform_id; + return platform_id; } /// @@ -236,7 +234,7 @@ public Configuration WithCABundleFile(string cabundle_file) } public string GetCABundleFile() { - return this.cabundle_file; + return cabundle_file; } /// @@ -251,7 +249,7 @@ public Configuration WithApplicationName(string application_name) } public string GetApplicationName() { - return this.application_name; + return application_name; } /// @@ -266,7 +264,7 @@ public Configuration WithApplicationVersion(string application_version) } public string GetApplicationVersion() { - return this.application_version; + return application_version; } /// @@ -281,7 +279,7 @@ public Configuration WithProxyHost(string proxy_host) } public string GetProxyHost() { - return this.proxy_host; + return proxy_host; } /// @@ -296,7 +294,7 @@ public Configuration WithProxyPort(int proxy_port) } public int GetProxyPort() { - return this.proxy_port; + return proxy_port; } /// @@ -311,7 +309,7 @@ public Configuration WithProxyUserName(string proxy_username) } public string GetProxyUserName() { - return this.proxy_username; + return proxy_username; } /// @@ -326,7 +324,7 @@ public Configuration WithProxyUserPassword(string proxy_password) } public string GetProxyUserPassword() { - return this.proxy_password; + return proxy_password; } /// @@ -341,7 +339,7 @@ public Configuration WithClientId(string client_id) } public string GetClientId() { - return this.client_id; + return client_id; } /// @@ -356,7 +354,7 @@ public Configuration WithAutoRetryOnThrottle(bool auto_retry_on_throttle) } public bool GetAutoRetryOnThrottle() { - return this.auto_retry_on_throttle; + return auto_retry_on_throttle; } } } diff --git a/AmazonPay/CommonRequests/GetServiceStatusRequest.cs b/AmazonPay/CommonRequests/GetServiceStatusRequest.cs index c4a0a85..d7f3c30 100644 --- a/AmazonPay/CommonRequests/GetServiceStatusRequest.cs +++ b/AmazonPay/CommonRequests/GetServiceStatusRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.CommonRequests +namespace AmazonPay.CommonRequests { /// /// Set the GetServiceStatus API call parameters @@ -12,15 +7,15 @@ public class GetServiceStatusRequest { private string merchant_id; private string mws_auth_token; - private string action; + private readonly string action; public GetServiceStatusRequest() { - this.action = Constants.GetServiceStatus; + action = Constants.GetServiceStatus; } public string GetAction() { - return this.action; + return action; } /// @@ -35,7 +30,7 @@ public GetServiceStatusRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -50,7 +45,7 @@ public GetServiceStatusRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/Constants.cs b/AmazonPay/Constants.cs index 11ffaf0..a6f3a49 100644 --- a/AmazonPay/Constants.cs +++ b/AmazonPay/Constants.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay +namespace AmazonPay { public static class Constants { @@ -10,7 +6,7 @@ public static class Constants public static readonly string SDKName = "amazon-pay-sdk-csharp"; public static readonly string PaymentsServiceVersion = "2013-01-01"; public static readonly int MaxErrorRetry = 3; - + /// /// common parameters for all API calls /// diff --git a/AmazonPay/HttpImpl.cs b/AmazonPay/HttpImpl.cs index aec80b4..d28ba36 100644 --- a/AmazonPay/HttpImpl.cs +++ b/AmazonPay/HttpImpl.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; @@ -14,17 +13,17 @@ namespace AmazonPay class HttpImpl { private string response; - private bool header = false; + private bool header; private string accessToken = ""; - public Dictionary responseDict; - private Configuration clientConfig; + public Dictionary responseDict; + private readonly Configuration clientConfig; private int statusCode; - + public HttpImpl(Configuration config) { - responseDict = new Dictionary(); - this.clientConfig = config; + responseDict = new Dictionary(); + clientConfig = config; } /// @@ -41,7 +40,7 @@ public void setHttpHeader() /// public void setAccessToken(string accesstoken) { - this.accessToken = accesstoken; + accessToken = accesstoken; } /// @@ -102,7 +101,7 @@ public string Get(string url) /// /// /// Dictionary responseDict - public Dictionary Post(string url, string userAgent, byte[] requestData) + public Dictionary Post(string url, string userAgent, byte[] requestData) { HttpWebRequest request = ConfigureWebRequest("POST", url, userAgent, requestData.Length); using (Stream requestStream = request.GetRequestStream()) @@ -128,13 +127,13 @@ private void execute(HttpWebRequest request) { statusCode = (int)httpResponse.StatusCode; StreamReader reader = new StreamReader(httpResponse.GetResponseStream(), Encoding.UTF8); - this.response = reader.ReadToEnd(); + response = reader.ReadToEnd(); } } catch (WebException we) { - using (HttpWebResponse httpErrorResponse = (HttpWebResponse)we.Response as HttpWebResponse) + using (HttpWebResponse httpErrorResponse = (HttpWebResponse)we.Response) { if (httpErrorResponse == null) @@ -143,10 +142,10 @@ private void execute(HttpWebRequest request) } if (httpErrorResponse != null) { - this.statusCode = (int)httpErrorResponse.StatusCode; + statusCode = (int)httpErrorResponse.StatusCode; using (StreamReader reader = new StreamReader(httpErrorResponse.GetResponseStream(), Encoding.UTF8)) { - this.response = reader.ReadToEnd(); + response = reader.ReadToEnd(); } } } diff --git a/AmazonPay/IClient.cs b/AmazonPay/IClient.cs index c227fb1..462eb62 100644 --- a/AmazonPay/IClient.cs +++ b/AmazonPay/IClient.cs @@ -1,35 +1,34 @@ -using System; -namespace AmazonPay +namespace AmazonPay { /// /// Interface class for the AmazonPay Client class /// public interface IClient { - AmazonPay.Responses.AuthorizeResponse Authorize(AmazonPay.StandardPaymentRequests.AuthorizeRequest requestParameters); - AmazonPay.Responses.AuthorizeResponse AuthorizeOnBillingAgreement(AmazonPay.RecurringPaymentRequests.AuthorizeOnBillingAgreementRequest requestParameters); - AmazonPay.Responses.CancelOrderReferenceResponse CancelOrderReference(AmazonPay.StandardPaymentRequests.CancelOrderReferenceRequest requestParameters); - AmazonPay.Responses.CaptureResponse Capture(AmazonPay.StandardPaymentRequests.CaptureRequest requestParameters); - AmazonPay.Responses.AuthorizeResponse Charge(AmazonPay.StandardPaymentRequests.ChargeRequest requestParameters); - AmazonPay.Responses.CloseAuthorizationResponse CloseAuthorization(AmazonPay.StandardPaymentRequests.CloseAuthorizationRequest requestParameters); - AmazonPay.Responses.CloseBillingAgreementResponse CloseBillingAgreement(AmazonPay.RecurringPaymentRequests.CloseBillingAgreementRequest requestParameters); - AmazonPay.Responses.CloseOrderReferenceResponse CloseOrderReference(AmazonPay.StandardPaymentRequests.CloseOrderReferenceRequest requestParameters); - AmazonPay.Responses.ConfirmBillingAgreementResponse ConfirmBillingAgreement(AmazonPay.RecurringPaymentRequests.ConfirmBillingAgreementRequest requestParameters); - AmazonPay.Responses.ConfirmOrderReferenceResponse ConfirmOrderReference(AmazonPay.StandardPaymentRequests.ConfirmOrderReferenceRequest requestParameters); - AmazonPay.Responses.OrderReferenceDetailsResponse CreateOrderReferenceForId(AmazonPay.RecurringPaymentRequests.CreateOrderReferenceForIdRequest requestParameters); - AmazonPay.Responses.AuthorizeResponse GetAuthorizationDetails(AmazonPay.StandardPaymentRequests.GetAuthorizationDetailsRequest requestParameters); - AmazonPay.Responses.BillingAgreementDetailsResponse GetBillingAgreementDetails(AmazonPay.RecurringPaymentRequests.GetBillingAgreementDetailsRequest requestParameters); - AmazonPay.Responses.CaptureResponse GetCaptureDetails(AmazonPay.StandardPaymentRequests.GetCaptureDetailsRequest requestParameters); - AmazonPay.Responses.OrderReferenceDetailsResponse GetOrderReferenceDetails(AmazonPay.StandardPaymentRequests.GetOrderReferenceDetailsRequest requestParameters); - AmazonPay.Responses.GetProviderCreditDetailsResponse GetProviderCreditDetails(AmazonPay.ProviderCreditRequests.GetProviderCreditDetailsRequest requestParameters); - AmazonPay.Responses.GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails(AmazonPay.ProviderCreditRequests.GetProviderCreditReversalDetailsRequest requestParameters); - AmazonPay.Responses.RefundResponse GetRefundDetails(AmazonPay.StandardPaymentRequests.GetRefundDetailsRequest requestParameters); - AmazonPay.Responses.GetServiceStatusResponse GetServiceStatus(AmazonPay.CommonRequests.GetServiceStatusRequest requestParameters); + Responses.AuthorizeResponse Authorize(StandardPaymentRequests.AuthorizeRequest requestParameters); + Responses.AuthorizeResponse AuthorizeOnBillingAgreement(RecurringPaymentRequests.AuthorizeOnBillingAgreementRequest requestParameters); + Responses.CancelOrderReferenceResponse CancelOrderReference(StandardPaymentRequests.CancelOrderReferenceRequest requestParameters); + Responses.CaptureResponse Capture(StandardPaymentRequests.CaptureRequest requestParameters); + Responses.AuthorizeResponse Charge(StandardPaymentRequests.ChargeRequest requestParameters); + Responses.CloseAuthorizationResponse CloseAuthorization(StandardPaymentRequests.CloseAuthorizationRequest requestParameters); + Responses.CloseBillingAgreementResponse CloseBillingAgreement(RecurringPaymentRequests.CloseBillingAgreementRequest requestParameters); + Responses.CloseOrderReferenceResponse CloseOrderReference(StandardPaymentRequests.CloseOrderReferenceRequest requestParameters); + Responses.ConfirmBillingAgreementResponse ConfirmBillingAgreement(RecurringPaymentRequests.ConfirmBillingAgreementRequest requestParameters); + Responses.ConfirmOrderReferenceResponse ConfirmOrderReference(StandardPaymentRequests.ConfirmOrderReferenceRequest requestParameters); + Responses.OrderReferenceDetailsResponse CreateOrderReferenceForId(RecurringPaymentRequests.CreateOrderReferenceForIdRequest requestParameters); + Responses.AuthorizeResponse GetAuthorizationDetails(StandardPaymentRequests.GetAuthorizationDetailsRequest requestParameters); + Responses.BillingAgreementDetailsResponse GetBillingAgreementDetails(RecurringPaymentRequests.GetBillingAgreementDetailsRequest requestParameters); + Responses.CaptureResponse GetCaptureDetails(StandardPaymentRequests.GetCaptureDetailsRequest requestParameters); + Responses.OrderReferenceDetailsResponse GetOrderReferenceDetails(StandardPaymentRequests.GetOrderReferenceDetailsRequest requestParameters); + Responses.GetProviderCreditDetailsResponse GetProviderCreditDetails(ProviderCreditRequests.GetProviderCreditDetailsRequest requestParameters); + Responses.GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails(ProviderCreditRequests.GetProviderCreditReversalDetailsRequest requestParameters); + Responses.RefundResponse GetRefundDetails(StandardPaymentRequests.GetRefundDetailsRequest requestParameters); + Responses.GetServiceStatusResponse GetServiceStatus(CommonRequests.GetServiceStatusRequest requestParameters); string GetUserInfo(string accessToken); - AmazonPay.Responses.RefundResponse Refund(AmazonPay.StandardPaymentRequests.RefundRequest requestParameters); - AmazonPay.Responses.GetProviderCreditReversalDetailsResponse ReverseProviderCredit(AmazonPay.ProviderCreditRequests.ReverseProviderCreditRequest requestParameters); - AmazonPay.Responses.BillingAgreementDetailsResponse SetBillingAgreementDetails(AmazonPay.RecurringPaymentRequests.SetBillingAgreementDetailsRequest requestParameters); - AmazonPay.Responses.OrderReferenceDetailsResponse SetOrderReferenceDetails(AmazonPay.StandardPaymentRequests.SetOrderReferenceDetailsRequest requestParameters); - AmazonPay.Responses.ValidateBillingAgreementResponse ValidateBillingAgreement(AmazonPay.RecurringPaymentRequests.ValidateBillingAgreementRequest requestParameters); + Responses.RefundResponse Refund(StandardPaymentRequests.RefundRequest requestParameters); + Responses.GetProviderCreditReversalDetailsResponse ReverseProviderCredit(ProviderCreditRequests.ReverseProviderCreditRequest requestParameters); + Responses.BillingAgreementDetailsResponse SetBillingAgreementDetails(RecurringPaymentRequests.SetBillingAgreementDetailsRequest requestParameters); + Responses.OrderReferenceDetailsResponse SetOrderReferenceDetails(StandardPaymentRequests.SetOrderReferenceDetailsRequest requestParameters); + Responses.ValidateBillingAgreementResponse ValidateBillingAgreement(RecurringPaymentRequests.ValidateBillingAgreementRequest requestParameters); } } diff --git a/AmazonPay/IpnHandler.cs b/AmazonPay/IpnHandler.cs index dede198..26b51de 100644 --- a/AmazonPay/IpnHandler.cs +++ b/AmazonPay/IpnHandler.cs @@ -4,14 +4,11 @@ using System.IO; using System.Text; using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Net; using Newtonsoft.Json.Linq; using Newtonsoft.Json; -using AmazonPay; using System.Xml; using AmazonPay.Responses; using System.Text.RegularExpressions; @@ -74,7 +71,7 @@ public IpnHandler(NameValueCollection headers, string jsonMessage) /// public IpnHandler(NameValueCollection headers, string jsonMessage, ILog logger) { - this.Logger = logger; + Logger = logger; IpnHandlerInit(headers, jsonMessage); } @@ -139,10 +136,10 @@ private void ParseRawMessage(NameValueCollection headers, string body) private void ParseNotification(NameValueCollection headers, string snsJson) { ValidateHeader(headers); - parseMessage(snsJson); + ParseMessage(snsJson); ValidateCertUrl(); ValidateMessageType(); - LogRequestDetails(headers, this.ToXml()); + LogRequestDetails(headers, ToXml()); } private void LogRequestDetails(NameValueCollection headers, string message) @@ -155,7 +152,7 @@ private void LogRequestDetails(NameValueCollection headers, string message) sb.AppendLine("[Key: " + headers.GetKey(i) + ", Value: " + headers.GetValues(headers.GetKey(i))[0] + "]"); } // Logging headers - LogMessage(sb.ToString(), AmazonPay.SanitizeData.DataType.Text); + LogMessage(sb.ToString(), SanitizeData.DataType.Text); // Logging response LogMessage(message, SanitizeData.DataType.Response); } @@ -166,7 +163,7 @@ private void LogRequestDetails(NameValueCollection headers, string message) /// private static void ValidateHeader(NameValueCollection headers) { - string messageType = null; + string messageType; try { @@ -184,19 +181,19 @@ private static void ValidateHeader(NameValueCollection headers) if (!messageType.Equals("Notification", StringComparison.InvariantCultureIgnoreCase)) { - throw new NullReferenceException(String.Format("Error with sns message - header x-amz-sns-message-type is invalid", messageType)); + throw new NullReferenceException(string.Format("Error with sns message - header x-amz-sns-message-type is invalid", messageType)); } } /// /// Ensure that the sns message is the valid notificaton type /// - private void ValidateMessageType() + private void ValidateMessageType() { string notificatonType = GetMandatoryField("Type"); if (!notificatonType.Equals("Notification", StringComparison.InvariantCultureIgnoreCase)) { - throw new Exception("METHOD__ValidateMessageType |" + String.Format("Error with sns notification - unexpected message with Type of ", notificatonType)); + throw new Exception("METHOD__ValidateMessageType |" + string.Format("Error with sns notification - unexpected message with Type of ", notificatonType)); } } @@ -204,11 +201,11 @@ private void ValidateMessageType() /// Create a new message the acts as a wrapper around the json string /// /// - private void parseMessage(string json) + private void ParseMessage(string json) { try { - this.parsedMessage = JObject.Parse(json); + parsedMessage = JObject.Parse(json); } catch (Exception ex) { @@ -240,7 +237,7 @@ private DateTime GetMandatoryFieldAsDateTime(string fieldName) } catch (FormatException fe) { - throw new FormatException(String.Format("Error with message - expected field should be of type DateTime object", fieldName), fe); + throw new FormatException(string.Format("Error with message - expected field should be of type DateTime object", fieldName), fe); } } @@ -251,11 +248,11 @@ private DateTime GetMandatoryFieldAsDateTime(string fieldName) /// JToken value private JToken GetValueAsToken(string fieldName) { - JToken value = this.parsedMessage.GetValue(fieldName); + JToken value = parsedMessage.GetValue(fieldName); if (value == null) { - throw new NullReferenceException(String.Format("Error with message - mandatory field cannot be found", fieldName)); + throw new NullReferenceException(string.Format("Error with message - mandatory field cannot be found", fieldName)); } return value; } @@ -265,24 +262,16 @@ private JToken GetValueAsToken(string fieldName) /// /// /// String or null if not defined - private String GetField(string fieldName) + private string GetField(string fieldName) { - JToken value = this.parsedMessage.GetValue(fieldName); - if (value != null) - { - return value.ToString(); - } - else - { - return null; - } + JToken value = parsedMessage.GetValue(fieldName); + return value?.ToString(); } /// /// Verifies that the signing certificate url is from a recognizable source. /// Returns the cert url if it cen be verified, otherwise throws an exception. /// - /// /// private void ValidateCertUrl() { @@ -294,14 +283,7 @@ private void ValidateCertUrl() { const string pattern = @"^sns\.[a-zA-Z0-9\-]{3,}\.amazonaws\.com(\.cn)?$"; var regex = new Regex(pattern); - if (!regex.IsMatch(uri.Host)) - { - isValidUrl = false; - } - else - { - isValidUrl = true; - } + isValidUrl = regex.IsMatch(uri.Host); } if (!isValidUrl) { @@ -322,7 +304,7 @@ private void ValidateMessageIsTrusted() VerifySnsMessageWithVersion1SignatureAlgorithm(); break; default: - throw new InvalidDataException(String.Format("Error with sns message verification - message is signed with unknown signature specification", signatureVersion)); + throw new InvalidDataException(string.Format("Error with sns message verification - message is signed with unknown signature specification", signatureVersion)); } } @@ -334,7 +316,7 @@ private void VerifySnsMessageWithVersion1SignatureAlgorithm() bool isValid = VerifyMsgMatchesSignatureV1WithCert(); if (!isValid) { - throw new InvalidDataException(String.Format("Error with sns message - signature verification failed", "1")); + throw new InvalidDataException(string.Format("Error with sns message - signature verification failed", "1")); } } @@ -384,7 +366,7 @@ private string GetMessageToSign() builder.Append("MessageId\n"); builder.Append(GetMandatoryField("MessageId")); builder.Append("\n"); - String subject = GetField("Subject"); + string subject = GetField("Subject"); if (subject != null) { builder.Append("Subject\n"); @@ -419,9 +401,9 @@ private bool VerifyCertIsIssuedByAmazon() /// /// /// value of the attribute or false - private bool VerifyCertificateSubject(String subject) + private bool VerifyCertificateSubject(string subject) { - string[] subjectAttributeDelimiters = new string[] { ", " }; + string[] subjectAttributeDelimiters = { ", " }; string[] subjectAttributesArr = subject.Split(subjectAttributeDelimiters, StringSplitOptions.None); List subjectAttributesList = convertSubjectAttributesArr(subjectAttributesArr); @@ -502,7 +484,7 @@ private X509Certificate2 GetCertificate(string certPath) X509Certificate2 cert = null; try { - cert = (X509Certificate2)HttpRuntime.Cache.Get(String.Format(Constants.CacheKey, certPath)); + cert = (X509Certificate2)HttpRuntime.Cache.Get(string.Format(Constants.CacheKey, certPath)); } catch (HttpException ex) { @@ -512,7 +494,7 @@ private X509Certificate2 GetCertificate(string certPath) if (cert == null) { cert = GetCertificateFromURI(certPath); - HttpRuntime.Cache.Insert(String.Format(Constants.CacheKey, certPath), cert, null, DateTime.UtcNow.AddDays(1.0), System.Web.Caching.Cache.NoSlidingExpiration); + HttpRuntime.Cache.Insert(string.Format(Constants.CacheKey, certPath), cert, null, DateTime.UtcNow.AddDays(1.0), System.Web.Caching.Cache.NoSlidingExpiration); } return cert; @@ -543,7 +525,7 @@ private bool VerifyCertificateChain() /// Gets certificate's subject information /// /// x509Cert.Subject - private String GetSubject() + private string GetSubject() { return x509Cert.Subject; } @@ -563,12 +545,11 @@ private AsymmetricAlgorithm GetPublicKey() /// private void GetIpnResponseObjects() { - string xml; - xml = this.ToXml(); + var xml = ToXml(); - if (Enum.IsDefined(typeof(NotificationType), this.GetNotificationType())) + if (Enum.IsDefined(typeof(NotificationType), GetNotificationType())) { - switch ((NotificationType)Enum.Parse(typeof(NotificationType), this.GetNotificationType())) + switch ((NotificationType)Enum.Parse(typeof(NotificationType), GetNotificationType())) { case NotificationType.OrderReferenceNotification: orderReferenceDetailsObject = new OrderReferenceDetailsResponse(xml); @@ -601,13 +582,10 @@ private void GetIpnResponseObjects() /// IPN in JSON string format public string ToJson() { - string xmlResponse; - string json; - - xmlResponse = this.ToXml(); + var xmlResponse = ToXml(); var xml = new XmlDocument(); xml.LoadXml(xmlResponse); - json = JsonConvert.SerializeObject(xml, Newtonsoft.Json.Formatting.Indented); + var json = JsonConvert.SerializeObject(xml, Newtonsoft.Json.Formatting.Indented); return json; } @@ -617,7 +595,7 @@ public string ToJson() /// IPN in XML string format public string ToXml() { - JObject message = JObject.Parse(this.parsedMessage.GetValue("Message").ToString()); + JObject message = JObject.Parse(parsedMessage.GetValue("Message").ToString()); string xmlResponse = message.GetValue("NotificationData").ToString().Trim(); parseRemainingIpnFields(); return xmlResponse; @@ -631,7 +609,7 @@ public Dictionary ToDict() { string json = ToJson(); Dictionary dict = JsonConvert.DeserializeObject>( - json, new JsonConverter[] { new AmazonPay.JsonParser() }); + json, new JsonParser()); return dict; } @@ -640,11 +618,11 @@ public Dictionary ToDict() /// private void parseRemainingIpnFields() { - JObject message = JObject.Parse(this.parsedMessage.GetValue("Message").ToString()); - this.notificationReferenceId = message.GetValue("NotificationReferenceId").ToString(); - this.notificationType = message.GetValue("NotificationType").ToString(); - this.sellerId = message.GetValue("SellerId").ToString(); - this.releaseEnvironment = message.GetValue("ReleaseEnvironment").ToString(); + JObject message = JObject.Parse(parsedMessage.GetValue("Message").ToString()); + notificationReferenceId = message.GetValue("NotificationReferenceId").ToString(); + notificationType = message.GetValue("NotificationType").ToString(); + sellerId = message.GetValue("SellerId").ToString(); + releaseEnvironment = message.GetValue("ReleaseEnvironment").ToString(); } @@ -654,7 +632,7 @@ private void parseRemainingIpnFields() /// public string GetSellerId() { - return this.sellerId; + return sellerId; } /// @@ -663,7 +641,7 @@ public string GetSellerId() /// public string GetNotificationReferenceId() { - return this.notificationReferenceId; + return notificationReferenceId; } /// @@ -672,7 +650,7 @@ public string GetNotificationReferenceId() /// public string GetReleaseEnvironment() { - return this.releaseEnvironment; + return releaseEnvironment; } /// @@ -682,7 +660,7 @@ public string GetReleaseEnvironment() /// public string GetNotificationType() { - return this.notificationType; + return notificationType; } /// @@ -691,7 +669,7 @@ public string GetNotificationType() /// OrderReferenceDetailsResponse Object public OrderReferenceDetailsResponse GetOrderReferenceDetailsResponse() { - return this.orderReferenceDetailsObject; + return orderReferenceDetailsObject; } /// @@ -700,7 +678,7 @@ public OrderReferenceDetailsResponse GetOrderReferenceDetailsResponse() /// BillingAgreementDetailsResponse Object public BillingAgreementDetailsResponse GetBillingAgreementDetailsResponse() { - return this.billingAgreementDetailsObject; + return billingAgreementDetailsObject; } /// @@ -709,7 +687,7 @@ public BillingAgreementDetailsResponse GetBillingAgreementDetailsResponse() /// AuthorizeResponse Object public AuthorizeResponse GetAuthorizeResponse() { - return this.authorizeResponseObject; + return authorizeResponseObject; } /// @@ -718,7 +696,7 @@ public AuthorizeResponse GetAuthorizeResponse() /// CaptureResponse Object public CaptureResponse GetCaptureResponse() { - return this.captureResponseObject; + return captureResponseObject; } /// @@ -727,7 +705,7 @@ public CaptureResponse GetCaptureResponse() /// RefundResponse Object public RefundResponse GetRefundResponse() { - return this.refundResponseObject; + return refundResponseObject; } /// @@ -736,7 +714,7 @@ public RefundResponse GetRefundResponse() /// GetProviderCreditDetailsResponse Object public GetProviderCreditDetailsResponse GetProviderCreditDetailsResponse() { - return this.providerCreditResponseObject; + return providerCreditResponseObject; } /// @@ -745,7 +723,7 @@ public GetProviderCreditDetailsResponse GetProviderCreditDetailsResponse() /// GetProviderCreditReversalDetailsResponse Object public GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetailsResponse() { - return this.providerCreditReversalResponseObject; + return providerCreditReversalResponseObject; } /// @@ -755,9 +733,9 @@ public GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails /// private void LogMessage(string message, SanitizeData.DataType type) { - if (this.Logger != null && this.Logger.IsDebugEnabled) + if (Logger != null && Logger.IsDebugEnabled) { - this.Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); + Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); } } } diff --git a/AmazonPay/NestedJsonToDictionary.cs b/AmazonPay/NestedJsonToDictionary.cs index 97dd4d6..8fdb70e 100644 --- a/AmazonPay/NestedJsonToDictionary.cs +++ b/AmazonPay/NestedJsonToDictionary.cs @@ -2,7 +2,6 @@ using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; -using System.Text; namespace AmazonPay { @@ -12,16 +11,16 @@ namespace AmazonPay /// public class NestedJsonToDictionary { - private Dictionary dictionary = new Dictionary(); + private readonly Dictionary dictionary = new Dictionary(); public NestedJsonToDictionary(string json) { - this.dictionary = JsonConvert.DeserializeObject>( - json, new JsonConverter[] { new JsonParser() }); + dictionary = JsonConvert.DeserializeObject>( + json, new JsonParser()); } public Dictionary GetDictionary() { - return this.dictionary; + return dictionary; } } public class JsonParser : CustomCreationConverter> diff --git a/AmazonPay/ProviderCreditRequests/GetProviderCreditDetailsRequest.cs b/AmazonPay/ProviderCreditRequests/GetProviderCreditDetailsRequest.cs index 040fadd..734f89f 100644 --- a/AmazonPay/ProviderCreditRequests/GetProviderCreditDetailsRequest.cs +++ b/AmazonPay/ProviderCreditRequests/GetProviderCreditDetailsRequest.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.ProviderCreditRequests +namespace AmazonPay.ProviderCreditRequests { /// /// Request class to set the GetProviderCreditDetails API call parameters /// public class GetProviderCreditDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_provider_credit_id; private string mws_auth_token; public GetProviderCreditDetailsRequest() { - this.action = Constants.GetProviderCreditDetails; + action = Constants.GetProviderCreditDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -35,7 +30,7 @@ public GetProviderCreditDetailsRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -50,7 +45,7 @@ public GetProviderCreditDetailsRequest WithAmazonProviderCreditId(string amazon_ } public string GetAmazonProviderCreditId() { - return this.amazon_provider_credit_id; + return amazon_provider_credit_id; } /// @@ -65,7 +60,7 @@ public GetProviderCreditDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/ProviderCreditRequests/GetProviderCreditReversalDetailsRequest.cs b/AmazonPay/ProviderCreditRequests/GetProviderCreditReversalDetailsRequest.cs index 5a3f6cf..002f765 100644 --- a/AmazonPay/ProviderCreditRequests/GetProviderCreditReversalDetailsRequest.cs +++ b/AmazonPay/ProviderCreditRequests/GetProviderCreditReversalDetailsRequest.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.ProviderCreditRequests +namespace AmazonPay.ProviderCreditRequests { /// /// Request class to set the GetProviderCreditReversalDetails API call parameters /// public class GetProviderCreditReversalDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_provider_credit_reversal_id; private string mws_auth_token; public GetProviderCreditReversalDetailsRequest() { - this.action = Constants.GetProviderCreditReversalDetails; + action = Constants.GetProviderCreditReversalDetails; } public string GetAction() { - return this.action; + return action; } /// @@ -36,7 +31,7 @@ public GetProviderCreditReversalDetailsRequest WithMerchantId(string merchant_id } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -51,7 +46,7 @@ public GetProviderCreditReversalDetailsRequest WithAmazonProviderCreditReversalI } public string GetAmazonProviderCreditReversalId() { - return this.amazon_provider_credit_reversal_id; + return amazon_provider_credit_reversal_id; } /// @@ -66,7 +61,7 @@ public GetProviderCreditReversalDetailsRequest WithMWSAuthToken(string mws_auth_ } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/ProviderCreditRequests/ReverseProviderCreditRequest.cs b/AmazonPay/ProviderCreditRequests/ReverseProviderCreditRequest.cs index 1a27d11..6622778 100644 --- a/AmazonPay/ProviderCreditRequests/ReverseProviderCreditRequest.cs +++ b/AmazonPay/ProviderCreditRequests/ReverseProviderCreditRequest.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.ProviderCreditRequests { @@ -10,7 +7,7 @@ namespace AmazonPay.ProviderCreditRequests /// public class ReverseProviderCreditRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_provider_credit_id; private string credit_reversal_reference_id; @@ -21,11 +18,11 @@ public class ReverseProviderCreditRequest public ReverseProviderCreditRequest() { - this.action = Constants.ReverseProviderCredit; + action = Constants.ReverseProviderCredit; } public string GetAction() { - return this.action; + return action; } /// @@ -40,7 +37,7 @@ public ReverseProviderCreditRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -55,7 +52,7 @@ public ReverseProviderCreditRequest WithAmazonProviderCreditId(string amazon_pro } public string GetAmazonProviderCreditId() { - return this.amazon_provider_credit_id; + return amazon_provider_credit_id; } /// @@ -70,7 +67,7 @@ public ReverseProviderCreditRequest WithCreditReversalReferenceId(string credit_ } public string GetCreditReversalReferenceId() { - return this.credit_reversal_reference_id; + return credit_reversal_reference_id; } /// @@ -85,7 +82,7 @@ public ReverseProviderCreditRequest WithAmount(decimal amount) } public decimal GetAmount() { - return this.amount; + return amount; } /// @@ -100,7 +97,7 @@ public ReverseProviderCreditRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -115,7 +112,7 @@ public ReverseProviderCreditRequest WithCreditReversalNote(string credit_reversa } public string GetCreditReversalNote() { - return this.credit_reversal_note; + return credit_reversal_note; } /// /// Sets the MWS Auth Token @@ -129,7 +126,7 @@ public ReverseProviderCreditRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/AuthorizeOnBillingAgreementRequest.cs b/AmazonPay/RecurringPaymentRequests/AuthorizeOnBillingAgreementRequest.cs index 82f57f8..7fdfea6 100644 --- a/AmazonPay/RecurringPaymentRequests/AuthorizeOnBillingAgreementRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/AuthorizeOnBillingAgreementRequest.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.RecurringPaymentRequests { @@ -10,7 +7,7 @@ namespace AmazonPay.RecurringPaymentRequests /// public class AuthorizeOnBillingAgreementRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_billing_agreement_id; private decimal amount; @@ -31,11 +28,11 @@ public class AuthorizeOnBillingAgreementRequest public AuthorizeOnBillingAgreementRequest() { - this.action = Constants.AuthorizeOnBillingAgreement; + action = Constants.AuthorizeOnBillingAgreement; } public string GetAction() { - return this.action; + return action; } /// @@ -51,7 +48,7 @@ public AuthorizeOnBillingAgreementRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -66,7 +63,7 @@ public AuthorizeOnBillingAgreementRequest WithAmazonBillingAgreementId(string am } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -81,7 +78,7 @@ public AuthorizeOnBillingAgreementRequest WithAuthorizationReferenceId(string au } public string GetAuthorizationReferenceId() { - return this.authorization_reference_id; + return authorization_reference_id; } /// /// Sets the Amount @@ -95,7 +92,7 @@ public AuthorizeOnBillingAgreementRequest WithAmount(decimal amount) } public decimal GetAmount() { - return this.amount; + return amount; } /// /// Sets the Currency Code @@ -110,7 +107,7 @@ public AuthorizeOnBillingAgreementRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -125,7 +122,7 @@ public AuthorizeOnBillingAgreementRequest WithSellerAuthorizationNote(string sel } public string GetSellerAuthorizationNote() { - return this.seller_authorization_note; + return seller_authorization_note; } /// @@ -140,7 +137,7 @@ public AuthorizeOnBillingAgreementRequest WithTransactionTimeout(int? transactio } public int? GetTransactionTimeout() { - return this.transaction_timeout; + return transaction_timeout; } /// @@ -155,7 +152,7 @@ public AuthorizeOnBillingAgreementRequest WithCaptureNow(bool capture_now = fals } public string GetCaptureNow() { - return this.capture_now.ToString().ToLower(); + return capture_now.ToString().ToLower(); } /// @@ -170,7 +167,7 @@ public AuthorizeOnBillingAgreementRequest WithSoftDescriptor(string soft_descrip } public string GetSoftDescriptor() { - return this.soft_descriptor; + return soft_descriptor; } /// @@ -185,7 +182,7 @@ public AuthorizeOnBillingAgreementRequest WithPlatformId(string platform_id) } public string GetPlatformId() { - return this.platform_id; + return platform_id; } /// @@ -200,7 +197,7 @@ public AuthorizeOnBillingAgreementRequest WithSellerNote(string seller_note) } public string GetSellerNote() { - return this.seller_note; + return seller_note; } /// /// Sets the Store Name @@ -214,7 +211,7 @@ public AuthorizeOnBillingAgreementRequest WithStoreName(string store_name) } public string GetStoreName() { - return this.store_name; + return store_name; } /// /// Sets the Seller Order ID @@ -228,7 +225,7 @@ public AuthorizeOnBillingAgreementRequest WithSellerOrderId(string seller_order_ } public string GetSellerOrderId() { - return this.seller_order_id; + return seller_order_id; } /// /// Sets the Custom Information @@ -242,7 +239,7 @@ public AuthorizeOnBillingAgreementRequest WithCustomInformation(string custom_in } public string GetCustomInformation() { - return this.custom_information; + return custom_information; } /// @@ -257,7 +254,7 @@ public AuthorizeOnBillingAgreementRequest WithInheritShippingAddress(bool inheri } public string GetInheritShippingAddress() { - return this.inherit_shipping_address.ToString().ToLower(); + return inherit_shipping_address.ToString().ToLower(); } /// @@ -272,7 +269,7 @@ public AuthorizeOnBillingAgreementRequest WithMWSAuthToken(string mws_auth_token } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/CloseBillingAgreementRequest.cs b/AmazonPay/RecurringPaymentRequests/CloseBillingAgreementRequest.cs index 9314c46..e04b2cb 100644 --- a/AmazonPay/RecurringPaymentRequests/CloseBillingAgreementRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/CloseBillingAgreementRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.RecurringPaymentRequests +namespace AmazonPay.RecurringPaymentRequests { /// /// Request class to set the CloseBillingAgreement API call parameters @@ -14,15 +9,15 @@ public class CloseBillingAgreementRequest private string amazon_billing_agreement_id; private string closure_reason; private string mws_auth_token; - private string action; + private readonly string action; public CloseBillingAgreementRequest() { - this.action = Constants.CloseBillingAgreement; + action = Constants.CloseBillingAgreement; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -36,7 +31,7 @@ public CloseBillingAgreementRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -51,7 +46,7 @@ public CloseBillingAgreementRequest WithAmazonBillingAgreementId(string amazon_b } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -66,7 +61,7 @@ public CloseBillingAgreementRequest WithClosureReason(string closure_reason) } public string GetClosureReason() { - return this.closure_reason; + return closure_reason; } /// @@ -81,7 +76,7 @@ public CloseBillingAgreementRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/ConfirmBillingAgreementRequest.cs b/AmazonPay/RecurringPaymentRequests/ConfirmBillingAgreementRequest.cs index 13a14ef..395cc6b 100644 --- a/AmazonPay/RecurringPaymentRequests/ConfirmBillingAgreementRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/ConfirmBillingAgreementRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.RecurringPaymentRequests +namespace AmazonPay.RecurringPaymentRequests { /// /// Request class to set the ConfirmBillingAgreement API call parameters @@ -13,15 +8,15 @@ public class ConfirmBillingAgreementRequest private string merchant_id; private string amazon_billing_agreement_id; private string mws_auth_token; - private string action; + private readonly string action; public ConfirmBillingAgreementRequest() { - this.action = Constants.ConfirmBillingAgreement; + action = Constants.ConfirmBillingAgreement; } public string GetAction() { - return this.action; + return action; } /// @@ -36,7 +31,7 @@ public ConfirmBillingAgreementRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -51,7 +46,7 @@ public ConfirmBillingAgreementRequest WithAmazonBillingreementId(string amazon_b } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// /// Sets the MWS Auth Token @@ -65,7 +60,7 @@ public ConfirmBillingAgreementRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/CreateOrderReferenceForIdRequest.cs b/AmazonPay/RecurringPaymentRequests/CreateOrderReferenceForIdRequest.cs index ab8dd28..7881ce2 100644 --- a/AmazonPay/RecurringPaymentRequests/CreateOrderReferenceForIdRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/CreateOrderReferenceForIdRequest.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.RecurringPaymentRequests { @@ -23,15 +20,15 @@ public class CreateOrderReferenceForIdRequest private string custom_information; private string amazon_billing_agreement_id; private string mws_auth_token; - private string action; + private readonly string action; public CreateOrderReferenceForIdRequest() { - this.action = Constants.CreateOrderReferenceForId; + action = Constants.CreateOrderReferenceForId; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -46,7 +43,7 @@ public CreateOrderReferenceForIdRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -56,12 +53,12 @@ public string GetMerchantId() /// CreateOrderReferenceForIdRequest Object public CreateOrderReferenceForIdRequest WithId(string id) { - this.amazon_billing_agreement_id = id; + amazon_billing_agreement_id = id; return this; } public string GetId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -76,7 +73,7 @@ public CreateOrderReferenceForIdRequest WithIdType(string id_type) } public string GetIdType() { - return this.id_type; + return id_type; } /// @@ -91,7 +88,7 @@ public CreateOrderReferenceForIdRequest WithInheritShippingAddress(bool inherit_ } public string GetInheritShippingAddress() { - return this.inherit_shipping_address.ToString().ToLower(); + return inherit_shipping_address.ToString().ToLower(); } /// @@ -106,7 +103,7 @@ public CreateOrderReferenceForIdRequest WithConfirmNow(bool confirm_now) } public string GetConfirmNow() { - return this.confirm_now.ToString().ToLower(); + return confirm_now.ToString().ToLower(); } /// @@ -121,7 +118,7 @@ public CreateOrderReferenceForIdRequest WithAmount(decimal amount) } public decimal GetAmount() { - return this.amount; + return amount; } /// @@ -136,7 +133,7 @@ public CreateOrderReferenceForIdRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -151,7 +148,7 @@ public CreateOrderReferenceForIdRequest WithPlatformId(string platform_id) } public string GetPlatformId() { - return this.platform_id; + return platform_id; } /// @@ -166,7 +163,7 @@ public CreateOrderReferenceForIdRequest WithSellerNote(string seller_note) } public string GetSellerNote() { - return this.seller_note; + return seller_note; } /// @@ -181,7 +178,7 @@ public CreateOrderReferenceForIdRequest WithSellerOrderId(string seller_order_id } public string GetSellerOrderId() { - return this.seller_order_id; + return seller_order_id; } /// @@ -196,7 +193,7 @@ public CreateOrderReferenceForIdRequest WithStoreName(string store_name) } public string GetStoreName() { - return this.store_name; + return store_name; } /// /// Sets the Custom Information @@ -210,7 +207,7 @@ public CreateOrderReferenceForIdRequest WithCustomInformation(string custom_info } public string GetCustomInformation() { - return this.custom_information; + return custom_information; } /// @@ -225,7 +222,7 @@ public CreateOrderReferenceForIdRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/GetBillingAgreementDetailsRequest.cs b/AmazonPay/RecurringPaymentRequests/GetBillingAgreementDetailsRequest.cs index ff710eb..a7eef69 100644 --- a/AmazonPay/RecurringPaymentRequests/GetBillingAgreementDetailsRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/GetBillingAgreementDetailsRequest.cs @@ -1,16 +1,11 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.RecurringPaymentRequests +namespace AmazonPay.RecurringPaymentRequests { /// /// Request class to set the GetBillingAgreementDetails API call parameters /// public class GetBillingAgreementDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_billing_agreement_id; private string mws_auth_token; @@ -18,11 +13,11 @@ public class GetBillingAgreementDetailsRequest public GetBillingAgreementDetailsRequest() { - this.action = Constants.GetBillingAgreementDetails; + action = Constants.GetBillingAgreementDetails; } public string GetAction() { - return this.action; + return action; } /// @@ -37,7 +32,7 @@ public GetBillingAgreementDetailsRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -52,7 +47,7 @@ public GetBillingAgreementDetailsRequest WithAmazonBillingAgreementId(string ama } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -67,7 +62,7 @@ public GetBillingAgreementDetailsRequest WithaddressConsentToken(string address_ } public string GetAddressConsentToken() { - return this.address_consent_token; + return address_consent_token; } /// @@ -82,7 +77,7 @@ public GetBillingAgreementDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/SetBillingAgreementDetailsRequest.cs b/AmazonPay/RecurringPaymentRequests/SetBillingAgreementDetailsRequest.cs index 26aa334..24a8933 100644 --- a/AmazonPay/RecurringPaymentRequests/SetBillingAgreementDetailsRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/SetBillingAgreementDetailsRequest.cs @@ -1,16 +1,11 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.RecurringPaymentRequests +namespace AmazonPay.RecurringPaymentRequests { /// /// Request class to set the SetBillingAgreementDetails API call parameters /// public class SetBillingAgreementDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_billing_agreement_id; private string platform_id; @@ -23,11 +18,11 @@ public class SetBillingAgreementDetailsRequest public SetBillingAgreementDetailsRequest() { - this.action = Constants.SetBillingAgreementDetails; + action = Constants.SetBillingAgreementDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -41,7 +36,7 @@ public SetBillingAgreementDetailsRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -56,7 +51,7 @@ public SetBillingAgreementDetailsRequest WithAmazonBillingAgreementId(string ama } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -71,7 +66,7 @@ public SetBillingAgreementDetailsRequest WithPlatformId(string platform_id) } public string GetPlatformId() { - return this.platform_id; + return platform_id; } /// @@ -86,7 +81,7 @@ public SetBillingAgreementDetailsRequest WithSellerNote(string seller_note) } public string GetSellerNote() { - return this.seller_note; + return seller_note; } /// @@ -101,7 +96,7 @@ public SetBillingAgreementDetailsRequest WithSellerBillingAgreementId(string sel } public string GetSellerBillingAgreementId() { - return this.seller_billing_agreement_id; + return seller_billing_agreement_id; } /// @@ -116,7 +111,7 @@ public SetBillingAgreementDetailsRequest WithStoreName(string store_name) } public string GetStoreName() { - return this.store_name; + return store_name; } /// /// Sets the Custom Information @@ -130,7 +125,7 @@ public SetBillingAgreementDetailsRequest WithCustomInformation(string custom_inf } public string GetCustomInformation() { - return this.custom_information; + return custom_information; } /// @@ -145,7 +140,7 @@ public SetBillingAgreementDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/RecurringPaymentRequests/ValidateBillingAgreementRequest.cs b/AmazonPay/RecurringPaymentRequests/ValidateBillingAgreementRequest.cs index 3032b0f..9b90092 100644 --- a/AmazonPay/RecurringPaymentRequests/ValidateBillingAgreementRequest.cs +++ b/AmazonPay/RecurringPaymentRequests/ValidateBillingAgreementRequest.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.RecurringPaymentRequests +namespace AmazonPay.RecurringPaymentRequests { /// /// Request class to set the ValidateBillingAgreement API call parameters /// public class ValidateBillingAgreementRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_billing_agreement_id; private string mws_auth_token; public ValidateBillingAgreementRequest() { - this.action = Constants.ValidateBillingAgreement; + action = Constants.ValidateBillingAgreement; } public string GetAction() { - return this.action; + return action; } /// @@ -36,7 +31,7 @@ public ValidateBillingAgreementRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -51,7 +46,7 @@ public ValidateBillingAgreementRequest WithAmazonBillingAgreementId(string amazo } public string GetAmazonBillingAgreementId() { - return this.amazon_billing_agreement_id; + return amazon_billing_agreement_id; } /// @@ -66,7 +61,7 @@ public ValidateBillingAgreementRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/Regions.cs b/AmazonPay/Regions.cs index 79342bd..573a12b 100644 --- a/AmazonPay/Regions.cs +++ b/AmazonPay/Regions.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace AmazonPay { @@ -30,29 +27,29 @@ private enum commonRegions /// MWS endpoint URL'S /// public static readonly Dictionary mwsServiceUrls = new Dictionary() { - {commonRegions.eu.ToString(), "mws-eu.amazonservices.com"}, - {commonRegions.na.ToString(), "mws.amazonservices.com"}, + {commonRegions.eu.ToString(), "mws-eu.amazonservices.com"}, + {commonRegions.na.ToString(), "mws.amazonservices.com"}, {supportedRegions.jp.ToString(), "mws.amazonservices.jp"} - }; + }; /// /// Production profile end points to get the user information /// public static readonly Dictionary ProfileEndpoint = new Dictionary() { - {supportedRegions.uk.ToString(), "amazon.co.uk"}, - {supportedRegions.us.ToString(), "amazon.com"}, - {supportedRegions.de.ToString(), "amazon.de"}, + {supportedRegions.uk.ToString(), "amazon.co.uk"}, + {supportedRegions.us.ToString(), "amazon.com"}, + {supportedRegions.de.ToString(), "amazon.de"}, {supportedRegions.jp.ToString(), "amazon.co.jp"} - }; + }; /// /// Region Mappings to map the regions to the zones /// public static readonly Dictionary regionMappings = new Dictionary() { - {supportedRegions.de.ToString(), commonRegions.eu.ToString()}, - {supportedRegions.uk.ToString(), commonRegions.eu.ToString()}, + {supportedRegions.de.ToString(), commonRegions.eu.ToString()}, + {supportedRegions.uk.ToString(), commonRegions.eu.ToString()}, {supportedRegions.us.ToString(), commonRegions.na.ToString()}, {supportedRegions.jp.ToString(), supportedRegions.jp.ToString()} - }; + }; } } diff --git a/AmazonPay/ResponseParser.cs b/AmazonPay/ResponseParser.cs index 457b7d7..98402da 100644 --- a/AmazonPay/ResponseParser.cs +++ b/AmazonPay/ResponseParser.cs @@ -1,11 +1,6 @@ using Newtonsoft.Json; -using System; using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.RegularExpressions; using System.Xml; -using System.Xml.XPath; namespace AmazonPay { @@ -14,7 +9,7 @@ namespace AmazonPay /// public static class ResponseParser { - public static string xmlResponse = null; + public static string xmlResponse; /*public ResponseParser(string xml) { @@ -36,7 +31,7 @@ public static void SetXml(string xml) /// string json public static string ToJson() { - string json = ""; + var json = ""; var xml = new XmlDocument(); xml.LoadXml(xmlResponse.Trim()); json = JsonConvert.SerializeObject(xml, Newtonsoft.Json.Formatting.Indented); @@ -50,7 +45,7 @@ public static string ToJson() /// Dictionary(string,object) public static Dictionary ToDict() { - string json = ToJson(); + var json = ToJson(); NestedJsonToDictionary jsonToDict = new NestedJsonToDictionary(json); return jsonToDict.GetDictionary(); } diff --git a/AmazonPay/Responses/AuthorizeResponse.cs b/AmazonPay/Responses/AuthorizeResponse.cs index 05cef08..ffe8f88 100644 --- a/AmazonPay/Responses/AuthorizeResponse.cs +++ b/AmazonPay/Responses/AuthorizeResponse.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -53,28 +52,28 @@ public class AuthorizeResponse : IResponse public string errorMessage; public string parentKey; - public bool success = false; + public bool success; public AuthorizeResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -207,7 +206,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// amazonOrderReferenceId public string GetAmazonOrderReferenceId() { - return this.amazonOrderReferenceId; + return amazonOrderReferenceId; } /// @@ -216,7 +215,7 @@ public string GetAmazonOrderReferenceId() /// authorizationId public string GetAuthorizationId() { - return this.authorizationId; + return authorizationId; } /// @@ -225,7 +224,7 @@ public string GetAuthorizationId() /// requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -234,7 +233,7 @@ public string GetRequestId() /// authorizationReferenceId public string GetAuthorizationReferenceId() { - return this.authorizationReferenceId; + return authorizationReferenceId; } /// @@ -243,7 +242,7 @@ public string GetAuthorizationReferenceId() /// sellerAuthorizationNote public string GetSellerAuthorizationNote() { - return this.sellerAuthorizationNote; + return sellerAuthorizationNote; } /// @@ -252,7 +251,7 @@ public string GetSellerAuthorizationNote() /// authorizationAmount public decimal GetAuthorizationAmount() { - return this.authorizationAmount; + return authorizationAmount; } /// @@ -261,7 +260,7 @@ public decimal GetAuthorizationAmount() /// authorizationAmountCurrencyCode public string GetAuthorizationAmountCurrencyCode() { - return this.authorizationAmountCurrencyCode; + return authorizationAmountCurrencyCode; } /// @@ -270,7 +269,7 @@ public string GetAuthorizationAmountCurrencyCode() /// capturedAmountCurrencyCode public string GetCapturedAmountCurrencyCode() { - return this.capturedAmountCurrencyCode; + return capturedAmountCurrencyCode; } /// @@ -279,7 +278,7 @@ public string GetCapturedAmountCurrencyCode() /// capturedAmount public decimal GetCapturedAmount() { - return this.capturedAmount; + return capturedAmount; } /// @@ -288,7 +287,7 @@ public decimal GetCapturedAmount() /// authorizationFee public decimal GetAuthorizationFee() { - return this.authorizationFee; + return authorizationFee; } /// @@ -297,7 +296,7 @@ public decimal GetAuthorizationFee() /// authorizationFeeCurrencyCode public string GetAuthorizationFeeCurrencyCode() { - return this.authorizationFeeCurrencyCode; + return authorizationFeeCurrencyCode; } /// @@ -306,7 +305,7 @@ public string GetAuthorizationFeeCurrencyCode() /// authorizationState public string GetAuthorizationState() { - return this.authorizationState; + return authorizationState; } /// @@ -315,7 +314,7 @@ public string GetAuthorizationState() /// captureId public IList GetCaptureIdList() { - return this.captureId.AsReadOnly(); + return captureId.AsReadOnly(); } /// @@ -324,7 +323,7 @@ public IList GetCaptureIdList() /// lastUpdateTimestamp public DateTime GetLastUpdateTimestamp() { - return this.lastUpdateTimestamp; + return lastUpdateTimestamp; } /// @@ -333,7 +332,7 @@ public DateTime GetLastUpdateTimestamp() /// expirationTimeStamp public DateTime GetExpirationTimestamp() { - return this.expirationTimeStamp; + return expirationTimeStamp; } /// @@ -342,7 +341,7 @@ public DateTime GetExpirationTimestamp() /// creationTimestamp public DateTime GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } /// @@ -351,7 +350,7 @@ public DateTime GetCreationTimestamp() /// reasonCode public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } /// @@ -360,7 +359,7 @@ public string GetReasonCode() /// reasonDescription public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } /// @@ -369,7 +368,7 @@ public string GetReasonDescription() /// captureNow public bool GetCaptureNow() { - return this.captureNow; + return captureNow; } /// @@ -378,7 +377,7 @@ public bool GetCaptureNow() /// softDescriptor public string GetSoftDescriptor() { - return this.softDescriptor; + return softDescriptor; } /// @@ -387,7 +386,7 @@ public string GetSoftDescriptor() /// success can be true or false public bool GetSuccess() { - return this.success; + return success; } /// @@ -396,7 +395,7 @@ public bool GetSuccess() /// errorCode public string GetErrorCode() { - return this.errorCode; + return errorCode; } /// @@ -405,7 +404,7 @@ public string GetErrorCode() /// errorMessage public string GetErrorMessage() { - return this.errorMessage; + return errorMessage; } /// @@ -414,7 +413,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -423,7 +422,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -432,7 +431,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/BillingAddressDetails.cs b/AmazonPay/Responses/BillingAddressDetails.cs index 046efef..9e48827 100644 --- a/AmazonPay/Responses/BillingAddressDetails.cs +++ b/AmazonPay/Responses/BillingAddressDetails.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -110,7 +108,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// addressLine1 public string GetAddressLine1() { - return this.addressLine1; + return addressLine1; } /// @@ -119,7 +117,7 @@ public string GetAddressLine1() /// addressLine2 public string GetAddressLine2() { - return this.addressLine2; + return addressLine2; } /// @@ -128,7 +126,7 @@ public string GetAddressLine2() /// addressLine3 public string GetAddressLine3() { - return this.addressLine3; + return addressLine3; } /// @@ -137,7 +135,7 @@ public string GetAddressLine3() /// city public string GetCity() { - return this.city; + return city; } /// @@ -146,7 +144,7 @@ public string GetCity() /// countryCode public string GetCountryCode() { - return this.countryCode; + return countryCode; } /// @@ -155,7 +153,7 @@ public string GetCountryCode() /// county public string GetCounty() { - return this.county; + return county; } /// @@ -164,7 +162,7 @@ public string GetCounty() /// addressType public string GetAddressType() { - return this.addressType; + return addressType; } /// @@ -173,7 +171,7 @@ public string GetAddressType() /// district public string GetDistrict() { - return this.district; + return district; } /// @@ -182,7 +180,7 @@ public string GetDistrict() /// name public string GetName() { - return this.name; + return name; } /// @@ -191,7 +189,7 @@ public string GetName() /// phone public string GetPhone() { - return this.phone; + return phone; } /// @@ -200,7 +198,7 @@ public string GetPhone() /// postalCode public string GetPostalCode() { - return this.postalCode; + return postalCode; } /// @@ -209,7 +207,7 @@ public string GetPostalCode() /// stateOrRegion public string GetStateOrRegion() { - return this.stateOrRegion; + return stateOrRegion; } } } diff --git a/AmazonPay/Responses/BillingAgreementDetailsResponse.cs b/AmazonPay/Responses/BillingAgreementDetailsResponse.cs index 0e01cc7..614f928 100644 --- a/AmazonPay/Responses/BillingAgreementDetailsResponse.cs +++ b/AmazonPay/Responses/BillingAgreementDetailsResponse.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -22,7 +21,7 @@ public class BillingAgreementDetailsResponse : IResponse public string releaseEnvironment; public List constraintId = new List(); public List description = new List(); - public bool hasConstraint = false; + public bool hasConstraint; public string reasonCode; public string reasonDescription; public string requestId; @@ -66,7 +65,7 @@ public class BillingAgreementDetailsResponse : IResponse public string errorCode; public string errorMessage; - public bool success = false; + public bool success; private string parentKey; BillingAddressDetails billingAddress; @@ -76,21 +75,21 @@ public BillingAgreementDetailsResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -297,7 +296,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string amazonBillingAgreementId public string GetAmazonBillingAgreementId() { - return this.amazonBillingAgreementId; + return amazonBillingAgreementId; } /// @@ -306,7 +305,7 @@ public string GetAmazonBillingAgreementId() /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -315,7 +314,7 @@ public string GetRequestId() /// DateTime lastUpdatedTimestamp public DateTime GetLastUpdatedTimestamp() { - return this.lastUpdatedTimestamp; + return lastUpdatedTimestamp; } /// @@ -324,7 +323,7 @@ public DateTime GetLastUpdatedTimestamp() /// DateTime timePeriodStartDate public DateTime GetTimePeriodStartDate() { - return this.timePeriodStartDate; + return timePeriodStartDate; } /// @@ -333,7 +332,7 @@ public DateTime GetTimePeriodStartDate() /// DateTime timePeriodEndDate public DateTime GetTimePeriodEndDate() { - return this.timePeriodEndDate; + return timePeriodEndDate; } /// @@ -342,7 +341,7 @@ public DateTime GetTimePeriodEndDate() /// sellerBillingAgreementId public string GetSellerBillingAgreementId() { - return this.sellerBillingAgreementId; + return sellerBillingAgreementId; } /// @@ -351,7 +350,7 @@ public string GetSellerBillingAgreementId() /// string reasonCode public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } /// @@ -360,7 +359,7 @@ public string GetReasonCode() /// string reasonDescription public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } /// @@ -369,7 +368,7 @@ public string GetReasonDescription() /// string billingAgreementState public string GetBillingAgreementState() { - return this.billingAgreementState; + return billingAgreementState; } /// @@ -378,7 +377,7 @@ public string GetBillingAgreementState() /// string addressLine1 public string GetAddressLine1() { - return this.addressLine1; + return addressLine1; } /// @@ -387,7 +386,7 @@ public string GetAddressLine1() /// string buyerShippingName public string GetBuyerShippingName() { - return this.buyerShippingName; + return buyerShippingName; } /// @@ -396,7 +395,7 @@ public string GetBuyerShippingName() /// string addressLine2 public string GetAddressLine2() { - return this.addressLine2; + return addressLine2; } /// @@ -405,7 +404,7 @@ public string GetAddressLine2() /// string addressLine3 public string GetAddressLine3() { - return this.addressLine3; + return addressLine3; } /// @@ -414,7 +413,7 @@ public string GetAddressLine3() /// string amountLimitPerTimePeriod public decimal GetAmountLimitPerTimePeriod() { - return this.amountLimitPerTimePeriod; + return amountLimitPerTimePeriod; } /// @@ -423,7 +422,7 @@ public decimal GetAmountLimitPerTimePeriod() /// string amountLimitPerTimePeriodCurrencyCode public string GetAmountLimitPerTimePeriodCurrencyCode() { - return this.amountLimitPerTimePeriodCurrencyCode; + return amountLimitPerTimePeriodCurrencyCode; } /// @@ -432,7 +431,7 @@ public string GetAmountLimitPerTimePeriodCurrencyCode() /// string currentRemainingBalanceAmount public decimal GetCurrentRemainingBalanceAmount() { - return this.currentRemainingBalanceAmount; + return currentRemainingBalanceAmount; } /// @@ -441,7 +440,7 @@ public decimal GetCurrentRemainingBalanceAmount() /// string currentRemainingBalanceAmount public string GetCurrentRemainingBalanceCurrencyCode() { - return this.currentRemainingBalanceCurrencyCode; + return currentRemainingBalanceCurrencyCode; } /// @@ -450,7 +449,7 @@ public string GetCurrentRemainingBalanceCurrencyCode() /// string city public string GetCity() { - return this.city; + return city; } /// @@ -459,7 +458,7 @@ public string GetCity() /// IList constraintId public IList GetConstraintIdList() { - return this.constraintId.AsReadOnly(); + return constraintId.AsReadOnly(); } /// @@ -468,7 +467,7 @@ public IList GetConstraintIdList() /// IList description public IList GetDescriptionList() { - return this.description.AsReadOnly(); + return description.AsReadOnly(); } /// @@ -477,7 +476,7 @@ public IList GetDescriptionList() /// string countryCode public string GetCountryCode() { - return this.countryCode; + return countryCode; } /// @@ -486,7 +485,7 @@ public string GetCountryCode() /// string county @@ -495,7 +494,7 @@ public string GetCounty() /// string destinationType @@ -504,7 +503,7 @@ public string GetDestinationType() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } /// @@ -513,7 +512,7 @@ public IDictionary GetDictionary() /// string district public string GetDistrict() { - return this.district; + return district; } /// @@ -522,7 +521,7 @@ public string GetDistrict() /// string email public string GetEmail() { - return this.email; + return email; } /// @@ -531,7 +530,7 @@ public string GetEmail() /// string errorCode public string GetErrorCode() { - return this.errorCode; + return errorCode; } /// @@ -540,7 +539,7 @@ public string GetErrorCode() /// string errorCode public string GetErrorMessage() { - return this.errorMessage; + return errorMessage; } /// @@ -558,7 +557,7 @@ public bool GetSuccess() /// true or false for hasConstraint public bool GetHasConstraint() { - return this.hasConstraint; + return hasConstraint; } /// @@ -567,7 +566,7 @@ public bool GetHasConstraint() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -576,7 +575,7 @@ public string GetJson() /// string buyerName public string GetBuyerName() { - return this.buyerName; + return buyerName; } /// @@ -585,7 +584,7 @@ public string GetBuyerName() /// string phone public string GetPhone() { - return this.phone; + return phone; } /// @@ -594,7 +593,7 @@ public string GetPhone() /// string platformId public string GetPlatformId() { - return this.platformId; + return platformId; } /// @@ -603,7 +602,7 @@ public string GetPlatformId() /// string postalCode public string GetPostalCode() { - return this.postalCode; + return postalCode; } /// @@ -612,7 +611,7 @@ public string GetPostalCode() /// string releaseEnvironment public string GetReleaseEnvironment() { - return this.releaseEnvironment; + return releaseEnvironment; } /// @@ -621,7 +620,7 @@ public string GetReleaseEnvironment() /// string sellerNote public string GetSellerNote() { - return this.sellerNote; + return sellerNote; } /// @@ -630,7 +629,7 @@ public string GetSellerNote() /// string sellerOrderId public string GetSellerOrderId() { - return this.sellerOrderId; + return sellerOrderId; } /// @@ -639,7 +638,7 @@ public string GetSellerOrderId() /// string stateOrRegion public string GetStateOrRegion() { - return this.stateOrRegion; + return stateOrRegion; } /// @@ -648,7 +647,7 @@ public string GetStateOrRegion() /// string storeName public string GetStoreName() { - return this.storeName; + return storeName; } /// @@ -657,7 +656,7 @@ public string GetStoreName() /// BillingAddressDetails billingAddress public BillingAddressDetails GetBillingAddressDetails() { - return this.billingAddress; + return billingAddress; } /// @@ -666,7 +665,7 @@ public BillingAddressDetails GetBillingAddressDetails() /// XML format Response public string GetXml() { - return this.xml; + return xml; } } } diff --git a/AmazonPay/Responses/CancelOrderReferenceResponse.cs b/AmazonPay/Responses/CancelOrderReferenceResponse.cs index 3ce0136..3b163f1 100644 --- a/AmazonPay/Responses/CancelOrderReferenceResponse.cs +++ b/AmazonPay/Responses/CancelOrderReferenceResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -13,27 +11,27 @@ public class CancelOrderReferenceResponse : IResponse public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public CancelOrderReferenceResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -72,7 +70,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -87,7 +85,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -123,7 +121,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -132,7 +130,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -141,7 +139,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/CaptureResponse.cs b/AmazonPay/Responses/CaptureResponse.cs index 2f97ac3..fe4f898 100644 --- a/AmazonPay/Responses/CaptureResponse.cs +++ b/AmazonPay/Responses/CaptureResponse.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -44,7 +43,7 @@ public class CaptureResponse : IResponse public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public string parentKey; @@ -53,21 +52,21 @@ public CaptureResponse(string xml) this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -108,7 +107,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) switch ((Operator)Enum.Parse(typeof(Operator), strKey)) { case Operator.AmazonCaptureId: - this.amazonCaptureId = obj.ToString(); + amazonCaptureId = obj.ToString(); break; case Operator.RequestId: requestId = obj.ToString(); @@ -226,7 +225,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string amazonCaptureId public string GetCaptureId() { - return this.amazonCaptureId; + return amazonCaptureId; } /// @@ -235,7 +234,7 @@ public string GetCaptureId() /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -244,7 +243,7 @@ public string GetRequestId() /// string captureReferenceId public string GetCaptureReferenceId() { - return this.captureReferenceId; + return captureReferenceId; } /// @@ -253,7 +252,7 @@ public string GetCaptureReferenceId() /// DateTime lastUpdateTimestamp public DateTime GetLastUpdatedTimestamp() { - return this.lastUpdateTimestamp; + return lastUpdateTimestamp; } /// @@ -262,7 +261,7 @@ public DateTime GetLastUpdatedTimestamp() /// string sellerCaptureNote public string GetSellerCaptureNote() { - return this.sellerCaptureNote; + return sellerCaptureNote; } /// @@ -271,7 +270,7 @@ public string GetSellerCaptureNote() /// decimal captureAmount public decimal GetCaptureAmount() { - return this.captureAmount; + return captureAmount; } /// @@ -280,7 +279,7 @@ public decimal GetCaptureAmount() /// string captureCurrencyCode public string GetCaptureAmountCurrencyCode() { - return this.captureCurrencyCode; + return captureCurrencyCode; } /// @@ -289,7 +288,7 @@ public string GetCaptureAmountCurrencyCode() /// decimal captureFeeAmount public decimal GetCaptureFee() { - return this.captureFeeAmount; + return captureFeeAmount; } /// @@ -298,7 +297,7 @@ public decimal GetCaptureFee() /// string captureFeeCurrencyCode public string GetCaptureFeeCurrencyCode() { - return this.captureFeeCurrencyCode; + return captureFeeCurrencyCode; } /// @@ -307,7 +306,7 @@ public string GetCaptureFeeCurrencyCode() /// string captureState public string GetCaptureState() { - return this.captureState; + return captureState; } /// @@ -316,7 +315,7 @@ public string GetCaptureState() /// IList refundId public IList GetRefundIdList() { - return this.refundId.AsReadOnly(); + return refundId.AsReadOnly(); } /// @@ -325,7 +324,7 @@ public IList GetRefundIdList() /// IList providerCreditId public IList GetProviderCreditIdList() { - return this.providerCreditId.AsReadOnly(); + return providerCreditId.AsReadOnly(); } /// @@ -334,7 +333,7 @@ public IList GetProviderCreditIdList() /// IList providerId public IList GetProviderIdList() { - return this.providerId.AsReadOnly(); + return providerId.AsReadOnly(); } /// @@ -343,7 +342,7 @@ public IList GetProviderIdList() /// DateTime creationTimestamp public DateTime GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } /// @@ -352,15 +351,15 @@ public DateTime GetCreationTimestamp() /// string reasonCode public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } public string GetSoftDescriptor() { - return this.softDescriptor; + return softDescriptor; } /// @@ -396,7 +395,7 @@ public bool GetSuccess() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -405,7 +404,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -414,7 +413,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/CloseAuthorizationResponse.cs b/AmazonPay/Responses/CloseAuthorizationResponse.cs index de751d5..c910a0c 100644 --- a/AmazonPay/Responses/CloseAuthorizationResponse.cs +++ b/AmazonPay/Responses/CloseAuthorizationResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -13,27 +11,27 @@ public class CloseAuthorizationResponse : IResponse public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public CloseAuthorizationResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -72,7 +70,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -87,7 +85,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -123,7 +121,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -132,7 +130,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -141,7 +139,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/CloseBillingAgreementResponse.cs b/AmazonPay/Responses/CloseBillingAgreementResponse.cs index 1d9f994..c1e6aac 100644 --- a/AmazonPay/Responses/CloseBillingAgreementResponse.cs +++ b/AmazonPay/Responses/CloseBillingAgreementResponse.cs @@ -1,8 +1,5 @@ -using Newtonsoft.Json.Linq; -using System; +using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -14,27 +11,27 @@ public class CloseBillingAgreementResponse : IResponse public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public CloseBillingAgreementResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -73,7 +70,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -88,7 +85,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -124,7 +121,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -133,7 +130,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -142,7 +139,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/CloseOrderReferenceResponse.cs b/AmazonPay/Responses/CloseOrderReferenceResponse.cs index adf9ad5..1384e0e 100644 --- a/AmazonPay/Responses/CloseOrderReferenceResponse.cs +++ b/AmazonPay/Responses/CloseOrderReferenceResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -13,27 +11,27 @@ public class CloseOrderReferenceResponse : IResponse public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public CloseOrderReferenceResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -72,7 +70,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -87,7 +85,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -123,7 +121,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -132,7 +130,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -141,7 +139,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/ConfirmBillingAgreementResponse.cs b/AmazonPay/Responses/ConfirmBillingAgreementResponse.cs index 257ce7f..aadd1ac 100644 --- a/AmazonPay/Responses/ConfirmBillingAgreementResponse.cs +++ b/AmazonPay/Responses/ConfirmBillingAgreementResponse.cs @@ -1,39 +1,37 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { public class ConfirmBillingAgreementResponse : IResponse { - public string xml; + public string xml; public string json; public IDictionary dictionary; public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public ConfirmBillingAgreementResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -72,7 +70,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -87,7 +85,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -123,7 +121,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -132,7 +130,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -141,7 +139,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/ConfirmOrderReferenceResponse.cs b/AmazonPay/Responses/ConfirmOrderReferenceResponse.cs index a4262f3..85de121 100644 --- a/AmazonPay/Responses/ConfirmOrderReferenceResponse.cs +++ b/AmazonPay/Responses/ConfirmOrderReferenceResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -23,27 +21,27 @@ public class ConfirmOrderReferenceResponse : IResponse public string requestId; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public ConfirmOrderReferenceResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -82,7 +80,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) { case Operator.RequestId: requestId = obj.ToString(); - this.success = true; + success = true; break; } } @@ -97,7 +95,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -133,7 +131,7 @@ public string GetErrorMessage() /// JSON format Response public string GetJson() { - return this.json; + return json; } /// @@ -142,7 +140,7 @@ public string GetJson() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -151,7 +149,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/ErrorResponse.cs b/AmazonPay/Responses/ErrorResponse.cs index b999897..13e20b0 100644 --- a/AmazonPay/Responses/ErrorResponse.cs +++ b/AmazonPay/Responses/ErrorResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -11,9 +9,9 @@ namespace AmazonPay.Responses public class ErrorResponse { - private string errorCode = null; - private string errorMessage = null; - private string requestId = null; + private string errorCode; + private string errorMessage; + private string requestId; public ErrorResponse(IDictionary dictionary) { @@ -75,7 +73,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string errorCode public string GetErrorCode() { - return this.errorCode; + return errorCode; } /// @@ -84,7 +82,7 @@ public string GetErrorCode() /// string errorMesage public string GetErrorMessage() { - return this.errorMessage; + return errorMessage; } /// @@ -111,7 +109,7 @@ public bool IsSetErrorMessage() /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } } } diff --git a/AmazonPay/Responses/GetProviderCreditDetailsResponse.cs b/AmazonPay/Responses/GetProviderCreditDetailsResponse.cs index 8b8f84a..f31d157 100644 --- a/AmazonPay/Responses/GetProviderCreditDetailsResponse.cs +++ b/AmazonPay/Responses/GetProviderCreditDetailsResponse.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -35,7 +34,7 @@ public class GetProviderCreditDetailsResponse : IResponse public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public string parentKey; @@ -43,21 +42,21 @@ public GetProviderCreditDetailsResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -97,7 +96,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) switch ((Operator)Enum.Parse(typeof(Operator), strKey)) { case Operator.AmazonProviderCreditId: - this.amazonProviderCreditId = obj.ToString(); + amazonProviderCreditId = obj.ToString(); break; case Operator.RequestId: requestId = obj.ToString(); @@ -197,7 +196,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) /// string amazonProviderCreditId public string GetAmazonProviderCreditId() { - return this.amazonProviderCreditId; + return amazonProviderCreditId; } /// @@ -206,7 +205,7 @@ public string GetAmazonProviderCreditId() /// string requestId public string GetRequestId() { - return this.requestId; + return requestId; } /// @@ -215,7 +214,7 @@ public string GetRequestId() /// DateTime creationTimestamp public DateTime GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } /// @@ -224,7 +223,7 @@ public DateTime GetCreationTimestamp() /// decimal creditAmount public decimal GetCreditAmount() { - return this.creditAmount; + return creditAmount; } /// @@ -233,7 +232,7 @@ public decimal GetCreditAmount() /// string creditAmountCurrencyCode public string GetCreditAmountCurrencyCode() { - return this.creditAmountCurrencyCode; + return creditAmountCurrencyCode; } /// @@ -242,7 +241,7 @@ public string GetCreditAmountCurrencyCode() /// string creditReferenceId public string GetCreditReferenceId() { - return this.creditReferenceId; + return creditReferenceId; } /// @@ -251,7 +250,7 @@ public string GetCreditReferenceId() /// decimal creditReversalAmount public decimal GetCreditReversalAmount() { - return this.creditReversalAmount; + return creditReversalAmount; } /// @@ -260,7 +259,7 @@ public decimal GetCreditReversalAmount() /// string creditReversalAmountCurrencyCode public string GetCreditReversalAmountCurrencyCode() { - return this.creditReversalAmountCurrencyCode; + return creditReversalAmountCurrencyCode; } /// @@ -269,7 +268,7 @@ public string GetCreditReversalAmountCurrencyCode() /// IList creditReversalIdList public IList GetCreditReversalIdList() { - return this.creditReversalIdList.AsReadOnly(); + return creditReversalIdList.AsReadOnly(); } /// @@ -278,7 +277,7 @@ public IList GetCreditReversalIdList() /// string creditStatus public string GetCreditStatus() { - return this.creditStatus; + return creditStatus; } /// @@ -287,7 +286,7 @@ public string GetCreditStatus() /// string reasonCode public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } /// @@ -296,7 +295,7 @@ public string GetReasonCode() /// string reasonDescription public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } /// @@ -305,7 +304,7 @@ public string GetReasonDescription() /// string softDescriptor public string GetSoftDescriptor() { - return this.softDescriptor; + return softDescriptor; } /// @@ -314,7 +313,7 @@ public string GetSoftDescriptor() /// string sellerId public string GetSellerId() { - return this.sellerId; + return sellerId; } /// @@ -341,7 +340,7 @@ public string GetErrorMessage() /// success can be true or false public bool GetSuccess() { - return this.success; + return success; } /// @@ -350,7 +349,7 @@ public bool GetSuccess() /// XML format Response public string GetXml() { - return this.xml; + return xml; } /// @@ -359,7 +358,7 @@ public string GetXml() /// Dictionary type Response public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } /// @@ -368,7 +367,7 @@ public IDictionary GetDictionary() /// JSON format Response public string GetJson() { - return this.json; + return json; } } } diff --git a/AmazonPay/Responses/GetProviderCreditReversalDetailsResponse.cs b/AmazonPay/Responses/GetProviderCreditReversalDetailsResponse.cs index 4d0cd70..942c12b 100644 --- a/AmazonPay/Responses/GetProviderCreditReversalDetailsResponse.cs +++ b/AmazonPay/Responses/GetProviderCreditReversalDetailsResponse.cs @@ -1,8 +1,5 @@ -using Newtonsoft.Json.Linq; -using System; +using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -29,29 +26,29 @@ public class GetProviderCreditReversalDetailsResponse : IResponse public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public string parentKey; - + public GetProviderCreditReversalDetailsResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -91,7 +88,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) switch ((Operator)Enum.Parse(typeof(Operator), strKey)) { case Operator.AmazonProviderCreditReversalId: - this.amazonProviderCreditReversalId = obj.ToString(); + amazonProviderCreditReversalId = obj.ToString(); break; case Operator.RequestId: requestId = obj.ToString(); @@ -129,47 +126,47 @@ private void ParseDictionaryToVariables(IDictionary dictionary) public string GetAmazonProviderCreditReversalId() { - return this.amazonProviderCreditReversalId; + return amazonProviderCreditReversalId; } public string GetRequestId() { - return this.requestId; + return requestId; } public string GetCreditReversalReferenceId() { - return this.creditReversalReferenceId; + return creditReversalReferenceId; } public string GetCreditReversalNote() { - return this.creditReversalNote; + return creditReversalNote; } public decimal GetCreditReversalAmount() { - return this.creditReversalAmount; + return creditReversalAmount; } public string GetCreditReversalAmountCurrencyCode() { - return this.creditReversalAmountCurrencyCode; + return creditReversalAmountCurrencyCode; } public string GetCreditReversalStatus() { - return this.creditReversalStatus; + return creditReversalStatus; } public string GetLastUpdateTimestamp() { - return this.lastUpdateTimestamp; + return lastUpdateTimestamp; } public string GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } public string GetErrorCode() { @@ -185,15 +182,15 @@ public bool GetSuccess() } public string GetJson() { - return this.json; + return json; } public string GetXml() { - return this.xml; + return xml; } public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/GetServiceStatusResponse.cs b/AmazonPay/Responses/GetServiceStatusResponse.cs index 48bbc7d..1bcffd0 100644 --- a/AmazonPay/Responses/GetServiceStatusResponse.cs +++ b/AmazonPay/Responses/GetServiceStatusResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -19,27 +17,27 @@ public class GetServiceStatusResponse : IResponse public DateTime timestamp; public string errorCode; public string errorMessage; - public bool success = false; + public bool success; public GetServiceStatusResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -94,7 +92,7 @@ private void ParseDictionaryToVariables(IDictionary dictionary) public string GetRequestId() { - return this.requestId; + return requestId; } public string GetStatus() { @@ -118,15 +116,15 @@ public bool GetSuccess() } public string GetJson() { - return this.json; + return json; } public string GetXml() { - return this.xml; + return xml; } public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } diff --git a/AmazonPay/Responses/IResponse.cs b/AmazonPay/Responses/IResponse.cs index 0dfe3ce..1cf0c22 100644 --- a/AmazonPay/Responses/IResponse.cs +++ b/AmazonPay/Responses/IResponse.cs @@ -1,5 +1,4 @@ -using System; -namespace AmazonPay.Responses +namespace AmazonPay.Responses { /// /// Interface for common Response methods diff --git a/AmazonPay/Responses/OrderReferenceDetailsResponse.cs b/AmazonPay/Responses/OrderReferenceDetailsResponse.cs index 1ad0394..132025d 100644 --- a/AmazonPay/Responses/OrderReferenceDetailsResponse.cs +++ b/AmazonPay/Responses/OrderReferenceDetailsResponse.cs @@ -1,9 +1,7 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -13,17 +11,17 @@ namespace AmazonPay.Responses public class OrderReferenceDetailsResponse : IResponse { - private string xml; - private string json; + private readonly string xml; + private readonly string json; private string amazonOrderReferenceId; private DateTime expirationTimeStamp; private DateTime creationTimestamp; private DateTime lastUpdateTimestamp; - private IDictionary dictionary; - private List constraintID = new List(); - private List description = new List(); - private bool hasConstraint = false; + private readonly IDictionary dictionary; + private readonly List constraintID = new List(); + private readonly List description = new List(); + private bool hasConstraint; private string requestId; private string reasonCode; @@ -38,7 +36,7 @@ public class OrderReferenceDetailsResponse : IResponse private decimal amount; private string currencyCode; - private List authorizationId = new List(); + private readonly List authorizationId = new List(); private string phone; private string buyerName; @@ -66,10 +64,10 @@ public class OrderReferenceDetailsResponse : IResponse private string id; private string type; - private string errorCode; - private string errorMessage; + private readonly string errorCode; + private readonly string errorMessage; - private bool success = false; + private readonly bool success; private string parentKey; BillingAddressDetails billingAddress; @@ -79,21 +77,21 @@ public OrderReferenceDetailsResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() || errorResponse.IsSetErrorMessage()) { - this.success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + success = false; + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { - this.success = true; - ParseDictionaryToVariables(this.dictionary); + success = true; + ParseDictionaryToVariables(dictionary); } } @@ -308,171 +306,171 @@ private void ParseDictionaryToVariables(IDictionary dictionary) public string GetAmazonOrderReferenceId() { - return this.amazonOrderReferenceId; + return amazonOrderReferenceId; } public DateTime GetExpirationTimestamp() { - return this.expirationTimeStamp; + return expirationTimeStamp; } public DateTime GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } public DateTime GetLastUpdateTimestamp() { - return this.lastUpdateTimestamp; + return lastUpdateTimestamp; } public string GetRequestId() { - return this.requestId; + return requestId; } public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } public string GetOrderReferenceState() { - return this.orderReferenceState; + return orderReferenceState; } public string GetOrderLanguage() { - return this.orderLanguage; + return orderLanguage; } public string GetAddressLine1() { - return this.addressLine1; + return addressLine1; } public string GetAddressLine2() { - return this.addressLine2; + return addressLine2; } public string GetAddressLine3() { - return this.addressLine3; + return addressLine3; } public decimal GetAmount() { - return this.amount; + return amount; } public string GetCurrencyCode() { - return this.currencyCode; + return currencyCode; } public IList GetAuthorizationIdList() { - return this.authorizationId.AsReadOnly(); + return authorizationId.AsReadOnly(); } public string GetCity() { - return this.city; + return city; } public IList GetConstraintIdList() { - return this.constraintID.AsReadOnly(); + return constraintID.AsReadOnly(); } public string GetBuyerShippingName() { - return this.buyerShippingName; + return buyerShippingName; } public string GetCountryCode() { - return this.countryCode; + return countryCode; } public string GetCounty() { - return this.county; + return county; } public string GetCustomInformation() { - return this.customInformation; + return customInformation; } public IList GetDescriptionList() { - return this.description.AsReadOnly(); + return description.AsReadOnly(); } public string GetDestinationType() { - return this.destinationType; + return destinationType; } public string GetDistrict() { - return this.district; + return district; } public string GetEmail() { - return this.email; + return email; } public string GetErrorCode() { - return this.errorCode; + return errorCode; } public string GetErrorMessage() { - return this.errorMessage; + return errorMessage; } public bool GetHasConstraint() { - return this.hasConstraint; + return hasConstraint; } public string GetBuyerName() { - return this.buyerName; + return buyerName; } public string GetPhone() { - return this.phone; + return phone; } public string GetPlatformId() { - return this.platformId; + return platformId; } public string GetPostalCode() { - return this.postalCode; + return postalCode; } public string GetReleaseEnvironment() { - return this.releaseEnvironment; + return releaseEnvironment; } public string GetSellerNote() { - return this.sellerNote; + return sellerNote; } public string GetSellerOrderId() { - return this.sellerOrderId; + return sellerOrderId; } public string GetStateOrRegion() { - return this.stateOrRegion; + return stateOrRegion; } public string GetStoreName() { - return this.storeName; + return storeName; } public BillingAddressDetails GetBillingAddressDetails() { - return this.billingAddress; + return billingAddress; } public bool GetSuccess() { - return this.success; + return success; } public string GetJson() { - return this.json; + return json; } public string GetXml() { - return this.xml; + return xml; } public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/Responses/RefundResponse.cs b/AmazonPay/Responses/RefundResponse.cs index 37a11fb..3f8571a 100644 --- a/AmazonPay/Responses/RefundResponse.cs +++ b/AmazonPay/Responses/RefundResponse.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -42,28 +41,28 @@ public class RefundResponse : IResponse public string errorCode; public string errorMessage; public string parentKey; - public bool success = false; + public bool success; public RefundResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -197,71 +196,71 @@ private void ParseDictionaryToVariables(IDictionary dictionary) public string GetRefundId() { - return this.amazonRefundId; + return amazonRefundId; } public string GetRequestId() { - return this.requestId; + return requestId; } public string GetRefundReferenceId() { - return this.refundReferenceId; + return refundReferenceId; } public string GetSellerRefundNote() { - return this.sellerRefundNote; + return sellerRefundNote; } public decimal GetRefundAmount() { - return this.refundAmount; + return refundAmount; } public string GetRefundAmountCurrencyCode() { - return this.refundCurrencyCode; + return refundCurrencyCode; } public decimal GetRefundFee() { - return this.feeRefunded; + return feeRefunded; } public string GetRefundFeeCurrencyCode() { - return this.feeRefundedCurrencyCode; + return feeRefundedCurrencyCode; } public string GetRefundType() { - return this.refundType; + return refundType; } public string GetRefundState() { - return this.refundState; + return refundState; } public IList GetProviderCreditReversalIdList() { - return this.providerCreditReversalId.AsReadOnly(); + return providerCreditReversalId.AsReadOnly(); } public IList GetProviderIdList() { - return this.providerId.AsReadOnly(); + return providerId.AsReadOnly(); } public DateTime GetLastUpdateTimestamp() { - return this.lastUpdateTimestamp; + return lastUpdateTimestamp; } public DateTime GetCreationTimestamp() { - return this.creationTimestamp; + return creationTimestamp; } public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } public string GetSoftDescriptor() { - return this.softDescriptor; + return softDescriptor; } public string GetErrorCode() { @@ -277,15 +276,15 @@ public bool GetSuccess() } public string GetXml() { - return this.xml; + return xml; } public string GetJson() { - return this.json; + return json; } public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } diff --git a/AmazonPay/Responses/ValidateBillingAgreementResponse.cs b/AmazonPay/Responses/ValidateBillingAgreementResponse.cs index ad161e3..f55d5d9 100644 --- a/AmazonPay/Responses/ValidateBillingAgreementResponse.cs +++ b/AmazonPay/Responses/ValidateBillingAgreementResponse.cs @@ -1,7 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.Responses { @@ -23,31 +21,31 @@ public class ValidateBillingAgreementResponse : IResponse private string requestId; private DateTime lastUpdatedTimestamp; - private string errorCode; - private string errorMessage; + private readonly string errorCode; + private readonly string errorMessage; public string parentKey; - private bool success = false; + private readonly bool success; public ValidateBillingAgreementResponse(string xml) { this.xml = xml; ResponseParser.SetXml(xml); - this.json = ResponseParser.ToJson(); - this.dictionary = ResponseParser.ToDict(); + json = ResponseParser.ToJson(); + dictionary = ResponseParser.ToDict(); - ErrorResponse errorResponse = new ErrorResponse(this.dictionary); + ErrorResponse errorResponse = new ErrorResponse(dictionary); if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) { success = false; - this.errorCode = errorResponse.GetErrorCode(); - this.errorMessage = errorResponse.GetErrorMessage(); - this.requestId = errorResponse.GetRequestId(); + errorCode = errorResponse.GetErrorCode(); + errorMessage = errorResponse.GetErrorMessage(); + requestId = errorResponse.GetRequestId(); } else { success = true; - ParseDictionaryToVariables(this.dictionary); + ParseDictionaryToVariables(dictionary); } } @@ -115,27 +113,27 @@ private void ParseDictionaryToVariables(IDictionary dictionary) public string GetValidationResult() { - return this.validationResult; + return validationResult; } public string GetFailureReasonCode() { - return this.failureReasonCode; + return failureReasonCode; } public string GetReasonCode() { - return this.reasonCode; + return reasonCode; } public string GetReasonDescription() { - return this.reasonDescription; + return reasonDescription; } public DateTime GetLastUpdatedTimestamp() { - return this.lastUpdatedTimestamp; + return lastUpdatedTimestamp; } public string GetRequestId() { - return this.requestId; + return requestId; } public bool GetSuccess() { @@ -151,15 +149,15 @@ public string GetErrorMessage() } public string GetJson() { - return this.json; + return json; } public string GetXml() { - return this.xml; + return xml; } public IDictionary GetDictionary() { - return this.dictionary; + return dictionary; } } } diff --git a/AmazonPay/SanitizeData.cs b/AmazonPay/SanitizeData.cs index 9e1d87f..d513b4e 100644 --- a/AmazonPay/SanitizeData.cs +++ b/AmazonPay/SanitizeData.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Text; using System.Xml; using System.Configuration; -using System.Collections.Specialized; using System.Web; using Newtonsoft.Json.Linq; @@ -45,7 +43,7 @@ public static string SanitizeGivenData(string data, DataType type) ""); // Load list of sanitized tags in to array - string[] listArray = ConfigurationManager.AppSettings["sanitizeList"].Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); + string[] listArray = ConfigurationManager.AppSettings["sanitizeList"].Split(new[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); // Load SanitizeDataList foreach (var item in listArray) { @@ -79,7 +77,7 @@ public static string SanitizeGivenData(string data, DataType type) { string[] separatedURLQueryString = data.Split('\n'); - var queryString = System.Web.HttpUtility.ParseQueryString(separatedURLQueryString[separatedURLQueryString.Length - 1].TrimStart()); + var queryString = HttpUtility.ParseQueryString(separatedURLQueryString[separatedURLQueryString.Length - 1].TrimStart()); // Load SanitizeDataList foreach (var item in sanitizeList) @@ -90,7 +88,7 @@ public static string SanitizeGivenData(string data, DataType type) separatedURLQueryString[separatedURLQueryString.Length - 1] = queryString.ToString(); - Array.ForEach(separatedURLQueryString, value => returnString += value + '\n'); + Array.ForEach(separatedURLQueryString, value => returnString += value + '\n'); returnString = returnString.Remove(returnString.Length - 1); } diff --git a/AmazonPay/Signature.cs b/AmazonPay/Signature.cs index 3c7f9f2..6ef6ce6 100644 --- a/AmazonPay/Signature.cs +++ b/AmazonPay/Signature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -14,10 +13,10 @@ namespace AmazonPay public class Signature { //pass only the required accesskey,secret key - private Configuration clientConfig = null; + private readonly Configuration clientConfig; // Final URL to where the API parameters POST done,based off the config["region"] and respective mwsServiceUrls - private string mwsServiceUrl = null; + private string mwsServiceUrl; private string mwsEndpointUrl = string.Empty; private string mwsEndpointPath = string.Empty; @@ -25,8 +24,8 @@ public class Signature // UserAgent to track the request and usage in the Logs private string userAgent = string.Empty; - private string parametersAsString = string.Empty; - private string serviceVersion = string.Empty; + private readonly string parametersAsString = string.Empty; + private readonly string serviceVersion = string.Empty; /// /// Common Looger Property @@ -35,27 +34,27 @@ public class Signature public Signature(Configuration configuration, string serviceVersion) { - this.clientConfig = configuration; + clientConfig = configuration; this.serviceVersion = serviceVersion; } - public string CalculateSignatureAndReturnParametersAsString(IDictionary parameters, string timeStamp = "", string mwsDevoUrl = "") + /// + /// + /// + /// + /// + /// + /// + public string CalculateSignatureAndReturnParametersAsString(IDictionary parameters, string timeStamp = "", string mwsDevoUrl = "") { - parameters.Add("AWSAccessKeyId", this.clientConfig.GetAccessKey()); - if (string.IsNullOrEmpty(timeStamp)) - { - parameters.Add("Timestamp", GetFormattedTimestamp()); - } - else - { - parameters.Add("Timestamp", timeStamp); - } + parameters.Add("AWSAccessKeyId", clientConfig.GetAccessKey()); + parameters.Add("Timestamp", string.IsNullOrEmpty(timeStamp) ? GetFormattedTimestamp() : timeStamp); parameters.Add("Version", serviceVersion); parameters.Add("SignatureVersion", "2"); - this.CreateServiceUrl(mwsDevoUrl); + CreateServiceUrl(mwsDevoUrl); - parameters.Add("Signature", SignParameters(parameters, this.clientConfig.GetSecretKey())); + parameters.Add("Signature", SignParameters(parameters, clientConfig.GetSecretKey())); return GetParametersAsString(parameters); } @@ -92,17 +91,17 @@ public string CalculateSignatureAndReturnParametersAsString(IDictionary /// /// signature string - private String SignParameters(IDictionary parameters, String key) + private string SignParameters(IDictionary parameters, string key) { - String signatureVersion = parameters["SignatureVersion"]; + string signatureVersion = parameters["SignatureVersion"]; KeyedHashAlgorithm algorithm = new HMACSHA1(); - String stringToSign = null; + string stringToSign = null; if ("2".Equals(signatureVersion)) { - String signatureMethod = "HmacSHA256"; + string signatureMethod = "HmacSHA256"; algorithm = KeyedHashAlgorithm.Create(signatureMethod.ToUpper()); parameters.Add("SignatureMethod", signatureMethod); stringToSign = CalculateStringToSignV2(parameters); @@ -120,18 +119,18 @@ private String SignParameters(IDictionary parameters, String key /// /// /// - private String CalculateStringToSignV2(IDictionary parameters) + private string CalculateStringToSignV2(IDictionary parameters) { StringBuilder data = new StringBuilder(); - IDictionary sorted = - new SortedDictionary(parameters, StringComparer.Ordinal); + IDictionary sorted = + new SortedDictionary(parameters, StringComparer.Ordinal); data.Append("POST"); data.Append("\n"); data.Append(mwsEndpointUrl); data.Append("\n"); data.Append(mwsEndpointPath); data.Append("\n"); - foreach (KeyValuePair pair in sorted) + foreach (KeyValuePair pair in sorted) { if (pair.Value != null) { @@ -143,19 +142,19 @@ private String CalculateStringToSignV2(IDictionary parameters) } - String result = data.ToString().Remove(data.Length - 1); + string result = data.ToString().Remove(data.Length - 1); LogMessage(result, SanitizeData.DataType.Request); return result; } - private String UrlEncode(String data, bool path) + private string UrlEncode(string data, bool path) { StringBuilder encoded = new StringBuilder(); - String unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~" + (path ? "/" : ""); + string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~" + (path ? "/" : ""); - foreach (char symbol in System.Text.Encoding.UTF8.GetBytes(data)) + foreach (char symbol in Encoding.UTF8.GetBytes(data)) { if (unreservedChars.IndexOf(symbol) != -1) { @@ -163,7 +162,7 @@ private String UrlEncode(String data, bool path) } else { - encoded.Append("%" + String.Format("{0:X2}", (int)symbol)); + encoded.Append("%" + string.Format("{0:X2}", (int)symbol)); } } @@ -178,7 +177,7 @@ private String UrlEncode(String data, bool path) /// /// /// string signature - private String Sign(String data, String key, KeyedHashAlgorithm algorithm) + private string Sign(string data, string key, KeyedHashAlgorithm algorithm) { Encoding encoding = new UTF8Encoding(); algorithm.Key = encoding.GetBytes(key); @@ -190,7 +189,7 @@ private String Sign(String data, String key, KeyedHashAlgorithm algorithm) /// Formats date as ISO 8601 timestamp /// /// DateTime object - private String GetFormattedTimestamp() + private string GetFormattedTimestamp() { DateTime dateTime = DateTime.Now; return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, @@ -204,28 +203,28 @@ private String GetFormattedTimestamp() /// /// Create MWS service URL and the Endpoint path /// - /// + /// private void CreateServiceUrl(string mwsTestUrl) { string region = ""; string mode = ""; - mode = System.Convert.ToBoolean(this.clientConfig.GetSandbox()) ? "OffAmazonPayments_Sandbox" : "OffAmazonPayments"; + mode = Convert.ToBoolean(clientConfig.GetSandbox()) ? "OffAmazonPayments_Sandbox" : "OffAmazonPayments"; - if (!string.IsNullOrEmpty(this.clientConfig.GetRegion())) + if (!string.IsNullOrEmpty(clientConfig.GetRegion())) { - region = this.clientConfig.GetRegion(); + region = clientConfig.GetRegion(); if (Regions.regionMappings.ContainsKey(region)) { // Set the Endpoint for the internal development else get the value from the if (mwsTestUrl != null && mwsTestUrl.Trim() != "") { - this.mwsServiceUrl = mwsTestUrl; + mwsServiceUrl = mwsTestUrl; mwsEndpointPath = ""; } else { - mwsEndpointUrl = Regions.mwsServiceUrls[Regions.regionMappings[region]].ToString(); + mwsEndpointUrl = Regions.mwsServiceUrls[Regions.regionMappings[region]]; mwsServiceUrl = "https://" + mwsEndpointUrl + "/" + mode + "/" + serviceVersion; mwsEndpointPath = "/" + mode + "/" + serviceVersion; } @@ -241,29 +240,33 @@ private void CreateServiceUrl(string mwsTestUrl) } } + /// + /// + /// + /// public void SetUserAgentHeader(params string[] additionalNameValuePairs) { StringBuilder sb = new StringBuilder(); sb.Append(Constants.SDKName + "/" + Constants.SDKClientVersion); - + sb.Append(" ( "); - if (!String.IsNullOrEmpty(this.clientConfig.GetApplicationName()) && !String.IsNullOrEmpty(this.clientConfig.GetApplicationVersion())) + if (!string.IsNullOrEmpty(clientConfig.GetApplicationName()) && !string.IsNullOrEmpty(clientConfig.GetApplicationVersion())) { - sb.Append(QuoteApplicationName(this.clientConfig.GetApplicationName())); + sb.Append(QuoteApplicationName(clientConfig.GetApplicationName())); sb.Append("/"); - sb.Append(QuoteApplicationVersion(this.clientConfig.GetApplicationVersion())); + sb.Append(QuoteApplicationVersion(clientConfig.GetApplicationVersion())); sb.Append("; "); } - else if (!String.IsNullOrEmpty(this.clientConfig.GetApplicationName())) + else if (!string.IsNullOrEmpty(clientConfig.GetApplicationName())) { - sb.Append(QuoteApplicationName(this.clientConfig.GetApplicationName())); + sb.Append(QuoteApplicationName(clientConfig.GetApplicationName())); sb.Append("; "); } - - else if (!String.IsNullOrEmpty(this.clientConfig.GetApplicationVersion())) + + else if (!string.IsNullOrEmpty(clientConfig.GetApplicationVersion())) { - sb.Append(QuoteApplicationVersion(this.clientConfig.GetApplicationVersion())); + sb.Append(QuoteApplicationVersion(clientConfig.GetApplicationVersion())); sb.Append("; "); } @@ -287,12 +290,12 @@ public void SetUserAgentHeader(params string[] additionalNameValuePairs) /// /// /// string - private string GetParametersAsString(IDictionary parameters) + private string GetParametersAsString(IDictionary parameters) { StringBuilder data = new StringBuilder(); - foreach (String key in (IEnumerable)parameters.Keys) + foreach (string key in parameters.Keys) { - String input = parameters[key]; + string input = parameters[key]; if (input != null) { data.Append(key); @@ -301,7 +304,7 @@ private string GetParametersAsString(IDictionary parameters) data.Append("&"); } } - String result = data.ToString(); + string result = data.ToString(); return result.Remove(result.Length - 1); } @@ -315,10 +318,7 @@ private static string Clean(string s) // matched character sequences are passed to a MatchEvaluator // delegate. The returned string from the delegate replaces // the matched sequence. - return Regex.Replace(s, @" {2,}|\s", delegate(Match m) - { - return " "; - }); + return Regex.Replace(s, @" {2,}|\s", m => " "); } /// @@ -363,27 +363,27 @@ private static string QuoteAttributeValue(string s) public string GetMwsServiceUrl() { - return this.mwsServiceUrl; + return mwsServiceUrl; } public string GetMwsEndpointUrl() { - return this.mwsEndpointUrl; + return mwsEndpointUrl; } public string GetMwsEndpointPath() { - return this.mwsEndpointPath; + return mwsEndpointPath; } public string GetUserAgent() { - return this.userAgent; + return userAgent; } public string GetParametersAsString() { - return this.parametersAsString; + return parametersAsString; } /// @@ -393,9 +393,9 @@ public string GetParametersAsString() /// Type of data private void LogMessage(string message, SanitizeData.DataType type) { - if (this.Logger != null && this.Logger.IsDebugEnabled) + if (Logger != null && Logger.IsDebugEnabled) { - this.Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); + Logger.Debug(SanitizeData.SanitizeGivenData(message, type)); } } } diff --git a/AmazonPay/StandardPaymentRequests/AuthorizeRequest.cs b/AmazonPay/StandardPaymentRequests/AuthorizeRequest.cs index 993037a..82b2e8f 100644 --- a/AmazonPay/StandardPaymentRequests/AuthorizeRequest.cs +++ b/AmazonPay/StandardPaymentRequests/AuthorizeRequest.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.StandardPaymentRequests { @@ -10,7 +8,7 @@ namespace AmazonPay.StandardPaymentRequests /// public class AuthorizeRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_order_reference_id; private decimal amount; @@ -21,16 +19,16 @@ public class AuthorizeRequest private string soft_descriptor; private int? transaction_timeout; private string mws_auth_token; - List> providerCredit = new List>(); + readonly List> providerCredit = new List>(); public AuthorizeRequest() { - this.action = Constants.Authorize; + action = Constants.Authorize; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -44,7 +42,7 @@ public AuthorizeRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -59,7 +57,7 @@ public AuthorizeRequest WithAmazonOrderReferenceId(string amazon_order_reference } public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// @@ -69,12 +67,12 @@ public string GetAmazonOrderReferenceId() /// Amount public AuthorizeRequest WithAmount(decimal authorization_amount) { - this.amount = authorization_amount; + amount = authorization_amount; return this; } public decimal GetAmount() { - return this.amount; + return amount; } /// @@ -89,7 +87,7 @@ public AuthorizeRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -104,7 +102,7 @@ public AuthorizeRequest WithAuthorizationReferenceId(string authorization_refere } public string GetAuthorizationReferenceId() { - return this.authorization_reference_id; + return authorization_reference_id; } /// /// Sets the Boolean value for the Capture Now @@ -118,7 +116,7 @@ public AuthorizeRequest WithCaptureNow(bool capture_now = false) } public string GetCaptureNow() { - return this.capture_now.ToString().ToLower(); + return capture_now.ToString().ToLower(); } /// @@ -142,7 +140,7 @@ public AuthorizeRequest WithProviderCreditDetails(string provider_id, decimal am public IList> GetProviderCreditDetails() { - return this.providerCredit; + return providerCredit; } /// @@ -157,7 +155,7 @@ public AuthorizeRequest WithSellerAuthorizationNote(string seller_authorization_ } public string GetSellerAuthorizationNote() { - return this.seller_authorization_note; + return seller_authorization_note; } /// @@ -172,7 +170,7 @@ public AuthorizeRequest WithTransactionTimeout(int? transaction_timeout = null) } public int? GetTransactionTimeout() { - return this.transaction_timeout; + return transaction_timeout; } /// @@ -187,7 +185,7 @@ public AuthorizeRequest WithSoftDescriptor(string soft_descriptor) } public string GetSoftDescriptor() { - return this.soft_descriptor; + return soft_descriptor; } /// @@ -202,7 +200,7 @@ public AuthorizeRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/CancelOrderReferenceRequest.cs b/AmazonPay/StandardPaymentRequests/CancelOrderReferenceRequest.cs index 54579ad..b30f659 100644 --- a/AmazonPay/StandardPaymentRequests/CancelOrderReferenceRequest.cs +++ b/AmazonPay/StandardPaymentRequests/CancelOrderReferenceRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the CancelOrderReference API call parameters @@ -14,15 +9,15 @@ public class CancelOrderReferenceRequest private string amazon_order_reference_id; private string cancelation_reason; private string mws_auth_token; - private string action; + private readonly string action; public CancelOrderReferenceRequest() { - this.action = Constants.CancelOrderReference; + action = Constants.CancelOrderReference; } public string GetAction() { - return this.action; + return action; } /// @@ -37,7 +32,7 @@ public CancelOrderReferenceRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -52,7 +47,7 @@ public CancelOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_orde } public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// @@ -67,7 +62,7 @@ public CancelOrderReferenceRequest WithCancelationReason(string cancelation_reas } public string GetCancelationReason() { - return this.cancelation_reason; + return cancelation_reason; } /// @@ -82,7 +77,7 @@ public CancelOrderReferenceRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/CaptureRequest.cs b/AmazonPay/StandardPaymentRequests/CaptureRequest.cs index de0e92b..5f47fa1 100644 --- a/AmazonPay/StandardPaymentRequests/CaptureRequest.cs +++ b/AmazonPay/StandardPaymentRequests/CaptureRequest.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.StandardPaymentRequests { @@ -11,7 +9,7 @@ namespace AmazonPay.StandardPaymentRequests public class CaptureRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_authorization_id; private decimal amount; @@ -20,15 +18,15 @@ public class CaptureRequest private string capture_reference_id; private string soft_descriptor; private string mws_auth_token; - List> providerCredit = new List>(); + readonly List> providerCredit = new List>(); public CaptureRequest() { - this.action = Constants.Capture; + action = Constants.Capture; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -42,7 +40,7 @@ public CaptureRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Authorization ID @@ -56,7 +54,7 @@ public CaptureRequest WithAmazonAuthorizationId(string amazon_authorization_id) } public string GetAmazonAuthorizationId() { - return this.amazon_authorization_id; + return amazon_authorization_id; } /// /// Sets the Capture amount @@ -65,12 +63,12 @@ public string GetAmazonAuthorizationId() /// CaptureRequest Object public CaptureRequest WithAmount(decimal capture_amount) { - this.amount = capture_amount; + amount = capture_amount; return this; } public decimal GetAmount() { - return this.amount; + return amount; } /// /// Sets the Capture Currency Code @@ -84,7 +82,7 @@ public CaptureRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// /// Sets the Capture Reference ID - Unique string @@ -98,7 +96,7 @@ public CaptureRequest WithCaptureReferenceId(string capture_reference_id) } public string GetCaptureReferenceId() { - return this.capture_reference_id; + return capture_reference_id; } /// @@ -121,7 +119,7 @@ public CaptureRequest WithProviderCreditDetails(string provider_id, decimal amou } public IList> GetProviderCreditDetails() { - return this.providerCredit.AsReadOnly(); + return providerCredit.AsReadOnly(); } /// @@ -137,7 +135,7 @@ public CaptureRequest WithSellerCaptureNote(string seller_capture_note) } public string GetSellerCaptureNote() { - return this.seller_capture_note; + return seller_capture_note; } /// /// Sets the Soft Descriptor @@ -152,7 +150,7 @@ public CaptureRequest WithSoftDescriptor(string soft_descriptor) } public string GetSoftDescriptor() { - return this.soft_descriptor; + return soft_descriptor; } /// /// Sets the MWS Auth Token @@ -166,7 +164,7 @@ public CaptureRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/ChargeRequest.cs b/AmazonPay/StandardPaymentRequests/ChargeRequest.cs index 620b987..555a4aa 100644 --- a/AmazonPay/StandardPaymentRequests/ChargeRequest.cs +++ b/AmazonPay/StandardPaymentRequests/ChargeRequest.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; using AmazonPay.RecurringPaymentRequests; using System.IO; @@ -74,7 +71,7 @@ public ChargeRequest WithMerchantId(string merchant_id) /// ChargeRequest public ChargeRequest WithAmazonReferenceId(string amazon_reference_id) { - if (amazon_reference_id != "" && amazon_reference_id != null) + if (!string.IsNullOrEmpty(amazon_reference_id)) { string switchChar = amazon_reference_id; switch (switchChar[0]) diff --git a/AmazonPay/StandardPaymentRequests/CloseAuthorizationRequest.cs b/AmazonPay/StandardPaymentRequests/CloseAuthorizationRequest.cs index cf6a634..2b8ed52 100644 --- a/AmazonPay/StandardPaymentRequests/CloseAuthorizationRequest.cs +++ b/AmazonPay/StandardPaymentRequests/CloseAuthorizationRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the CloseAuthorization API call parameters @@ -14,15 +9,15 @@ public class CloseAuthorizationRequest private string amazon_authorization_id; private string closure_reason; private string mws_auth_token; - private string action; + private readonly string action; public CloseAuthorizationRequest() { - this.action = Constants.CloseAuthorization; + action = Constants.CloseAuthorization; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -36,7 +31,7 @@ public CloseAuthorizationRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Authorization ID @@ -50,7 +45,7 @@ public CloseAuthorizationRequest WithAmazonAuthorizationId(string amazon_authori } public string GetAmazonAuthorizationId() { - return this.amazon_authorization_id; + return amazon_authorization_id; } /// @@ -65,7 +60,7 @@ public CloseAuthorizationRequest WithClosureReason(string closure_reason) } public string GetClosureReason() { - return this.closure_reason; + return closure_reason; } /// @@ -80,7 +75,7 @@ public CloseAuthorizationRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/CloseOrderReferenceRequest.cs b/AmazonPay/StandardPaymentRequests/CloseOrderReferenceRequest.cs index 082c5a8..7b6ad78 100644 --- a/AmazonPay/StandardPaymentRequests/CloseOrderReferenceRequest.cs +++ b/AmazonPay/StandardPaymentRequests/CloseOrderReferenceRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the CloseOrderReference API call parameters @@ -14,15 +9,15 @@ public class CloseOrderReferenceRequest private string amazon_order_reference_id; private string closure_reason; private string mws_auth_token; - private string action; + private readonly string action; public CloseOrderReferenceRequest() { - this.action = Constants.CloseOrderReference; + action = Constants.CloseOrderReference; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -36,7 +31,7 @@ public CloseOrderReferenceRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Order Reference ID @@ -50,7 +45,7 @@ public CloseOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_order } public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// /// Sets the Closure reason @@ -64,7 +59,7 @@ public CloseOrderReferenceRequest WithClosureReason(string closure_reason) } public string GetClosureReason() { - return this.closure_reason; + return closure_reason; } /// /// Sets the MWS Auth Token @@ -78,7 +73,7 @@ public CloseOrderReferenceRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/ConfirmOrderReferenceRequest.cs b/AmazonPay/StandardPaymentRequests/ConfirmOrderReferenceRequest.cs index fcab1fb..dde8b19 100644 --- a/AmazonPay/StandardPaymentRequests/ConfirmOrderReferenceRequest.cs +++ b/AmazonPay/StandardPaymentRequests/ConfirmOrderReferenceRequest.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the ConfirmOrderReference API call parameters /// public class ConfirmOrderReferenceRequest { - private string action; + private readonly string action; private string amazon_order_reference_id; private string merchant_id; private string mws_auth_token; public ConfirmOrderReferenceRequest() { - this.action = Constants.ConfirmOrderReference; + action = Constants.ConfirmOrderReference; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -36,7 +31,7 @@ public ConfirmOrderReferenceRequest WithMerchantId(string merchant_id) public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Order Reference ID @@ -50,7 +45,7 @@ public ConfirmOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_ord } public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// /// Sets the MWS Auth Token @@ -65,7 +60,7 @@ public ConfirmOrderReferenceRequest WithMWSAuthToken(string mws_auth_token) public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/GetAuthorizationDetailsRequest.cs b/AmazonPay/StandardPaymentRequests/GetAuthorizationDetailsRequest.cs index adced55..5e2ff52 100644 --- a/AmazonPay/StandardPaymentRequests/GetAuthorizationDetailsRequest.cs +++ b/AmazonPay/StandardPaymentRequests/GetAuthorizationDetailsRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the GetAuthorizationDetails API call parameters @@ -13,15 +8,15 @@ public class GetAuthorizationDetailsRequest private string merchant_id; private string amazon_authorization_id; private string mws_auth_token; - private string action; + private readonly string action; public GetAuthorizationDetailsRequest() { - this.action = Constants.GetAuthorizationDetails; + action = Constants.GetAuthorizationDetails; } public string GetAction() { - return this.action; + return action; } /// @@ -36,7 +31,7 @@ public GetAuthorizationDetailsRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -51,7 +46,7 @@ public GetAuthorizationDetailsRequest WithAmazonAuthorizationId(string amazon_au } public string GetAmazonAuthorizationId() { - return this.amazon_authorization_id; + return amazon_authorization_id; } /// @@ -66,7 +61,7 @@ public GetAuthorizationDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/GetCaptureDetailsRequest.cs b/AmazonPay/StandardPaymentRequests/GetCaptureDetailsRequest.cs index 3aabf95..e20d2e9 100644 --- a/AmazonPay/StandardPaymentRequests/GetCaptureDetailsRequest.cs +++ b/AmazonPay/StandardPaymentRequests/GetCaptureDetailsRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the GetCaptureDetails API call parameters @@ -13,15 +8,15 @@ public class GetCaptureDetailsRequest private string merchant_id; private string amazon_capture_id; private string mws_auth_token; - private string action; + private readonly string action; public GetCaptureDetailsRequest() { - this.action = Constants.GetCaptureDetails; + action = Constants.GetCaptureDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -35,7 +30,7 @@ public GetCaptureDetailsRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Capture ID @@ -49,7 +44,7 @@ public GetCaptureDetailsRequest WithAmazonCaptureId(string amazon_capture_id) } public string GetAmazonCaptureId() { - return this.amazon_capture_id; + return amazon_capture_id; } /// /// Sets the MWS Auth Token @@ -63,7 +58,7 @@ public GetCaptureDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/GetOrderReferenceDetailsRequest.cs b/AmazonPay/StandardPaymentRequests/GetOrderReferenceDetailsRequest.cs index d23f423..ac6c946 100644 --- a/AmazonPay/StandardPaymentRequests/GetOrderReferenceDetailsRequest.cs +++ b/AmazonPay/StandardPaymentRequests/GetOrderReferenceDetailsRequest.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the GetOrderReferenceDetails API call parameters @@ -15,19 +9,19 @@ public class GetOrderReferenceDetailsRequest private string amazon_order_reference_id; private string address_consent_token; private string mws_auth_token; - private string action; - + private readonly string action; + /// /// Constructor sets the Action variable for the MWS request /// public GetOrderReferenceDetailsRequest() { - this.action = Constants.GetOrderReferenceDetails; + action = Constants.GetOrderReferenceDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -42,7 +36,7 @@ public GetOrderReferenceDetailsRequest WithMerchantId(string merchant_id) public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -58,7 +52,7 @@ public GetOrderReferenceDetailsRequest WithAmazonOrderReferenceId(string amazon_ public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// /// Sets the Address Consent Token @@ -73,7 +67,7 @@ public GetOrderReferenceDetailsRequest WithaddressConsentToken(string address_co public string GetAddressConsentToken() { - return this.address_consent_token; + return address_consent_token; } /// @@ -89,7 +83,7 @@ public GetOrderReferenceDetailsRequest WithMWSAuthToken(string mws_auth_token) public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } diff --git a/AmazonPay/StandardPaymentRequests/GetRefundDetailsRequest.cs b/AmazonPay/StandardPaymentRequests/GetRefundDetailsRequest.cs index 7148b2e..05f859e 100644 --- a/AmazonPay/StandardPaymentRequests/GetRefundDetailsRequest.cs +++ b/AmazonPay/StandardPaymentRequests/GetRefundDetailsRequest.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace AmazonPay.StandardPaymentRequests +namespace AmazonPay.StandardPaymentRequests { /// /// Request class to set the GetRefundDetails API call parameters /// public class GetRefundDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_refund_id; private string mws_auth_token; public GetRefundDetailsRequest() { - this.action = Constants.GetRefundDetails; + action = Constants.GetRefundDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -30,12 +25,12 @@ public string GetAction() /// GetRefundDetailsRequest Object public GetRefundDetailsRequest WithMerchantId(string merchant_id) { - this.merchant_id = merchant_id; - return this; + this.merchant_id = merchant_id; + return this; } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// /// Sets the Amazon Refund ID @@ -49,7 +44,7 @@ public GetRefundDetailsRequest WithAmazonRefundId(string amazon_refund_id) } public string GetAmazonRefundId() { - return this.amazon_refund_id; + return amazon_refund_id; } /// /// Sets the MWS Auth Token @@ -63,7 +58,7 @@ public GetRefundDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/RefundRequest.cs b/AmazonPay/StandardPaymentRequests/RefundRequest.cs index 0b8e8f3..a109ee8 100644 --- a/AmazonPay/StandardPaymentRequests/RefundRequest.cs +++ b/AmazonPay/StandardPaymentRequests/RefundRequest.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; namespace AmazonPay.StandardPaymentRequests { @@ -10,7 +8,7 @@ namespace AmazonPay.StandardPaymentRequests /// public class RefundRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_capture_id; private decimal amount; @@ -19,15 +17,15 @@ public class RefundRequest private string refund_reference_id; private string soft_descriptor; private string mws_auth_token; - List> providerReverseCredit = new List>(); + readonly List> providerReverseCredit = new List>(); public RefundRequest() { - this.action = Constants.Refund; + action = Constants.Refund; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -41,7 +39,7 @@ public RefundRequest WithMerchantId(string merchant_id) } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -56,7 +54,7 @@ public RefundRequest WithAmazonCaptureId(string amazon_capture_id) } public string GetAmazonCaptureId() { - return this.amazon_capture_id; + return amazon_capture_id; } /// @@ -66,12 +64,12 @@ public string GetAmazonCaptureId() /// RefundRequest Object public RefundRequest WithAmount(decimal refund_amount) { - this.amount = refund_amount; + amount = refund_amount; return this; } public decimal GetAmount() { - return this.amount; + return amount; } /// @@ -86,7 +84,7 @@ public RefundRequest WithCurrencyCode(Enum currency_code) } public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -101,7 +99,7 @@ public RefundRequest WithRefundReferenceId(string refund_reference_id) } public string GetRefundReferenceId() { - return this.refund_reference_id; + return refund_reference_id; } /// @@ -124,7 +122,7 @@ public RefundRequest WithProviderCreditReversalDetails(string provider_id, decim } public IList> GetProviderReverseCredit() { - return this.providerReverseCredit.AsReadOnly(); + return providerReverseCredit.AsReadOnly(); } /// @@ -139,7 +137,7 @@ public RefundRequest WithSellerRefundNote(string seller_refund_note) } public string GetSellerRefundNote() { - return this.seller_refund_note; + return seller_refund_note; } /// @@ -154,7 +152,7 @@ public RefundRequest WithSoftDescriptor(string soft_descriptor) } public string GetSoftDescriptor() { - return this.soft_descriptor; + return soft_descriptor; } /// @@ -169,7 +167,7 @@ public RefundRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/AmazonPay/StandardPaymentRequests/SetOrderReferenceDetailsRequest.cs b/AmazonPay/StandardPaymentRequests/SetOrderReferenceDetailsRequest.cs index 9720461..c146aab 100644 --- a/AmazonPay/StandardPaymentRequests/SetOrderReferenceDetailsRequest.cs +++ b/AmazonPay/StandardPaymentRequests/SetOrderReferenceDetailsRequest.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; namespace AmazonPay.StandardPaymentRequests { @@ -10,7 +7,7 @@ namespace AmazonPay.StandardPaymentRequests /// public class SetOrderReferenceDetailsRequest { - private string action; + private readonly string action; private string merchant_id; private string amazon_order_reference_id; private decimal amount; @@ -21,15 +18,15 @@ public class SetOrderReferenceDetailsRequest private string store_name; private string custom_information; private string mws_auth_token; - + public SetOrderReferenceDetailsRequest() { - this.action = Constants.SetOrderReferenceDetails; + action = Constants.SetOrderReferenceDetails; } public string GetAction() { - return this.action; + return action; } /// /// Sets the Merchant ID @@ -39,12 +36,12 @@ public string GetAction() public SetOrderReferenceDetailsRequest WithMerchantId(string merchant_id) { this.merchant_id = merchant_id; - + return this; } public string GetMerchantId() { - return this.merchant_id; + return merchant_id; } /// @@ -60,7 +57,7 @@ public SetOrderReferenceDetailsRequest WithAmazonOrderReferenceId(string amazon_ public string GetAmazonOrderReferenceId() { - return this.amazon_order_reference_id; + return amazon_order_reference_id; } /// /// Sets the Amount for the order @@ -75,7 +72,7 @@ public SetOrderReferenceDetailsRequest WithAmount(decimal amount) public decimal GetAmount() { - return this.amount; + return amount; } /// @@ -91,7 +88,7 @@ public SetOrderReferenceDetailsRequest WithCurrencyCode(Enum currency_code) public string GetCurrencyCode() { - return this.currency_code; + return currency_code; } /// @@ -106,7 +103,7 @@ public SetOrderReferenceDetailsRequest WithPlatformId(string platform_id) } public string GetPlatformId() { - return this.platform_id; + return platform_id; } /// @@ -121,7 +118,7 @@ public SetOrderReferenceDetailsRequest WithSellerNote(string seller_note) } public string GetSellerNote() { - return this.seller_note; + return seller_note; } /// /// Sets the Seller Order ID @@ -135,7 +132,7 @@ public SetOrderReferenceDetailsRequest WithSellerOrderId(string seller_order_id) } public string GetSellerOrderId() { - return this.seller_order_id; + return seller_order_id; } /// @@ -150,7 +147,7 @@ public SetOrderReferenceDetailsRequest WithStoreName(string store_name) } public string GetStoreName() { - return this.store_name; + return store_name; } /// @@ -165,7 +162,7 @@ public SetOrderReferenceDetailsRequest WithCustomInformation(string custom_infor } public string GetCustomInformation() { - return this.custom_information; + return custom_information; } /// @@ -180,7 +177,7 @@ public SetOrderReferenceDetailsRequest WithMWSAuthToken(string mws_auth_token) } public string GetMWSAuthToken() { - return this.mws_auth_token; + return mws_auth_token; } } } diff --git a/UnitTests/AmazonPayUnitTests.cs b/UnitTests/AmazonPayUnitTests.cs index ae6b0ee..efa5fec 100644 --- a/UnitTests/AmazonPayUnitTests.cs +++ b/UnitTests/AmazonPayUnitTests.cs @@ -1,7 +1,5 @@ using System; -using System.Web; using System.Collections.Generic; -using System.Text; using NUnit.Framework; using AmazonPay; using System.Collections; @@ -22,7 +20,7 @@ namespace UnitTests [TestFixture] public class AmazonPayUnitTests { - Configuration clientConfig = new Configuration(); + readonly Configuration clientConfig = new Configuration(); public AmazonPayUnitTests() { @@ -152,10 +150,9 @@ public void TestLoggingMessageClient() client.SetTimeStamp("0000"); // Test call to the API GetOrderReferenceDetails - client = new Client(clientConfig); + client = new Client(clientConfig) { Logger = logger }; // Set Logger for Client - client.Logger = logger; client.SetTimeStamp("0000"); @@ -201,8 +198,7 @@ public void TestLoggingMessage_IpnHandler() string xmlData = JObject.Parse(json["Message"].ToString())["NotificationData"].ToString(); - NameValueCollection headers = new NameValueCollection(); - headers.Add("x-amz-sns-message-type", "Notification"); + NameValueCollection headers = new NameValueCollection { { "x-amz-sns-message-type", "Notification" } }; IpnHandler ipnHandler = new IpnHandler(headers, File.ReadAllText("AuthorizeNotification.json"), logger); Assert.AreEqual(ipnHandler.GetAuthorizeResponse().authorizationId, new AmazonPay.Responses.AuthorizeResponse(xmlData).authorizationId); @@ -996,7 +992,7 @@ public void TestGetProviderCreditDetails() Dictionary expectedParameters = new Dictionary() { {"Action","GetProviderCreditDetails"}, - {"SellerId","test"}, + {"SellerId","test"}, {"MWSAuthToken","test"}, {"AmazonProviderCreditId","test"} }; @@ -1029,7 +1025,7 @@ public void TestGetProviderCreditReversalDetails() Dictionary expectedParameters = new Dictionary() { {"Action","GetProviderCreditReversalDetails"}, - {"SellerId","test"}, + {"SellerId","test"}, {"MWSAuthToken","test"}, {"AmazonProviderCreditReversalId","test"} }; @@ -1059,14 +1055,14 @@ public void TestGetProviderCreditReversalDetails() [Test] public void TestGetUserInfo() { - Enum emptyRegion = null; - Client client = new Client(clientConfig); - // Exeption for Null "Region" value - Assert.Throws(()=> clientConfig.WithRegion(emptyRegion)); - // Exeption for Null value - Assert.Throws(() => client.GetUserInfo(null)); - // Check for invalid Access token - Assert.IsTrue(Regex.IsMatch(client.GetUserInfo("Atza"),"invalid_token",RegexOptions.IgnoreCase)); + Enum emptyRegion = null; + Client client = new Client(clientConfig); + // Exeption for Null "Region" value + Assert.Throws(() => clientConfig.WithRegion(emptyRegion)); + // Exeption for Null value + Assert.Throws(() => client.GetUserInfo(null)); + // Check for invalid Access token + Assert.IsTrue(Regex.IsMatch(client.GetUserInfo("Atza"), "invalid_token", RegexOptions.IgnoreCase)); } [Test] @@ -1098,13 +1094,15 @@ public void Test500or503() [Test] public void TestJsonResponse() { - Hashtable response = new Hashtable(); - response["ResponseBody"] = - "" - + "S01-5806490-2147504" - + "2015-09-27T02:18:33.408Z" - + "This is testing API call" - + ""; + Hashtable response = new Hashtable + { + ["ResponseBody"] = + "" + + "S01-5806490-2147504" + + "2015-09-27T02:18:33.408Z" + + "This is testing API call" + + "" + }; string json = File.ReadAllText("json.txt"); @@ -1171,7 +1169,7 @@ private MethodInfo GetMethod(string methodName) .GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) - Assert.Fail(string.Format("{0} method not found", methodName)); + Assert.Fail("{0} method not found", methodName); return method; }