Skip to content

Merge Future into Master for June 2015 SDK release #85

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

Merged
merged 46 commits into from
Jun 1, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
61a4f78
Create .gitignore
Dthurman Dec 17, 2014
380c778
Fixing build url
ramittal Dec 20, 2014
3526a57
Update source code to convert decimal values to string using invarien…
Dthurman Jan 30, 2015
4b3f434
Merge pull request #64 from Dthurman/master
Dthurman Jan 30, 2015
a3fa731
Fix DotNet SDK Isseue #60. ResponseCode property now returns ParseRe…
Dthurman Feb 2, 2015
42f6b6d
Merge pull request #65 from Dthurman/master
Dthurman Feb 2, 2015
a19a9c6
Add ResponseReasonCode property to GatewayResponse, revert ResponseCo…
Dthurman Feb 2, 2015
23644aa
removed visa email from my ResponseReasonCode regression test
Dthurman Feb 2, 2015
2a0df92
Merge pull request #66 from Dthurman/master
Dthurman Feb 2, 2015
74f79b6
remove invariantculture references from crypto.cs
Dthurman Feb 3, 2015
fd6e025
Merge pull request #67 from Dthurman/master
Dthurman Feb 3, 2015
d3e9d2f
Adding SampleTests for echeck transactions, credits and unlinked cre…
Dthurman Feb 4, 2015
a38ffc7
Update validation in new model tests, update failing tests.
Dthurman Feb 9, 2015
5478600
Cleaned up Samples and Tests to improve validation and error handling
Dthurman Feb 10, 2015
108b990
Changed Int64.parse to long.parse to improve compatability
Dthurman Feb 10, 2015
e358535
Updated SetValidSubscriptionAmount to return dollars and cents value,…
Dthurman Feb 23, 2015
a0c168b
Update SetValidTransactionAmount to return values with dollars and ce…
Dthurman Feb 23, 2015
a85566f
Update setValidSubscriptionAmount, setValidAmount and setValidTransac…
Dthurman Feb 26, 2015
a82c23e
Fixing compile errors reported by ci.
Dthurman Feb 26, 2015
d5a1e95
Merge pull request #68 from Dthurman/master
Dthurman Feb 26, 2015
a19d0f8
Adding sample of processing Error messages from faild request.
Dthurman Mar 2, 2015
d4fa6f4
Merge pull request #74 from Dthurman/master
Dthurman Mar 6, 2015
f72fc76
Merge remote-tracking branch 'upstream/future'
ramittal Mar 6, 2015
89216a1
Fixing bug in createCustomerProfileTransaction where direct response …
ramittal Mar 6, 2015
53788cf
Merge branch 'master' of https://github.com/ramittal/sdk-dotnet into …
Mar 23, 2015
fe8bf44
made sure CI URL was correct
Mar 23, 2015
fcec6e8
Merge branch 'ramittal-master' into future
Mar 23, 2015
b2be014
Update README.md
brianmc Mar 23, 2015
76721ba
Fixed failed tests.
xianwang423 Apr 20, 2015
3f7ed35
Minor changes.
xianwang423 Apr 20, 2015
e01ad23
Removed add console write statements.
xianwang423 Apr 20, 2015
f3b921b
Continue fixing failures. Now 3 failures out of 131 tests.
xianwang423 Apr 20, 2015
88e86c3
Continue fixing the failures. Now 3 failures out of 131 tests, plus s…
xianwang423 Apr 20, 2015
b8c2dda
Added configuration of ApplePay, use https for the PayPal call-back.
xianwang423 Apr 21, 2015
273c868
Added comment to advice enabling PayPal feature.
xianwang423 Apr 21, 2015
487fdf0
Added more assertions specific to tests.
xianwang423 Apr 21, 2015
c9685a6
Fixed failed sdk-dotnet tests.
xianwang423 Apr 20, 2015
06c5ec5
Merged from the future.
xianwang423 Apr 21, 2015
a7a4c7e
Revert the PayPal message code back to 1, its original value.
xianwang423 Apr 22, 2015
5f3b662
Change the PayPal test to use the code 2000, Need the payer's consent.
xianwang423 Apr 27, 2015
5b1e3c1
Merge pull request #82 from xianwang423/future
brianmc May 21, 2015
b0da1bd
Code changes for Visa Checkout API
baluveer May 28, 2015
0542bbe
deleted decryptPaymentDataContollerTest.CS
baluveer May 28, 2015
029cc8e
code changes for refactoring ResponseReasonCode and GetValuebyIndex
baluveer May 29, 2015
d10869e
Update .travis.yml
brianmc May 29, 2015
bf203de
Merge pull request #84 from baluveer/future
brianmc May 29, 2015
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
Prev Previous commit
Next Next commit
Update setValidSubscriptionAmount, setValidAmount and setValidTransac…
…tionAmount to return amounts as #.## instead of whole numbers

