Skip to content

Commit

Permalink
Adding dcd co-relationid header
Browse files Browse the repository at this point in the history
  • Loading branch information
ramittal committed Feb 26, 2017
1 parent 175c051 commit 10c17f9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions Authorize.NET/Api/Controllers/Bases/ApiOperationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ protected void SetApiRequest(TQ apiRequest) {
_apiRequest = apiRequest;
}

public Guid RequestId { set; get; }

public TS GetApiResponse() {
return _apiResponse;
}
Expand Down Expand Up @@ -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<ANetApiRequest, ANetApiResponse>.RunEnvironment; }
if (null == environment) throw new ArgumentException(NullEnvironmentErrorMessage);

var httpApiResponse = HttpUtility.PostData<TQ, TS>(environment, GetApiRequest());
var httpApiResponse = HttpUtility.PostData<TQ, TS>(environment, GetApiRequest(), this.RequestId);

if (null != httpApiResponse)
{
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions Authorize.NET/Util/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static class Constants {

public const string SDKVersion = "1.9.1";

public static readonly string DCDRequestIdHeaderName = "x-DCD-RequestId";
}
#pragma warning restore 1591
}
6 changes: 5 additions & 1 deletion Authorize.NET/Util/HttpUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static Uri GetPostUrl(AuthorizeNet.Environment env)
return postUrl;
}

public static ANetApiResponse PostData<TQ, TS>(AuthorizeNet.Environment env, TQ request)
public static ANetApiResponse PostData<TQ, TS>(AuthorizeNet.Environment env, TQ request, Guid requestId)
where TQ : ANetApiRequest
where TS : ANetApiResponse
{
Expand All @@ -48,6 +48,10 @@ public static ANetApiResponse PostData<TQ, TS>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions AuthorizeNETtest/CardPresentGatewayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void SendTest_Auth_Approved()

CardPresentGateway target = new CardPresentGateway(ApiLogin, TransactionKey, true);

IGatewayRequest request = new CardPresentAuthorizationRequest((decimal)30.11, "4111111111111111", "02", "16");
IGatewayRequest request = new CardPresentAuthorizationRequest((decimal)30.11, "4111111111111111", "02", "20");
string description = "CP Auth transaction approved testing";

IGatewayResponse actual = target.Send(request, description);
Expand Down Expand Up @@ -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", "16");
IGatewayRequest request = new CardPresentAuthorizationRequest(amount, "4111111111111111", "02", "24");
string description = "CP Auth transaction approved testing";

IGatewayResponse response = target.Send(request, description);
Expand Down

0 comments on commit 10c17f9

Please sign in to comment.