diff --git a/Authorize.NET/Api/Controllers/Bases/ApiOperationBase.cs b/Authorize.NET/Api/Controllers/Bases/ApiOperationBase.cs index c0c46e76..bfc36b3f 100644 --- a/Authorize.NET/Api/Controllers/Bases/ApiOperationBase.cs +++ b/Authorize.NET/Api/Controllers/Bases/ApiOperationBase.cs @@ -61,6 +61,8 @@ protected void SetApiRequest(TQ apiRequest) { _apiRequest = apiRequest; } + public Guid RequestId { set; get; } + public TS GetApiResponse() { return _apiResponse; } @@ -88,13 +90,18 @@ public TS ExecuteWithApiResponse(AuthorizeNet.Environment environment = null) public void Execute(AuthorizeNet.Environment environment = null) { BeforeExecute(); + + if ( Guid.Empty == this.RequestId) + { + this.RequestId = Guid.NewGuid(); + } //Logger.debug(string.Format(CultureInfo.InvariantCulture, "Executing Request:'{0}'", XmlUtility.GetXml(GetApiRequest()))); if (null == environment) { environment = ApiOperationBase.RunEnvironment; } if (null == environment) throw new ArgumentException(NullEnvironmentErrorMessage); - var httpApiResponse = HttpUtility.PostData(environment, GetApiRequest()); + var httpApiResponse = HttpUtility.PostData(environment, GetApiRequest(), this.RequestId); if (null != httpApiResponse) { @@ -190,7 +197,7 @@ private void Validate() { var impersonationAuthenticationType = merchantAuthenticationType.impersonationAuthentication; if ( null != impersonationAuthenticationType) throw new IllegalArgumentException("ImpersonationAuthenticationType needs to be null"); */ - // impersonationAuthenticationType.setPartnerLoginId(CnpApiLoginIdKey); + // impersonationAuthenticationType.setPartnerLoginId(CnpApiLoginIdKey); // impersonationAuthenticationType.setPartnerTransactionKey(CnpTransactionKey); // merchantAuthenticationType.setImpersonationAuthentication(impersonationAuthenticationType); diff --git a/Authorize.NET/Util/Constants.cs b/Authorize.NET/Util/Constants.cs index 0daf447e..3dd5eb17 100644 --- a/Authorize.NET/Util/Constants.cs +++ b/Authorize.NET/Util/Constants.cs @@ -28,6 +28,7 @@ public static class Constants { public const string SDKVersion = "1.9.4"; + public static readonly string DCDRequestIdHeaderName = "x-DCD-RequestId"; } #pragma warning restore 1591 } diff --git a/Authorize.NET/Util/HttpUtility.cs b/Authorize.NET/Util/HttpUtility.cs index a3673de5..70618ecc 100644 --- a/Authorize.NET/Util/HttpUtility.cs +++ b/Authorize.NET/Util/HttpUtility.cs @@ -29,7 +29,7 @@ private static Uri GetPostUrl(AuthorizeNet.Environment env) return postUrl; } - public static ANetApiResponse PostData(AuthorizeNet.Environment env, TQ request) + public static ANetApiResponse PostData(AuthorizeNet.Environment env, TQ request, Guid requestId) where TQ : ANetApiRequest where TS : ANetApiResponse { @@ -48,6 +48,10 @@ public static ANetApiResponse PostData(AuthorizeNet.Environment env, TQ webRequest.KeepAlive = true; webRequest.Proxy = SetProxyIfRequested(webRequest.Proxy); + //add corelationId + webRequest.Headers[Constants.DCDRequestIdHeaderName] = requestId.ToString(); + Logger.info( string.Format("Co-relationId for the web-request: {0} ", requestId)); + //set the http connection timeout var httpConnectionTimeout = AuthorizeNet.Environment.getIntProperty(Constants.HttpConnectionTimeout); webRequest.Timeout = (httpConnectionTimeout != 0 ? httpConnectionTimeout : Constants.HttpConnectionDefaultTimeout); diff --git a/AuthorizeNETtest/Api/Controllers/SampleTest/ArbSubscriptionSampleTest.cs b/AuthorizeNETtest/Api/Controllers/SampleTest/ArbSubscriptionSampleTest.cs index 9673e9d7..0bc74fa2 100644 --- a/AuthorizeNETtest/Api/Controllers/SampleTest/ArbSubscriptionSampleTest.cs +++ b/AuthorizeNETtest/Api/Controllers/SampleTest/ArbSubscriptionSampleTest.cs @@ -49,6 +49,8 @@ public void SampleCodeGetSubscriptionList() }; var createController = new ARBCreateSubscriptionController(createRequest); + createController.RequestId = Guid.NewGuid(); + createController.Execute(); var createResponse = createController.GetApiResponse(); Assert.IsNotNull(createResponse.subscriptionId); diff --git a/AuthorizeNETtest/CardPresentGatewayTest.cs b/AuthorizeNETtest/CardPresentGatewayTest.cs index ef3bf606..7c7fd049 100644 --- a/AuthorizeNETtest/CardPresentGatewayTest.cs +++ b/AuthorizeNETtest/CardPresentGatewayTest.cs @@ -162,7 +162,7 @@ private string SendAuthOnly(decimal amount, bool returnTransID) CardPresentGateway target = new CardPresentGateway(ApiLogin, TransactionKey, true); - IGatewayRequest request = new CardPresentAuthorizationRequest(amount, "4111111111111111", "02", "20"); + IGatewayRequest request = new CardPresentAuthorizationRequest(amount, "4111111111111111", "02", "24"); string description = "CP Auth transaction approved testing"; IGatewayResponse response = target.Send(request, description);