├── .github └── PULL_REQUEST_TEMPLATE.md ├── AmazonPay.nuspec ├── AmazonPay.sln ├── AmazonPay.v12.suo ├── AmazonPay ├── AccountStatus.cs ├── AmazonPay.csproj ├── AmazonPay.nuspec ├── AmazonPayPublic.snk ├── BillingAgreementType.cs ├── Client.cs ├── CommonRequests │ ├── Configuration.cs │ └── GetServiceStatusRequest.cs ├── Constants.cs ├── DelegateRequest.cs ├── HttpImpl.cs ├── IClient.cs ├── IpnHandler.cs ├── KeyFile.snk ├── NestedJsonToDictionary.cs ├── ProviderCreditRequests │ ├── GetProviderCreditDetailsRequest.cs │ ├── GetProviderCreditReversalDetailsRequest.cs │ └── ReverseProviderCreditRequest.cs ├── RecurringPaymentRequests │ ├── AuthorizeOnBillingAgreementRequest.cs │ ├── CloseBillingAgreementRequest.cs │ ├── ConfirmBillingAgreementRequest.cs │ ├── CreateOrderReferenceForIdRequest.cs │ ├── GetBillingAgreementDetailsRequest.cs │ ├── SetBillingAgreementDetailsRequest.cs │ └── ValidateBillingAgreementRequest.cs ├── Regions.cs ├── ResponseParser.cs ├── Responses │ ├── AbstractResponse.cs │ ├── AuthorizeResponse.cs │ ├── BillingAddressDetails.cs │ ├── BillingAgreementDetailsResponse.cs │ ├── CancelOrderReferenceResponse.cs │ ├── CaptureResponse.cs │ ├── ChargebackResponse.cs │ ├── CloseAuthorizationResponse.cs │ ├── CloseBillingAgreementResponse.cs │ ├── CloseOrderReferenceResponse.cs │ ├── ConfirmBillingAgreementResponse.cs │ ├── ConfirmOrderReferenceResponse.cs │ ├── ErrorResponse.cs │ ├── GetMerchantAccountStatusResponse.cs │ ├── GetMerchantNotificationConfigurationResponse.cs │ ├── GetProviderCreditDetailsResponse.cs │ ├── GetProviderCreditReversalDetailsResponse.cs │ ├── GetServiceStatusResponse.cs │ ├── IResponse.cs │ ├── ListOrderReferenceResponse.cs │ ├── Operator.cs │ ├── OrderReferenceDetailsResponse.cs │ ├── PaymentDetailsResponse.cs │ ├── RefundResponse.cs │ ├── SetMerchantNotificationConfigurationResponse.cs │ └── ValidateBillingAgreementResponse.cs ├── SanitizeData.cs ├── Signature.cs ├── StandardPaymentRequests │ ├── AuthorizeRequest.cs │ ├── CancelOrderReferenceRequest.cs │ ├── CaptureRequest.cs │ ├── ChargeRequest.cs │ ├── CloseAuthorizationRequest.cs │ ├── CloseOrderReferenceRequest.cs │ ├── ConfirmOrderReferenceRequest.cs │ ├── GetAuthorizationDetailsRequest.cs │ ├── GetCaptureDetailsRequest.cs │ ├── GetMerchantAccountStatusRequest.cs │ ├── GetMerchantNotificationConfigurationRequest.cs │ ├── GetOrderReferenceDetailsRequest.cs │ ├── GetRefundDetailsRequest.cs │ ├── ListOrderReferenceByNextTokenRequest.cs │ ├── ListOrderReferenceRequest.cs │ ├── RefundRequest.cs │ ├── SetMerchantNotificationConfigurationRequest.cs │ ├── SetOrderAttributesRequest.cs │ └── SetOrderReferenceDetailsRequest.cs └── region.Designer.cs ├── CHANGES.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── NOTICE.txt ├── README.md └── UnitTests ├── AmazonPayUnitTests.cs ├── App.config ├── Json.txt ├── TestFiles ├── AuthorizeNotification.json ├── AuthorizeNotification_BadSignature.json ├── AuthorizeResponse.xml ├── BillingAgreementDetailsResponse.xml ├── CancelOrderReference.xml ├── CaptureResponse.xml ├── CloseAuthorizationResponse.xml ├── CloseBillingAgreementResponse.xml ├── CloseOrderReference.xml ├── ConfirmBillingAgreementResponse.xml ├── ConfirmOrderReference.xml ├── GetAuthorizationDetails.xml ├── GetCaptureDetails.xml ├── GetCaptureDetails_MultiCurrency.xml ├── GetMerchantAccountStatusResponse.xml ├── GetMerchantNotificationConfiguration.xml ├── GetOrderReferenceDetails.xml ├── GetProviderCreditDetailsResponse.xml ├── GetProviderCreditReversalDetailsResponse.xml ├── GetRefundDetails.xml ├── GetRefundDetails_MultiCurrency.xml ├── GetServiceStatusResponse.xml ├── ListOrderReference.xml ├── RefundResponse.xml ├── SetMerchantNotificationConfiguration.xml └── ValidateBillingAgreementResponse.xml ├── UnitTests.csproj ├── appsettings.json └── config.json /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 7 | -------------------------------------------------------------------------------- /AmazonPay.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | 3.9.2 6 | $title$ 7 | AmazonPay 8 | AmazonPay 9 | https://github.com/amzn/amazon-pay-sdk-csharp 10 | https://images-na.ssl-images-amazon.com/images/G/01/Iris3_US/en_US/inca/images/60x38-white-x1.png 11 | false 12 | AmazonPay service. This API section enables you to programmatically retrieve shipping and payment information provided by the buyer from their Amazon account. It allows you to authorize, capture, and refund payments, enabling a variety of payments scenarios. 13 | v3.9.2 14 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 15 | AmazonPay 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /AmazonPay.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.168 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{D8DE71F8-9464-43C5-BB22-E9BDBC04D12F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmazonPay", "AmazonPay\AmazonPay.csproj", "{A8D8E745-6C1D-4A33-B2C5-4F7C1E4FD4DF}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{AA3DDC73-72A8-426B-BE73-FE238EE7E24B}" 11 | ProjectSection(SolutionItems) = preProject 12 | .nuget\packages.config = .nuget\packages.config 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {D8DE71F8-9464-43C5-BB22-E9BDBC04D12F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {D8DE71F8-9464-43C5-BB22-E9BDBC04D12F}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {D8DE71F8-9464-43C5-BB22-E9BDBC04D12F}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {D8DE71F8-9464-43C5-BB22-E9BDBC04D12F}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {A8D8E745-6C1D-4A33-B2C5-4F7C1E4FD4DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {A8D8E745-6C1D-4A33-B2C5-4F7C1E4FD4DF}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {A8D8E745-6C1D-4A33-B2C5-4F7C1E4FD4DF}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {A8D8E745-6C1D-4A33-B2C5-4F7C1E4FD4DF}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {582EC2B9-861D-45B2-9240-0B3B2544DD28} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /AmazonPay.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amzn/amazon-pay-sdk-csharp/49d6d00cbc041f5ccc058f21e62078a50a478e61/AmazonPay.v12.suo -------------------------------------------------------------------------------- /AmazonPay/AccountStatus.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay 2 | { 3 | public enum AccountStatus 4 | { 5 | ACTIVE, 6 | INACTIVE 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /AmazonPay/AmazonPay.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0;net20 5 | Copyright Amazon.com Inc. or its affiliates. 6 | Amazon Pay 7 | 3.9.2 8 | true 9 | KeyFile.snk 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | NETSTANDARD; 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | NETFULL 45 | 46 | 47 | -------------------------------------------------------------------------------- /AmazonPay/AmazonPay.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | 3.9.2 6 | $title$ 7 | AmazonPay 8 | AmazonPay 9 | https://github.com/amzn/amazon-pay-sdk-csharp 10 | https://images-na.ssl-images-amazon.com/images/G/01/Iris3_US/en_US/inca/images/60x38-white-x1.png 11 | false 12 | AmazonPay service. This API section enables you to programmatically retrieve shipping and payment information provided by the buyer from their Amazon account. It allows you to authorize, capture, and refund payments, enabling a variety of payments scenarios. 13 | v3.9.2 14 | Copyright Amazon.com Inc. or its affiliates. 15 | AmazonPay 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /AmazonPay/AmazonPayPublic.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amzn/amazon-pay-sdk-csharp/49d6d00cbc041f5ccc058f21e62078a50a478e61/AmazonPay/AmazonPayPublic.snk -------------------------------------------------------------------------------- /AmazonPay/BillingAgreementType.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.Types 2 | { 3 | /// 4 | /// This enum class represents region codes for United States(na), Europe(eu) and Japan(jp). 5 | /// 6 | /// The region value is used while constructing the mandatory headers. 7 | /// 8 | public enum BillingAgreementTypes 9 | { 10 | CustomerInitiatedTransaction, MerchantInitiatedTransaction 11 | } 12 | } -------------------------------------------------------------------------------- /AmazonPay/CommonRequests/GetServiceStatusRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace AmazonPay.CommonRequests 7 | { 8 | /// 9 | /// Set the GetServiceStatus API call parameters 10 | /// 11 | public class GetServiceStatusRequest : DelegateRequest 12 | { 13 | public GetServiceStatusRequest() 14 | { 15 | SetAction(Constants.GetServiceStatus); 16 | } 17 | 18 | protected override GetServiceStatusRequest GetThis() 19 | { 20 | return this; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AmazonPay/DelegateRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using AmazonPay.StandardPaymentRequests; 5 | 6 | namespace AmazonPay 7 | { 8 | abstract public class DelegateRequest 9 | { 10 | protected string action; 11 | protected string merchant_id; 12 | protected string mws_auth_token; 13 | 14 | protected abstract T GetThis(); 15 | 16 | protected void SetAction(string action) 17 | { 18 | this.action = action; 19 | } 20 | 21 | /// 22 | /// Gets the action 23 | /// 24 | /// action 25 | public string GetAction() 26 | { 27 | return action; 28 | } 29 | /// 30 | /// Sets the Merchant ID 31 | /// 32 | /// 33 | /// Subclass Request Object 34 | public T WithMerchantId(string merchant_id) 35 | { 36 | this.merchant_id = merchant_id; 37 | return GetThis(); 38 | } 39 | 40 | /// 41 | /// Gets the Merchant ID 42 | /// 43 | /// Merchant ID 44 | public string GetMerchantId() 45 | { 46 | return merchant_id; 47 | } 48 | 49 | /// 50 | /// Sets the MWS Auth Token 51 | /// 52 | /// 53 | /// Subclass Request Object 54 | public T WithMWSAuthToken(string mws_auth_token) 55 | { 56 | this.mws_auth_token = mws_auth_token; 57 | return GetThis(); 58 | } 59 | 60 | /// 61 | /// Gets the MWS AuthToken 62 | /// 63 | /// MWS AuthToken 64 | public string GetMWSAuthToken() 65 | { 66 | return mws_auth_token; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /AmazonPay/HttpImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Net; 6 | using System.Text; 7 | using AmazonPay.CommonRequests; 8 | 9 | namespace AmazonPay 10 | { 11 | /// 12 | /// Class HttpImpl - Handles POST and GET functionality for all requests 13 | /// 14 | class HttpImpl 15 | { 16 | private string response; 17 | private bool header = false; 18 | private string accessToken = ""; 19 | public Dictionary responseDict; 20 | private Configuration clientConfig; 21 | private int statusCode; 22 | 23 | 24 | public HttpImpl(Configuration config) 25 | { 26 | responseDict = new Dictionary(); 27 | this.clientConfig = config; 28 | } 29 | 30 | /// 31 | /// Setter for boolean header to get the user info 32 | /// 33 | public void setHttpHeader() 34 | { 35 | header = true; 36 | } 37 | 38 | /// 39 | /// Setter for Access token to get the user info 40 | /// 41 | /// 42 | public void setAccessToken(string accesstoken) 43 | { 44 | this.accessToken = accesstoken; 45 | } 46 | 47 | /// 48 | /// Add the common POST Parameters 49 | /// 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// HttpWebRequest request 55 | private HttpWebRequest ConfigureWebRequest(string method, string url, string userAgent = null, int contentLength = 0) 56 | { 57 | HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; 58 | 59 | if (clientConfig.GetProxyHost() != null && (clientConfig.GetProxyPort()) != -1) 60 | { 61 | WebProxy proxy = new WebProxy(clientConfig.GetProxyHost(), clientConfig.GetProxyPort()); 62 | if (!(string.IsNullOrEmpty(clientConfig.GetProxyUserName()) && !(string.IsNullOrEmpty(clientConfig.GetProxyUserPassword())))) 63 | { 64 | proxy.Credentials = new NetworkCredential(clientConfig.GetProxyUserName(), clientConfig.GetProxyUserPassword()); 65 | } 66 | 67 | request.Proxy = proxy; 68 | } 69 | if (!string.IsNullOrEmpty(userAgent)) 70 | { 71 | request.UserAgent = userAgent; 72 | } 73 | if (header) 74 | { 75 | request.Headers.Add("x-amz-access-token:" + accessToken); 76 | } 77 | request.Method = method; 78 | request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; 79 | request.ContentLength = contentLength; 80 | 81 | responseDict.Clear(); 82 | 83 | return request; 84 | } 85 | 86 | /// 87 | /// GET Method 88 | /// 89 | /// 90 | /// string response 91 | public string Get(string url) 92 | { 93 | HttpWebRequest request = ConfigureWebRequest("GET", url); 94 | execute(request); 95 | return response; 96 | } 97 | 98 | /// 99 | /// POST Method 100 | /// 101 | /// 102 | /// 103 | /// 104 | /// Dictionary responseDict 105 | public Dictionary Post(string url, string userAgent, byte[] requestData) 106 | { 107 | HttpWebRequest request = ConfigureWebRequest("POST", url, userAgent, requestData.Length); 108 | using (Stream requestStream = request.GetRequestStream()) 109 | { 110 | requestStream.Write(requestData, 0, requestData.Length); 111 | } 112 | execute(request); 113 | responseDict.Add("response", response); 114 | responseDict.Add("statusCode", statusCode.ToString()); 115 | 116 | return responseDict; 117 | } 118 | 119 | /// 120 | /// Executes the request 121 | /// 122 | /// 123 | private void execute(HttpWebRequest request) 124 | { 125 | try 126 | { 127 | using (HttpWebResponse httpResponse = request.GetResponse() as HttpWebResponse) 128 | { 129 | statusCode = (int)httpResponse.StatusCode; 130 | StreamReader reader = new StreamReader(httpResponse.GetResponseStream(), Encoding.UTF8); 131 | this.response = reader.ReadToEnd(); 132 | } 133 | 134 | } 135 | catch (WebException we) 136 | { 137 | using (HttpWebResponse httpErrorResponse = (HttpWebResponse)we.Response as HttpWebResponse) 138 | { 139 | 140 | if (httpErrorResponse == null) 141 | { 142 | throw new NullReferenceException("Http Response is empty " + we); 143 | } 144 | if (httpErrorResponse != null) 145 | { 146 | this.statusCode = (int)httpErrorResponse.StatusCode; 147 | using (StreamReader reader = new StreamReader(httpErrorResponse.GetResponseStream(), Encoding.UTF8)) 148 | { 149 | this.response = reader.ReadToEnd(); 150 | } 151 | } 152 | } 153 | } 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /AmazonPay/IClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace AmazonPay 3 | { 4 | /// 5 | /// Interface class for the AmazonPay Client class 6 | /// 7 | public interface IClient 8 | { 9 | Responses.AuthorizeResponse Authorize(StandardPaymentRequests.AuthorizeRequest requestParameters); 10 | Responses.AuthorizeResponse AuthorizeOnBillingAgreement(RecurringPaymentRequests.AuthorizeOnBillingAgreementRequest requestParameters); 11 | Responses.CancelOrderReferenceResponse CancelOrderReference(StandardPaymentRequests.CancelOrderReferenceRequest requestParameters); 12 | Responses.CaptureResponse Capture(StandardPaymentRequests.CaptureRequest requestParameters); 13 | Responses.AuthorizeResponse Charge(StandardPaymentRequests.ChargeRequest requestParameters); 14 | Responses.CloseAuthorizationResponse CloseAuthorization(StandardPaymentRequests.CloseAuthorizationRequest requestParameters); 15 | Responses.CloseBillingAgreementResponse CloseBillingAgreement(RecurringPaymentRequests.CloseBillingAgreementRequest requestParameters); 16 | Responses.CloseOrderReferenceResponse CloseOrderReference(StandardPaymentRequests.CloseOrderReferenceRequest requestParameters); 17 | Responses.ConfirmBillingAgreementResponse ConfirmBillingAgreement(RecurringPaymentRequests.ConfirmBillingAgreementRequest requestParameters); 18 | Responses.ConfirmOrderReferenceResponse ConfirmOrderReference(StandardPaymentRequests.ConfirmOrderReferenceRequest requestParameters); 19 | Responses.OrderReferenceDetailsResponse CreateOrderReferenceForId(RecurringPaymentRequests.CreateOrderReferenceForIdRequest requestParameters); 20 | Responses.AuthorizeResponse GetAuthorizationDetails(StandardPaymentRequests.GetAuthorizationDetailsRequest requestParameters); 21 | Responses.BillingAgreementDetailsResponse GetBillingAgreementDetails(RecurringPaymentRequests.GetBillingAgreementDetailsRequest requestParameters); 22 | Responses.CaptureResponse GetCaptureDetails(StandardPaymentRequests.GetCaptureDetailsRequest requestParameters); 23 | Responses.OrderReferenceDetailsResponse GetOrderReferenceDetails(StandardPaymentRequests.GetOrderReferenceDetailsRequest requestParameters); 24 | Responses.GetProviderCreditDetailsResponse GetProviderCreditDetails(ProviderCreditRequests.GetProviderCreditDetailsRequest requestParameters); 25 | Responses.GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails(ProviderCreditRequests.GetProviderCreditReversalDetailsRequest requestParameters); 26 | Responses.RefundResponse GetRefundDetails(StandardPaymentRequests.GetRefundDetailsRequest requestParameters); 27 | Responses.GetServiceStatusResponse GetServiceStatus(CommonRequests.GetServiceStatusRequest requestParameters); 28 | string GetUserInfo(string accessToken); 29 | Responses.RefundResponse Refund(StandardPaymentRequests.RefundRequest requestParameters); 30 | Responses.GetProviderCreditReversalDetailsResponse ReverseProviderCredit(ProviderCreditRequests.ReverseProviderCreditRequest requestParameters); 31 | Responses.BillingAgreementDetailsResponse SetBillingAgreementDetails(RecurringPaymentRequests.SetBillingAgreementDetailsRequest requestParameters); 32 | Responses.OrderReferenceDetailsResponse SetOrderReferenceDetails(StandardPaymentRequests.SetOrderReferenceDetailsRequest requestParameters); 33 | Responses.OrderReferenceDetailsResponse SetOrderAttributes(StandardPaymentRequests.SetOrderAttributesRequest requestParameters); 34 | Responses.PaymentDetailsResponse GetPaymentDetails(String amazonOrderReferenceID, String mwsAuthToken); 35 | Responses.ValidateBillingAgreementResponse ValidateBillingAgreement(RecurringPaymentRequests.ValidateBillingAgreementRequest requestParameters); 36 | Responses.GetMerchantAccountStatusResponse GetMerchantAccountStatus(StandardPaymentRequests.GetMerchantAccountStatusRequest requestParameters); 37 | Responses.SetMerchantNotificationConfigurationResponse SetMerchantNotificationConfiguration(StandardPaymentRequests.SetMerchantNotificationConfigurationRequest requestParameters); 38 | Responses.GetMerchantNotificationConfigurationResponse GetMerchantNotificationConfiguration(StandardPaymentRequests.GetMerchantNotificationConfigurationRequest requestParameters); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/KeyFile.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amzn/amazon-pay-sdk-csharp/49d6d00cbc041f5ccc058f21e62078a50a478e61/AmazonPay/KeyFile.snk -------------------------------------------------------------------------------- /AmazonPay/NestedJsonToDictionary.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AmazonPay 7 | { 8 | /// 9 | /// JsonParser class for recursive parsing of a Dictionary 10 | /// 11 | /// 12 | public class NestedJsonToDictionary 13 | { 14 | private Dictionary dictionary = new Dictionary(); 15 | 16 | public NestedJsonToDictionary(string json) 17 | { 18 | this.dictionary = JsonConvert.DeserializeObject>( 19 | json, new JsonConverter[] { new JsonParser() }); 20 | } 21 | public Dictionary GetDictionary() 22 | { 23 | return this.dictionary; 24 | } 25 | } 26 | public class JsonParser : CustomCreationConverter> 27 | { 28 | public override IDictionary Create(Type objectType) 29 | { 30 | return new Dictionary(); 31 | } 32 | 33 | public override bool CanConvert(Type objectType) 34 | { 35 | // In addition to handling IDictionary 36 | // we want to handle the deserialization of dict value 37 | // which is of type object 38 | return objectType == typeof(object) || base.CanConvert(objectType); 39 | } 40 | 41 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 42 | { 43 | if (reader.TokenType == JsonToken.StartObject 44 | || reader.TokenType == JsonToken.Null) 45 | return base.ReadJson(reader, objectType, existingValue, serializer); 46 | 47 | // If the next token is not an object 48 | // then fall back on standard deserializer (strings, numbers etc.) 49 | return serializer.Deserialize(reader); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /AmazonPay/ProviderCreditRequests/GetProviderCreditDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.ProviderCreditRequests 2 | { 3 | /// 4 | /// Request class to set the GetProviderCreditDetails API call parameters 5 | /// 6 | public class GetProviderCreditDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_provider_credit_id; 9 | 10 | public GetProviderCreditDetailsRequest() 11 | { 12 | SetAction(Constants.GetProviderCreditDetails); 13 | } 14 | 15 | protected override GetProviderCreditDetailsRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Provider Credit ID 22 | /// 23 | /// 24 | /// GetProviderCreditDetailsRequest Object 25 | public GetProviderCreditDetailsRequest WithAmazonProviderCreditId(string amazon_provider_credit_id) 26 | { 27 | this.amazon_provider_credit_id = amazon_provider_credit_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon Provider Credit ID 33 | /// 34 | /// Amazon Provider Credit ID 35 | public string GetAmazonProviderCreditId() 36 | { 37 | return this.amazon_provider_credit_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/ProviderCreditRequests/GetProviderCreditReversalDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.ProviderCreditRequests 2 | { 3 | /// 4 | /// Request class to set the GetProviderCreditReversalDetails API call parameters 5 | /// 6 | public class GetProviderCreditReversalDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_provider_credit_reversal_id; 9 | 10 | public GetProviderCreditReversalDetailsRequest() 11 | { 12 | SetAction(Constants.GetProviderCreditReversalDetails); 13 | } 14 | 15 | protected override GetProviderCreditReversalDetailsRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Provider Credit Reversal ID 22 | /// 23 | /// 24 | /// GetProviderCreditReversalDetailsRequest Object 25 | public GetProviderCreditReversalDetailsRequest WithAmazonProviderCreditReversalId(string amazon_provider_credit_reversal_id) 26 | { 27 | this.amazon_provider_credit_reversal_id = amazon_provider_credit_reversal_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon Provider Credit Reversal ID 33 | /// 34 | /// Amazon Provider Credit Reversal ID 35 | public string GetAmazonProviderCreditReversalId() 36 | { 37 | return this.amazon_provider_credit_reversal_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/ProviderCreditRequests/ReverseProviderCreditRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AmazonPay.ProviderCreditRequests 4 | { 5 | /// 6 | /// Request class to set the ReverseProviderCredit API call parameters 7 | /// 8 | public class ReverseProviderCreditRequest : DelegateRequest 9 | { 10 | private string amazon_provider_credit_id; 11 | private string credit_reversal_reference_id; 12 | private decimal amount; 13 | private string currency_code; 14 | private string credit_reversal_note; 15 | 16 | public ReverseProviderCreditRequest() 17 | { 18 | SetAction(Constants.ReverseProviderCredit); 19 | } 20 | 21 | protected override ReverseProviderCreditRequest GetThis() 22 | { 23 | return this; 24 | } 25 | 26 | /// 27 | /// Sets the Amazon Provider Credit ID 28 | /// 29 | /// 30 | /// ReverseProviderCreditRequest Object 31 | public ReverseProviderCreditRequest WithAmazonProviderCreditId(string amazon_provider_credit_id) 32 | { 33 | this.amazon_provider_credit_id = amazon_provider_credit_id; 34 | return this; 35 | } 36 | 37 | /// 38 | /// Gets the Amazon Provider Credit ID 39 | /// 40 | /// Amazon Provider Credit ID 41 | public string GetAmazonProviderCreditId() 42 | { 43 | return this.amazon_provider_credit_id; 44 | } 45 | 46 | /// 47 | /// Sets the Credit Reversal Reference ID - Unique string 48 | /// 49 | /// 50 | /// ReverseProviderCreditRequest Object 51 | public ReverseProviderCreditRequest WithCreditReversalReferenceId(string credit_reversal_reference_id) 52 | { 53 | this.credit_reversal_reference_id = credit_reversal_reference_id; 54 | return this; 55 | } 56 | 57 | /// 58 | /// Gets the Credit Reversal Reference ID 59 | /// 60 | /// Credit Reversal Reference ID 61 | public string GetCreditReversalReferenceId() 62 | { 63 | return this.credit_reversal_reference_id; 64 | } 65 | 66 | /// 67 | /// Sets the Amount for the reversal 68 | /// 69 | /// 70 | /// ReverseProviderCreditRequest Object 71 | public ReverseProviderCreditRequest WithAmount(decimal amount) 72 | { 73 | this.amount = amount; 74 | return this; 75 | } 76 | 77 | /// 78 | /// Gets the amount for reversal 79 | /// 80 | /// amount 81 | public decimal GetAmount() 82 | { 83 | return this.amount; 84 | } 85 | 86 | /// 87 | /// sets the Currency Code 88 | /// 89 | /// 90 | /// ReverseProviderCreditRequest Object 91 | public ReverseProviderCreditRequest WithCurrencyCode(Enum currency_code) 92 | { 93 | this.currency_code = currency_code.ToString(); 94 | return this; 95 | } 96 | public string GetCurrencyCode() 97 | { 98 | return this.currency_code; 99 | } 100 | 101 | /// 102 | /// Sets the Credit Reversal Note 103 | /// 104 | /// 105 | /// ReverseProviderCreditRequest Object 106 | public ReverseProviderCreditRequest WithCreditReversalNote(string credit_reversal_note) 107 | { 108 | this.credit_reversal_note = credit_reversal_note; 109 | return this; 110 | } 111 | public string GetCreditReversalNote() 112 | { 113 | return this.credit_reversal_note; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /AmazonPay/RecurringPaymentRequests/CloseBillingAgreementRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.RecurringPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the CloseBillingAgreement API call parameters 5 | /// 6 | public class CloseBillingAgreementRequest : DelegateRequest 7 | { 8 | private string amazon_billing_agreement_id; 9 | private string closure_reason; 10 | 11 | public CloseBillingAgreementRequest() 12 | { 13 | SetAction(Constants.CloseBillingAgreement); 14 | } 15 | 16 | protected override CloseBillingAgreementRequest GetThis() 17 | { 18 | return this; 19 | } 20 | 21 | /// 22 | /// Sets the Amazon Billing Agreement ID 23 | /// 24 | /// 25 | /// CloseBillingAgreementRequest Object 26 | public CloseBillingAgreementRequest WithAmazonBillingAgreementId(string amazon_billing_agreement_id) 27 | { 28 | this.amazon_billing_agreement_id = amazon_billing_agreement_id; 29 | return this; 30 | } 31 | 32 | /// 33 | /// Gets the Amazon Billing Agreement ID 34 | /// 35 | /// Amazon Billing Agreement ID 36 | public string GetAmazonBillingAgreementId() 37 | { 38 | return this.amazon_billing_agreement_id; 39 | } 40 | 41 | /// 42 | /// Sets the Closure reason 43 | /// 44 | /// 45 | /// CloseBillingAgreementRequest Object 46 | public CloseBillingAgreementRequest WithClosureReason(string closure_reason) 47 | { 48 | this.closure_reason = closure_reason; 49 | return this; 50 | } 51 | 52 | /// 53 | /// Gets the Closure Reason 54 | /// 55 | /// Closure Reason 56 | public string GetClosureReason() 57 | { 58 | return this.closure_reason; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AmazonPay/RecurringPaymentRequests/ConfirmBillingAgreementRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.RecurringPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the ConfirmBillingAgreement API call parameters 5 | /// 6 | public class ConfirmBillingAgreementRequest : DelegateRequest 7 | { 8 | private string amazon_billing_agreement_id; 9 | private string success_url; 10 | private string failure_url; 11 | 12 | public ConfirmBillingAgreementRequest() 13 | { 14 | SetAction(Constants.ConfirmBillingAgreement); 15 | } 16 | 17 | protected override ConfirmBillingAgreementRequest GetThis() 18 | { 19 | return this; 20 | } 21 | 22 | /// 23 | /// Sets the Amazon Billing Agreement ID 24 | /// 25 | /// 26 | /// ConfirmBillingAgreementRequest Object 27 | /// Deprecating because of typo in method name 28 | [System.Obsolete("Erroneous method name. Please use WithAmazonBillingAgreementId")] 29 | public ConfirmBillingAgreementRequest WithAmazonBillingreementId(string amazon_billing_agreement_id) 30 | { 31 | this.amazon_billing_agreement_id = amazon_billing_agreement_id; 32 | return this; 33 | } 34 | 35 | /// 36 | /// Sets the Amazon Billing Agreement ID 37 | /// 38 | /// 39 | /// ConfirmBillingAgreementRequest Object 40 | public ConfirmBillingAgreementRequest WithAmazonBillingAgreementId(string amazon_billing_agreement_id) 41 | { 42 | this.amazon_billing_agreement_id = amazon_billing_agreement_id; 43 | return this; 44 | } 45 | 46 | /// 47 | /// Gets the Amazon Billing Agreement ID 48 | /// 49 | /// Amazon Billing Agreement ID 50 | public string GetAmazonBillingAgreementId() 51 | { 52 | return this.amazon_billing_agreement_id; 53 | } 54 | 55 | /// 56 | /// Sets the Success URL 57 | /// 58 | /// 59 | /// ConfirmBillingAgreementRequest Object 60 | public ConfirmBillingAgreementRequest WithSuccessUrl(string success_url) 61 | { 62 | this.success_url = success_url; 63 | return this; 64 | } 65 | 66 | /// 67 | /// Gets the Success URL 68 | /// 69 | /// Success URL 70 | public string GetSuccessUrl() 71 | { 72 | return this.success_url; 73 | } 74 | 75 | /// 76 | /// Sets the Failure URL 77 | /// 78 | /// 79 | /// ConfirmBillingAgreementRequest Object 80 | public ConfirmBillingAgreementRequest WithFailureUrl(string failure_url) 81 | { 82 | this.failure_url = failure_url; 83 | return this; 84 | } 85 | 86 | /// 87 | /// Gets the Failure URL 88 | /// 89 | /// Failure URL 90 | public string GetFailureUrl() 91 | { 92 | return this.failure_url; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /AmazonPay/RecurringPaymentRequests/GetBillingAgreementDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.RecurringPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the GetBillingAgreementDetails API call parameters 5 | /// 6 | public class GetBillingAgreementDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_billing_agreement_id; 9 | private string address_consent_token; 10 | 11 | public GetBillingAgreementDetailsRequest() 12 | { 13 | SetAction(Constants.GetBillingAgreementDetails); 14 | } 15 | 16 | protected override GetBillingAgreementDetailsRequest GetThis() 17 | { 18 | return this; 19 | } 20 | 21 | /// 22 | /// Sets the Amazon Billing Agreement ID 23 | /// 24 | /// 25 | /// GetBillingAgreementDetailsRequest Object 26 | public GetBillingAgreementDetailsRequest WithAmazonBillingAgreementId(string amazon_billing_agreement_id) 27 | { 28 | this.amazon_billing_agreement_id = amazon_billing_agreement_id; 29 | return this; 30 | } 31 | 32 | /// 33 | /// Gets the Amazon Billing Agreement ID 34 | /// 35 | /// Amazon Billing Agreement ID 36 | public string GetAmazonBillingAgreementId() 37 | { 38 | return this.amazon_billing_agreement_id; 39 | } 40 | 41 | /// 42 | /// Sets the Address Consent Token 43 | /// 44 | /// 45 | /// GetBillingAgreementDetailsRequest Object 46 | public GetBillingAgreementDetailsRequest WithaddressConsentToken(string address_consent_token) 47 | { 48 | this.address_consent_token = System.Web.HttpUtility.UrlDecode(address_consent_token); 49 | return this; 50 | } 51 | 52 | /// 53 | /// Gets the Address Consent Token 54 | /// 55 | /// Address Consent Token 56 | public string GetAddressConsentToken() 57 | { 58 | return this.address_consent_token; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AmazonPay/RecurringPaymentRequests/ValidateBillingAgreementRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.RecurringPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the ValidateBillingAgreement API call parameters 5 | /// 6 | public class ValidateBillingAgreementRequest : DelegateRequest 7 | { 8 | private string amazon_billing_agreement_id; 9 | 10 | public ValidateBillingAgreementRequest() 11 | { 12 | SetAction(Constants.ValidateBillingAgreement); 13 | } 14 | 15 | protected override ValidateBillingAgreementRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Billing Agreement ID 22 | /// 23 | /// 24 | /// ValidateBillingAgreementRequest Object 25 | public ValidateBillingAgreementRequest WithAmazonBillingAgreementId(string amazon_billing_agreement_id) 26 | { 27 | this.amazon_billing_agreement_id = amazon_billing_agreement_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon Billing Agreement ID 33 | /// 34 | /// Amazon Billing Agreement ID 35 | public string GetAmazonBillingAgreementId() 36 | { 37 | return this.amazon_billing_agreement_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/Regions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace AmazonPay 4 | { 5 | /// 6 | /// Define the regions supported 7 | /// 8 | public static class Regions 9 | { 10 | /// 11 | /// Enum for supported Region values 12 | /// 13 | public enum supportedRegions 14 | { 15 | us, uk, de, jp 16 | } 17 | public enum currencyCode 18 | { 19 | USD, GBP, EUR, JPY, AUD, ZAR, CHF, NOK, DKK, SEK, NZD, HKD 20 | } 21 | 22 | private enum commonRegions 23 | { 24 | eu, na 25 | } 26 | /// 27 | /// MWS endpoint URL'S 28 | /// 29 | public static readonly Dictionary mwsServiceUrls = new Dictionary() { 30 | {commonRegions.eu.ToString(), "mws-eu.amazonservices.com"}, 31 | {commonRegions.na.ToString(), "mws.amazonservices.com"}, 32 | {supportedRegions.jp.ToString(), "mws.amazonservices.jp"} 33 | }; 34 | 35 | /// 36 | /// Production profile end points to get the user information 37 | /// 38 | public static readonly Dictionary ProfileEndpoint = new Dictionary() { 39 | {supportedRegions.uk.ToString(), "amazon.co.uk"}, 40 | {supportedRegions.us.ToString(), "amazon.com"}, 41 | {supportedRegions.de.ToString(), "amazon.de"}, 42 | {supportedRegions.jp.ToString(), "amazon.co.jp"} 43 | }; 44 | 45 | /// 46 | /// Region Mappings to map the regions to the zones 47 | /// 48 | public static readonly Dictionary regionMappings = new Dictionary() { 49 | {supportedRegions.de.ToString(), commonRegions.eu.ToString()}, 50 | {supportedRegions.uk.ToString(), commonRegions.eu.ToString()}, 51 | {supportedRegions.us.ToString(), commonRegions.na.ToString()}, 52 | {supportedRegions.jp.ToString(), supportedRegions.jp.ToString()} 53 | }; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /AmazonPay/ResponseParser.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | 5 | namespace AmazonPay 6 | { 7 | /// 8 | /// ResponseParser - Methods provided to convert the Response from the POST to XML, Dictionary or JSON 9 | /// 10 | public static class ResponseParser 11 | { 12 | 13 | /// 14 | /// Convert API response to JSON 15 | /// 16 | /// string json 17 | public static string ToJson(string xmlResponse) 18 | { 19 | string json = ""; 20 | var xml = new XmlDocument(); 21 | xml.LoadXml(xmlResponse.Trim()); 22 | json = JsonConvert.SerializeObject(xml, Newtonsoft.Json.Formatting.Indented); 23 | 24 | return json; 25 | } 26 | 27 | /// 28 | /// Convert API response to Dictionary 29 | /// 30 | /// Dictionary(string,object) 31 | public static Dictionary ToDict(string xmlResponse) 32 | { 33 | string json = ToJson(xmlResponse); 34 | NestedJsonToDictionary jsonToDict = new NestedJsonToDictionary(json); 35 | return jsonToDict.GetDictionary(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AmazonPay/Responses/AbstractResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class AbstractResponse : IResponse 7 | { 8 | protected string xml; 9 | protected string json; 10 | protected IDictionary dictionary; 11 | protected string requestId; 12 | protected string errorCode; 13 | protected string errorMessage; 14 | protected bool success = false; 15 | 16 | protected void SetDictionaryAndErrorResponse(string xml) 17 | { 18 | this.xml = xml; 19 | this.json = ResponseParser.ToJson(xml); 20 | this.dictionary = ResponseParser.ToDict(xml); 21 | 22 | ErrorResponse errorResponse = new ErrorResponse(this.dictionary); 23 | if (errorResponse.IsSetErrorCode() && errorResponse.IsSetErrorMessage()) 24 | { 25 | success = false; 26 | this.errorCode = errorResponse.GetErrorCode(); 27 | this.errorMessage = errorResponse.GetErrorMessage(); 28 | this.requestId = errorResponse.GetRequestId(); 29 | } 30 | else 31 | { 32 | success = true; 33 | } 34 | } 35 | 36 | /// 37 | /// Flattening the Dictionary 38 | /// The input dictionary contains key value pairs in the below format 39 | /// Type 1. Key (string) , Value (string) 40 | /// Type 2. Key (string) , Value (Dictionary) 41 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 42 | /// else it will recursively parse the inner dictionary for Type 2 43 | /// 44 | /// 45 | protected void ParseDictionaryToVariables(IDictionary dictionary) 46 | { 47 | foreach (string strKey in dictionary.Keys) 48 | { 49 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 50 | object obj = dictionary[strKey]; 51 | if (obj != null) 52 | { 53 | // If obj is dictionary recursively parse it 54 | if (obj is IDictionary) 55 | { 56 | ParseDictionaryToVariables((IDictionary)obj); 57 | } 58 | else 59 | { 60 | if (Enum.IsDefined(typeof(Operator), strKey)) 61 | { 62 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 63 | { 64 | case Operator.RequestId: 65 | requestId = obj.ToString(); 66 | this.success = true; 67 | break; 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | /// 76 | /// Get the requestId 77 | /// 78 | /// string requestId 79 | public string GetRequestId() 80 | { 81 | return this.requestId; 82 | } 83 | 84 | /// 85 | /// Get the bool value to know if the API call was a success(true) or a failure(false) 86 | /// 87 | /// success can be true or false 88 | public bool GetSuccess() 89 | { 90 | return success; 91 | } 92 | 93 | /// 94 | /// Get the ErrorCode when te API call failed 95 | /// 96 | /// string errorCode 97 | public string GetErrorCode() 98 | { 99 | return errorCode; 100 | } 101 | 102 | /// 103 | /// Get the ErrorMessage when the API call failed 104 | /// 105 | /// string errorMesage 106 | public string GetErrorMessage() 107 | { 108 | return errorMessage; 109 | } 110 | 111 | /// 112 | /// Response returned in JSON format 113 | /// 114 | /// JSON format Response 115 | public string GetJson() 116 | { 117 | return this.json; 118 | } 119 | 120 | /// 121 | /// Response returned in XML format 122 | /// 123 | /// XML format Response 124 | public string GetXml() 125 | { 126 | return this.xml; 127 | } 128 | 129 | /// 130 | /// Response in Dictionary Format 131 | /// 132 | /// Dictionary type Response 133 | public IDictionary GetDictionary() 134 | { 135 | return this.dictionary; 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /AmazonPay/Responses/BillingAddressDetails.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class BillingAddressDetails 7 | { 8 | private string phone; 9 | private string name; 10 | 11 | private string stateOrRegion; 12 | private string addressLine1; 13 | private string addressLine2; 14 | private string addressLine3; 15 | private string city; 16 | private string postalCode; 17 | private string countryCode; 18 | private string district; 19 | private string county; 20 | private string addressType; 21 | 22 | public BillingAddressDetails(IDictionary dictionary) 23 | { 24 | 25 | ParseDictionaryToVariables(dictionary); 26 | } 27 | 28 | private enum Operator 29 | { 30 | PostalCode, Name, Phone, CountryCode, StateOrRegion, AddressLine1, AddressLine2, AddressLine3, 31 | City, County, District, AddressType 32 | } 33 | 34 | /// 35 | /// Flattening the Dictionary 36 | /// The input dictionary contains key value pairs in the below format 37 | /// Type 1. Key (string) , Value (string) 38 | /// Type 2. Key (string) , Value (Dictionary) 39 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 40 | /// else it will recursively parse the inner dictionary for Type 2 41 | /// 42 | /// 43 | private void ParseDictionaryToVariables(IDictionary dictionary) 44 | { 45 | foreach (string strKey in dictionary.Keys) 46 | { 47 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 48 | object obj = dictionary[strKey]; 49 | if (obj != null) 50 | { 51 | // If obj is dictionary recursively parse it 52 | if (obj is IDictionary) 53 | { 54 | ParseDictionaryToVariables((IDictionary)obj); 55 | } 56 | else 57 | { 58 | if (Enum.IsDefined(typeof(Operator), strKey)) 59 | { 60 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 61 | { 62 | case Operator.PostalCode: 63 | postalCode = obj.ToString(); 64 | break; 65 | case Operator.Name: 66 | name = obj.ToString(); 67 | break; 68 | case Operator.Phone: 69 | phone = obj.ToString(); 70 | break; 71 | case Operator.CountryCode: 72 | countryCode = obj.ToString(); 73 | break; 74 | case Operator.StateOrRegion: 75 | stateOrRegion = obj.ToString(); 76 | break; 77 | case Operator.AddressLine1: 78 | addressLine1 = obj.ToString(); 79 | break; 80 | case Operator.AddressLine2: 81 | addressLine2 = obj.ToString(); 82 | break; 83 | case Operator.AddressLine3: 84 | addressLine3 = obj.ToString(); 85 | break; 86 | case Operator.City: 87 | city = obj.ToString(); 88 | break; 89 | case Operator.County: 90 | county = obj.ToString(); 91 | break; 92 | case Operator.District: 93 | district = obj.ToString(); 94 | break; 95 | case Operator.AddressType: 96 | addressType = obj.ToString(); 97 | break; 98 | } 99 | } 100 | } 101 | } 102 | } 103 | } 104 | 105 | /// 106 | /// Get the Billing Address Line 1 of the buyer 107 | /// 108 | /// addressLine1 109 | public string GetAddressLine1() 110 | { 111 | return this.addressLine1; 112 | } 113 | 114 | /// 115 | /// Get the Billing Address Line 2 of the Buyer 116 | /// 117 | /// addressLine2 118 | public string GetAddressLine2() 119 | { 120 | return this.addressLine2; 121 | } 122 | 123 | /// 124 | /// Get the Billing Address Line 3 of the Buyer 125 | /// 126 | /// addressLine3 127 | public string GetAddressLine3() 128 | { 129 | return this.addressLine3; 130 | } 131 | 132 | /// 133 | /// Get the Billing Address City of the Buyer 134 | /// 135 | /// city 136 | public string GetCity() 137 | { 138 | return this.city; 139 | } 140 | 141 | /// 142 | /// Get the Billing Address countryCode of the Buyer 143 | /// 144 | /// countryCode 145 | public string GetCountryCode() 146 | { 147 | return this.countryCode; 148 | } 149 | 150 | /// 151 | /// Get the Billing Address county of the Buyer 152 | /// 153 | /// county 154 | public string GetCounty() 155 | { 156 | return this.county; 157 | } 158 | 159 | /// 160 | /// Get the Billing Address addressType of the Buyer 161 | /// 162 | /// addressType 163 | public string GetAddressType() 164 | { 165 | return this.addressType; 166 | } 167 | 168 | /// 169 | /// Get the Billing Address district of the Buyer 170 | /// 171 | /// district 172 | public string GetDistrict() 173 | { 174 | return this.district; 175 | } 176 | 177 | /// 178 | /// Get the Billing Address Buyers name 179 | /// 180 | /// name 181 | public string GetName() 182 | { 183 | return this.name; 184 | } 185 | 186 | /// 187 | /// Get the Billing Address Buyers phone number 188 | /// 189 | /// phone 190 | public string GetPhone() 191 | { 192 | return this.phone; 193 | } 194 | 195 | /// 196 | /// Get the Billing Address Buyers postalCode 197 | /// 198 | /// postalCode 199 | public string GetPostalCode() 200 | { 201 | return this.postalCode; 202 | } 203 | 204 | /// 205 | /// Get the Billing Address Buyers stateOrRegion 206 | /// 207 | /// stateOrRegion 208 | public string GetStateOrRegion() 209 | { 210 | return this.stateOrRegion; 211 | } 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /AmazonPay/Responses/CancelOrderReferenceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class CancelOrderReferenceResponse : AbstractResponse 7 | { 8 | 9 | /// 10 | /// CancelOrderreferenceResponse 11 | /// 12 | /// 13 | public CancelOrderReferenceResponse(string xml) 14 | { 15 | SetDictionaryAndErrorResponse(xml); 16 | if (success) 17 | { 18 | ParseDictionaryToVariables(this.dictionary); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ChargebackResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace AmazonPay.Responses 7 | { 8 | 9 | public class ChargebackResponse : AbstractResponse 10 | { 11 | private string amazonChargebackId; 12 | private string amazonOrderReferenceId; 13 | private string amazonCaptureReferenceId; 14 | private DateTime creationTimestamp; 15 | private string chargebackState; 16 | private string chargebackReason; 17 | private decimal chargebackAmount; 18 | private string chargebackAmountCurrencyCode; 19 | 20 | private string parentKey; 21 | 22 | /// 23 | /// Get the ChargebackResponse 24 | /// 25 | public ChargebackResponse(string xml) 26 | { 27 | SetDictionaryAndErrorResponse(xml); 28 | if (success) 29 | { 30 | ParseDictionaryToNewVariables(this.dictionary); 31 | } 32 | } 33 | 34 | /// 35 | /// Flattening the Dictionary 36 | /// The input dictionary contains key value pairs in the below format 37 | /// Type 1. Key (string) , Value (string) 38 | /// Type 2. Key (string) , Value (Dictionary) 39 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 40 | /// else it will recursively parse the inner dictionary for Type 2 41 | /// 42 | /// 43 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 44 | { 45 | foreach (string strKey in dictionary.Keys) 46 | { 47 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 48 | object obj = dictionary[strKey]; 49 | if (obj != null) 50 | { 51 | // If obj is dictionary recursively parse it 52 | if (obj is IDictionary) 53 | { 54 | parentKey = strKey; 55 | ParseDictionaryToNewVariables((IDictionary)obj); 56 | } 57 | else 58 | { 59 | if (Enum.IsDefined(typeof(Operator), strKey)) 60 | { 61 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 62 | { 63 | case Operator.AmazonCaptureReferenceId: 64 | amazonCaptureReferenceId = obj.ToString(); 65 | break; 66 | case Operator.AmazonChargebackId: 67 | amazonChargebackId = obj.ToString(); 68 | break; 69 | case Operator.AmazonOrderReferenceId: 70 | amazonOrderReferenceId = obj.ToString(); 71 | break; 72 | case Operator.RequestId: 73 | requestId = obj.ToString(); 74 | break; 75 | case Operator.Amount: 76 | chargebackAmount = decimal.Parse(obj.ToString(), Constants.USNumberFormat); 77 | break; 78 | case Operator.CurrencyCode: 79 | chargebackAmountCurrencyCode = obj.ToString(); 80 | break; 81 | case Operator.ChargebackReason: 82 | chargebackReason = obj.ToString(); 83 | break; 84 | case Operator.ChargebackState: 85 | chargebackState = obj.ToString(); 86 | break; 87 | case Operator.CreationTimestamp: 88 | creationTimestamp = DateTime.Parse(obj.ToString()); 89 | break; 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | 97 | /// 98 | /// Get the Amazon ChargebackId 99 | /// 100 | /// string amazonChargebackId 101 | public string GetAmazonChargebackId() 102 | { 103 | return this.amazonChargebackId; 104 | } 105 | 106 | /// 107 | /// Get the AmazonCaptureId 108 | /// 109 | /// string AmazonCaptureId 110 | public string GetAmazonCaptureId() 111 | { 112 | return this.amazonCaptureReferenceId; 113 | } 114 | 115 | /// 116 | /// Get the AmazonOrderReferenceId 117 | /// 118 | /// string AmazonOrderReferenceId 119 | public string GetOrderReferenceId() 120 | { 121 | return this.amazonOrderReferenceId; 122 | } 123 | 124 | /// 125 | /// Get the Chargeback Amount 126 | /// 127 | /// decimal chargebackAmount 128 | public decimal GetChargebackAmount() 129 | { 130 | return this.chargebackAmount; 131 | } 132 | 133 | /// 134 | /// Get the Chargeback Amount Currency Code 135 | /// 136 | /// string chargebackAmountCurrencyCode 137 | public string GetChargebackAmountCurrencyCode() 138 | { 139 | return this.chargebackAmountCurrencyCode; 140 | } 141 | 142 | /// 143 | /// Get the Chargeback State 144 | /// 145 | /// string chargebackState 146 | public string GetChargebackState() 147 | { 148 | return this.chargebackState; 149 | } 150 | 151 | /// 152 | /// Get the chargeback Reason 153 | /// 154 | /// string chargebackReason 155 | public string GetChargebackReason() 156 | { 157 | return this.chargebackReason; 158 | } 159 | 160 | /// 161 | /// Get the CreationTimestamp 162 | /// 163 | /// DateTime creationTimestamp 164 | public DateTime GetCreationTimestamp() 165 | { 166 | return this.creationTimestamp; 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /AmazonPay/Responses/CloseAuthorizationResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class CloseAuthorizationResponse : AbstractResponse 7 | { 8 | /// 9 | /// CloseAuthorizationResponse 10 | /// 11 | public CloseAuthorizationResponse(string xml) 12 | { 13 | SetDictionaryAndErrorResponse(xml); 14 | if (success) 15 | { 16 | ParseDictionaryToVariables(this.dictionary); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AmazonPay/Responses/CloseBillingAgreementResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class CloseBillingAgreementResponse : AbstractResponse 7 | { 8 | /// 9 | /// CloseBillingAgreementResponse 10 | /// 11 | public CloseBillingAgreementResponse(string xml) 12 | { 13 | SetDictionaryAndErrorResponse(xml); 14 | if (success) 15 | { 16 | ParseDictionaryToVariables(this.dictionary); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AmazonPay/Responses/CloseOrderReferenceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class CloseOrderReferenceResponse : AbstractResponse 7 | { 8 | /// 9 | /// CloseOrderReferenceResponse 10 | /// 11 | public CloseOrderReferenceResponse(string xml) 12 | { 13 | SetDictionaryAndErrorResponse(xml); 14 | if (success) 15 | { 16 | ParseDictionaryToVariables(this.dictionary); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ConfirmBillingAgreementResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class ConfirmBillingAgreementResponse : AbstractResponse 7 | { 8 | /// 9 | /// ConfirmBillingAgreementResponse 10 | /// 11 | public ConfirmBillingAgreementResponse(string xml) 12 | { 13 | SetDictionaryAndErrorResponse(xml); 14 | if (success) 15 | { 16 | ParseDictionaryToVariables(this.dictionary); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ConfirmOrderReferenceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | 7 | public class ConfirmOrderReferenceResponse : AbstractResponse 8 | { 9 | /// 10 | /// ConfirmOrderReferenceResponse 11 | /// 12 | public ConfirmOrderReferenceResponse(string xml) 13 | { 14 | SetDictionaryAndErrorResponse(xml); 15 | if (success) 16 | { 17 | ParseDictionaryToVariables(this.dictionary); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | /// 7 | /// Documentation Source https://pay.amazon.com/documentation/apireference/201752580#201753060 8 | /// 9 | 10 | public class ErrorResponse 11 | { 12 | private string errorCode = null; 13 | private string errorMessage = null; 14 | private string requestId = null; 15 | 16 | public ErrorResponse(IDictionary dictionary) 17 | { 18 | ParseDictionaryToVariables(dictionary); 19 | } 20 | 21 | private enum Operator 22 | { 23 | Code, Message, RequestId 24 | } 25 | 26 | /// 27 | /// Flattening the Dictionary 28 | /// The input dictionary contains key value pairs in the below format 29 | /// Type 1. Key (string) , Value (string) 30 | /// Type 2. Key (string) , Value (Dictionary) 31 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 32 | /// else it will recursively parse the inner dictionary for Type 2 33 | /// 34 | /// 35 | private void ParseDictionaryToVariables(IDictionary dictionary) 36 | { 37 | foreach (string strKey in dictionary.Keys) 38 | { 39 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 40 | object obj = dictionary[strKey]; 41 | if (obj != null) 42 | { 43 | // If obj is dictionary recursively parse it 44 | if (obj is IDictionary) 45 | { 46 | ParseDictionaryToVariables((IDictionary)obj); 47 | } 48 | else 49 | { 50 | if (Enum.IsDefined(typeof(Operator), strKey)) 51 | { 52 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 53 | { 54 | case Operator.Code: 55 | errorCode = obj.ToString(); 56 | break; 57 | case Operator.Message: 58 | errorMessage = obj.ToString(); 59 | break; 60 | case Operator.RequestId: 61 | requestId = obj.ToString(); 62 | break; 63 | } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | 70 | /// 71 | /// Get the ErrorCode when te API call failed 72 | /// 73 | /// string errorCode 74 | public string GetErrorCode() 75 | { 76 | return this.errorCode; 77 | } 78 | 79 | /// 80 | /// Get the ErrorMessage when the API call failed 81 | /// 82 | /// string errorMesage 83 | public string GetErrorMessage() 84 | { 85 | return this.errorMessage; 86 | } 87 | 88 | /// 89 | /// Return true or false if the ErrorCode is set 90 | /// 91 | /// boolean errorCode 92 | public bool IsSetErrorCode() 93 | { 94 | return errorCode != null; 95 | } 96 | 97 | /// 98 | /// Return true or false if the ErrorMessage is set 99 | /// 100 | /// boolean errorMessage 101 | public bool IsSetErrorMessage() 102 | { 103 | return errorMessage != null; 104 | } 105 | 106 | /// 107 | /// Get the requestId 108 | /// 109 | /// string requestId 110 | public string GetRequestId() 111 | { 112 | return this.requestId; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /AmazonPay/Responses/GetMerchantAccountStatusResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Text; 4 | 5 | namespace AmazonPay.Responses 6 | { 7 | public class GetMerchantAccountStatusResponse : AbstractResponse 8 | { 9 | private AccountStatus accountStatus; 10 | 11 | /// 12 | /// GetMerchantAccountStatusResponse 13 | /// 14 | public GetMerchantAccountStatusResponse(string xml) 15 | { 16 | SetDictionaryAndErrorResponse(xml); 17 | if (success) 18 | { 19 | ParseDictionaryToNewVariables(this.dictionary); 20 | } 21 | } 22 | 23 | /// 24 | /// Flattening the Dictionary 25 | /// The input dictionary contains key value pairs in the below format 26 | /// Type 1. Key (string) , Value (string) 27 | /// Type 2. Key (string) , Value (Dictionary) 28 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 29 | /// else it will recursively parse the inner dictionary for Type 2 30 | /// 31 | /// 32 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 33 | { 34 | foreach (string strKey in dictionary.Keys) 35 | { 36 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 37 | object obj = dictionary[strKey]; 38 | if (obj != null) 39 | { 40 | // If obj is dictionary recursively parse it 41 | if (obj is IDictionary) 42 | { 43 | ParseDictionaryToNewVariables((IDictionary)obj); 44 | } 45 | else 46 | { 47 | if (Enum.IsDefined(typeof(Operator), strKey)) 48 | { 49 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 50 | { 51 | case Operator.RequestId: 52 | requestId = obj.ToString(); 53 | break; 54 | case Operator.AccountStatus: 55 | accountStatus = (AccountStatus)Enum.Parse(typeof(AccountStatus), obj.ToString()); 56 | break; 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | 64 | /// 65 | /// Get the AccountStatus 66 | /// 67 | /// AccountStatus accountStatus 68 | public AccountStatus GetAccountStatus() 69 | { 70 | return this.accountStatus; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /AmazonPay/Responses/GetMerchantNotificationConfigurationResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | namespace AmazonPay.Responses 8 | { 9 | /// 10 | /// Request class to parse the GetMerchantNotificationConfiguration API call response 11 | /// 12 | 13 | public class GetMerchantNotificationConfigurationResponse : AbstractResponse 14 | { 15 | private string parentKey; 16 | private Dictionary> notificationsUrls = new Dictionary>(); 17 | private string notificationUrl; 18 | private string requestId; 19 | /// 20 | /// Get the GetMerchantNotificationConfigurationResponse 21 | /// 22 | public GetMerchantNotificationConfigurationResponse(string xml) 23 | { 24 | SetDictionaryAndErrorResponse(xml); 25 | if (success) 26 | { 27 | ParseDictionaryToNewVariables(this.dictionary); 28 | } 29 | } 30 | 31 | /// 32 | /// Flattening the Dictionary 33 | /// The input dictionary contains key value pairs in the below format 34 | /// Type 1. Key (string) , Value (string) 35 | /// Type 2. Key (string) , Value (Dictionary) 36 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 37 | /// else it will recursively parse the inner dictionary for Type 2 38 | /// 39 | /// 40 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 41 | { 42 | foreach (string strKey in dictionary.Keys) 43 | { 44 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 45 | object obj = dictionary[strKey]; 46 | if (obj != null) 47 | { 48 | // If obj is dictionary recursively parse it 49 | if (obj is IDictionary) 50 | { 51 | parentKey = strKey; 52 | ParseDictionaryToNewVariables((IDictionary)obj); 53 | } 54 | else 55 | { 56 | if (Enum.IsDefined(typeof(Operator), strKey)) 57 | { 58 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 59 | { 60 | case Operator.RequestId: 61 | requestId = obj.ToString(); 62 | break; 63 | case Operator.member: 64 | if (parentKey == "NotificationConfigurationList") 65 | { 66 | JArray array = JArray.Parse(obj.ToString()); 67 | foreach (JObject notificationUrlsJSON in array.Children()) 68 | { 69 | List eventTypes = new List(); 70 | 71 | foreach (JProperty notificationUrlJSON in notificationUrlsJSON.Properties()) 72 | { 73 | if (notificationUrlJSON.Name.Equals( "NotificationUrl" )) 74 | { 75 | notificationUrl = notificationUrlJSON.Value.ToString(); 76 | } 77 | if (notificationUrlJSON.Name.Equals( "EventTypes" )) 78 | { 79 | JToken eventTypeObject = notificationUrlJSON.Value; 80 | JToken eTO = eventTypeObject.First.First.ToString(); 81 | string[] eventTypesString = eTO.ToString().Split(','); 82 | foreach (string eventType in eventTypesString) 83 | { 84 | if( Enum.IsDefined(typeof(Constants.URLEventTypes), eventType)) 85 | { 86 | Constants.URLEventTypes thisEventType = (Constants.URLEventTypes)Enum.Parse(typeof(Constants.URLEventTypes), eventType, true); 87 | eventTypes.Add(thisEventType); 88 | } 89 | } 90 | } 91 | } 92 | notificationsUrls.Add(notificationUrl, eventTypes); 93 | } 94 | } 95 | break; 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | /// 104 | /// Get the Notification URLs 105 | /// 106 | /// string orderLanguage 107 | public Dictionary> GetNotificationUrls() 108 | { 109 | return this.notificationsUrls; 110 | } 111 | 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /AmazonPay/Responses/GetProviderCreditReversalDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | public class GetProviderCreditReversalDetailsResponse : AbstractResponse 7 | { 8 | private string amazonProviderCreditReversalId; 9 | private string sellerId; 10 | private string providerId; 11 | private string creditReversalReferenceId; 12 | private string creditReversalNote; 13 | 14 | private decimal creditReversalAmount; 15 | private string creditReversalAmountCurrencyCode; 16 | private string creditReversalStatus; 17 | private string lastUpdateTimestamp; 18 | private string creationTimestamp; 19 | 20 | private string reasonCode; 21 | private string reasonDescription; 22 | 23 | private string parentKey; 24 | 25 | /// 26 | /// ProviderCreditReversalDetailsResponse 27 | /// 28 | public GetProviderCreditReversalDetailsResponse(string xml) 29 | { 30 | SetDictionaryAndErrorResponse(xml); 31 | if (success) 32 | { 33 | ParseDictionaryToNewVariables(this.dictionary); 34 | } 35 | } 36 | 37 | /// 38 | /// Flattening the Dictionary 39 | /// The input dictionary contains key value pairs in the below format 40 | /// Type 1. Key (string) , Value (string) 41 | /// Type 2. Key (string) , Value (Dictionary) 42 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 43 | /// else it will recursively parse the inner dictionary for Type 2 44 | /// 45 | /// 46 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 47 | { 48 | foreach (string strKey in dictionary.Keys) 49 | { 50 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 51 | object obj = dictionary[strKey]; 52 | if (obj != null) 53 | { 54 | // If obj is dictionary recursively parse it 55 | if (obj is IDictionary) 56 | { 57 | parentKey = strKey; 58 | ParseDictionaryToNewVariables((IDictionary)obj); 59 | } 60 | else 61 | { 62 | if (Enum.IsDefined(typeof(Operator), strKey)) 63 | { 64 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 65 | { 66 | case Operator.AmazonProviderCreditReversalId: 67 | this.amazonProviderCreditReversalId = obj.ToString(); 68 | break; 69 | case Operator.RequestId: 70 | requestId = obj.ToString(); 71 | break; 72 | case Operator.CreditReversalNote: 73 | creditReversalNote = obj.ToString(); 74 | break; 75 | case Operator.CreditReversalReferenceId: 76 | creditReversalReferenceId = obj.ToString(); 77 | break; 78 | case Operator.Amount: 79 | creditReversalAmount = decimal.Parse(obj.ToString()); 80 | break; 81 | case Operator.CurrencyCode: 82 | creditReversalAmountCurrencyCode = obj.ToString(); 83 | break; 84 | case Operator.ReasonCode: 85 | reasonCode = obj.ToString(); 86 | break; 87 | case Operator.ReasonDescription: 88 | reasonDescription = obj.ToString(); 89 | break; 90 | case Operator.State: 91 | creditReversalStatus = obj.ToString(); 92 | break; 93 | case Operator.LastUpdateTimestamp: 94 | lastUpdateTimestamp = obj.ToString(); 95 | break; 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | /// 104 | /// Get the Amazon ProviderCreditReversalId 105 | /// 106 | /// string amazonProviderCreditReversalId 107 | public string GetAmazonProviderCreditReversalId() 108 | { 109 | return this.amazonProviderCreditReversalId; 110 | } 111 | 112 | /// 113 | /// Get the CreditReversalReferenceId 114 | /// 115 | /// string creditReversalReferenceId 116 | public string GetCreditReversalReferenceId() 117 | { 118 | return this.creditReversalReferenceId; 119 | } 120 | 121 | /// 122 | /// Get the CreditReversalNote 123 | /// 124 | /// string creditReversalNote 125 | public string GetCreditReversalNote() 126 | { 127 | return this.creditReversalNote; 128 | } 129 | 130 | /// 131 | /// Get the CreditReversalAmount 132 | /// 133 | /// string creditReversalAmount 134 | public decimal GetCreditReversalAmount() 135 | { 136 | return this.creditReversalAmount; 137 | } 138 | 139 | /// 140 | /// Get the CreditReversalAmountCurrencyCode 141 | /// 142 | /// string creditReversalAmountCurrencyCode 143 | public string GetCreditReversalAmountCurrencyCode() 144 | { 145 | return this.creditReversalAmountCurrencyCode; 146 | } 147 | 148 | /// 149 | /// Get the CreditReversalStatus 150 | /// 151 | /// string creditReversalStatus 152 | public string GetCreditReversalStatus() 153 | { 154 | return this.creditReversalStatus; 155 | } 156 | 157 | /// 158 | /// Get the LastUpdateTimestamp 159 | /// 160 | /// string lastUpdatetimestamp 161 | public string GetLastUpdateTimestamp() 162 | { 163 | return this.lastUpdateTimestamp; 164 | } 165 | 166 | /// 167 | /// Get the Creationtimestamp 168 | /// 169 | /// string creationtimestamp 170 | public string GetCreationTimestamp() 171 | { 172 | return this.creationTimestamp; 173 | } 174 | 175 | /// 176 | /// Get the ReasonCode 177 | /// 178 | /// string reasonCode 179 | public string GetReasonCode() 180 | { 181 | return this.reasonCode; 182 | } 183 | 184 | /// 185 | /// Get the ReasonDescription 186 | /// 187 | /// string reasonDescription 188 | public string GetReasonDescription() 189 | { 190 | return this.reasonDescription; 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /AmazonPay/Responses/GetServiceStatusResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | /// 7 | /// Documentation Source https://pay.amazon.com/documentation/apireference/201752740#201752110 8 | /// 9 | 10 | public class GetServiceStatusResponse : AbstractResponse 11 | { 12 | private string status; 13 | private DateTime timestamp; 14 | 15 | /// 16 | /// ServiceStatusResponse 17 | /// 18 | public GetServiceStatusResponse(string xml) 19 | { 20 | SetDictionaryAndErrorResponse(xml); 21 | if (success) 22 | { 23 | ParseDictionaryToNewVariables(this.dictionary); 24 | } 25 | } 26 | 27 | /// 28 | /// Flattening the Dictionary 29 | /// The input dictionary contains key value pairs in the below format 30 | /// Type 1. Key (string) , Value (string) 31 | /// Type 2. Key (string) , Value (Dictionary) 32 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 33 | /// else it will recursively parse the inner dictionary for Type 2 34 | /// 35 | /// 36 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 37 | { 38 | foreach (string strKey in dictionary.Keys) 39 | { 40 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 41 | object obj = dictionary[strKey]; 42 | if (obj != null) 43 | { 44 | // If obj is dictionary recursively parse it 45 | if (obj is IDictionary) 46 | { 47 | ParseDictionaryToNewVariables((IDictionary)obj); 48 | } 49 | else 50 | { 51 | if (Enum.IsDefined(typeof(Operator), strKey)) 52 | { 53 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 54 | { 55 | case Operator.RequestId: 56 | requestId = obj.ToString(); 57 | break; 58 | case Operator.Status: 59 | status = obj.ToString(); 60 | break; 61 | case Operator.Timestamp: 62 | timestamp = DateTime.Parse(obj.ToString()); 63 | break; 64 | } 65 | } 66 | } 67 | } 68 | } 69 | } 70 | 71 | /// 72 | /// Get the Status 73 | /// 74 | /// string status 75 | public string GetStatus() 76 | { 77 | return status; 78 | } 79 | 80 | /// 81 | /// Get the timestamp 82 | /// 83 | /// DateTime timestamp 84 | public DateTime GetTimestamp() 85 | { 86 | return timestamp; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /AmazonPay/Responses/IResponse.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.Responses 2 | { 3 | /// 4 | /// Interface for common Response methods 5 | /// 6 | public interface IResponse 7 | { 8 | /// 9 | /// Response in Dictionary format 10 | /// 11 | /// Dictionary 12 | System.Collections.IDictionary GetDictionary(); 13 | 14 | /// 15 | /// Response in Json format 16 | /// 17 | /// string json 18 | string GetJson(); 19 | 20 | /// 21 | /// Returns true or false if API call was a success/failure 22 | /// 23 | /// bool true or false 24 | bool GetSuccess(); 25 | 26 | /// 27 | /// Response in XML format 28 | /// 29 | /// string xml 30 | string GetXml(); 31 | 32 | /// 33 | /// Errorcode as string 34 | /// 35 | /// string Error code 36 | string GetErrorCode(); 37 | 38 | /// 39 | /// Error Message 40 | /// 41 | /// Error Message 42 | string GetErrorMessage(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ListOrderReferenceResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace AmazonPay.Responses 7 | { 8 | public class ListOrderReferenceResponse : AbstractResponse 9 | { 10 | private List> orderReferences = new List>(); 11 | private string nextPageToken = ""; 12 | 13 | /// 14 | /// GetMerchantAccountStatusResponse 15 | /// 16 | public ListOrderReferenceResponse(string xml) 17 | { 18 | SetDictionaryAndErrorResponse(xml); 19 | if (success) 20 | { 21 | ParseDictionaryToNewVariables(this.dictionary); 22 | } 23 | } 24 | 25 | /// 26 | /// Flattening the Dictionary 27 | /// The input dictionary contains key value pairs in the below format 28 | /// Type 1. Key (string) , Value (string) 29 | /// Type 2. Key (string) , Value (Dictionary) 30 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 31 | /// else it will recursively parse the inner dictionary for Type 2 32 | /// 33 | /// 34 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 35 | { 36 | foreach (string strKey in dictionary.Keys) 37 | { 38 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 39 | object obj = dictionary[strKey]; 40 | if (obj != null) 41 | { 42 | // if obj is a single instance of OrderReference it will process wrong by default, 43 | // this pulls the relevant json from the object and converts it to a single instance to a JArray string for consumption 44 | if (obj is IDictionary && strKey == "OrderReference") 45 | { 46 | JObject jsonObject = JObject.Parse(this.json); 47 | if (this.json.Contains("ListOrderReferenceResponse")) 48 | { 49 | obj = "[" + jsonObject["ListOrderReferenceResponse"]["ListOrderReferenceResult"]["OrderReferenceList"]["OrderReference"].ToString() + "]"; 50 | } 51 | else 52 | { 53 | obj = "[" + jsonObject["ListOrderReferenceByNextTokenResponse"]["ListOrderReferenceByNextTokenResult"]["OrderReferenceList"]["OrderReference"].ToString() + "]"; 54 | } 55 | } 56 | // If obj is dictionary recursively parse it 57 | if (obj is IDictionary) 58 | { 59 | ParseDictionaryToNewVariables((IDictionary)obj); 60 | } 61 | else 62 | { 63 | if (Enum.IsDefined(typeof(Operator), strKey)) 64 | { 65 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 66 | { 67 | case Operator.NextPageToken: 68 | nextPageToken = obj.ToString(); 69 | break; 70 | case Operator.OrderReference: 71 | JArray array = JArray.Parse(obj.ToString()); 72 | 73 | foreach (JObject orderReference in array.Children()) 74 | { 75 | int orderRefIx = orderReferences.Count; 76 | orderReferences.Add(new Dictionary()); 77 | orderReferences[orderRefIx].Add("ReleaseEnvironment", orderReference["ReleaseEnvironment"].ToString()); 78 | orderReferences[orderRefIx].Add("AmazonOrderReferenceId", orderReference["AmazonOrderReferenceId"].ToString()); 79 | orderReferences[orderRefIx].Add("CreationTimestamp", orderReference["CreationTimestamp"].ToString()); 80 | orderReferences[orderRefIx].Add("StoreName", orderReference["SellerOrderAttributes"]["StoreName"].ToString()); 81 | orderReferences[orderRefIx].Add("SellerOrderId", orderReference["SellerOrderAttributes"]["SellerOrderId"].ToString()); 82 | orderReferences[orderRefIx].Add("State", orderReference["OrderReferenceStatus"]["State"].ToString()); 83 | orderReferences[orderRefIx].Add("LastUpdateTimestamp", orderReference["OrderReferenceStatus"]["LastUpdateTimestamp"].ToString()); 84 | orderReferences[orderRefIx].Add("CurrencyCode", orderReference["OrderTotal"]["CurrencyCode"].ToString()); 85 | orderReferences[orderRefIx].Add("Amount", orderReference["OrderTotal"]["Amount"].ToString()); 86 | orderReferences[orderRefIx].Add("ReasonDescription", (orderReference["OrderReferenceStatus"]["ReasonDescription"] == null) ? null : orderReference["OrderReferenceStatus"]["ReasonDescription"].ToString()); 87 | orderReferences[orderRefIx].Add("ReasonCode", (orderReference["OrderReferenceStatus"]["ReasonCode"] == null) ? null : orderReference["OrderReferenceStatus"]["ReasonCode"].ToString()); 88 | } 89 | break; 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | /// 97 | /// Get the CreationTimestamp 98 | /// 99 | /// Datetime creationTimestamp 100 | public List> GetOrderReferences() 101 | { 102 | return this.orderReferences; 103 | } 104 | /// 105 | /// Get the NextPageToken for use in ListOrderReferenceByToken 106 | /// 107 | /// Datetime creationTimestamp 108 | public string GetNextPageToken() 109 | { 110 | return this.nextPageToken; 111 | } 112 | 113 | } 114 | } -------------------------------------------------------------------------------- /AmazonPay/Responses/Operator.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.Responses 2 | { 3 | public enum Operator 4 | { 5 | //Common to responses 6 | RequestId, Amount, CurrencyCode, ReasonCode, ReasonDescription, State, SoftDescriptor, 7 | LastUpdateTimestamp, CreationTimestamp, member, 8 | 9 | //CaptureResponse 10 | AmazonCaptureId, SellerCaptureNote, CaptureReferenceId, CaptureAmount, RefundedAmount, CaptureFee, 11 | ConvertedAmount, ConversionRate, IdList, ProviderCreditSummaryList, ProviderId, ProviderSellerId, ProviderCreditId, 12 | 13 | //AuthorizeResponse.cs 14 | AmazonOrderReferenceId, AmazonAuthorizationId, SellerAuthorizationNote, ExpirationTimestamp, AuthorizationReferenceId, 15 | AuthorizationAmount, CapturedAmount, AuthorizationFee, SoftDecline, CaptureNow, 16 | 17 | //BillingAgreementDetailsResponse 18 | AmazonBillingAgreementId, TimePeriodStartDate, TimePeriodEndDate, LastUpdatedTimestamp, AmountLimitPerTimePeriod, 19 | CurrentRemainingBalance, SellerNote, PlatformId, PostalCode, Name, Type, Id, Email, Phone, CountryCode, StateOrRegion, 20 | AddressLine1, AddressLine2, AddressLine3, City, County, District, DestinationType, ReleaseEnvironment, SellerOrderId, 21 | SellerBillingAgreementId, CustomInformation, StoreName, Constraint, ConstraintID, Description, BillingAddress, Buyer, 22 | BillingAgreementType, SubscriptionAmount, 23 | 24 | //ChargebackResponse 25 | AmazonChargebackId, AmazonCaptureReferenceId, ChargebackReason, ChargebackState, 26 | 27 | //GetProviderCreditDetailsResponse 28 | AmazonProviderCreditId, CreditReferenceId, CreditAmount, CreditReversalAmount, SellerId, 29 | 30 | //GetProviderCreditReversalDetailsResponse 31 | AmazonProviderCreditReversalId, CreditReversalNote, CreditReversalReferenceId, 32 | 33 | //GetServiceStatusResponse 34 | Status, Timestamp, 35 | 36 | //OrderReferenceDetailsResponse 37 | FullDescriptor, isAmazonBalanceFirst, OrderLanguage, RequestPaymentAuthorization, PaymentServiceProviderId, 38 | PaymentServiceProviderOrderId, OrderItemCategory, SupplementaryData, StaticToken, OrderReferenceStatus, 39 | 40 | //GetMerchantAccountStatusResponse 41 | AccountStatus, 42 | 43 | //RefundResponse 44 | AmazonRefundId, SellerRefundNote, RefundReferenceId, RefundAmount, FeeRefunded, RefundType, 45 | ProviderCreditReversalSummaryList, ProviderCreditReversalId, 46 | 47 | //ValidateBillingAgreementResponse 48 | ValidationResult, FailureReasonCode, 49 | 50 | //GetMerchantNotificationConfigurationResponse 51 | NotificationConfigurationList, NotificationsUrl, EventTypes, 52 | 53 | //ListOrderReferenceResponse 54 | OrderReferenceList, OrderReference, NextPageToken 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /AmazonPay/Responses/PaymentDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using AmazonPay.Responses; 4 | 5 | 6 | namespace AmazonPay.Responses 7 | { 8 | /// 9 | /// PaymentDetailsResponse is a helper method which returns OrderReference, Authorization, Capture and 10 | /// Refund response 11 | /// 12 | public class PaymentDetailsResponse 13 | { 14 | private OrderReferenceDetailsResponse orderReferenceDetails; 15 | private String id; 16 | private Dictionary authorizationDetails = new Dictionary(); 17 | private Dictionary captureDetails = new Dictionary(); 18 | private Dictionary refundDetails = new Dictionary(); 19 | 20 | 21 | /// 22 | /// Add OrderReferenceID and OrderReferenceDetails 23 | /// 24 | public void PutOrderReferenceDetails(String id, OrderReferenceDetailsResponse orderReferenceResponse) 25 | { 26 | this.orderReferenceDetails = orderReferenceResponse; 27 | this.id = id; 28 | } 29 | 30 | /// 31 | /// Add AmazonAuthorizationReferenceID and AuthrizationDetails 32 | /// 33 | public void PutAuthorizationDetails(String id, AuthorizeResponse authorizeResponse) 34 | { 35 | authorizationDetails.Add(id, authorizeResponse); 36 | } 37 | 38 | /// 39 | /// Add AmazonCaptureID and CaptureDetails 40 | /// 41 | public void PutCaptureDetails(String id, CaptureResponse captureResponse) 42 | { 43 | captureDetails.Add(id, captureResponse); 44 | } 45 | 46 | /// 47 | /// Add AmazonRefundID and RefundDetails 48 | /// 49 | public void PutRefundDetails(String id, RefundResponse refundResponse) 50 | { 51 | refundDetails.Add(id, refundResponse); 52 | } 53 | 54 | /// 55 | /// Get the OrderReferenceDetails 56 | /// 57 | /// OrderReferenceDetailsResponse orderReferenceDetails 58 | public OrderReferenceDetailsResponse GetOrderReferenceDetails() 59 | { 60 | return orderReferenceDetails; 61 | } 62 | 63 | /// 64 | /// Get the AuthorizationDetails 65 | /// 66 | /// Dictionary authorizationDetails 67 | public Dictionary GetAuthorizationDetails() 68 | { 69 | return this.authorizationDetails; 70 | } 71 | 72 | /// 73 | /// Get the CaptureDetials 74 | /// 75 | /// Dictionary captureDetials 76 | public Dictionary GetCaptureDetails() 77 | { 78 | return this.captureDetails; 79 | } 80 | 81 | /// 82 | /// Get the RefundDetails 83 | /// 84 | /// Dictionary refundDetails 85 | public Dictionary GetRefundDetails() 86 | { 87 | return this.refundDetails; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /AmazonPay/Responses/SetMerchantNotificationConfigurationResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | 7 | public class SetMerchantNotificationConfigurationResponse : AbstractResponse 8 | { 9 | /// 10 | /// SetMerchantNotificationConfigurationResponse 11 | /// 12 | public SetMerchantNotificationConfigurationResponse(string xml) 13 | { 14 | SetDictionaryAndErrorResponse(xml); 15 | if (success) 16 | { 17 | ParseDictionaryToVariables(this.dictionary); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AmazonPay/Responses/ValidateBillingAgreementResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace AmazonPay.Responses 5 | { 6 | /// 7 | /// Documentation Source https://pay.amazon.com/documentation/apireference/201752740#201751720 8 | /// 9 | 10 | public class ValidateBillingAgreementResponse : AbstractResponse 11 | { 12 | private string validationResult; 13 | private string failureReasonCode; 14 | private string billingAgreementState; 15 | 16 | private string reasonCode; 17 | private string reasonDescription; 18 | private DateTime lastUpdatedTimestamp; 19 | 20 | private string parentKey; 21 | 22 | 23 | /// 24 | /// Get the ValidateBillingAgreementResponse 25 | /// 26 | public ValidateBillingAgreementResponse(string xml) 27 | { 28 | SetDictionaryAndErrorResponse(xml); 29 | if (success) 30 | { 31 | ParseDictionaryToNewVariables(this.dictionary); 32 | } 33 | } 34 | 35 | /// 36 | /// Flattening the Dictionary 37 | /// The input dictionary contains key value pairs in the below format 38 | /// Type 1. Key (string) , Value (string) 39 | /// Type 2. Key (string) , Value (Dictionary) 40 | /// The function will parse the dictionary values into respective class variables by directly jumping to to the switch case for Type 1 41 | /// else it will recursively parse the inner dictionary for Type 2 42 | /// 43 | /// 44 | private void ParseDictionaryToNewVariables(IDictionary dictionary) 45 | { 46 | foreach (string strKey in dictionary.Keys) 47 | { 48 | // Obj is the value of the dictionary key. this could either be a string or a nested inner dictionary. 49 | object obj = dictionary[strKey]; 50 | if (obj != null) 51 | { 52 | // If obj is dictionary recursively parse it 53 | if (obj is IDictionary) 54 | { 55 | parentKey = strKey; 56 | ParseDictionaryToNewVariables((IDictionary)obj); 57 | } 58 | else 59 | { 60 | if (Enum.IsDefined(typeof(Operator), strKey)) 61 | { 62 | switch ((Operator)Enum.Parse(typeof(Operator), strKey)) 63 | { 64 | case Operator.ValidationResult: 65 | validationResult = obj.ToString(); 66 | break; 67 | case Operator.FailureReasonCode: 68 | failureReasonCode = obj.ToString(); 69 | break; 70 | case Operator.State: 71 | billingAgreementState = obj.ToString(); 72 | break; 73 | case Operator.ReasonCode: 74 | reasonCode = obj.ToString(); 75 | break; 76 | case Operator.ReasonDescription: 77 | reasonDescription = obj.ToString(); 78 | break; 79 | case Operator.LastUpdatedTimestamp: 80 | lastUpdatedTimestamp = DateTime.Parse(obj.ToString()); 81 | break; 82 | case Operator.RequestId: 83 | requestId = obj.ToString(); 84 | break; 85 | } 86 | } 87 | } 88 | } 89 | } 90 | } 91 | 92 | /// 93 | /// Get the ValidationResult 94 | /// 95 | /// string validationResult 96 | public string GetValidationResult() 97 | { 98 | return this.validationResult; 99 | } 100 | 101 | /// 102 | /// Get the FailureReasonCode 103 | /// 104 | /// string failureReasonCode 105 | public string GetFailureReasonCode() 106 | { 107 | return this.failureReasonCode; 108 | } 109 | 110 | /// 111 | /// Get the BillingAgreementState 112 | /// 113 | /// string billingAgreementState 114 | public string GetBillingAgreementState() 115 | { 116 | return this.billingAgreementState; 117 | } 118 | 119 | /// 120 | /// Get the ReasonCode 121 | /// 122 | /// string reasonCode 123 | public string GetReasonCode() 124 | { 125 | return this.reasonCode; 126 | } 127 | 128 | /// 129 | /// Get the ReasonDescription 130 | /// 131 | /// string reasonDescription 132 | public string GetReasonDescription() 133 | { 134 | return this.reasonDescription; 135 | } 136 | 137 | /// 138 | /// Get the LastUpdatedTimestamp 139 | /// 140 | /// DateTime lastUpdatedTimestamp 141 | public DateTime GetLastUpdatedTimestamp() 142 | { 143 | return this.lastUpdatedTimestamp; 144 | } 145 | } 146 | } 147 | 148 | -------------------------------------------------------------------------------- /AmazonPay/SanitizeData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | using System.Configuration; 5 | using System.Web; 6 | using Newtonsoft.Json.Linq; 7 | #if NETSTANDARD 8 | using Microsoft.Extensions.Configuration; 9 | #endif 10 | 11 | namespace AmazonPay 12 | { 13 | /// 14 | /// Static Class for Sanitizing data for request and Response 15 | /// 16 | public static class SanitizeData 17 | { 18 | /// 19 | /// Enum datatype for Sanitazation 20 | /// 21 | public enum DataType 22 | { 23 | Request, 24 | Response, 25 | Text, 26 | JsonString 27 | }; 28 | 29 | public static string[] LoadSanitizeList() 30 | { 31 | #if NETSTANDARD 32 | // check for legacy appsettings 33 | if (ConfigurationManager.AppSettings.HasKeys() && 34 | !string.IsNullOrEmpty(ConfigurationManager.AppSettings["sanitizeList"])) 35 | return ConfigurationManager.AppSettings["sanitizeList"].Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); 36 | 37 | try 38 | { 39 | IConfigurationRoot configuration = new ConfigurationBuilder() 40 | .AddJsonFile("appsettings.json") 41 | .Build(); 42 | 43 | var appSettings = configuration["appSettings:sanitizeList"]; 44 | if (string.IsNullOrEmpty(appSettings)) throw new ArgumentException(); 45 | 46 | return appSettings.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); ; 47 | } 48 | catch (Exception e) 49 | { 50 | throw new ArgumentException("You have set Logger but we are missing sanitezeList property in appsettings.json. \n " + 51 | "Please add:' \n" + 52 | "\"appSettings\": { \n" + 53 | "\"sanitizeList\": \"Example1;Example2;Example3\"/> \n" + 54 | "}"); 55 | } 56 | 57 | #else 58 | if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["sanitizeList"])) 59 | throw new ArgumentException("You have set Logger but we are missing sanitezeList property in configuration file. \n " + 60 | "Please add:' \n" + 61 | " \n" + 62 | " \n" + 63 | ""); 64 | 65 | // Load list of sanitized tags in to array 66 | return ConfigurationManager.AppSettings["sanitizeList"].Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); 67 | #endif 68 | } 69 | 70 | /// 71 | /// Function for sanitizing data 72 | /// 73 | /// String XML data 74 | /// Type of Data beeing provided 75 | /// Sanitized String of data 76 | public static string SanitizeGivenData(string data, DataType type) 77 | { 78 | string returnString = string.Empty; 79 | const string REMOVED_TEXT = "*REMOVED*"; 80 | List sanitizeList = new List(); 81 | 82 | var listArray = LoadSanitizeList(); 83 | 84 | // Load SanitizeDataList 85 | foreach (var item in listArray) 86 | { 87 | sanitizeList.Add(item); 88 | } 89 | // return data if sanitazation list is empty 90 | if (sanitizeList.Count < 1) return data; 91 | 92 | // Response Data type 93 | if (type == DataType.Response) 94 | { 95 | // Load data as XML 96 | XmlDocument doc = new XmlDocument(); 97 | 98 | doc.LoadXml(data); 99 | 100 | // Find and remove data 101 | foreach (string item in sanitizeList) 102 | { 103 | XmlNode node = doc.GetElementsByTagName(item).Item(0); 104 | if (node != null && node.ChildNodes.Count > 0) 105 | { 106 | node.InnerText = REMOVED_TEXT; 107 | } 108 | } 109 | returnString = doc.OuterXml; 110 | 111 | } 112 | // Request Data type 113 | else if (type == DataType.Request) 114 | { 115 | string[] separatedURLQueryString = data.Split('\n'); 116 | 117 | var queryString = HttpUtility.ParseQueryString(separatedURLQueryString[separatedURLQueryString.Length - 1].TrimStart()); 118 | 119 | // Load SanitizeDataList 120 | foreach (var item in sanitizeList) 121 | { 122 | // Remove unwanted queries 123 | if (!String.IsNullOrEmpty(queryString[item])) queryString.Set(item, REMOVED_TEXT); 124 | } 125 | 126 | separatedURLQueryString[separatedURLQueryString.Length - 1] = queryString.ToString(); 127 | 128 | Array.ForEach(separatedURLQueryString, value => returnString += value + '\n'); 129 | 130 | returnString = returnString.Remove(returnString.Length - 1); 131 | } 132 | // Json Data type 133 | else if (type == DataType.JsonString) 134 | { 135 | var jsonObj = JObject.Parse(data); 136 | 137 | // Load SanitizeDataList 138 | foreach (var item in sanitizeList) 139 | { 140 | // Replace unwanted data 141 | if (jsonObj[item] != null) 142 | jsonObj[item].Replace(REMOVED_TEXT); 143 | } 144 | 145 | returnString = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); 146 | } 147 | // Text Data Type 148 | else if (type == DataType.Text) 149 | { 150 | returnString = data; 151 | } 152 | return returnString; 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/CancelOrderReferenceRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the CancelOrderReference API call parameters 5 | /// 6 | public class CancelOrderReferenceRequest : DelegateRequest 7 | { 8 | private string amazon_order_reference_id; 9 | private string cancelation_reason; 10 | 11 | public CancelOrderReferenceRequest() 12 | { 13 | SetAction(Constants.CancelOrderReference); 14 | } 15 | 16 | protected override CancelOrderReferenceRequest GetThis() 17 | { 18 | return this; 19 | } 20 | 21 | /// 22 | /// Sets the Amazon Order Reference ID 23 | /// 24 | /// 25 | /// CancelOrderReferenceRequest Object 26 | public CancelOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_order_reference_id) 27 | { 28 | this.amazon_order_reference_id = amazon_order_reference_id; 29 | return this; 30 | } 31 | 32 | /// 33 | /// Gets the Amazon Order Reference ID 34 | /// 35 | /// Amazon Order Reference ID 36 | public string GetAmazonOrderReferenceId() 37 | { 38 | return this.amazon_order_reference_id; 39 | } 40 | 41 | /// 42 | /// Sets the Cancelation reason for the order 43 | /// 44 | /// 45 | /// CancelOrderReferenceRequest Object 46 | public CancelOrderReferenceRequest WithCancelationReason(string cancelation_reason) 47 | { 48 | this.cancelation_reason = cancelation_reason; 49 | return this; 50 | } 51 | 52 | /// 53 | /// Gets the Cancelation reason 54 | /// 55 | /// Cancelation reason 56 | public string GetCancelationReason() 57 | { 58 | return this.cancelation_reason; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/CaptureRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace AmazonPay.StandardPaymentRequests 5 | { 6 | /// 7 | /// Request class to set the Capture API call parameters 8 | /// 9 | public class CaptureRequest : DelegateRequest 10 | { 11 | private string amazon_authorization_id; 12 | private decimal amount; 13 | private string currency_code; 14 | private string seller_capture_note; 15 | private string capture_reference_id; 16 | private string soft_descriptor; 17 | List> providerCredit = new List>(); 18 | 19 | public CaptureRequest() 20 | { 21 | SetAction(Constants.Capture); 22 | } 23 | 24 | protected override CaptureRequest GetThis() 25 | { 26 | return this; 27 | } 28 | 29 | /// 30 | /// Sets the Amazon Authorization ID 31 | /// 32 | /// 33 | /// CaptureRequest Object 34 | public CaptureRequest WithAmazonAuthorizationId(string amazon_authorization_id) 35 | { 36 | this.amazon_authorization_id = amazon_authorization_id; 37 | return this; 38 | } 39 | 40 | /// 41 | /// Gets the Amazon Authorization ID 42 | /// 43 | /// Amazon Authorization ID 44 | public string GetAmazonAuthorizationId() 45 | { 46 | return this.amazon_authorization_id; 47 | } 48 | 49 | /// 50 | /// Sets the Capture amount 51 | /// 52 | /// 53 | /// CaptureRequest Object 54 | public CaptureRequest WithAmount(decimal capture_amount) 55 | { 56 | this.amount = capture_amount; 57 | return this; 58 | } 59 | 60 | /// 61 | /// Gets the Capture amount 62 | /// 63 | /// Capture amount 64 | public decimal GetAmount() 65 | { 66 | return this.amount; 67 | } 68 | 69 | /// 70 | /// Sets the Capture Currency Code 71 | /// 72 | /// 73 | /// CaptureRequest Object 74 | public CaptureRequest WithCurrencyCode(Enum currency_code) 75 | { 76 | this.currency_code = currency_code.ToString(); 77 | return this; 78 | } 79 | 80 | /// 81 | /// Gets the Capture Currency Code 82 | /// 83 | /// Currency Code 84 | public string GetCurrencyCode() 85 | { 86 | return this.currency_code; 87 | } 88 | 89 | /// 90 | /// Sets the Capture Reference ID - Unique string 91 | /// 92 | /// 93 | /// CaptureRequest Object 94 | public CaptureRequest WithCaptureReferenceId(string capture_reference_id) 95 | { 96 | this.capture_reference_id = capture_reference_id; 97 | return this; 98 | } 99 | 100 | /// 101 | /// Gets the Capture Reference ID 102 | /// 103 | /// Capture Reference ID 104 | public string GetCaptureReferenceId() 105 | { 106 | return this.capture_reference_id; 107 | } 108 | 109 | /// 110 | /// Sets the Provider Credit Details 111 | /// 112 | /// 113 | /// 114 | /// 115 | /// CaptureRequest Object 116 | public CaptureRequest WithProviderCreditDetails(string provider_id, decimal amount, string currency_code) 117 | { 118 | Dictionary providerCreditDetails = new Dictionary(); 119 | providerCreditDetails.Clear(); 120 | providerCreditDetails[Constants.ProviderId] = provider_id; 121 | providerCreditDetails[Constants.CreditAmount_Amount] = amount.ToString(); 122 | providerCreditDetails[Constants.CreditAmount_CurrencyCode] = currency_code.ToUpper(); 123 | 124 | providerCredit.Add(providerCreditDetails); 125 | return this; 126 | } 127 | 128 | /// 129 | /// Gets the Provider Credit Details 130 | /// 131 | /// Provider Credit Details 132 | public IList> GetProviderCreditDetails() 133 | { 134 | return this.providerCredit.AsReadOnly(); 135 | } 136 | 137 | /// 138 | /// Sets the Seller Capture Note 139 | /// 140 | /// 141 | /// CaptureRequest Object 142 | public CaptureRequest WithSellerCaptureNote(string seller_capture_note) 143 | { 144 | this.seller_capture_note = seller_capture_note; 145 | return this; 146 | 147 | } 148 | 149 | /// 150 | /// Gets the Seller Capture Note 151 | /// 152 | /// Seller Capture Note 153 | public string GetSellerCaptureNote() 154 | { 155 | return this.seller_capture_note; 156 | } 157 | 158 | /// 159 | /// Sets the Soft Descriptor 160 | /// 161 | /// 162 | /// CaptureRequest Object 163 | public CaptureRequest WithSoftDescriptor(string soft_descriptor) 164 | { 165 | this.soft_descriptor = soft_descriptor; 166 | return this; 167 | 168 | } 169 | 170 | /// 171 | /// Gets the Soft Descriptor value 172 | /// 173 | /// Soft Descriptor 174 | public string GetSoftDescriptor() 175 | { 176 | return this.soft_descriptor; 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/CloseAuthorizationRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the CloseAuthorization API call parameters 5 | /// 6 | public class CloseAuthorizationRequest : DelegateRequest 7 | { 8 | private string amazon_authorization_id; 9 | private string closure_reason; 10 | 11 | public CloseAuthorizationRequest() 12 | { 13 | SetAction(Constants.CloseAuthorization); 14 | } 15 | 16 | protected override CloseAuthorizationRequest GetThis() 17 | { 18 | return this; 19 | } 20 | 21 | /// 22 | /// Sets the Amazon Authorization ID 23 | /// 24 | /// 25 | /// CloseAuthorizationRequest Object 26 | public CloseAuthorizationRequest WithAmazonAuthorizationId(string amazon_authorization_id) 27 | { 28 | this.amazon_authorization_id = amazon_authorization_id; 29 | return this; 30 | } 31 | 32 | /// 33 | /// Gets the Amazon Authorization ID 34 | /// 35 | /// Amazon Authorization ID> 36 | public string GetAmazonAuthorizationId() 37 | { 38 | return this.amazon_authorization_id; 39 | } 40 | 41 | /// 42 | /// Sets the Closure Reason 43 | /// 44 | /// 45 | /// CloseAuthorizationRequest Object 46 | public CloseAuthorizationRequest WithClosureReason(string closure_reason) 47 | { 48 | this.closure_reason = closure_reason; 49 | return this; 50 | } 51 | 52 | /// 53 | /// Gets the Closure Reason 54 | /// 55 | /// Closure Reason 56 | public string GetClosureReason() 57 | { 58 | return this.closure_reason; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/CloseOrderReferenceRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the CloseOrderReference API call parameters 5 | /// 6 | public class CloseOrderReferenceRequest : DelegateRequest 7 | { 8 | private string amazon_order_reference_id; 9 | private string closure_reason; 10 | 11 | public CloseOrderReferenceRequest() 12 | { 13 | SetAction(Constants.CloseOrderReference); 14 | } 15 | 16 | protected override CloseOrderReferenceRequest GetThis() 17 | { 18 | return this; 19 | } 20 | 21 | /// 22 | /// Sets the Amazon Order Reference ID 23 | /// 24 | /// 25 | /// CloseOrderReferenceRequest Object 26 | public CloseOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_order_reference_id) 27 | { 28 | this.amazon_order_reference_id = amazon_order_reference_id; 29 | return this; 30 | } 31 | 32 | /// 33 | /// Gets the Amazon Order Reference ID 34 | /// 35 | /// Amazon Order Reference ID 36 | public string GetAmazonOrderReferenceId() 37 | { 38 | return this.amazon_order_reference_id; 39 | } 40 | 41 | /// 42 | /// Sets the Closure reason 43 | /// 44 | /// 45 | /// CloseOrderReferenceRequest Object 46 | public CloseOrderReferenceRequest WithClosureReason(string closure_reason) 47 | { 48 | this.closure_reason = closure_reason; 49 | return this; 50 | } 51 | 52 | /// 53 | /// Gets the Closure Reason 54 | /// 55 | /// Closure Reason 56 | public string GetClosureReason() 57 | { 58 | return this.closure_reason; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/ConfirmOrderReferenceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AmazonPay.StandardPaymentRequests 4 | { 5 | /// 6 | /// Request class to set the ConfirmOrderReference API call parameters 7 | /// 8 | public class ConfirmOrderReferenceRequest : DelegateRequest 9 | { 10 | private string amazon_order_reference_id; 11 | private string success_url; 12 | private string failure_url; 13 | private decimal? amount; 14 | private string currency_code; 15 | private bool? expectImmediateAuthorization; 16 | 17 | public ConfirmOrderReferenceRequest() 18 | { 19 | SetAction(Constants.ConfirmOrderReference); 20 | } 21 | 22 | protected override ConfirmOrderReferenceRequest GetThis() 23 | { 24 | return this; 25 | } 26 | 27 | /// 28 | /// Sets the Amazon Order Reference ID 29 | /// 30 | /// 31 | /// ConfirmOrderReferenceRequest Object 32 | public ConfirmOrderReferenceRequest WithAmazonOrderReferenceId(string amazon_order_reference_id) 33 | { 34 | this.amazon_order_reference_id = amazon_order_reference_id; 35 | return this; 36 | } 37 | 38 | /// 39 | /// Gets the Amazon Order Reference ID 40 | /// 41 | /// Amazon Order Reference ID 42 | public string GetAmazonOrderReferenceId() 43 | { 44 | return this.amazon_order_reference_id; 45 | } 46 | 47 | /// 48 | /// Sets the amount 49 | /// 50 | /// 51 | /// ConfirmOrderReferenceRequest Object 52 | public ConfirmOrderReferenceRequest WithAmount(decimal? amount) 53 | { 54 | this.amount = amount; 55 | return this; 56 | } 57 | 58 | /// 59 | /// Gets the amount 60 | /// 61 | /// amount 62 | public decimal? GetAmount() 63 | { 64 | return this.amount; 65 | } 66 | 67 | /// 68 | /// Sets the Currency Code 69 | /// 70 | /// 71 | /// ConfirmOrderReferenceRequest Object 72 | public ConfirmOrderReferenceRequest WithCurrencyCode(Enum currency_code) 73 | { 74 | this.currency_code = currency_code.ToString(); 75 | return this; 76 | } 77 | 78 | /// 79 | /// Gets the Currency Code 80 | /// 81 | /// Currency Code 82 | public string GetCurrencyCode() 83 | { 84 | return this.currency_code; 85 | } 86 | 87 | /// 88 | /// Sets the success url 89 | /// 90 | /// 91 | /// ConfirmOrderReferenceRequest Object 92 | public ConfirmOrderReferenceRequest WithSuccessUrl(string success_url) 93 | { 94 | this.success_url = success_url; 95 | return this; 96 | } 97 | 98 | /// 99 | /// Gets the success url 100 | /// 101 | /// success url 102 | public string GetSuccessUrl() 103 | { 104 | return this.success_url; 105 | } 106 | 107 | /// 108 | /// Sets the failure url 109 | /// 110 | /// 111 | /// ConfirmOrderReferenceRequest Object 112 | public ConfirmOrderReferenceRequest WithFailureUrl(string failure_url) 113 | { 114 | this.failure_url = failure_url; 115 | return this; 116 | } 117 | 118 | /// 119 | /// Gets the failure url 120 | /// 121 | /// failure url 122 | public string GetFailureUrl() 123 | { 124 | return this.failure_url; 125 | } 126 | 127 | /// 128 | /// Sets the Boolean value for expect immediate authorization flag 129 | /// The accepted values are true, false and null. 130 | /// 131 | /// 132 | /// ConfirmOrderReferenceRequest Object 133 | public ConfirmOrderReferenceRequest WithExpectImmediateAuthorization(bool? expect_immediate_authorization) 134 | { 135 | this.expectImmediateAuthorization = expect_immediate_authorization; 136 | return this; 137 | } 138 | 139 | /// 140 | /// Gets the expect immediate authorization flag 141 | /// 142 | /// expect immediate authorization flag 143 | public bool? GetExpectImmediateAuthorization() 144 | { 145 | return this.expectImmediateAuthorization; 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetAuthorizationDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the GetAuthorizationDetails API call parameters 5 | /// 6 | public class GetAuthorizationDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_authorization_id; 9 | 10 | public GetAuthorizationDetailsRequest() 11 | { 12 | SetAction(Constants.GetAuthorizationDetails); 13 | } 14 | 15 | protected override GetAuthorizationDetailsRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Authorization ID 22 | /// 23 | /// 24 | /// GetAuthorizationDetailsRequest Object 25 | public GetAuthorizationDetailsRequest WithAmazonAuthorizationId(string amazon_authorization_id) 26 | { 27 | this.amazon_authorization_id = amazon_authorization_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon AUthorization ID 33 | /// 34 | /// Amazon AUthorization ID 35 | public string GetAmazonAuthorizationId() 36 | { 37 | return this.amazon_authorization_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetCaptureDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the GetCaptureDetails API call parameters 5 | /// 6 | public class GetCaptureDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_capture_id; 9 | 10 | public GetCaptureDetailsRequest() 11 | { 12 | SetAction(Constants.GetCaptureDetails); 13 | } 14 | 15 | protected override GetCaptureDetailsRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Capture ID 22 | /// 23 | /// 24 | /// GetCaptureDetailsRequest Object 25 | public GetCaptureDetailsRequest WithAmazonCaptureId(string amazon_capture_id) 26 | { 27 | this.amazon_capture_id = amazon_capture_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon Capture ID 33 | /// 34 | /// Amazon Capture ID 35 | public string GetAmazonCaptureId() 36 | { 37 | return this.amazon_capture_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetMerchantAccountStatusRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AmazonPay.StandardPaymentRequests 6 | { 7 | /// 8 | /// Request class to set the GetMerchantAccountStatus API call parameters 9 | /// 10 | public class GetMerchantAccountStatusRequest : DelegateRequest 11 | { 12 | public GetMerchantAccountStatusRequest() 13 | { 14 | SetAction(Constants.GetMerchantAccountStatus); 15 | } 16 | 17 | protected override GetMerchantAccountStatusRequest GetThis() 18 | { 19 | return this; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetMerchantNotificationConfigurationRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the GetMerchantNotificationConfiguration API call parameters, 5 | /// which are inhereted from the DelegateRequest parent object. 6 | /// 7 | public class GetMerchantNotificationConfigurationRequest : DelegateRequest 8 | { 9 | 10 | public GetMerchantNotificationConfigurationRequest() 11 | { 12 | SetAction(Constants.GetMerchantNotificationConfiguration); 13 | } 14 | 15 | protected override GetMerchantNotificationConfigurationRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetOrderReferenceDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace AmazonPay.StandardPaymentRequests 3 | { 4 | /// 5 | /// Request class to set the GetOrderReferenceDetails API call parameters 6 | /// 7 | public class GetOrderReferenceDetailsRequest : DelegateRequest 8 | { 9 | private string amazon_order_reference_id; 10 | private string address_consent_token; 11 | private string access_token; 12 | 13 | /// 14 | /// Constructor sets the Action variable for the MWS request 15 | /// 16 | public GetOrderReferenceDetailsRequest() 17 | { 18 | SetAction(Constants.GetOrderReferenceDetails); 19 | } 20 | 21 | protected override GetOrderReferenceDetailsRequest GetThis() 22 | { 23 | return this; 24 | } 25 | 26 | /// 27 | /// Sets the Amazon Order Reference ID 28 | /// 29 | /// 30 | /// GetOrderReferenceDetailsRequest Object 31 | public GetOrderReferenceDetailsRequest WithAmazonOrderReferenceId(string amazon_order_reference_id) 32 | { 33 | this.amazon_order_reference_id = amazon_order_reference_id; 34 | return this; 35 | } 36 | 37 | /// 38 | /// Gets the Amazon Order Reference ID 39 | /// 40 | /// Amazon Order Reference ID 41 | public string GetAmazonOrderReferenceId() 42 | { 43 | return this.amazon_order_reference_id; 44 | } 45 | /// 46 | /// Sets the Address Consent Token 47 | /// 48 | /// 49 | /// GetOrderReferenceDetailsRequest Object 50 | [Obsolete("use WithAccessToken instead")] 51 | public GetOrderReferenceDetailsRequest WithaddressConsentToken(string address_consent_token) 52 | { 53 | this.address_consent_token = System.Web.HttpUtility.UrlDecode(address_consent_token); 54 | return this; 55 | } 56 | 57 | /// 58 | /// Gets the Address Consent Token 59 | /// 60 | /// Address Consent Token 61 | [Obsolete("use GetAccessToken instead")] 62 | public string GetAddressConsentToken() 63 | { 64 | return this.address_consent_token; 65 | } 66 | 67 | /// 68 | /// Sets the Access Token 69 | /// 70 | /// 71 | /// GetOrderReferenceDetailsRequest Object 72 | public GetOrderReferenceDetailsRequest WithAccessToken(string access_token) 73 | { 74 | this.access_token = System.Web.HttpUtility.UrlDecode(access_token); // Decode AccessToken from Atza%7CIwEBIJfreMiImhHw6s_C... to Atza|IwEDIJfreMiImhHw6s_C... 75 | return this; 76 | } 77 | 78 | /// 79 | /// Gets the Access Token 80 | /// 81 | /// Access Token 82 | public string GetAccessToken() 83 | { 84 | return this.access_token; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/GetRefundDetailsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace AmazonPay.StandardPaymentRequests 2 | { 3 | /// 4 | /// Request class to set the GetRefundDetails API call parameters 5 | /// 6 | public class GetRefundDetailsRequest : DelegateRequest 7 | { 8 | private string amazon_refund_id; 9 | 10 | public GetRefundDetailsRequest() 11 | { 12 | SetAction(Constants.GetRefundDetails); 13 | } 14 | 15 | protected override GetRefundDetailsRequest GetThis() 16 | { 17 | return this; 18 | } 19 | 20 | /// 21 | /// Sets the Amazon Refund ID 22 | /// 23 | /// 24 | /// GetRefundDetailsRequest Object 25 | public GetRefundDetailsRequest WithAmazonRefundId(string amazon_refund_id) 26 | { 27 | this.amazon_refund_id = amazon_refund_id; 28 | return this; 29 | } 30 | 31 | /// 32 | /// Gets the Amazon Refund ID 33 | /// 34 | /// Amazon Refund ID 35 | public string GetAmazonRefundId() 36 | { 37 | return this.amazon_refund_id; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/ListOrderReferenceByNextTokenRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AmazonPay.StandardPaymentRequests 6 | { 7 | public class ListOrderReferenceByNextTokenRequest : DelegateRequest 8 | { 9 | private string next_page_token; 10 | 11 | /// 12 | /// Constructor sets the Action variable for the MWS request 13 | /// 14 | public ListOrderReferenceByNextTokenRequest() 15 | { 16 | SetAction(Constants.ListOrderReferenceByNextToken); 17 | } 18 | protected override ListOrderReferenceByNextTokenRequest GetThis() 19 | { 20 | return this; 21 | } 22 | 23 | /// 24 | /// Sets the Token for the next page of results 25 | /// 26 | /// 27 | /// ListOrderReferenceRequest Object 28 | public ListOrderReferenceByNextTokenRequest WithNextPageToken(string next_page_token) 29 | { 30 | this.next_page_token = next_page_token; 31 | return this; 32 | } 33 | 34 | /// 35 | /// Gets the Token for the next page of results 36 | /// 37 | /// 38 | /// ListOrderReferenceRequest Object 39 | public string GetNextPageToken() 40 | { 41 | return this.next_page_token; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/ListOrderReferenceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Globalization; 5 | 6 | namespace AmazonPay.StandardPaymentRequests 7 | { 8 | /// 9 | /// Request class to set the GetOrderReferenceDetails API call parameters 10 | /// 11 | public class ListOrderReferenceRequest : DelegateRequest 12 | { 13 | private string query_id; 14 | private string query_id_type; 15 | private int page_size; 16 | private string created_start_time; 17 | private string created_end_time; 18 | private string access_token; 19 | private string payment_domain; 20 | 21 | /// 22 | /// Constructor sets the Action variable for the MWS request 23 | /// 24 | public ListOrderReferenceRequest() 25 | { 26 | SetAction(Constants.ListOrderReference); 27 | } 28 | 29 | protected override ListOrderReferenceRequest GetThis() 30 | { 31 | return this; 32 | } 33 | 34 | /// 35 | /// Sets the Unique query ID for this request 36 | /// 37 | /// 38 | /// ListOrderReferenceRequest Object 39 | public ListOrderReferenceRequest WithQueryId(string query_id) 40 | { 41 | this.query_id = query_id; 42 | return this; 43 | } 44 | 45 | /// 46 | /// Sets the Query Id Type for this request (merchant order id) 47 | /// 48 | /// 49 | /// ListOrderReferenceRequest Object 50 | public ListOrderReferenceRequest WithQueryIdType(string query_id_type) 51 | { 52 | this.query_id_type = query_id_type; 53 | return this; 54 | } 55 | 56 | /// 57 | /// Sets the Page Size for this request (number of orders per page) 58 | /// 59 | /// 60 | /// ListOrderReferenceRequest Object 61 | public ListOrderReferenceRequest WithPageSize(int page_size) 62 | { 63 | this.page_size = page_size; 64 | return this; 65 | } 66 | 67 | /// 68 | /// Sets the start date boundary for search request 69 | /// 70 | /// 71 | /// ListOrderReferenceRequest Object 72 | public ListOrderReferenceRequest WithCreatedStartTime(DateTime created_start_time) 73 | { 74 | this.created_start_time = created_start_time.ToString("o"); 75 | return this; 76 | } 77 | 78 | /// 79 | /// Sets the end date boundary for search request 80 | /// 81 | /// 82 | /// ListOrderReferenceRequest Object 83 | public ListOrderReferenceRequest WithCreatedEndTime(DateTime created_end_time) 84 | { 85 | this.created_end_time = created_end_time.ToString("o"); 86 | return this; 87 | } 88 | 89 | /// 90 | /// Sets the Access Token 91 | /// 92 | /// 93 | /// GetOrderReferenceDetailsRequest Object 94 | public ListOrderReferenceRequest WithAccessToken(string access_token) 95 | { 96 | this.access_token = System.Web.HttpUtility.UrlDecode(access_token); // Decode AccessToken from Atza%7CIwEBIJfreMiImhHw6s_C... to Atza|IwEDIJfreMiImhHw6s_C... 97 | return this; 98 | } 99 | 100 | /// 101 | /// Sets the Payment Domain 102 | /// 103 | /// 104 | /// GetOrderReferenceDetailsRequest Object 105 | public ListOrderReferenceRequest WithPaymentDomain(string payment_domain) 106 | { 107 | this.payment_domain = payment_domain; 108 | return this; 109 | } 110 | 111 | /// 112 | /// Gets the Unique query ID from this request 113 | /// 114 | /// 115 | /// string query_id 116 | public string GetQueryId() 117 | { 118 | return this.query_id; 119 | } 120 | 121 | /// 122 | /// Gets the Query Id Type from this request (merchant order id) 123 | /// 124 | /// 125 | /// string query_id_type 126 | public string GetQueryIdType() 127 | { 128 | return this.query_id_type; 129 | } 130 | 131 | /// 132 | /// Gets the Page Size from this request (number of orders per page) 133 | /// 134 | /// 135 | /// int page_size 136 | public int GetPageSize() 137 | { 138 | return this.page_size; 139 | } 140 | 141 | /// 142 | /// Gets the start date boundary from search request 143 | /// 144 | /// 145 | /// DateTime created_start_time 146 | public string GetCreatedStartTime() 147 | { 148 | return this.created_start_time; 149 | } 150 | 151 | /// 152 | /// Gets the end date boundary from search request 153 | /// 154 | /// 155 | /// ListOrderReferenceRequest Object 156 | public string GetCreatedEndTime() 157 | { 158 | return this.created_end_time; 159 | } 160 | 161 | /// 162 | /// Gets the Payment Domain from this request 163 | /// 164 | /// 165 | /// int payment_domain 166 | public string GetPaymentDomain() 167 | { 168 | return this.payment_domain; 169 | } 170 | 171 | /// 172 | /// Gets the Access Token 173 | /// 174 | /// Access Token 175 | public string GetAccessToken() 176 | { 177 | return this.access_token; 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/RefundRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace AmazonPay.StandardPaymentRequests 5 | { 6 | /// 7 | /// Request class to set the Refund API call parameters 8 | /// 9 | public class RefundRequest : DelegateRequest 10 | { 11 | private string amazon_capture_id; 12 | private decimal amount; 13 | private string currency_code; 14 | private string seller_refund_note; 15 | private string refund_reference_id; 16 | private string soft_descriptor; 17 | List> providerReverseCredit = new List>(); 18 | 19 | public RefundRequest() 20 | { 21 | SetAction(Constants.Refund); 22 | } 23 | 24 | protected override RefundRequest GetThis() 25 | { 26 | return this; 27 | } 28 | 29 | /// 30 | /// sets the Amazon Capture ID 31 | /// 32 | /// 33 | /// RefundRequest Object 34 | public RefundRequest WithAmazonCaptureId(string amazon_capture_id) 35 | { 36 | this.amazon_capture_id = amazon_capture_id; 37 | return this; 38 | } 39 | 40 | /// 41 | /// Gets the Amazon Capture ID 42 | /// 43 | /// Amazon Capture ID 44 | public string GetAmazonCaptureId() 45 | { 46 | return this.amazon_capture_id; 47 | } 48 | 49 | /// 50 | /// Sets the Refund Amount 51 | /// 52 | /// 53 | /// RefundRequest Object 54 | public RefundRequest WithAmount(decimal refund_amount) 55 | { 56 | this.amount = refund_amount; 57 | return this; 58 | } 59 | 60 | /// 61 | /// Gets the Refund Amount 62 | /// 63 | /// Refund Amount 64 | public decimal GetAmount() 65 | { 66 | return this.amount; 67 | } 68 | 69 | /// 70 | /// Sets the Currency Code 71 | /// 72 | /// 73 | /// RefundRequest Object 74 | public RefundRequest WithCurrencyCode(Enum currency_code) 75 | { 76 | this.currency_code = currency_code.ToString(); 77 | return this; 78 | } 79 | 80 | /// 81 | /// Gets the Currency Code 82 | /// 83 | /// Currency Code 84 | public string GetCurrencyCode() 85 | { 86 | return this.currency_code; 87 | } 88 | 89 | /// 90 | /// Sets the Refund Refrence ID - Unique string 91 | /// 92 | /// 93 | /// RefundRequest Object 94 | public RefundRequest WithRefundReferenceId(string refund_reference_id) 95 | { 96 | this.refund_reference_id = refund_reference_id; 97 | return this; 98 | } 99 | 100 | /// 101 | /// Gets the Refund Reference ID 102 | /// 103 | /// Refund Refrence ID 104 | public string GetRefundReferenceId() 105 | { 106 | return this.refund_reference_id; 107 | } 108 | 109 | /// 110 | /// Sets the Provider Credit Reversal Details 111 | /// 112 | /// 113 | /// 114 | /// 115 | /// RefundRequest Object 116 | public RefundRequest WithProviderCreditReversalDetails(string provider_id, decimal amount, string currency_code) 117 | { 118 | Dictionary providerCreditDetails = new Dictionary(); 119 | providerCreditDetails.Clear(); 120 | providerCreditDetails[Constants.ProviderId] = provider_id; 121 | providerCreditDetails[Constants.CreditReversalAmount_Amount] = amount.ToString(); 122 | providerCreditDetails[Constants.CreditReversalAmount_CurrencyCode] = currency_code.ToUpper(); 123 | 124 | providerReverseCredit.Add(providerCreditDetails); 125 | return this; 126 | } 127 | 128 | /// 129 | /// Gets the Provider Reverse Credit 130 | /// 131 | /// Provider Reverse Credit 132 | public IList> GetProviderReverseCredit() 133 | { 134 | return this.providerReverseCredit.AsReadOnly(); 135 | } 136 | 137 | /// 138 | /// Sets the Seller Refund Note 139 | /// 140 | /// 141 | /// RefundRequest Object 142 | public RefundRequest WithSellerRefundNote(string seller_refund_note) 143 | { 144 | this.seller_refund_note = seller_refund_note; 145 | return this; 146 | } 147 | 148 | /// 149 | /// Gets the Seller Refund Note 150 | /// 151 | /// Seller Refund Note 152 | public string GetSellerRefundNote() 153 | { 154 | return this.seller_refund_note; 155 | } 156 | 157 | /// 158 | /// Sets the Soft Descriptor 159 | /// 160 | /// 161 | /// RefundRequest Object 162 | public RefundRequest WithSoftDescriptor(string soft_descriptor) 163 | { 164 | this.soft_descriptor = soft_descriptor; 165 | return this; 166 | } 167 | 168 | /// 169 | /// Gets the Soft Descriptor value 170 | /// 171 | /// Soft Descriptor 172 | public string GetSoftDescriptor() 173 | { 174 | return this.soft_descriptor; 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /AmazonPay/StandardPaymentRequests/SetMerchantNotificationConfigurationRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace AmazonPay.StandardPaymentRequests 5 | { 6 | /// 7 | /// Request class to set the SetMerchantNotificationConfigurationRequest API call parameters 8 | /// 9 | public class SetMerchantNotificationConfigurationRequest : DelegateRequest 10 | { 11 | private Dictionary> merchant_notification_urls; 12 | 13 | public SetMerchantNotificationConfigurationRequest() 14 | { 15 | SetAction(Constants.SetMerchantNotificationConfiguration); 16 | } 17 | 18 | protected override SetMerchantNotificationConfigurationRequest GetThis() 19 | { 20 | return this; 21 | } 22 | 23 | /// 24 | /// Sets the notification URLs object (Dictionary url, List Event types 25 | /// 26 | /// 27 | /// SetMerchantNotificationConfigurationRequest Object 28 | public SetMerchantNotificationConfigurationRequest WithMerchantNotificationUrls(Dictionary> notification_urls) 29 | { 30 | this.merchant_notification_urls = notification_urls; 31 | return this; 32 | } 33 | 34 | /// 35 | /// Returns the MerchantNotificationUrls Configuration 36 | /// 37 | /// Dictionary> 38 | public Dictionary> GetMerchantNotificationUrls() 39 | { 40 | return this.merchant_notification_urls; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AmazonPay/region.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AmazonPay { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class region : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static region defaultInstance = ((region)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new region()))); 19 | 20 | public static region Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CHANGES.txt: -------------------------------------------------------------------------------- 1 | Version 3.9.2 - August 2022 2 | - Fixed security vulnerabilities by upgrading Newtonsoft.Json to 13.0.1 3 | 4 | Version 3.9.1 - March 2021 5 | - Fixed security risk - Buyer Access token is passed as HTTP header instead of query parameter in URL for GetUserInfo API 6 | 7 | Version 3.9.0 - February 2021 8 | - Added additional attribute (expectImmediateAuthorization) to ConfirmOrderReference. This value can be set to true or false (Boolean). See Amazon Pay Strong Customer Authentication (SCA) Upgrade Integration Guide for more information. 9 | 10 | Version 3.8.1 January 2021 11 | - Adding support for strong name support (key for signing) 12 | 13 | Version 3.8.0 December 2020 14 | - Added support for .Net Standard 2.0 15 | 16 | Version 3.7.0 January 2020 17 | - Added ListOrderReference API Call 18 | - Add ListOrderReferenceByNextToken API call 19 | 20 | Version 3.6.1 December 2019 21 | - Add GetMerchantNotificationConfiguration API call 22 | - Add SetMerchantNotificationConfiguration API call 23 | 24 | Version 3.6.0.2 25 | - Added additional attributes (success_url, failure_url) to ConfirmBillingAgreement and (subscription_amount, currency_code) to SetBillingAgreement Details. 26 | - See Amazon Pay Strong Customer Authentication (SCA) Upgrade Integration Guide for more information. 27 | 28 | Version 3.5.1 June 2019 29 | - Updated Newtonsoft.Json version number AmazonPay.nuspec to match changes that were deployed in 3.5.0 30 | 31 | Version 3.5.0 Febraury 2019 32 | - Add support for 'Amazon Pay Strong Customer Authentication (SCA) Upgrade' fields in ConfirmOrderReference API. 33 | - Add support for Supplementary data in CreateOrderReferenceForId and AuthorizeOnBillingAgreement APIs. 34 | - Add getters for refundedAmount and refundedAmountCurrencyCode in CaptureResponse. 35 | 36 | Version 3.4.3.2 October 2018 37 | - Fix timestamp generation for signatures. 38 | 39 | Version 3.4.3.1 August 2018 40 | - Update SetOrderAttributes comments with mws auth token parameter in Client.cs. 41 | 42 | Version 3.4.3 August 2018 43 | - Set mws auth token in SetOrderAttributes response. 44 | 45 | Version 3.4.2 July 2018 46 | - Add parameter SupplementaryData to SetOrderAttributes, SetOrderReferenceDetails and GetOrderReferenceDetails API calls. 47 | - Update Newtonsoft JSON.NET library version from 4.5.11 to 11.0.2. 48 | 49 | Version 3.4.1 May 2018 50 | - Update json files with the new SigningCertURL value. 51 | 52 | Version 3.4.0 April 2018 53 | - Add support for GetMerchantAccountStatus API call. 54 | - Refactor all response classes. 55 | - Refactor all request classes. 56 | - Add unit tests for all responses. 57 | 58 | Version 3.3.2 February 2018 59 | - Update version number in all relevant files 60 | 61 | Version 3.3.1 December 2017 62 | - Fix default values of inherit_shipping_address, capture_now and confirm_now flags in all APIs 63 | - Amazon Pay C# SDK Strong Named Assembly release 64 | 65 | Version 3.3.0 November 2017 66 | - Add support for new SetOrderAttributes API call. 67 | - Fix ResponseParser.cs to avoid race condition in setting xml. 68 | 69 | Version 3.2.0 September 2017 70 | - Support for Chargeback IPN 71 | 72 | Version 3.1.1 August 2017 73 | - Amazon Pay C# SDK Strong Named Assembly release 74 | 75 | Version 3.1.0 - July 2017 76 | - Missing getters in C# SDK: BillingAgreementState, SoftDecline, CreationTimestamp 77 | - Extend C# SDK with convenience functions for getting payment details 78 | - SDK changes for Multi-Currency Payments 79 | - Update SDK with ability to retrieve payment instrument information 80 | - I18N aware SDK - amount field 81 | - Code Cleanup - During this, some of the class fields access modifiers have been changed from 'public' to 'private'. 82 | If you were using class fields to get and set the values, please use the getters and setters available for those classes. 83 | - Cleanup to make the project compatible with Debug and Release mode by adding 'xml comments' for getters in class files and fixing the UnitTests class-paths. 84 | - Added unit-tests for GetOrderReferenceDetails, GetAuthorizationDetails, GetCaptureDetails, GetRefundDetails responses. 85 | 86 | Version 3.0.0 - Feb 2017 87 | - Amazon Pay Rebrand Change 88 | 89 | Version 2.0.0 - Oct 2016 90 | - Initial Pay With Amazon Release -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/amzn/amazon-pay-sdk-csharp/issues), or [recently closed](https://github.com/amzn/amazon-pay-sdk-csharp/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/amzn/amazon-pay-sdk-csharp/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/amzn/amazon-pay-sdk-csharp/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Amazon Pay SDK (C#) 2 | Copyright 2017-2018 Amazon Technologies, Inc 3 | 4 | This product includes software developed by 5 | Amazon Technologies, Inc (http://www.amazon.com/). 6 | 7 | /******************************************************************************* 8 | * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * 11 | * You may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at: 13 | * http://aws.amazon.com/apache2.0 14 | * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 15 | * CONDITIONS OF ANY KIND, either express or implied. See the License 16 | * for the 17 | * specific language governing permissions and limitations under the 18 | * License. 19 | * ***************************************************************************** 20 | */ 21 | -------------------------------------------------------------------------------- /UnitTests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /UnitTests/Json.txt: -------------------------------------------------------------------------------- 1 | { 2 | "GetOrderReferenceDetailsResponse": { 3 | "@xmlns": "http://mws.amazonservices.com/schema/OffAmazonPayments/2013-01-01", 4 | "AmazonOrderReferenceId": "S01-5806490-2147504", 5 | "ExpirationTimestamp": "2015-09-27T02:18:33.408Z", 6 | "SellerNote": "This is testing API call" 7 | } 8 | } -------------------------------------------------------------------------------- /UnitTests/TestFiles/AuthorizeNotification.json: -------------------------------------------------------------------------------- 1 | { 2 | "Type": "Notification", 3 | "MessageId": "9aacc6b9-c502-5e7c-85be-9360c11ad32d", 4 | "TopicArn": "arn:aws:sns:us-east-1:291180941288:A3BXB0YN3XH17HA10Z9MFRRW4V14", 5 | "Message": "{\"ReleaseEnvironment\":\"Sandbox\",\"MarketplaceID\":\"623690\",\"Version\":\"2013-01-01\",\"NotificationType\":\"PaymentAuthorize\",\"SellerId\":\"A10Z9MFRRW4V14\",\"NotificationReferenceId\":\"1176c49b-0599-45b7-8c2e-4776e377332c\",\"Timestamp\":\"2019-08-22T20:58:00.354Z\",\"NotificationData\":\"\\n \\n S01-7922233-4167005-A092060<\\/AmazonAuthorizationId>\\n 5d5f01d72e0c3<\\/AuthorizationReferenceId>\\n \\n 19.95<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/AuthorizationAmount>\\n \\n 0.0<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/CapturedAmount>\\n \\n 0.0<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/AuthorizationFee>\\n \\n 2019-08-22T20:57:59.609Z<\\/CreationTimestamp>\\n 2019-09-21T20:57:59.609Z<\\/ExpirationTimestamp>\\n \\n Open<\\/State>\\n 2019-08-22T20:57:59.609Z<\\/LastUpdateTimestamp>\\n <\\/AuthorizationStatus>\\n false<\\/SoftDecline>\\n \\n false<\\/CaptureNow>\\n \\n <\\/AuthorizationDetails>\\n<\\/AuthorizationNotification>\"}", 6 | "Timestamp": "2019-08-22T20:58:00.359Z", 7 | "SignatureVersion": "1", 8 | "Signature": "Sqqrwenmjz/gu1Ape79xv76dP2wFHgazWCTJS3BEP8HXAdnYKSYxzVjUCtmWaBBBcCJV7Di/D8HJKGoe0osMcqhovK5znVYdGt/bi30gQBpFyzI0OgYS3u5loeFOQHcvMZp2Iox1ao4UwulZUlGH1RTu5t8PfRDsbhOrMFlMfYcXuUSvTTWwAkqx4YpL//7uetIa39EzAb4qUHkfwGg0xdHGiVsG0gRV+zKzanYZ6z3X0Wdzs46BukTqQu6iwZqDAtJDQRDiiBos1uwFIXBMBxxISGAQ8LzjQH1YYrIJu6Z/CTyH/byVRuhgZFxhS1Wh7WeQ+vH9G7IVHFupZxveBQ==", 9 | "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem", 10 | "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:291180941288:A3BXB0YN3XH17HA10Z9MFRRW4V14:85b19ce1-40d9-43b5-9458-a0867511b2a0" 11 | } -------------------------------------------------------------------------------- /UnitTests/TestFiles/AuthorizeNotification_BadSignature.json: -------------------------------------------------------------------------------- 1 | { 2 | "Type": "Notification", 3 | "MessageId": "9aacc6b9-c502-5e7c-85be-9360c11ad32d", 4 | "TopicArn": "arn:aws:sns:us-east-1:291180941288:A3BXB0YN3XH17HA10Z9MFRRW4V14", 5 | "Message": "{\"ReleaseEnvironment\":\"Sandbox\",\"MarketplaceID\":\"623690\",\"Version\":\"2013-01-01\",\"NotificationType\":\"PaymentAuthorize\",\"SellerId\":\"A10Z9MFRRW4V14\",\"NotificationReferenceId\":\"1176c49b-0599-45b7-8c2e-4776e377332c\",\"Timestamp\":\"2019-08-22T20:58:00.354Z\",\"NotificationData\":\"\\n \\n S01-7922233-4167005-A092060<\\/AmazonAuthorizationId>\\n 5d5f01d72e0c3<\\/AuthorizationReferenceId>\\n \\n 19.95<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/AuthorizationAmount>\\n \\n 0.0<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/CapturedAmount>\\n \\n 0.0<\\/Amount>\\n USD<\\/CurrencyCode>\\n <\\/AuthorizationFee>\\n \\n 2019-08-22T20:57:59.609Z<\\/CreationTimestamp>\\n 2019-09-21T20:57:59.609Z<\\/ExpirationTimestamp>\\n \\n Open<\\/State>\\n 2019-08-22T20:57:59.609Z<\\/LastUpdateTimestamp>\\n <\\/AuthorizationStatus>\\n false<\\/SoftDecline>\\n \\n false<\\/CaptureNow>\\n \\n <\\/AuthorizationDetails>\\n<\\/AuthorizationNotification>\"}", 6 | "Timestamp": "2019-08-22T20:58:00.359Z", 7 | "SignatureVersion": "1", 8 | "Signature": "XXXXSqqrwenmjz/gu1Ape79xv76dP2wFHgazWCTJS3BEP8HXAdnYKSYxzVjUCtmWaBBBcCJV7Di/D8HJKGoe0osMcqhovK5znVYdGt/bi30gQBpFyzI0OgYS3u5loeFOQHcvMZp2Iox1ao4UwulZUlGH1RTu5t8PfRDsbhOrMFlMfYcXuUSvTTWwAkqx4YpL//7uetIa39EzAb4qUHkfwGg0xdHGiVsG0gRV+zKzanYZ6z3X0Wdzs46BukTqQu6iwZqDAtJDQRDiiBos1uwFIXBMBxxISGAQ8LzjQH1YYrIJu6Z/CTyH/byVRuhgZFxhS1Wh7WeQ+vH9G7IVHFupZxveBQ==", 9 | "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem", 10 | "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:291180941288:A3BXB0YN3XH17HA10Z9MFRRW4V14:85b19ce1-40d9-43b5-9458-a0867511b2a0" 11 | } -------------------------------------------------------------------------------- /UnitTests/TestFiles/AuthorizeResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | USD 7 | 1.00 8 | 9 | 10 | USD 11 | 0 12 | 13 | AMZ*testikiki 14 | 2015-11-29T21:02:38.508Z 15 | 16 | S01-9821095-1837200-C041953 17 | 18 | 19 | 2015-10-30T21:02:38.508Z 20 | Closed 21 | MaxCapturesProcessed 22 | 23 | 24 | USD 25 | 0.00 26 | 27 | true 28 | testing 29 | 2015-10-30T21:02:38.508Z 30 | S01-9821095-1837200-A041953 31 | asdcdsd5iiiii 32 | 33 | 34 | 35 | adabc99d-8351-48dc-acef-1bc049215f55 36 | 37 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/BillingAgreementDetailsResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | C01-3925266-2250830 6 | 7 | Draft 8 | 9 | 10 | Physical 11 | 12 | BC 13 | 9999999999 14 | Vancouver 15 | CA 16 | V6C 3B5 17 | TEST_NAME 18 | 999 Canada Place 140 19 | 20 | 21 | false 22 | 23 | 24 | BuyerConsentNotSet 25 | The buyer has not given consent for this billing agreement. 26 | 27 | 28 | 29 | 30 | Test Buyer 31 | testbuyer2@amazon.com 32 | 33 | Sandbox 34 | 2015-11-02T17:36:30.173Z 35 | 36 | 2015-11-01T00:00:00Z 37 | 38 | USD 39 | 500.00 40 | 41 | 42 | USD 43 | 500 44 | 45 | 2015-12-01T00:00:00Z 46 | 47 | 48 | 49 | 50 | d69e8d60-3682-43d7-bf5e-e2ef64dc685e 51 | 52 | 53 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/CancelOrderReference.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 0714c2dd-c3fa-45af-afc7-b48055cfd7bf 6 | 7 | 8 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/CaptureResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | testcsal 6 | 7 | USD 8 | 0.00 9 | 10 | S01-9821095-1837200-C053432 11 | 2015-10-30T21:47:10.797Z 12 | AMZ*testsd 13 | 14 | 15 | 2015-10-30T21:47:10.797Z 16 | Completed 17 | 18 | 19 | 20 | USD 21 | 0 22 | 23 | 24 | USD 25 | 1.00 26 | 27 | 28 | 29 | 30 | 1ec2813f-3d33-4b3a-a198-a25cd608310d 31 | 32 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/CloseAuthorizationResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 3e130e5b-41ae-41fd-b307-dbbf45663d79 6 | 7 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/CloseBillingAgreementResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 7541230f-e349-4180-a4ac-ba9f2cf6ac79 6 | 7 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/CloseOrderReference.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5f20169b-7ab2-11df-bcef-d35615e2b044 5 | 6 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/ConfirmBillingAgreementResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 3d1db999-b790-47bb-87d3-9c673c38a1ed 6 | 7 | 8 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/ConfirmOrderReference.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | f1f52572-a347-4f7a-a630-be066f3ba827 5 | 6 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetAuthorizationDetails.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | USD 7 | 1.00 8 | 9 | 10 | USD 11 | 1.00 12 | 13 | AMZ*testikiki 14 | 2015-11-29T21:02:38.508Z 15 | 16 | S01-9821095-1837200-C041953 17 | 18 | 19 | 2015-10-30T21:02:38.508Z 20 | MaxCapturesProcessed 21 | Closed 22 | 23 | 24 | USD 25 | 0.00 26 | 27 | true 28 | testing 29 | 2015-10-30T21:02:38.508Z 30 | S01-9821095-1837200-A041953 31 | asdcdsd5iiiii 32 | 33 | 34 | 35 | 6173ac5a-8915-4541-922f-f9e104930731 36 | 37 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetCaptureDetails.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | asdcdsd5iiiii 6 | 7 | USD 8 | 0.00 9 | 10 | 2015-10-30T21:02:38.608Z 11 | S01-9821095-1837200-C041953 12 | AMZ*testikiki 13 | 14 | 15 | 2015-10-30T21:02:38.608Z 16 | Completed 17 | 18 | 19 | USD 20 | 0 21 | 22 | testing 23 | 24 | USD 25 | 1.00 26 | 27 | 28 | 29 | 30 | 21acf393-d625-497e-b2c0-d1dc0b0d2bb6 31 | 32 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetCaptureDetails_MultiCurrency.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | EUR 7 | 1.88 8 | 9 | 7a087b12a3cb4d0ba3cb4230aa953de4 10 | 11 | EUR 12 | 0.00 13 | 14 | AMZ*Matt's Test Stor 15 | 16 | 1.1297854087 17 | 18 | CHF 19 | 0.99 20 | 21 | S02-7423235-4925359-C052508 22 | 2017-06-27T22:07:18.931Z 23 | 24 | 2017-06-27T22:07:18.999Z 25 | Completed 26 | 27 | 28 | 29 | CHF 30 | 0 31 | 32 | 33 | 34 | 35 | a17ee562-9a97-4b22-8487-20e8e7230639 36 | 37 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetMerchantAccountStatusResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | ACTIVE 4 | 5 | 6 | 51eaf2d5-0b9c-4630-b0e7-1ef61582076a 7 | 8 | 9 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetMerchantNotificationConfiguration.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | https://www.xyz.com 6 | 7 | PAYMENT_CAPTURE 8 | 9 | 10 | 11 | https://www.abc.com 12 | 13 | ORDER_REFERENCE,PAYMENT_AUTHORIZE 14 | 15 | 16 | 17 | 18 | 19 | 7ccba952-b840-4b5b-bd3c-5585c574b981 20 | 21 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetOrderReferenceDetails.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A2STY9B5HPCDII 6 | PSP-Order-Id 7 | 8 | 9 | 2017-07-23T22:01:49.694Z 10 | Open 11 | 12 | 13 | Physical 14 | 15 | New York 16 | NY 17 | 10101-9876 18 | US 19 | 20 | 21 | 2018-01-19T21:58:56.816Z 22 | 23 | S01-9111020-6707923-A077760 24 | 25 | 26 | Java Cosmos Store 27 | Java SDK OneTime Checkout Sample 28 | 29 | Antiques 30 | Apparel 31 | 32 | test-12345 33 | {"Travel": {"version" : "1.0", "PassengerName": "Megan Fisher", "AirlineCode": "AS", "FlightDate": "2018-01-01","DepartureAirport": "SEA"},"Accommodation": {"version" : "2.0","GuestName": "John Walker","LengthOfStay": 2,"NumberOfGuests": 1}} 34 | 35 | 36 | Visa 37 | 11 38 | Amazon Pay (Visa **11) 39 | false 40 | 41 | 42 | USD 43 | 1.29 44 | 45 | 46 | REQUIRED 47 | 48 | 49 | John Green 50 | test@gmail.com 51 | 52 | Sandbox 53 | 54 | z50RVvXyKBkhRX40zy2VazJIfJBRmhGF32FUW9Np6PU= 55 | 56 | 1st Amazon Pay OneTime Checkout Order 57 | S01-9111020-6707923 58 | 2017-07-23T21:58:56.816Z 59 | 60 | 61 | WI 62 | Appleton 63 | US 64 | 54911 65 | Christopher C. Conn 66 | 4996 Rockford Mountain Lane 67 | 68 | Physical 69 | 70 | false 71 | 72 | 73 | 74 | 373eb307-5f37-468c-b6ba-1ef578ac2f51 75 | 76 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetProviderCreditDetailsResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | TEST_SELLER_ID 6 | 7 | S01-2117025-2155793-Q068906 8 | S01-2117025-2155793-Q023847 9 | 10 | 11 | USD 12 | 1.00 13 | 14 | S01-2117025-2155793nesasdh 15 | TEST_PROVIDER_ID 16 | 2015-10-23T00:30:42.996Z 17 | S01-2117025-2155793-P045170 18 | 19 | 2015-10-26T23:26:46.945Z 20 | MaxAmountReversed 21 | Closed 22 | 23 | 24 | USD 25 | 1.00 26 | 27 | 28 | 29 | 30 | 21162350-7135-46ae-aa20-68d5361cef17 31 | 32 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetProviderCreditReversalDetailsResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | S01-2117025-2155793-P045170 6 | TEST_SELLER_ID 7 | 8 | USD 9 | 1.00 10 | 11 | S01-2117025-2155793nesasdh 12 | TEST_PROVIDER_ID 13 | 14 | 2015-10-26T23:26:46.945Z 15 | Closed 16 | MaxAmountReversed 17 | 18 | 2015-10-23T00:30:42.996Z 19 | 20 | 21 | 22 | 10a7736b-bb9b-447c-9be1-4f5e76166e48 23 | 24 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetRefundDetails.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | testRefundId1354077 6 | SellerInitiated 7 | testing 8 | 2015-11-02T21:18:17.751Z 9 | AMZ*test 10 | 11 | 2015-11-02T21:18:48.932Z 12 | Completed 13 | 14 | 15 | USD 16 | 0.00 17 | 18 | 19 | USD 20 | 0.50 21 | 22 | S01-5695290-1354077-R072290 23 | 24 | 25 | 26 | 98cdadd5-8b44-4757-8e4f-351f39af7fcf 27 | 28 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetRefundDetails_MultiCurrency.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | EUR 7 | 1.03 8 | 9 | 10 | 11 | 2017-06-28T18:15:07.659Z 12 | Completed 13 | 14 | AMZ*Matt's Test Stor 15 | 9.9248293483 16 | aed9ba8bee564c8cb943bd6481633ad1 17 | SellerInitiated 18 | 2017-06-28T18:14:34.752Z 19 | 20 | EUR 21 | 0.00 22 | 23 | 24 | NOK 25 | 1.33 26 | 27 | S02-8274313-3487267-R019346 28 | 29 | 30 | 31 | 3b14705b-0a11-4b05-98d3-eb62c9bf1d22 32 | 33 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/GetServiceStatusResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | GREEN 5 | 2016-11-27T02:57:30.504Z 6 | 7 | 8 | 93437336-70dd-4359-b453-f13a90dccb99 9 | 10 | 11 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/ListOrderReference.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Sandbox 6 | 7 | 2020-01-03T16:00:05.506Z 8 | Open 9 | 10 | S01-9222526-6648893 11 | 2020-01-03T15:59:14.478Z 12 | 13 | IntroProd 14 | YOUR_CUSTOM_ORDER_REFERENCE_ID 15 | 16 | 17 | USD 18 | 100.00 19 | 20 | 21 | 22 | Sandbox 23 | 24 | AMAZON ON BEHALF OF MERCHANT 25 | 2020-01-03T15:58:35.672Z 26 | SellerCanceled 27 | Canceled 28 | 29 | S01-3139477-8890805 30 | 2020-01-03T15:58:19.663Z 31 | 32 | IntroProd 33 | YOUR_CUSTOM_ORDER_REFERENCE_ID 34 | 35 | 36 | USD 37 | 100.00 38 | 39 | 40 | 41 | eyJuZXh0UGFnZVRva2VuIjoiQUFBQUFBQUFBQUZoeS84eVBPTy9LK05Za0hTV2s0Ukx0SEZWNUxZaC85bG0zRTJqem95dmd4eHhJM1d2blEyUG5FZGtlYlBnWjE1SjJ3bmFud2ZoUTUxU21MSm5BSzJqMTFkTWphVEJxR0lURVR4a0QrWHNLaFJMWEU3KzU4NDliYUs2Tjh2OVdRVlpDTWh2WDNsZXNzbjVMeFFUUWFnU3RWbVFLR3lRUHgvWGJLaWJ4ZjlOM3RjTHlHLytheUY0ZEwzUlpyc1ZKNHM3RXRYUStpVUVtZUJGU29VRnFwQ2FPcFMxenplY1hmdVVGSUY3NHoxQWpjaWRKbkU3UHRXTlYvMHNxa0VxSzJyOCtjVUcvdEIvdjRYa0U4Y0orRE0xdGx4T3JZSFlzTEwrUGNjcFRTTGFwbEVKQUlWYmkrNFRNMzNrOURRaWpzZytydWZjZ0paNWNTZ2puQzUwcitiNXB5YXRBbEV2aGUybXFFdVVtZ0cvM3pITWtKU1E1R1hVZUI2b2FWZkZKeVJjRjdxN0NxaGtqdHVhUFZQbHZJalFKM2UvLzduNGZKbHpYell6SDJIeHp2b3RzUm9JOXlqRTZhaFFKK1BTR2w1VVNGTmZuQldEcHlBSHBITDhpQ1BMa2MwVFpyZHNHMGFLM0srQ3hMKyt1OHFCYjBTTGtPSVAzTmFyVU1CbHZmM2kxVHRtdXpCS2YwaVBpT0s1TUtPbFJGUXgyMlplQmVjTFR1YnA2UFJpSDQ2YUkxcnBGaWNIZ1hLdGJlRkt4R0Q3OXVYbVBtTUJDdW5ueE83V3RZRTloZW9kam9mdnhCTldVM3lIcE9aZnA4bTVZV2tRMmJvTldTbWlzVDZGTnJjdUdrazQxN3YzZ1UzMEMxQWkvMWNERy9nRDUrWEdrbkE0TFhicHpDeEsvVlNMQ1lXb3paSkVMRkdxWXppVTNNV2RXcWhQdkNLbDVwWE5YYTZNZDhXUzJUT0NuZm4yek5DSWxJWm9LYy9FdjlHNHNhV0RLQ0FMVVF0Tm9kZWtKZHlWY0tvWFpDK0ZSRCsrOVZTa3ltNkwiLCJtYXJrZXRwbGFjZUlkIjoiQTNCWEIwWU4zWEgxN0gifQ== 42 | 43 | 44 | 8203cfe9-caec-42ba-95e6-fd12277ee3cb 45 | 46 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/RefundResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | testRefundId1354077 6 | SellerInitiated 7 | testing 8 | 2015-11-02T21:18:17.751Z 9 | AMZ*test 10 | 11 | 2015-11-02T21:18:17.751Z 12 | Pending 13 | 14 | 15 | USD 16 | 0.00 17 | 18 | 19 | USD 20 | 0.50 21 | 22 | S01-5695290-1354077-R072290 23 | 24 | 25 | 26 | 2be495ee-0a86-4357-a6a5-5f0af88398d9 27 | 28 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/SetMerchantNotificationConfiguration.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6cc80335-f1bc-4689-bff6-8e7072df537c 4 | 5 | -------------------------------------------------------------------------------- /UnitTests/TestFiles/ValidateBillingAgreementResponse.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 2015-11-02T17:38:29.511Z 6 | Open 7 | 8 | Success 9 | 10 | 11 | 0f48a4e0-2a7c-4036-9a8a-339e419fd53f 12 | 13 | 14 | -------------------------------------------------------------------------------- /UnitTests/UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0;net20 5 | netcoreapp3.0 6 | false 7 | Copyright © 2017-2020 8 | 3.8.0 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | NETSTANDARD; 40 | 41 | 42 | NETFULL 43 | app.config 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Always 53 | 54 | 55 | Always 56 | 57 | 58 | Always 59 | 60 | 61 | 62 | 63 | 64 | Always 65 | 66 | 67 | Always 68 | 69 | 70 | Always 71 | 72 | 73 | Always 74 | 75 | 76 | Always 77 | 78 | 79 | Always 80 | 81 | 82 | Always 83 | 84 | 85 | Always 86 | 87 | 88 | Always 89 | 90 | 91 | Always 92 | 93 | 94 | Always 95 | 96 | 97 | Always 98 | 99 | 100 | Always 101 | 102 | 103 | Always 104 | 105 | 106 | Always 107 | 108 | 109 | Always 110 | 111 | 112 | Always 113 | 114 | 115 | Always 116 | 117 | 118 | Always 119 | 120 | 121 | Always 122 | 123 | 124 | Always 125 | 126 | 127 | Always 128 | 129 | 130 | Always 131 | 132 | 133 | Always 134 | 135 | 136 | Always 137 | 138 | 139 | Always 140 | 141 | 142 | Always 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /UnitTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "appSettings": { 10 | "sanitizeList": "RequestID;Error;SellerId;SignatureMethod;CaptureNow" 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /UnitTests/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "merchant_id": "test", 3 | "access_Key": "test", 4 | "secret_Key": "test", 5 | "currency_Code": "USD", 6 | "client_Id": "test", 7 | "region": "us", 8 | "sandbox": true, 9 | "application_Name": "sdk testing", 10 | "application_Version": "1.0", 11 | "proxy_Host": null, 12 | "proxy_Port": -1, 13 | "proxy_Username": null, 14 | "proxy_Password": null 15 | } --------------------------------------------------------------------------------