and in range between 1.00 and either maxTransactionAmount or maxSubscriptionAmount
  • Loading branch information
Dthurman committed Feb 26, 2015
commit a85566f28421728c7d1015397f3a7f8307df78eb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private long GetTransactionId()
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

//set up data based on transaction
var transactionAmount = SetValidTransactionAmount(Counter)/100;
var transactionAmount = SetValidTransactionAmount(Counter);
var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0622" };
var aCustomer = new customerDataType { email = string.Format( "{0}@b.bla", Counter)};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void SampleCodeCreateTransactionUsingProfile()
var transactionRequestType = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
amount = SetValidTransactionAmount(Counter)/100,
amount = SetValidTransactionAmount(Counter),
profile = profileToCharge
};
var createRequest = new createTransactionRequest
Expand Down Expand Up @@ -266,7 +266,7 @@ public void SampleCodeCreateTransactionWithPayPal()
{
//Common code to set for all requests
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; //TestEnvironment;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PLUM; //TestEnvironment;

//set up data for transaction
var transactionAmount = SetValidTransactionAmount(Counter) / 100;
Expand Down Expand Up @@ -443,5 +443,49 @@ public void SampleCodeCreateTransactionPriorAuthCapture()
//validate
Assert.AreEqual("1", capResponse.transactionResponse.messages[0].code);
}

[Test]
public void TransactionRequest_HandleError()
{
LogHelper.info(Logger, "CreateProfileWithCreateTransactionRequestTest");

ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

//create a transaction
var transactionRequestType = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
amount = SetValidTransactionAmount(Counter),
payment = new paymentType { Item = new creditCardType { cardNumber = "0111111111111111", expirationDate = "122035" } },
order = OrderType,
customer = CustomerDataOne,
billTo = CustomerAddressOne,
shipTo = CustomerAddressOne,
};
var createRequest = new createTransactionRequest
{
refId = RefId,
transactionRequest = transactionRequestType,
};
//create controller, execute and get response
var createController = new createTransactionController(createRequest);
createController.Execute();
var createResponse = createController.GetApiResponse();

//Validate error code where request is submitted properly, but request fails.
Assert.AreEqual("6", createResponse.transactionResponse.errors[0].errorCode);

//Validate error code where submission of request fails.
((creditCardType)transactionRequestType.payment.Item).cardNumber = "01";
createController = new createTransactionController(createRequest);
createController.Execute();

if (createController.GetApiResponse() == null)
{
var errorResponse = createController.GetErrorResponse();
Assert.AreEqual("E00003", errorResponse.messages.message[0].code);
}
}
}
}
14 changes: 10 additions & 4 deletions AuthorizeNETtest/Api/Controllers/Test/ApiCoreTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public void SetUp()
interval = interval,
startDate = _nowDate,
totalOccurrences = 5,
trialOccurrences = 0,
};

ArbSubscriptionOne = new ARBSubscriptionType
Expand All @@ -313,7 +312,6 @@ public void SetUp()
payment = PaymentOne,
paymentSchedule = PaymentScheduleTypeOne,
shipTo = NameAndAddressTypeOne,
trialAmount= SetValidSubscriptionAmount(0),
};

CustomerDataOne = new customerDataType
Expand Down Expand Up @@ -360,8 +358,15 @@ public decimal SetValidSubscriptionAmount(int number)
return setValidAmount(number, MaxSubscriptionAmount);
}

