Add reviewed NMI hosted invoices and read-only payment reconciliation

This commit is contained in:
wolf-demon
2026-09-15 09:31:05 +01:00
parent 5bd71175c0
commit ad57a8b1bd
20 changed files with 411 additions and 12 deletions
+12 -1
View File
@@ -16,7 +16,8 @@ await store.Initialize();
try
{
await ReplyTests.Run(Check, store);
await PmsTests.Run(Check, store);
await PmsTests.Run(Check, store);
await PaymentTests.Run(Check, store);
var a = new Hotel { Name = "Hotel A" }; a.HotelId = a.Id;
var b = new Hotel { Name = "Hotel B" }; b.HotelId = b.Id;
await store.Insert(a); await store.Insert(b);
@@ -86,6 +87,14 @@ try
Check("Preview cannot enable PMS updates", (await one.PutAsJsonAsync("/api/pms/controls",new{version=0,enabled=true})).StatusCode==HttpStatusCode.BadRequest);
Check("Unknown PMS snapshot cannot be proposed", (await two.PostAsJsonAsync("/api/pms/changes",new{snapshotId="foreign",kind="AddNote",arrival="",departure="",note="test"})).StatusCode==HttpStatusCode.NotFound);
Check("Unknown PMS operation cannot be applied", (await two.PostAsJsonAsync("/api/pms/changes/foreign/apply",new{version=0,availabilityAndPriceChecked=true})).StatusCode==HttpStatusCode.NotFound);
var paymentStatus=await Read(one,"/api/payments/status");
Check("Preview payment status is disabled and contains no secret", !paymentStatus.GetProperty("configured").GetBoolean()&&!paymentStatus.GetRawText().Contains("securityKey"));
Check("Preview cannot enable invoice creation",(await one.PutAsJsonAsync("/api/payments/controls",new{version=0,enabled=true})).StatusCode==HttpStatusCode.BadRequest);
Check("Preview cannot prepare a real payment",(await one.PostAsJsonAsync("/api/payments/requests",new{reference="TEST",email="guest@example.invalid",description="Deposit",amount=80,currency="GBP"})).StatusCode==HttpStatusCode.BadRequest);
var payments=await Read(one,"/api/payments/requests");var paymentId=payments[0].GetProperty("id").GetString();
Check("Foreign payment cannot be approved",(await two.PostAsJsonAsync($"/api/payments/requests/{paymentId}/create",new{version=0,emailAndAmountApproved=true})).StatusCode==HttpStatusCode.NotFound);
Check("Foreign payment cannot be reconciled",(await two.PostAsJsonAsync($"/api/payments/requests/{paymentId}/check",new{version=0})).StatusCode==HttpStatusCode.NotFound);
Check("Preview sample invoice cannot be created",(await one.PostAsJsonAsync($"/api/payments/requests/{paymentId}/create",new{version=0,emailAndAmountApproved=true})).StatusCode==HttpStatusCode.BadRequest);
var cookie=(await one.GetAsync("/api/session")).Headers;
Check("Session response is not cacheable", cookie.CacheControl?.NoStore==true);
await one.PostAsJsonAsync("/api/auth/logout",new {});
@@ -98,3 +107,5 @@ finally
// This suite owns only a fresh, randomly named database under a fixed test prefix.
if (uri != null && dbName.StartsWith("guestops_test_")) await new MongoClient(uri).DropDatabaseAsync(dbName);
}