2024-04-04 16:31:04 +09:00
|
|
|
#nullable enable
|
|
|
|
using System;
|
2019-05-29 14:33:31 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2024-04-04 16:31:04 +09:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2019-05-29 14:33:31 +00:00
|
|
|
using BTCPayServer.Payments;
|
2024-04-04 16:31:04 +09:00
|
|
|
using BTCPayServer.Payments.Bitcoin;
|
|
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
using Newtonsoft.Json.Linq;
|
2019-05-29 14:33:31 +00:00
|
|
|
|
|
|
|
namespace BTCPayServer.Services.Invoices
|
|
|
|
{
|
2024-05-01 10:22:07 +09:00
|
|
|
public class PaymentMethodHandlerDictionary : HandlersDictionary<PaymentMethodId, IPaymentMethodHandler>
|
2019-05-29 14:33:31 +00:00
|
|
|
{
|
2024-05-01 10:22:07 +09:00
|
|
|
public PaymentMethodHandlerDictionary(IEnumerable<IPaymentMethodHandler> paymentMethodHandlers) : base(paymentMethodHandlers)
|
2019-05-29 14:33:31 +00:00
|
|
|
{
|
|
|
|
}
|
2024-04-04 16:31:04 +09:00
|
|
|
|
|
|
|
public object? ParsePaymentPromptDetails(PaymentPrompt prompt)
|
|
|
|
{
|
|
|
|
if (prompt.Details is null or JToken { Type: JTokenType.Null })
|
|
|
|
return null;
|
|
|
|
if (!this.TryGetValue(prompt.PaymentMethodId, out var handler))
|
|
|
|
return null;
|
|
|
|
return handler.ParsePaymentPromptDetails(prompt.Details);
|
|
|
|
}
|
2019-05-29 14:33:31 +00:00
|
|
|
}
|
|
|
|
}
|