Skip to content

Commit d9d5243

Browse files
committed
Merge pull request #56 from kikmak42/master
Removed Expect: 100-continue header from the HTTP request.
2 parents 7970928 + 83207f1 commit d9d5243

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

src/main/java/net/authorize/api/controller/CreateCustomerProfileController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected void validateRequest() {
1818

1919
//validate required fields
2020
if ( null == request.getProfile()) throw new NullPointerException("Profile cannot be null");
21-
if ( null == request.getRefId()) throw new NullPointerException("RefId cannot be null");
21+
//if ( null == request.getRefId()) throw new NullPointerException("RefId cannot be null");
2222
if ( null == request.getValidationMode() || ValidationModeEnum.NONE == request.getValidationMode()) throw new NullPointerException("ValidationMode cannot be null");
2323
if ( null == request.getProfile().getPaymentProfiles() || 0 == request.getProfile().getPaymentProfiles().size()) throw new NullPointerException("Payment Profile cannot be null or empty");
2424

src/main/java/net/authorize/util/HttpClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.http.conn.params.ConnRoutePNames;
2525
import org.apache.http.entity.StringEntity;
2626
import org.apache.http.impl.client.DefaultHttpClient;
27+
import org.apache.http.params.CoreProtocolPNames;
2728
import org.apache.http.protocol.HTTP;
2829

2930
/**
@@ -68,6 +69,7 @@ private static HttpPost createHttpPost(Environment env, Transaction transaction)
6869
}
6970

7071
httpPost = new HttpPost(postUrl);
72+
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
7173
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
7274
httpPost.setEntity(new StringEntity(transaction.toNVPString()));
7375
} else if (transaction instanceof net.authorize.arb.Transaction ||
@@ -76,6 +78,7 @@ private static HttpPost createHttpPost(Environment env, Transaction transaction)
7678

7779
postUrl = new URI(env.getXmlBaseUrl() + "/xml/v1/request.api");
7880
httpPost = new HttpPost(postUrl);
81+
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
7982
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");
8083
httpPost.setEntity(new StringEntity(transaction.toXMLString()));
8184
}

src/main/java/net/authorize/util/HttpUtility.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.logging.LogFactory;
2424
import org.apache.http.client.methods.HttpPost;
2525
import org.apache.http.entity.StringEntity;
26+
import org.apache.http.params.CoreProtocolPNames;
2627

2728
/**
2829
* Helper methods for http calls
@@ -59,6 +60,7 @@ static HttpPost createPostRequest(Environment env, ANetApiRequest request) throw
5960
logger.debug(String.format("MerchantInfo->LoginId/TransactionKey: '%s':'%s'", request.getMerchantAuthentication().getName(), request.getMerchantAuthentication().getTransactionKey() ));
6061
logger.debug(String.format("Posting request to Url: '%s'", postUrl));
6162
httpPost = new HttpPost(postUrl);
63+
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
6264
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");
6365

6466
String xmlRequest = XmlUtility.getXml(request);

src/test/java/net/authorize/cim/functional_test/CIMTest.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,41 @@ private MyReturnValuesTest createCustomerProfileWithAuthOnly(
876876

877877
return new MyReturnValuesTest(customerProfileId, null, customerPaymentProfileId, null, authCode, splitTenderId, transactionId, customerShippingAddressId);
878878
}
879-
879+
880+
@SuppressWarnings("unchecked")
881+
@Test
882+
public void testZeroCustomerProfile() {
883+
// get all existing customer profile ids
884+
net.authorize.cim.Transaction transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS);
885+
Result<Transaction> result = (Result<Transaction>) merchant.postTransaction(transaction);
886+
ArrayList<String> customerProfileIds = result.getCustomerProfileIdList();
887+
888+
// delete all existing customer profile
889+
for (int i = 0; i < customerProfileIds.size(); i++) {
890+
transaction = merchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE);
891+
transaction.setCustomerProfileId(customerProfileIds.get(i));
892+
result = (Result<Transaction>) merchant.postTransaction(transaction);
893+
}
894+
895+
// test for getCustomerProfileIds request
896+
transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS);
897+
result = (Result<Transaction>) merchant.postTransaction(transaction);
898+
Assert.assertNotNull(result);
899+
result.printMessages();
900+
Assert.assertTrue(result.isOk());
901+
Assert.assertTrue(result.getCustomerProfileIdList().isEmpty());
902+
903+
// test for getCustomerProfile request
904+
transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE);
905+
transaction.setCustomerProfileId(customerProfileIds.get(customerProfileIds.size() - 1));
906+
result = (Result<Transaction>) merchant.postTransaction(transaction);
907+
Assert.assertNotNull(result);
908+
result.printMessages();
909+
Assert.assertTrue(result.isError());
910+
Assert.assertNull(result.getCustomerProfileId());
911+
Assert.assertNull(result.getCustomerProfile());
912+
Assert.assertTrue(result.getCustomerPaymentProfileIdList().isEmpty());
913+
}
880914
private String createdCustomerPaymentProfileId = null;
881915
}
882916

0 commit comments

Comments
 (0)