Skip to content

Commit c02c0f0

Browse files
committed
Add settlement search
1 parent f31ba1b commit c02c0f0

22 files changed

+406
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All Notable changes will be documented in this file
44

5+
## 1.3.0.0
6+
7+
- Added Settlement Search
8+
59
## 1.2.1.0
610

711
- Dependencies tightened to AutoMapper 3.3.1 - 4.1.1
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using eWAY.Rapid.Enums;
2+
using eWAY.Rapid.Models;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
5+
namespace eWAY.Rapid.Tests.IntegrationTests
6+
{
7+
[TestClass]
8+
public class SettlementSearchTests : SdkTestBase
9+
{
10+
[TestMethod]
11+
public void SettlementSearch_ByDate_Test()
12+
{
13+
var client = CreateRapidApiClient();
14+
//Arrange
15+
16+
//Act
17+
var settlementSearch = new SettlementSearchRequest() { ReportMode = SettlementSearchMode.Both, SettlementDate = "2016-02-01" };
18+
var settlementResponse = client.SettlementSearch(settlementSearch);
19+
20+
//Assert
21+
Assert.IsNotNull(settlementResponse);
22+
}
23+
24+
[TestMethod]
25+
public void SettlementSearch_ByDateRange_Test()
26+
{
27+
var client = CreateRapidApiClient();
28+
//Arrange
29+
30+
//Act
31+
var settlementSearch = new SettlementSearchRequest() {
32+
ReportMode = SettlementSearchMode.Both,
33+
StartDate = "2016-02-01",
34+
EndDate = "2016-02-08",
35+
CardType = CardType.ALL,
36+
};
37+
var settlementResponse = client.SettlementSearch(settlementSearch);
38+
39+
//Assert
40+
Assert.IsNotNull(settlementResponse);
41+
Assert.IsTrue(settlementResponse.SettlementTransactions.Length > 1);
42+
Assert.IsTrue(settlementResponse.SettlementSummaries.Length > 1);
43+
}
44+
45+
[TestMethod]
46+
public void SettlementSearch_WithPage_Test()
47+
{
48+
var client = CreateRapidApiClient();
49+
//Arrange
50+
51+
//Act
52+
var settlementSearch = new SettlementSearchRequest()
53+
{
54+
ReportMode = SettlementSearchMode.TransactionOnly,
55+
SettlementDate = "2016-02-01",
56+
Page = 1,
57+
PageSize = 5
58+
};
59+
var settlementResponse = client.SettlementSearch(settlementSearch);
60+
61+
//Assert
62+
Assert.IsNotNull(settlementResponse);
63+
Assert.IsTrue(settlementResponse.SettlementTransactions.Length < 6);
64+
}
65+
66+
}
67+
}

