Skip to content

Commit 3d9547d

Browse files
committed
mti field check should be enabled only for auth service
1 parent 1c203d9 commit 3d9547d

6 files changed

Lines changed: 28 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,7 @@ keytool -list -v -keystore <Your_keystore_name>`
174174
- Second entry should be for `CyberSource_SJC_US` certificate with alias name as CyberSource_SJC_US
175175

176176
## PoolingHttpClient
177-
PoolingHttpClient is built using the apache's PoolingHttpClientConnectionManager class. It comes with retry functionality which is very much needed in case if
178-
SDK receives an I/O error/exception, when executing a request over a connection that has been closed at the server side. However there might be some cases when
179-
transaction has reached server and similar or some other exception has occurred. It is not recommended to retry on non-idempotent methods, so we are considering
180-
`merchantTransactionIdentifier` as idempotent key. Hence if you want to use PoolingHttpClient, merchantTransactionIdentifier field is mandatory in the payload(nvp or xml).
181-
182-
merchantTransactionIdentifier field should be present in the original request for all the services. The value of the merchant transaction ID must be unique for 60 days.
183-
184-
To get more information related to connection pooling please refer wiki.
177+
5
185178

186179
## Message Level Encryption
187180
CyberSource supports Message Level Encryption (MLE) for Simple Order API. Message level encryption conforms to the SOAP Security 1.0 specification published by the OASIS standards group.

java/src/main/java/com/cybersource/ws/client/Client.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static Map<String, String> runTransaction(
103103

104104
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
105105

106-
if (mc.getUseHttpClientWithConnectionPool()){
106+
String isAuthService = request.get(AUTH_SERVICE_NVP);
107+
if (Boolean.valueOf(isAuthService) && mc.getUseHttpClientWithConnectionPool()){
107108
String mtiField = request.get(MERCHANT_TRANSACTION_IDENTIFIER);
108109
if(StringUtils.isBlank(mtiField)) {
109110
throw new ClientException(HTTP_BAD_REQUEST, MTI_FIELD_ERR_MSG, false, logger);

java/src/main/java/com/cybersource/ws/client/MerchantConfig.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,8 @@ public int getLogMaximumSize() {
254254
}
255255

256256
/**
257-
* retryIfMTIFieldExist If enabled and merchantTransactionIdentifier field is passed in payload then SDK will
258-
* retry the transaction in case when connection pooling http client is used and if SDK receives an I/O error/exception, when executing
259-
* a request over a connection that has been closed at the server side.
260-
*
261-
* The value of the merchantTransactionIdentifier[MTI] field must be unique
257+
* retryIfMTIFieldExist If enabled then SDK will retry the transaction in case when connection pooling http client is used
258+
* and if SDK receives an I/O error/exception, when executing a request over a connection that has been closed at the server side.
262259
*
263260
* If not enabled, a transaction may fail(retry wont occur in some cases) if while sending transaction SDK receives an I/O error/exception, when executing
264261
* a request over a connection that has been closed at the server side.

java/src/main/java/com/cybersource/ws/client/Utility.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ private Utility() {
5050
public static final String SDK_ELAPSED_TIMESTAMP = "v-c-client-computetime";
5151
public static final String RESPONSE_TIME_REPLY = "v-c-response-time";
5252
public static final String MERCHANT_TRANSACTION_IDENTIFIER = "merchantTransactionIdentifier";
53+
54+
public static final String AUTH_SERVICE = "ccAuthService";
55+
public static final String AUTH_SERVICE_XML_RUN_ATT = "run";
56+
public static final String AUTH_SERVICE_NVP = "ccAuthService_run";
57+
5358
public static final String ELEM_MERCHANT_ID = "merchantID";
5459
public static final String KEY_ALIAS = "keyAlias";
5560
public static final String ELEM_MERCHANT_REFERENCE_CODE = "merchantReferenceCode";
@@ -592,4 +597,15 @@ public static String checkIfMTIFiledExist(Document request, String nsURI) {
592597
return mtiFieldValue;
593598
}
594599

600+
public static String checkIfAuthServiceFieldExist(Document request, String nsURI) {
601+
Element authServiceElement = Utility.getElement(request, AUTH_SERVICE, nsURI);
602+
if(authServiceElement == null){
603+
authServiceElement = Utility.getElement(request, AUTH_SERVICE, null);
604+
}
605+
String isAuthService = null;
606+
if(authServiceElement != null){
607+
isAuthService = authServiceElement.getAttribute(AUTH_SERVICE_XML_RUN_ATT);
608+
}
609+
return isAuthService;
610+
}
595611
}

java/src/main/java/com/cybersource/ws/client/XMLClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ public static Document runTransaction(
171171

172172
logger = new LoggerWrapper(_logger, prepare, logTranStart, mc);
173173

174-
if (mc.getUseHttpClientWithConnectionPool()){
174+
String isAuthService = checkIfAuthServiceFieldExist(request, nsURI);
175+
if (Boolean.valueOf(isAuthService) && mc.getUseHttpClientWithConnectionPool()){
175176
String mtiField = checkIfMTIFiledExist(request, nsURI);
176177
if(StringUtils.isBlank(mtiField)) {
177178
throw new ClientException(HTTP_BAD_REQUEST, MTI_FIELD_ERR_MSG, false, logger);

zip/README

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,11 @@ try {
164164
}
165165

166166
##PoolingHttpClient
167-
PoolingHttpClient is built using the apache's PoolingHttpClientConnectionManager class. It comes with retry functionality which is very much needed in case if SDK receives
168-
an I/O error/exception, when executing a request over a connection that has been closed at the server side. However there might be some cases when transaction has reached
169-
server and similar or some other exception has occurred. It is not recommended to retry on non-idempotent methods, so we are considering `merchantTransactionIdentifier` as
170-
idempotent key. Hence if you want to use PoolingHttpClient, merchantTransactionIdentifier field is mandatory in the payload(nvp or xml).
171-
172-
merchantTransactionIdentifier field should be present in the original request for all the services. The value of the merchant transaction ID must be unique for 60 days.
167+
PoolingHttpClient is built using the apache's PoolingHttpClientConnectionManager class. It comes with retry functionality which is very much needed in case if
168+
SDK receives an I/O error/exception, when executing a request over a connection that has been closed at the server side. However there might be some cases when
169+
transaction has reached server and similar or some other exception has occurred. We are considering `merchantTransactionIdentifier` as idempotent key, specially in
170+
case of auth service(`ccAuthService`). Hence if you want to use PoolingHttpClient, for auth service(`ccAuthService`) merchantTransactionIdentifier field is mandatory
171+
in the payload for both nvp and xml. The value of the merchant transaction ID must be unique for 60 days.
173172

174173
To get more information related to connection pooling please refer wiki.
175174

0 commit comments

Comments
 (0)