private decimal setValidAmount(int number, int maxAmount) {
return new decimal(number > maxAmount ? (number % maxAmount) : number);
private decimal setValidAmount(int number, int maxAmount)
{
//Test that result is not larger than the specified max value
number = (number > maxAmount) ? (number % maxAmount) : number;

Decimal dollarsAndCents = (decimal)number / 100;

//Test that result is not less than the global Min Value
return dollarsAndCents = (dollarsAndCents < MinAmount) ? (MinAmount + dollarsAndCents) : dollarsAndCents;
}

static ANetApiResponse _errorResponse;
Expand All @@ -372,6 +377,7 @@ protected ANetApiResponse GetErrorResponse() {

private const int MaxSubscriptionAmount = 1000; //214747;
private const int MaxTransactionAmount = 10000; //214747;
private const int MinAmount = 1;
private const decimal TaxRate = 0.10m;

protected static TS ExecuteTestRequestWithSuccess<TQ, TS, TT>(TQ request, AuthorizeNet.Environment execEnvironment = null)
Expand Down
165 changes: 147 additions & 18 deletions AuthorizeNETtest/Api/Controllers/Test/ArbSubscriptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace AuthorizeNet.Api.Controllers.Test
using System;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Controllers.Bases;
using AuthorizeNet.Api.Controllers.Test;
using AuthorizeNet.Util;
using NUnit.Framework;
using System.Linq;
Expand Down Expand Up @@ -94,30 +96,112 @@ public void TestGetSubscriptionList()

[Test]
public void TestSubscription() {
//create a transaction
var transactionRequestType = new transactionRequestType
Random rnd = new Random(DateTime.Now.Millisecond);
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

//create a subscription
var subscriptionDef = new ARBSubscriptionType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
amount = SetValidTransactionAmount(Counter),
paymentSchedule = new paymentScheduleType
{
interval = new paymentScheduleTypeInterval
{
length = 1,
unit = ARBSubscriptionUnitEnum.months,
},
startDate = DateTime.UtcNow,
totalOccurrences = 12,
},


amount = 9.99M,
billTo = CustomerAddressTwo,

payment = PaymentOne,
order = OrderType,
customer = CustomerDataOne,
billTo = CustomerAddressOne,

customer = CustomerOne,

order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) },
};
var createRequest = new createTransactionRequest

var arbRequest = new ARBCreateSubscriptionRequest { subscription = subscriptionDef };
var arbController = new ARBCreateSubscriptionController(arbRequest);
arbController.Execute();

var arbCreateResponse = arbController.GetApiResponse();

Assert.AreEqual(messageTypeEnum.Ok,arbController.GetResultCode());

}

[Test]
public void TestSubscription_ExpiredCC()
{
Random rnd = new Random(DateTime.Now.Millisecond);
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;
//create a subscription
var subscriptionDef = new ARBSubscriptionType
{
refId = RefId,
transactionRequest = transactionRequestType,
merchantAuthentication = CustomMerchantAuthenticationType,


paymentSchedule = new paymentScheduleType
{
interval = new paymentScheduleTypeInterval
{
length = 7,
unit = ARBSubscriptionUnitEnum.days
},
startDate = DateTime.UtcNow,
totalOccurrences = 2,
},


amount = 9.99M,

billTo = new nameAndAddressType
{
address = "1234 Elm St NE",
city = "Bellevue",
state = "WA",
zip = "98007",
firstName = "First",
lastName = "Last"
},

payment = new paymentType
{
Item = new creditCardType
{
cardCode = "655",
//cardNumber = "4007000",
cardNumber = "4111111111111111",
expirationDate = "122013",
}
},

customer = new customerType { email = "[email protected]", id = "5", },

order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) },
};

var createResponse = ExecuteTestRequestWithSuccess<createTransactionRequest, createTransactionResponse, createTransactionController>(createRequest, TestEnvironment);
string txnId = createResponse.transactionResponse.transId;
var arbRequest = new ARBCreateSubscriptionRequest { subscription = subscriptionDef };
var arbController = new ARBCreateSubscriptionController(arbRequest);
arbController.Execute();

var subscriptionId = CreateSubscription(CustomMerchantAuthenticationType, txnId);
GetSubscription(CustomMerchantAuthenticationType, subscriptionId);
CancelSubscription(CustomMerchantAuthenticationType, subscriptionId);
}
var arbCreateResponse = arbController.GetApiResponse();

//If request responds with an error, walk the messages and get code and text for each message.
if (arbController.GetResultCode() == messageTypeEnum.Error)
{
foreach(var msg in arbCreateResponse.messages.message)
{
Console.WriteLine("Error Num = {0}, Message = {1}", msg.code, msg.text);
}
}

}

