mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Remove PaymentMethodData from invoice entity
This commit is contained in:
@@ -13,60 +13,5 @@ namespace BTCPayServer.Client.Models
|
|||||||
public InvoiceStatus Status { get; set; }
|
public InvoiceStatus Status { get; set; }
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public InvoiceExceptionStatus AdditionalStatus { get; set; }
|
public InvoiceExceptionStatus AdditionalStatus { get; set; }
|
||||||
public Dictionary<string, PaymentMethodDataModel> PaymentMethodData { get; set; }
|
|
||||||
|
|
||||||
public class PaymentMethodDataModel
|
|
||||||
{
|
|
||||||
public string Destination { get; set; }
|
|
||||||
public string PaymentLink { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal Rate { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal PaymentMethodPaid { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal TotalPaid { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal Due { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal Amount { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal NetworkFee { get; set; }
|
|
||||||
|
|
||||||
public List<Payment> Payments { get; set; }
|
|
||||||
|
|
||||||
public class Payment
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
|
|
||||||
public DateTime ReceivedDate { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal Value { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))]
|
|
||||||
public decimal Fee { get; set; }
|
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
public PaymentStatus Status { get; set; }
|
|
||||||
|
|
||||||
public string Destination { get; set; }
|
|
||||||
|
|
||||||
public enum PaymentStatus
|
|
||||||
{
|
|
||||||
Invalid,
|
|
||||||
AwaitingConfirmation,
|
|
||||||
AwaitingCompletion,
|
|
||||||
Complete
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,5 +246,5 @@
|
|||||||
<_ContentIncludedByDefault Remove="Views\Components\NotificationsDropdown\Default.cshtml" />
|
<_ContentIncludedByDefault Remove="Views\Components\NotificationsDropdown\Default.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ProjectExtensions><VisualStudio><UserProperties wwwroot_4swagger_4v1_4swagger_1template_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1pull-payments_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1serverinfo_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1stores_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" /></VisualStudio></ProjectExtensions>
|
<ProjectExtensions><VisualStudio><UserProperties wwwroot_4swagger_4v1_4swagger_1template_1invoices_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1pull-payments_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1serverinfo_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1stores_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" /></VisualStudio></ProjectExtensions>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -269,50 +269,7 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
PaymentMethods =
|
PaymentMethods =
|
||||||
entity.GetPaymentMethods().Select(method => method.GetId().ToString()).ToArray(),
|
entity.GetPaymentMethods().Select(method => method.GetId().ToString()).ToArray(),
|
||||||
SpeedPolicy = entity.SpeedPolicy
|
SpeedPolicy = entity.SpeedPolicy
|
||||||
},
|
}
|
||||||
PaymentMethodData = entity.GetPaymentMethods().ToDictionary(method => method.GetId().ToString(),
|
|
||||||
method =>
|
|
||||||
{
|
|
||||||
var accounting = method.Calculate();
|
|
||||||
var details = method.GetPaymentMethodDetails();
|
|
||||||
var payments = method.ParentEntity.GetPayments().Where(paymentEntity =>
|
|
||||||
paymentEntity.GetPaymentMethodId() == method.GetId());
|
|
||||||
|
|
||||||
return new InvoiceData.PaymentMethodDataModel()
|
|
||||||
{
|
|
||||||
Destination = details.GetPaymentDestination(),
|
|
||||||
Rate = method.Rate,
|
|
||||||
Due = accounting.Due.ToDecimal(MoneyUnit.BTC),
|
|
||||||
TotalPaid = accounting.Paid.ToDecimal(MoneyUnit.BTC),
|
|
||||||
PaymentMethodPaid = accounting.CryptoPaid.ToDecimal(MoneyUnit.BTC),
|
|
||||||
Amount = accounting.Due.ToDecimal(MoneyUnit.BTC),
|
|
||||||
NetworkFee = accounting.NetworkFee.ToDecimal(MoneyUnit.BTC),
|
|
||||||
PaymentLink =
|
|
||||||
method.GetId().PaymentType.GetPaymentLink(method.Network, details, accounting.Due,
|
|
||||||
Request.GetAbsoluteRoot()),
|
|
||||||
Payments = payments.Select(paymentEntity =>
|
|
||||||
{
|
|
||||||
var data = paymentEntity.GetCryptoPaymentData();
|
|
||||||
return new InvoiceData.PaymentMethodDataModel.Payment()
|
|
||||||
{
|
|
||||||
Destination = data.GetDestination(),
|
|
||||||
Id = data.GetPaymentId(),
|
|
||||||
Status = !paymentEntity.Accounted
|
|
||||||
? InvoiceData.PaymentMethodDataModel.Payment.PaymentStatus.Invalid
|
|
||||||
: data.PaymentCompleted(paymentEntity)
|
|
||||||
? InvoiceData.PaymentMethodDataModel.Payment.PaymentStatus.Complete
|
|
||||||
: data.PaymentConfirmed(paymentEntity, entity.SpeedPolicy)
|
|
||||||
? InvoiceData.PaymentMethodDataModel.Payment.PaymentStatus
|
|
||||||
.AwaitingCompletion
|
|
||||||
: InvoiceData.PaymentMethodDataModel.Payment.PaymentStatus
|
|
||||||
.AwaitingConfirmation,
|
|
||||||
Fee = paymentEntity.NetworkFee,
|
|
||||||
Value = data.GetValue(),
|
|
||||||
ReceivedDate = paymentEntity.ReceivedTime.DateTime
|
|
||||||
};
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -533,124 +533,11 @@
|
|||||||
"additionalStatus": {
|
"additionalStatus": {
|
||||||
"$ref": "#/components/schemas/InvoiceAdditionalStatus",
|
"$ref": "#/components/schemas/InvoiceAdditionalStatus",
|
||||||
"description": "a secondary status of the invoice"
|
"description": "a secondary status of the invoice"
|
||||||
},
|
|
||||||
"paymentMethodData": {
|
|
||||||
"type": "object",
|
|
||||||
"nullable": false,
|
|
||||||
"additionalProperties": {
|
|
||||||
"$ref": "#/components/schemas/PaymentMethodDataModel"
|
|
||||||
},
|
|
||||||
"description": "Activated payment methods details"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"PaymentMethodDataModel": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"properties": {
|
|
||||||
"destination": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "The destination the payment must be made to"
|
|
||||||
},
|
|
||||||
"paymentLink": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "A payment link that helps pay to the payment destination"
|
|
||||||
},
|
|
||||||
"rate": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The rate between this payment method's currency and the invoice currency"
|
|
||||||
},
|
|
||||||
"paymentMethodPaid": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The amount paid by this payment method"
|
|
||||||
},
|
|
||||||
"totalPaid": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The total amount paid by all payment methods to the invoice, converted to this payment method's currency"
|
|
||||||
},
|
|
||||||
"due": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The total amount left to be paid, converted to this payment method's currency"
|
|
||||||
},
|
|
||||||
"amount": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The invoice amount, converted to this payment method's currency"
|
|
||||||
},
|
|
||||||
"networkFee": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The added merchant fee to pay for network costs of this payment method."
|
|
||||||
},
|
|
||||||
"payments": {
|
|
||||||
"type": "array",
|
|
||||||
"nullable": true,
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/Payment"
|
|
||||||
},
|
|
||||||
"description": "Payments made with this payment method."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Payment": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "A unique identifier for this payment"
|
|
||||||
},
|
|
||||||
"receivedDate": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time",
|
|
||||||
"description": "The date the payment was recorded"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The value of the payment"
|
|
||||||
},
|
|
||||||
"fee": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "decimal",
|
|
||||||
"description": "The fee paid for the payment"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"$ref": "#/components/schemas/PaymentStatus",
|
|
||||||
"description": "The status of the payment"
|
|
||||||
},
|
|
||||||
"destination": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"description": "The destination the payment was made to"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PaymentStatus": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "",
|
|
||||||
"x-enumNames": [
|
|
||||||
"Invalid",
|
|
||||||
"AwaitingConfirmation",
|
|
||||||
"AwaitingCompletion",
|
|
||||||
"Complete"
|
|
||||||
],
|
|
||||||
"enum": [
|
|
||||||
"Invalid",
|
|
||||||
"AwaitingConfirmation",
|
|
||||||
"AwaitingCompletion",
|
|
||||||
"Complete"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"CreateInvoiceRequest": {
|
"CreateInvoiceRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@@ -700,7 +587,7 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": "A specific set of payment methods to use for this invoice"
|
"description": "A specific set of payment methods to use for this invoice (ie. BTC, BTC_OnChain). By default, select all payment methods activated in the store."
|
||||||
},
|
},
|
||||||
"expirationMinutes": {
|
"expirationMinutes": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
Reference in New Issue
Block a user