2020-06-29 04:44:35 +02:00
|
|
|
|
2020-09-17 16:39:55 +02:00
|
|
|
using BTCPayServer;
|
2017-09-13 08:47:34 +02:00
|
|
|
using BTCPayServer.Controllers;
|
2020-09-17 16:39:55 +02:00
|
|
|
using BTCPayServer.Services.Apps;
|
2020-03-13 11:47:22 +01:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
|
|
namespace Microsoft.AspNetCore.Mvc
|
|
|
|
{
|
|
|
|
public static class UrlHelperExtensions
|
|
|
|
{
|
2020-04-10 08:59:39 +02:00
|
|
|
public static string EmailConfirmationLink(this LinkGenerator urlHelper, string userId, string code, string scheme, HostString host, string pathbase)
|
2017-09-13 08:47:34 +02:00
|
|
|
{
|
2022-01-07 04:32:00 +01:00
|
|
|
return urlHelper.GetUriByAction(nameof(UIAccountController.ConfirmEmail), "UIAccount",
|
2020-06-28 10:55:27 +02:00
|
|
|
new { userId, code }, scheme, host, pathbase);
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|
|
|
|
|
2021-12-31 08:59:02 +01:00
|
|
|
public static string ResetPasswordCallbackLink(this LinkGenerator urlHelper, string userId, string code, string scheme, HostString host, string pathbase)
|
2017-09-13 08:47:34 +02:00
|
|
|
{
|
2020-09-05 12:16:48 +02:00
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIAccountController.SetPassword),
|
|
|
|
controller: "UIAccount",
|
2017-09-13 08:47:34 +02:00
|
|
|
values: new { userId, code },
|
2020-09-05 12:16:48 +02:00
|
|
|
scheme: scheme,
|
2021-12-31 08:59:02 +01:00
|
|
|
host: host,
|
2020-09-05 12:16:48 +02:00
|
|
|
pathBase: pathbase
|
|
|
|
);
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|
2020-04-19 13:12:07 +02:00
|
|
|
|
2020-06-28 10:55:27 +02:00
|
|
|
public static string PaymentRequestLink(this LinkGenerator urlHelper, string paymentRequestId, string scheme, HostString host, string pathbase)
|
2020-04-19 13:12:07 +02:00
|
|
|
{
|
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIPaymentRequestController.ViewPaymentRequest),
|
|
|
|
controller: "UIPaymentRequest",
|
2020-06-28 10:55:27 +02:00
|
|
|
values: new { id = paymentRequestId },
|
2020-04-19 13:12:07 +02:00
|
|
|
scheme, host, pathbase);
|
|
|
|
}
|
2020-04-28 09:53:34 +02:00
|
|
|
|
2021-12-31 08:59:02 +01:00
|
|
|
public static string AppLink(this LinkGenerator urlHelper, string appId, string scheme, HostString host, string pathbase)
|
2020-09-17 16:39:55 +02:00
|
|
|
{
|
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIAppsPublicController.RedirectToApp),
|
|
|
|
controller: "UIAppsPublic",
|
2021-12-31 08:59:02 +01:00
|
|
|
values: new { appId },
|
2020-09-17 16:39:55 +02:00
|
|
|
scheme, host, pathbase);
|
|
|
|
}
|
|
|
|
|
2020-06-28 10:55:27 +02:00
|
|
|
public static string InvoiceLink(this LinkGenerator urlHelper, string invoiceId, string scheme, HostString host, string pathbase)
|
2020-04-28 09:53:34 +02:00
|
|
|
{
|
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIInvoiceController.Invoice),
|
|
|
|
controller: "UIInvoice",
|
2020-06-28 10:55:27 +02:00
|
|
|
values: new { invoiceId = invoiceId },
|
2020-04-28 09:53:34 +02:00
|
|
|
scheme, host, pathbase);
|
|
|
|
}
|
2020-09-17 16:39:55 +02:00
|
|
|
|
2020-12-10 15:34:50 +01:00
|
|
|
public static string CheckoutLink(this LinkGenerator urlHelper, string invoiceId, string scheme, HostString host, string pathbase)
|
|
|
|
{
|
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIInvoiceController.Checkout),
|
|
|
|
controller: "UIInvoice",
|
2020-12-10 15:34:50 +01:00
|
|
|
values: new { invoiceId = invoiceId },
|
|
|
|
scheme, host, pathbase);
|
|
|
|
}
|
|
|
|
|
2021-12-31 08:59:02 +01:00
|
|
|
public static string PayoutLink(this LinkGenerator urlHelper, string walletIdOrStoreId, string pullPaymentId, string scheme, HostString host, string pathbase)
|
2020-09-17 16:39:55 +02:00
|
|
|
{
|
2021-10-22 04:17:40 +02:00
|
|
|
WalletId.TryParse(walletIdOrStoreId, out var wallet);
|
2020-09-17 16:39:55 +02:00
|
|
|
return urlHelper.GetUriByAction(
|
2022-01-07 04:32:00 +01:00
|
|
|
action: nameof(UIStorePullPaymentsController.Payouts),
|
|
|
|
controller: "UIStorePullPayments",
|
2021-12-31 08:59:02 +01:00
|
|
|
values: new { storeId = wallet?.StoreId ?? walletIdOrStoreId, pullPaymentId },
|
2020-09-17 16:39:55 +02:00
|
|
|
scheme, host, pathbase);
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|
|
|
|
}
|