private ARBGetSubscriptionListRequest SetupSubscriptionListRequest(merchantAuthenticationType merchantAuthentication) {

Expand Down Expand Up @@ -171,7 +255,8 @@ private ARBSubscriptionStatusEnum GetSubscription(merchantAuthenticationType mer
return getResponse.status;
}

private string CreateSubscription( merchantAuthenticationType merchantAuthentication, string RefId) {
private string CreateSubscription( merchantAuthenticationType merchantAuthentication, string RefId)
{
//create a new subscription
//RequestFactoryWithSpecified.paymentType(ArbSubscriptionOne.payment);
//RequestFactoryWithSpecified.paymentScheduleType(ArbSubscriptionOne.paymentSchedule);
Expand All @@ -190,5 +275,49 @@ private string CreateSubscription( merchantAuthenticationType merchantAuthentica

return createResponse.subscriptionId;
}

[Test]
public void TestSubscription_serialization_error()
{
Random rnd = new Random(DateTime.Now.Millisecond);
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

//create a subscription
var subscriptionDef = new ARBSubscriptionType
{
paymentSchedule = new paymentScheduleType
{
interval = new paymentScheduleTypeInterval
{
length = 1,
unit = ARBSubscriptionUnitEnum.months,
},
startDate = DateTime.UtcNow,
totalOccurrences = 12,
},


amount = 9.99M,
billTo = new customerAddressType { firstName = "first", lastName = "last" },

payment = PaymentOne,

customer = CustomerOne,

order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) },
};

var arbRequest = new ARBCreateSubscriptionRequest { subscription = subscriptionDef };
var arbController = new ARBCreateSubscriptionController(arbRequest);
arbController.Execute();

if (arbController.GetResultCode() == messageTypeEnum.Error)
{
var errorResp = arbController.GetErrorResponse();
Console.WriteLine("{0}: {1}", errorResp.messages.message[0].code, errorResp.messages.message[0].text);
}

}
}
}
4 changes: 2 additions & 2 deletions AuthorizeNETtest/CardPresentGatewayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void SendTest_PriorAuthCap_Approved()
Assert.IsTrue(sError == "", sError);

//setup
decimal amount = (decimal) 30.13;
decimal amount = getValidAmount();
string transID = SendAuthOnly(amount + 1, true);
Assert.IsTrue(transID.Trim().Length > 0);
Assert.IsTrue(long.Parse(transID) > 0);
Expand Down Expand Up @@ -128,7 +128,7 @@ public void SendTest_PriorAuthCap_LessAmount_Failed()
Assert.IsTrue(sError == "", sError);

//setup
decimal amount = (decimal)30.13;
decimal amount = getValidAmount();
string transID = SendAuthOnly(amount - 1, true);
Assert.IsTrue(transID.Trim().Length > 0);
Assert.IsTrue(long.Parse(transID) > 0);
Expand Down
6 changes: 4 additions & 2 deletions AuthorizeNETtest/CustomerGatewayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,9 @@ public void AuthorizeAndCaptureTest()
string sError = CheckLoginPassword();
Assert.IsTrue(sError == "", sError);

string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,2C99N3,Y,2207640586,,,25.10,CC,auth_capture,,,,,,,,,,,,[email protected],,,,,,,,,,,,,,C40BBCC10984A7A95471323B34FD4FFB,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>";
decimal txnAmount = getValidAmount();

string responseString = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,2C99N3,Y,2207640586,,,{0},CC,auth_capture,,,,,,,,,,,,[email protected],,,,,,,,,,,,,,C40BBCC10984A7A95471323B34FD4FFB,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>", txnAmount);
LocalRequestObject.ResponseString = responseString;
XmlSerializer serializer = new XmlSerializer(typeof(createCustomerProfileTransactionResponse));
StringReader reader = new StringReader(responseString);
Expand All @@ -665,7 +667,7 @@ public void AuthorizeAndCaptureTest()
string profileID = "24231938";
string paymentProfileID = "22219473";
Order order = new Order(profileID, paymentProfileID, "");
order.Amount = (decimal) 25.10;
order.Amount = txnAmount;

IGatewayResponse actual = null;

Expand Down