Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dcd co-relationid header #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.4";

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
2 changes: 1 addition & 1 deletion AuthorizeNETtest/CardPresentGatewayTest.cs
Original file line number Diff line number Diff line change
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", "20");
IGatewayRequest request = new CardPresentAuthorizationRequest(amount, "4111111111111111", "02", "24");
string description = "CP Auth transaction approved testing";

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