Update NopCommerce 4.9 / BTCPay 2
This commit is contained in:
parent
68ca0e12dc
commit
8bcbdd1c9f
@ -133,6 +133,7 @@ namespace Nop.Plugin.Payments.BTCPayServer
|
||||
"<ul>" +
|
||||
" <li>The \"BTCPay Url,\" \"API Key,\" \"BTCPay Store ID,\" and \"WebHook Secret\" fields must be filled out, then save.</li>" +
|
||||
" <li>Read detailed step by step <a href =\"https://github.com/btcpayserver/nopcommerce?tab=readme-ov-file#manual-configuration\" target=\"_blank\"> instructions on how to manually configure</a>. </li>" +
|
||||
"</ul>",
|
||||
|
||||
["Plugins.Payments.BTCPayServer.WebHookInfo"] = "Here is the URL to set for the WebHook creation in BTCPay : ",
|
||||
|
||||
@ -298,7 +299,7 @@ namespace Nop.Plugin.Payments.BTCPayServer
|
||||
// implement process payment
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
var myStore = await _storeService.GetStoreByIdAsync(processPaymentRequest.StoreId);
|
||||
var currency = await _currencyService.GetCurrencyByIdAsync(_currencySettings.PrimaryStoreCurrencyId);
|
||||
var lang = await _languageService.GetLanguageByIdAsync(myStore.DefaultLanguageId);
|
||||
@ -359,7 +360,7 @@ namespace Nop.Plugin.Payments.BTCPayServer
|
||||
var result = new RefundPaymentResult();
|
||||
try
|
||||
{
|
||||
var sUrl = await _btcPayService.CreateRefund(_btcPaySettings, refundPaymentRequest);
|
||||
var sUrl = await _btcPayService.CreateRefund(_btcPaySettings, refundPaymentRequest);
|
||||
result.NewPaymentStatus = refundPaymentRequest.IsPartialRefund ? PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded;
|
||||
await _orderService.InsertOrderNoteAsync(new OrderNote
|
||||
{
|
||||
@ -410,4 +411,4 @@ namespace Nop.Plugin.Payments.BTCPayServer
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ using NUglify.Helpers;
|
||||
|
||||
namespace Nop.Plugin.Payments.BTCPayServer.Controllers
|
||||
{
|
||||
[Area(AreaNames.Admin)]
|
||||
[Area(AreaNames.ADMIN)]
|
||||
[AutoValidateAntiforgeryToken]
|
||||
public class PaymentBTCPayServerController : BasePaymentController
|
||||
{
|
||||
@ -78,7 +78,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Controllers
|
||||
[AuthorizeAdmin]
|
||||
public async Task<IActionResult> Configure()
|
||||
{
|
||||
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
|
||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Configuration.MANAGE_PAYMENT_METHODS))
|
||||
return AccessDeniedView();
|
||||
|
||||
//load settings for a chosen store scope
|
||||
@ -126,7 +126,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Controllers
|
||||
Policies.CanCreateInvoice, // create invoices for payment
|
||||
Policies.CanViewInvoices, // fetch created invoices to check status
|
||||
Policies.CanModifyInvoices, // able to mark an invoice invalid in case merchant wants to void the order
|
||||
Policies.CanModifyStoreWebhooks, // able to create the webhook required automatically
|
||||
Policies.CanModifyWebhooks, // able to create the webhook required automatically
|
||||
Policies.CanViewStoreSettings, // able to fetch rates
|
||||
Policies.CanCreateNonApprovedPullPayments // able to create refunds
|
||||
},
|
||||
@ -139,7 +139,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Controllers
|
||||
[AuthorizeAdmin]
|
||||
public async Task<IActionResult> Configure(ConfigurationModel model, string command = null)
|
||||
{
|
||||
if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
|
||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Configuration.MANAGE_PAYMENT_METHODS))
|
||||
return AccessDeniedView();
|
||||
|
||||
//load settings for a chosen store scope
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Controllers
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Process([FromHeader(Name = "BTCPAY-SIG")] string BtcPaySig)
|
||||
public async Task<IActionResult> Process([FromHeader(Name = "BTCPAY-Sig")] string BtcPaySig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Copyright>Copyright © Nisaba Solutions</Copyright>
|
||||
<Company>Nisaba Solutions</Company>
|
||||
<Authors>Nisaba Solutions</Authors>
|
||||
@ -45,7 +45,7 @@
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BTCPayServer.Client" Version="1.7.3" />
|
||||
<PackageReference Include="BTCPayServer.Client" Version="2.0.1" />
|
||||
</ItemGroup>
|
||||
<!-- This target execute after "Build" target -->
|
||||
<Target Name="NopTarget" AfterTargets="Build">
|
||||
|
||||
6
Nop.Plugin.Payments.BtcPayServer.csproj.user
Normal file
6
Nop.Plugin.Payments.BtcPayServer.csproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_LastSelectedProfileId>C:\CODES-SOURCES\NopCommerce2\src\Plugins\Nop.Plugin.Payments.BTCPayServer\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -50,8 +50,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Services
|
||||
{
|
||||
DefaultLanguage = paymentData.Lang,
|
||||
RedirectURL = paymentData.RedirectionURL,
|
||||
RedirectAutomatically = true,
|
||||
RequiresRefundEmail = false
|
||||
RedirectAutomatically = true
|
||||
},
|
||||
Metadata = JObject.FromObject(new
|
||||
{
|
||||
@ -74,11 +73,11 @@ namespace Nop.Plugin.Payments.BTCPayServer.Services
|
||||
var client = GetClient(settings);
|
||||
var invoice = await client.GetInvoicePaymentMethods(settings.BtcPayStoreID,
|
||||
refundRequest.Order.AuthorizationTransactionId);
|
||||
var pm = (invoice.FirstOrDefault(p => p.Payments.Any()) ?? invoice.First()).PaymentMethod;
|
||||
var pm = (invoice.FirstOrDefault(p => p.Payments.Any()) ?? invoice.First()).PaymentMethodId;
|
||||
var refundInvoiceRequest = new RefundInvoiceRequest()
|
||||
{
|
||||
Name = "Refund order " + refundRequest.Order.OrderGuid,
|
||||
PaymentMethod = pm,
|
||||
PayoutMethodId = pm,
|
||||
};
|
||||
if (refundRequest.IsPartialRefund)
|
||||
{
|
||||
@ -90,7 +89,7 @@ namespace Nop.Plugin.Payments.BTCPayServer.Services
|
||||
else
|
||||
{
|
||||
refundInvoiceRequest.Description = "Full";
|
||||
refundInvoiceRequest.PaymentMethod = "BTC";
|
||||
refundInvoiceRequest.PayoutMethodId = "BTC";
|
||||
refundInvoiceRequest.RefundVariant = RefundVariant.Fiat;
|
||||
}
|
||||
|
||||
@ -266,11 +265,11 @@ namespace Nop.Plugin.Payments.BTCPayServer.Services
|
||||
case WebhookEventType.InvoiceReceivedPayment
|
||||
when webhookEvent.ReadAs<WebhookInvoiceReceivedPaymentEvent>() is { } receivedPaymentEvent:
|
||||
return
|
||||
$"Payment detected ({receivedPaymentEvent.PaymentMethod}: {receivedPaymentEvent.Payment.Value})";
|
||||
$"Payment detected ({receivedPaymentEvent.PaymentMethodId}: {receivedPaymentEvent.Payment.Value})";
|
||||
case WebhookEventType.InvoicePaymentSettled
|
||||
when webhookEvent.ReadAs<WebhookInvoicePaymentSettledEvent>() is { } receivedPaymentEvent:
|
||||
return
|
||||
$"Payment settled ({receivedPaymentEvent.PaymentMethod}: {receivedPaymentEvent.Payment.Value})";
|
||||
$"Payment settled ({receivedPaymentEvent.PaymentMethodId}: {receivedPaymentEvent.Payment.Value})";
|
||||
case WebhookEventType.InvoiceProcessing
|
||||
when webhookEvent.ReadAs<WebhookInvoiceProcessingEvent>() is { } receivedPaymentEvent &&
|
||||
receivedPaymentEvent.OverPaid:
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
"Group": "Payment methods",
|
||||
"FriendlyName": "Bitcoin payments with BTCPay",
|
||||
"SystemName": "Payments.BTCPayServer",
|
||||
"Version": "1.01",
|
||||
"SupportedVersions": [ "4.60" ],
|
||||
"Version": "1.11",
|
||||
"SupportedVersions": [ "4.90" ],
|
||||
"Author": "Nisaba Solutions",
|
||||
"DisplayOrder": 1,
|
||||
"FileName": "Nop.Plugin.Payments.BTCPayServer.dll",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user