diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..29397ef
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,8 @@
+
+before_build:
+ - nuget restore
+
+environment:
+ matrix:
+ - APIVERSION: 31
+ - APIVERSION: 40
\ No newline at end of file
diff --git a/eWAY.Rapid.Tests/App.config b/eWAY.Rapid.Tests/App.config
index 0b7c764..4a62d18 100644
--- a/eWAY.Rapid.Tests/App.config
+++ b/eWAY.Rapid.Tests/App.config
@@ -4,5 +4,6 @@
+
\ No newline at end of file
diff --git a/eWAY.Rapid.Tests/IntegrationTests/QueryTransactionTests.cs b/eWAY.Rapid.Tests/IntegrationTests/QueryTransactionTests.cs
index bf915f6..883919d 100644
--- a/eWAY.Rapid.Tests/IntegrationTests/QueryTransactionTests.cs
+++ b/eWAY.Rapid.Tests/IntegrationTests/QueryTransactionTests.cs
@@ -160,5 +160,38 @@ public void QueryTransaction_InvalidInputData_ReturnVariousErrors()
Assert.IsNotNull(queryByInvoiceRefResponse.Errors);
Assert.AreEqual(queryByInvoiceRefResponse.Errors.FirstOrDefault(), "V6171");
}
+
+ [TestMethod]
+ public void QueryTransaction_Rapidv40_Test()
+ {
+ string version = System.Environment.GetEnvironmentVariable("APIVERSION");
+ int v;
+
+ if (int.TryParse(version, out v) && v > 31)
+ {
+ var client = CreateRapidApiClient();
+ //Arrange
+ var transaction = TestUtil.CreateTransaction();
+
+ //Act
+ var response = client.Create(PaymentMethod.Direct, transaction);
+ var filter = new TransactionFilter() { TransactionID = response.TransactionStatus.TransactionID };
+ var queryResponse = client.QueryTransaction(filter);
+ var queryResponse2 = client.QueryTransaction(response.TransactionStatus.TransactionID);
+ //Assert
+ Assert.IsNotNull(queryResponse);
+ Assert.IsNotNull(queryResponse2);
+ Assert.AreEqual(response.TransactionStatus.TransactionID, queryResponse.TransactionStatus.TransactionID);
+ Assert.AreEqual(response.TransactionStatus.TransactionID, queryResponse2.TransactionStatus.TransactionID);
+ Assert.AreEqual(response.TransactionStatus.Total, queryResponse2.TransactionStatus.Total);
+
+ Assert.AreEqual("036", queryResponse2.Transaction.CurrencyCode);
+ Assert.AreEqual(response.TransactionStatus.Total, queryResponse2.Transaction.MaxRefund);
+ } else
+ {
+ Assert.Inconclusive();
+ }
+
+ }
}
}
diff --git a/eWAY.Rapid.Tests/IntegrationTests/SdkTestBase.cs b/eWAY.Rapid.Tests/IntegrationTests/SdkTestBase.cs
index c514417..4deaf1c 100644
--- a/eWAY.Rapid.Tests/IntegrationTests/SdkTestBase.cs
+++ b/eWAY.Rapid.Tests/IntegrationTests/SdkTestBase.cs
@@ -7,10 +7,24 @@ public abstract class SdkTestBase
public static string PASSWORD = ConfigurationManager.AppSettings["PASSWORD"];
public static string APIKEY = ConfigurationManager.AppSettings["APIKEY"];
public static string ENDPOINT = ConfigurationManager.AppSettings["ENDPOINT"];
+ public static int APIVERSION = int.Parse(ConfigurationManager.AppSettings["APIVERSION"]);
protected IRapidClient CreateRapidApiClient()
{
- return RapidClientFactory.NewRapidClient(APIKEY, PASSWORD, ENDPOINT);
+ var client = RapidClientFactory.NewRapidClient(APIKEY, PASSWORD, ENDPOINT);
+ client.SetVersion(GetVersion());
+ return client;
+ }
+
+ protected int GetVersion()
+ {
+ string version = System.Environment.GetEnvironmentVariable("APIVERSION");
+ int v;
+ if (version != null && int.TryParse(version, out v))
+ {
+ return v;
+ }
+ return APIVERSION;
}
}
}
diff --git a/eWAY.Rapid/IRapidClient.cs b/eWAY.Rapid/IRapidClient.cs
index b3b9d7f..1cbb080 100644
--- a/eWAY.Rapid/IRapidClient.cs
+++ b/eWAY.Rapid/IRapidClient.cs
@@ -16,6 +16,12 @@ public interface IRapidClient
/// Password matching the API Key
void SetCredentials(string apiKey, string password);
+ ///
+ /// Set the Rapid API version to use
+ ///
+ /// Rapid API version
+ void SetVersion(int version);
+
///
/// This Method is used to create a transaction for the merchant in their eWAY account
///
diff --git a/eWAY.Rapid/Internals/Models/TransactionResult.cs b/eWAY.Rapid/Internals/Models/TransactionResult.cs
index db3a7bf..5a6ec0d 100644
--- a/eWAY.Rapid/Internals/Models/TransactionResult.cs
+++ b/eWAY.Rapid/Internals/Models/TransactionResult.cs
@@ -18,5 +18,14 @@ internal class TransactionResult
public Customer Customer { get; set; }
public string CustomerNote { get; set; }
public ShippingAddress ShippingAddress { get; set; }
- }
+
+ //Rapid v40 fields
+ public string TransactionDateTime { get; set; }
+ public string FraudAction { get; set; }
+ public bool? TransactionCaptured { get; set; }
+ public string CurrencyCode { get; set; }
+ public int? Source { get; set; }
+ public int? MaxRefund { get; set; }
+ public int? OriginalTransactionId { get; set; }
+}
}
diff --git a/eWAY.Rapid/Internals/RapidClient.cs b/eWAY.Rapid/Internals/RapidClient.cs
index 92065a6..c87e831 100644
--- a/eWAY.Rapid/Internals/RapidClient.cs
+++ b/eWAY.Rapid/Internals/RapidClient.cs
@@ -35,6 +35,11 @@ public void SetCredentials(string apiKey, string password)
_rapidService.SetCredentials(apiKey, password);
}
+ public void SetVersion(int version)
+ {
+ _rapidService.SetVersion(version);
+ }
+
private CreateTransactionResponse CreateInternal(PaymentMethod paymentMethod, Transaction transaction)
{
switch (paymentMethod)
diff --git a/eWAY.Rapid/Internals/Response/CreateAccessCodeResponse.cs b/eWAY.Rapid/Internals/Response/CreateAccessCodeResponse.cs
index c096015..4abde5e 100644
--- a/eWAY.Rapid/Internals/Response/CreateAccessCodeResponse.cs
+++ b/eWAY.Rapid/Internals/Response/CreateAccessCodeResponse.cs
@@ -9,5 +9,6 @@ internal class CreateAccessCodeResponse: BaseResponse
public Payment Payment { get;set; }
public string FormActionURL { get;set; }
public string CompleteCheckoutURL { get; set; }
+ public string AmexECEncryptedData { get; set; }
}
}
diff --git a/eWAY.Rapid/Internals/Services/IRapidService.cs b/eWAY.Rapid/Internals/Services/IRapidService.cs
index 5e085f6..584bee3 100644
--- a/eWAY.Rapid/Internals/Services/IRapidService.cs
+++ b/eWAY.Rapid/Internals/Services/IRapidService.cs
@@ -28,6 +28,7 @@ internal interface IRapidService
string GetRapidEndpoint();
void SetRapidEndpoint(string value);
void SetCredentials(string apiKey, string password);
+ void SetVersion(int version);
bool IsValid();
List GetErrorCodes();
}
diff --git a/eWAY.Rapid/Internals/Services/RapidService.cs b/eWAY.Rapid/Internals/Services/RapidService.cs
index a743f69..5943821 100644
--- a/eWAY.Rapid/Internals/Services/RapidService.cs
+++ b/eWAY.Rapid/Internals/Services/RapidService.cs
@@ -19,6 +19,7 @@ internal class RapidService : IRapidService
{
private string _rapidEndpoint;
private string _authenticationHeader;
+ private int? _version;
private bool _isValidEndPoint;
private bool _isValidCredentials;
@@ -242,6 +243,11 @@ private void AddHeaders(HttpWebRequest webRequest, string httpMethod)
webRequest.UserAgent = "eWAY SDK .NET " + Assembly.GetExecutingAssembly().GetName().Version;
webRequest.Method = httpMethod;
webRequest.ContentType = "application/json";
+
+ if (_version.HasValue)
+ {
+ webRequest.Headers.Add("X-EWAY-APIVERSION", _version.ToString());
+ }
}
private string HandleWebException(WebException ex)
@@ -321,6 +327,11 @@ public void SetCredentials(string apiKey, string password)
_isValidCredentials = !string.IsNullOrWhiteSpace(apiKey) && !string.IsNullOrWhiteSpace(password);
}
+ public void SetVersion(int version)
+ {
+ _version = version;
+ }
+
public bool IsValid()
{
return _isValidCredentials && _isValidEndPoint;
diff --git a/eWAY.Rapid/Models/CreateTransactionResponse.cs b/eWAY.Rapid/Models/CreateTransactionResponse.cs
index f242534..8767e7a 100644
--- a/eWAY.Rapid/Models/CreateTransactionResponse.cs
+++ b/eWAY.Rapid/Models/CreateTransactionResponse.cs
@@ -26,5 +26,9 @@ public class CreateTransactionResponse : BaseResponse
/// The AccessCode for this transaction (can be used to call query transaction for searching before the transaction has completed processing)
///
public string AccessCode { get; set; }
+ ///
+ /// (Rapid v40 only) A token used to configure AMEX Express Checkout
+ ///
+ public string AmexECEncryptedData { get; set; }
}
}
diff --git a/eWAY.Rapid/Models/Transaction.cs b/eWAY.Rapid/Models/Transaction.cs
index 6c92328..75c5967 100644
--- a/eWAY.Rapid/Models/Transaction.cs
+++ b/eWAY.Rapid/Models/Transaction.cs
@@ -117,6 +117,35 @@ public class Transaction
///
public string LogoUrl { get; set; }
+ ///
+ /// (v40 query response only) The date and time the transaction took place
+ ///
+ public string TransactionDateTime { get; set; }
+ ///
+ /// (v40 query response only) The fraud action that occurred if any. One of NotChallenged, Allow, Review, PreAuth, Processed, Approved, Block
+ ///
+ public string FraudAction { get; set; }
+ ///
+ /// (v40 query response only) True if funds were captured in the transaction.
+ ///
+ public bool? TransactionCaptured { get; set; }
+ ///
+ /// (v40 query response only) The ISO 4217 numeric currency code (e.g. AUD = 036)
+ ///
+ public string CurrencyCode { get; set; }
+ ///
+ /// (v40 query response only) Reserved for future use
+ ///
+ public int? Source { get; set; }
+ ///
+ /// (v40 query response only) The maximum amount that could be refunded from this transaction
+ ///
+ public int? MaxRefund { get; set; }
+ ///
+ /// (v40 query response only) Contains the original transaction ID if the queried transaction is a refund
+ ///
+ public int? OriginalTransactionId { get; set; }
+
///
/// Initializes a new instance of the Transaction class
///