Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ Given I create the following api scopes
| MerchantName | AddressLine1 | Town | Region | PostalCode | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | Address Line 1 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 |

Scenario Outline: Process a Bank Deposit Callback
Scenario: Process a Bank Deposit Callback
Given I have the following Bank Deposit Callbacks
| Amount | DateTime | DepositId | HostIdentifier | SortCode | AccountNumber |
| 100.00 | Today | 6AE04AFC-D7F8-4936-A3A2-DCA177CAA106 | DC4A7DDA-45A1-4D5B-8D46-21FA99A3868E | 11-22-33 | 12345678 |
When I send the requests to the callback handler for deposits
Then the deposit records are recorded

Examples:
| APIVersion |
| 1 |
Then the deposit records are recorded
8 changes: 3 additions & 5 deletions CallbackHandler.IntegrationTests/Shared/SharedSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ public async Task GivenIHaveTheFollowingBankDepositCallbacks(DataTable table)

[When(@"I send the requests to the callback handler for deposits")]
public async Task WhenISendTheRequestsToTheCallbackHandlerForDeposits() {
String apiVersion = ScenarioContext.ScenarioInfo.Arguments["APIVersion"].ToString();


using HttpClient client = new();
foreach (var testingContextDeposit in this.TestingContext.Deposits)
{
String requestUri =
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/v{apiVersion}/callbacks";
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks";
HttpRequestMessage msg = new(HttpMethod.Post, requestUri);
var payload = StringSerialiser.Serialise(testingContextDeposit);

Expand All @@ -88,12 +87,11 @@ public async Task WhenISendTheRequestsToTheCallbackHandlerForDeposits() {
[Then("the deposit records are recorded")]
public async Task ThenTheDepositRecordsAreRecorded()
{
String apiVersion = ScenarioContext.ScenarioInfo.Arguments["APIVersion"].ToString();
using HttpClient client = new();
foreach (var sentCallback in this.TestingContext.SentCallbacks)
{
String requestUri =
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/v{apiVersion}/callbacks/{sentCallback.Key}";
$"http://localhost:{this.TestingContext.DockerHelper.GetCallbackHandlerPort()}/api/callbacks/{sentCallback.Key}";
HttpRequestMessage msg = new(HttpMethod.Get, requestUri);
var response = await client.SendAsync(msg);
response.StatusCode.ShouldBe(HttpStatusCode.OK);
Expand Down
14 changes: 5 additions & 9 deletions CallbackHandler/Endpoints/CallbackEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Asp.Versioning;
using Asp.Versioning.Builder;
using CallbackHandler.DataTransferObjects;
using CallbackHandler.DataTransferObjects;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
Expand All @@ -10,18 +8,16 @@ namespace CallbackHandler.Endpoints
{
public static class CallbackEndpoints
{
private const string BaseRoute = "/api/callbacks";

public static IEndpointRouteBuilder MapCallbackEndpoints(this IEndpointRouteBuilder endpoints)
{
IVersionedEndpointRouteBuilder api = endpoints.NewVersionedApi("Callbacks");
RouteGroupBuilder group = api
.MapGroup("/api/v{version:apiVersion}/callbacks")
.WithTags("Callbacks")
.HasApiVersion(new ApiVersion(1.0));
RouteGroupBuilder group = endpoints.MapGroup(BaseRoute).WithTags("Callbacks");

group.MapPost("/", Handlers.CallbackHandlers.RecordCallback)
.WithName("RecordCallback")
.WithSummary("Receive a deposit callback")
.WithDescription("Accepts a deposit notification from the transaction processor, records it, and returns the identifier assigned to the callback. Use that identifier with GetCallback to retrieve the recorded message.")
.WithDescription("Accepts a deposit notification from an external bank, records it, and returns the identifier assigned to the callback. Use that identifier with GetCallback to retrieve the recorded message.")
.Accepts<Deposit>("application/json")
.Produces<CallbackResponse>(StatusCodes.Status200OK)
.Produces<ErrorResponse>(StatusCodes.Status400BadRequest)
Expand Down
Loading