mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Remove invoices/email for this PR
This commit is contained in:
@@ -47,17 +47,6 @@ namespace BTCPayServer.Client
|
|||||||
return await HandleResponse<InvoiceData>(response);
|
return await HandleResponse<InvoiceData>(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task<InvoiceData> AddCustomerEmailToInvoice(string storeId, string invoiceId,
|
|
||||||
AddCustomerEmailRequest request, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
if (request == null)
|
|
||||||
throw new ArgumentNullException(nameof(request));
|
|
||||||
var response = await _httpClient.SendAsync(
|
|
||||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}/email", bodyPayload: request,
|
|
||||||
method: HttpMethod.Post), token);
|
|
||||||
return await HandleResponse<InvoiceData>(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual async Task<InvoiceData> MarkInvoiceStatus(string storeId, string invoiceId,
|
public virtual async Task<InvoiceData> MarkInvoiceStatus(string storeId, string invoiceId,
|
||||||
MarkInvoiceStatusRequest request, CancellationToken token = default)
|
MarkInvoiceStatusRequest request, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -845,17 +845,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal(newInvoice.Metadata, invoice.Metadata);
|
Assert.Equal(newInvoice.Metadata, invoice.Metadata);
|
||||||
|
|
||||||
//update
|
//update
|
||||||
await AssertHttpError(403, async () =>
|
|
||||||
{
|
|
||||||
await viewOnly.AddCustomerEmailToInvoice(user.StoreId, invoice.Id, new AddCustomerEmailRequest()
|
|
||||||
{
|
|
||||||
Email = "j@g.com"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
await client.AddCustomerEmailToInvoice(user.StoreId, invoice.Id, new AddCustomerEmailRequest()
|
|
||||||
{
|
|
||||||
Email = "j@g.com"
|
|
||||||
});
|
|
||||||
invoice = await viewOnly.GetInvoice(user.StoreId, newInvoice.Id);
|
invoice = await viewOnly.GetInvoice(user.StoreId, newInvoice.Id);
|
||||||
|
|
||||||
await AssertValidationError(new[] { nameof(MarkInvoiceStatusRequest.Status) }, async () =>
|
await AssertValidationError(new[] { nameof(MarkInvoiceStatusRequest.Status) }, async () =>
|
||||||
|
|||||||
@@ -183,43 +183,6 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
return await GetInvoice(storeId, invoiceId);
|
return await GetInvoice(storeId, invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanCreateInvoice,
|
|
||||||
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
|
||||||
[HttpPost("~/api/v1/stores/{storeId}/invoices/{invoiceId}/email")]
|
|
||||||
public async Task<IActionResult> AddCustomerEmail(string storeId, string invoiceId,
|
|
||||||
AddCustomerEmailRequest request)
|
|
||||||
{
|
|
||||||
var store = HttpContext.GetStoreData();
|
|
||||||
if (store == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var invoice = await _invoiceRepository.GetInvoice(invoiceId, true);
|
|
||||||
if (invoice.StoreId != store.Id)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EmailValidator.IsEmail(request.Email))
|
|
||||||
{
|
|
||||||
request.AddModelError(invoiceRequest => invoiceRequest.Email, "Invalid email address",
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(invoice.Metadata.BuyerEmail))
|
|
||||||
{
|
|
||||||
request.AddModelError(invoiceRequest => invoiceRequest.Email, "Email address already set",
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return this.CreateValidationError(ModelState);
|
|
||||||
|
|
||||||
await _invoiceRepository.UpdateInvoice(invoice.Id, new UpdateCustomerModel() { Email = request.Email });
|
|
||||||
|
|
||||||
return await GetInvoice(storeId, invoiceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanModifyStoreSettings,
|
[Authorize(Policy = Policies.CanModifyStoreSettings,
|
||||||
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
[HttpPost("~/api/v1/stores/{storeId}/invoices/{invoiceId}/unarchive")]
|
[HttpPost("~/api/v1/stores/{storeId}/invoices/{invoiceId}/unarchive")]
|
||||||
|
|||||||
@@ -216,79 +216,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/v1/stores/{storeId}/invoices/{invoiceId}/email": {
|
|
||||||
"post": {
|
|
||||||
"tags": [
|
|
||||||
"Invoices"
|
|
||||||
],
|
|
||||||
"summary": "Add customer email to invoice",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "storeId",
|
|
||||||
"in": "path",
|
|
||||||
"required": true,
|
|
||||||
"description": "The store to query",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "invoiceId",
|
|
||||||
"in": "path",
|
|
||||||
"required": true,
|
|
||||||
"description": "The invoice to update",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Adds the customer's email to the invoice if it has not been set already.",
|
|
||||||
"operationId": "Invoices_AddCustomerEmail",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "The updated invoice",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/InvoiceData"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "A list of errors that occurred when updating the invoice",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/ValidationProblemDetails"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"403": {
|
|
||||||
"description": "If you are authenticated but forbidden to update the invoice"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/AddCustomerEmailRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"API Key": [
|
|
||||||
"btcpay.store.cancreateinvoice"
|
|
||||||
],
|
|
||||||
"Basic": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/api/v1/stores/{storeId}/invoices/{invoiceId}/status": {
|
"/api/v1/stores/{storeId}/invoices/{invoiceId}/status": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|||||||
Reference in New Issue
Block a user