eWAY.Rapid.Tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("eWAY")]
1111
[assembly: AssemblyProduct("eWAY.Rapid.Tests")]
12-
[assembly: AssemblyCopyright("Copyright © Web Active 2015")]
12+
[assembly: AssemblyCopyright("Copyright © Web Active 2015-2016")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.2.1.0")]
35-
[assembly: AssemblyFileVersion("1.2.1.0")]
34+
[assembly: AssemblyVersion("1.3.0.0")]
35+
[assembly: AssemblyFileVersion("1.3.0.0")]

eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<Compile Include="IntegrationTests\DirectRefundTests.cs" />
6666
<Compile Include="IntegrationTests\PreAuthTests.cs" />
6767
<Compile Include="IntegrationTests\QueryCustomerTests.cs" />
68+
<Compile Include="IntegrationTests\SettlementSearchTests.cs" />
6869
<Compile Include="IntegrationTests\QueryTransactionTests.cs" />
6970
<Compile Include="IntegrationTests\UpdateCustomerTests.cs" />
7071
<Compile Include="MappingTests\MappingTests.cs" />

eWAY.Rapid/Enums/CardType.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace eWAY.Rapid.Enums
2+
{
3+
/// <summary>
4+
/// Defines the possible card types for filtering a settlement search
5+
/// </summary>
6+
public enum CardType
7+
{
8+
/// <summary>
9+
/// All cards
10+
/// </summary>
11+
ALL,
12+
/// <summary>
13+
/// Visa
14+
/// </summary>
15+
VI,
16+
/// <summary>
17+
/// Mastercard
18+
/// </summary>
19+
MC,
20+
/// <summary>
21+
/// AMEX
22+
/// </summary>
23+
AX,
24+
/// <summary>
25+
/// Diners Club
26+
/// </summary>
27+
DC,
28+
/// <summary>
29+
/// JCB
30+
/// </summary>
31+
JC,
32+
/// <summary>
33+
/// Maestro UK
34+
/// </summary>
35+
MD,
36+
/// <summary>
37+
/// Maestro International
38+
/// </summary>
39+
MI,
40+
/// <summary>
41+
/// Solo
42+
/// </summary>
43+
SO,
44+
/// <summary>
45+
/// Laser
46+
/// </summary>
47+
LA,
48+
/// <summary>
49+
/// Discover
50+
/// </summary>
51+
DS,
52+
}
53+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace eWAY.Rapid.Enums
2+
{
3+
/// <summary>
4+
/// Defines the possible types of settlement reports
5+
/// </summary>
6+
public enum SettlementSearchMode
7+
{
8+
/// <summary>
9+
/// This mode will ONLY query the settlement summary.
10+
/// </summary>
11+
SummaryOnly,
12+
/// <summary>
13+
/// This mode will ONLY query the settlement transactions (individually).
14+
/// </summary>
15+
TransactionOnly,
16+
/// <summary>
17+
/// This mode will query both the Settlement summary, as well as the settlement transactions.
18+
/// </summary>
19+
Both,
20+
}
21+
}

eWAY.Rapid/IRapidClient.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using eWAY.Rapid.Enums;
3-
using eWAY.Rapid.Internals.Response;
43
using eWAY.Rapid.Models;
54

65
namespace eWAY.Rapid
@@ -108,16 +107,22 @@ public interface IRapidClient
108107
/// Complete an authorised transaction with a Capture request
109108
/// </summary>
110109
/// <param name="captureRequest">Contains the details of the Payment</param>
111-
/// <returns></returns>
110+
/// <returns>CapturePaymentResponse</returns>
112111
CapturePaymentResponse CapturePayment(CapturePaymentRequest captureRequest);
113112

114113
/// <summary>
115114
/// Cancel an authorised transaction with a Cancel request
116115
/// </summary>
117116
/// <param name="cancelRequest">Contains the TransactionId of which needs to be cancelled</param>
118-
/// <returns></returns>
117+
/// <returns>CancelAuthorisationResponse</returns>
119118
CancelAuthorisationResponse CancelAuthorisation(CancelAuthorisationRequest cancelRequest);
120119

120+
/// <summary>
121+
/// Perform a search of settlements with a given filter
122+
/// </summary>
123+
/// <param name="settlementSearchRequest">Contains the filter to search settlements by</param>
124+
/// <returns>SettlementSearchResponse</returns>
125+
SettlementSearchResponse SettlementSearch(SettlementSearchRequest settlementSearchRequest);
121126

122127
/// <summary>
123128
/// True if the Client has valid API Key, Password and Endpoint Set.

eWAY.Rapid/Internals/Enums/SettlementReportMode.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

eWAY.Rapid/Internals/Models/SettlementTransaction.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace eWAY.Rapid.Internals.Models
55
internal class SettlementTransaction
66
{
77
public string SettlementID { get; set; }
8-
public string CurrencyCardTypeTransactionID { get; set; }
98
public int eWAYCustomerID { get; set; }
109
public string Currency { get; set; }
1110
public int TransactionID { get; set; }

eWAY.Rapid/Internals/RapidClient.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Web;
4+
using System.Reflection;
35
using eWAY.Rapid.Enums;
46
using eWAY.Rapid.Internals.Request;
57
using eWAY.Rapid.Internals.Response;
@@ -209,6 +211,28 @@ public CancelAuthorisationResponse CancelAuthorisation(CancelAuthorisationReques
209211
return _mappingService.Map<DirectCancelAuthorisationResponse, CancelAuthorisationResponse>(response);
210212
}
211213

214+
public SettlementSearchResponse SettlementSearch(SettlementSearchRequest settlementSearchRequest)
215+
{
216+
if (!IsValid) return SdkInvalidStateErrorsResponse<SettlementSearchResponse>();
217+
218+
var query = HttpUtility.ParseQueryString(string.Empty);
219+
var properties = settlementSearchRequest.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
220+
foreach (var prop in properties)
221+
{
222+
var value = prop.GetValue(settlementSearchRequest, null);
223+
if (value != null && !String.IsNullOrWhiteSpace(value.ToString()))
224+
{
225+
if ((!prop.Name.Equals("Page") && !prop.Name.Equals("PageSize")) || !value.Equals(0))
226+
{
227+
query[prop.Name] = value.ToString();
228+
}
229+
}
230+
}
231+
232+
var response = _rapidService.SettlementSearch(query.ToString());
233+
return _mappingService.Map<DirectSettlementSearchResponse, SettlementSearchResponse>(response);
234+
}
235+
212236
public bool IsValid
213237
{
214238
get

0 commit comments

Comments
 (0)