Merge pull request #11 from btcpayserver/ft/refund_options

Make current exchange rate the default refund option
This commit is contained in:
Chukwuleta Tobechi 2026-01-22 18:41:01 +01:00 committed by GitHub
commit e9f9a1d401
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 16 deletions

View File

@ -7,7 +7,7 @@
<PropertyGroup>
<Product>BTCPay Server Shopify Plugin v2</Product>
<Description>BTCPay server integration with Shopify.</Description>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>
<!-- Plugin development properties -->

View File

@ -330,6 +330,7 @@ public class UIShopifyV2Controller : Controller
Enum.TryParse<ShopifyRefundWebhookSettingsViewModel.RefundOption>(settings.Setup?.SelectedRefundOption, ignoreCase: true, out var refundOption);
var vm = new ShopifyRefundWebhookSettingsViewModel
{
ShopName = GetShopName(settings.Setup?.ShopUrl),
WebhookUrl = Url.Action(nameof(Webhook), "UIShopifyV2", new { storeId }, Request.Scheme),
WebhookSecret = settings.Setup?.WebhookSecret,
SpreadPercentage = settings.Setup.SpreadPercentage,

View File

@ -7,15 +7,14 @@ public class ShopifyRefundWebhookSettingsViewModel
{
public enum RefundOption
{
RateThen,
CurrentRate
CurrentRate,
RateThen
}
public string ShopName { get; set; }
public string WebhookUrl { get; set; }
[Required(ErrorMessage = "Webhook secret is required")]
public string WebhookSecret { get; set; }
[Required(ErrorMessage = "Please select a refund option")]
public RefundOption? SelectedRefundOption { get; set; }
public RefundOption SelectedRefundOption { get; set; } = RefundOption.CurrentRate;
[Range(0, 99, ErrorMessage = "Spread must be between 0 and 99")]
public decimal SpreadPercentage { get; set; } = 0;

View File

@ -41,13 +41,16 @@
and sends a secure claim link to the customer by email.
</p>
<p class="mb-2">
Copy the webhook URL below and paste it into your Shopify Admin dashboard.
Copy the webhook URL below and create a webhook via
<a href="https://admin.shopify.com/store/@(Model.ShopName)/settings/notifications/webhooks"
target="_blank" rel="noopener noreferrer" style="color: inherit; text-decoration: underline;">
this link</a>.
Use the settings below:
</p>
<ul class="mb-2">
<li>Go to <strong>Settings → Notifications → Webhooks</strong></li>
<li>Create a webhook for the <strong>Refund create</strong> event</li>
<li>Set the format to <strong>JSON</strong></li>
<li>Use Webhook API version <strong>2026-01</strong></li>
<li>Event: <strong>Refund create</strong></li>
<li>Format: <strong>JSON</strong></li>
<li>Webhook API version: <strong>2026-01</strong></li>
</ul>
</div>
@ -62,7 +65,7 @@
</div>
</div>
<div class="mb-4">
<label asp-for="WebhookSecret" class="form-label fw-bold">Webhook Secret</label>
<label asp-for="WebhookSecret" class="form-label fw-bold">Webhook Signature</label>
<input asp-for="WebhookSecret" class="form-control" placeholder="Enter your Shopify webhook secret" />
<span asp-validation-for="WebhookSecret" class="text-danger"></span>
<div class="form-text">
@ -73,14 +76,14 @@
<div class="mb-4">
<label class="form-label fw-bold">Refund Option Method</label>
<span asp-validation-for="SelectedRefundOption" class="text-danger"></span>
<div class="form-check">
<input class="form-check-input" type="radio" asp-for="SelectedRefundOption" value="RateThen" id="refundRateThen" />
<label class="form-check-label" for="refundRateThen">Use exchange rate at time of original payment</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" asp-for="SelectedRefundOption" value="CurrentRate" id="refundCurrentRate" />
<label class="form-check-label" for="refundCurrentRate"> Use current exchange rate at time of refund</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" asp-for="SelectedRefundOption" value="RateThen" id="refundRateThen" />
<label class="form-check-label" for="refundRateThen">Use exchange rate at time of original payment</label>
</div>
</div>
<div class="mb-4">