mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Use Outstanding amount for shopify order invoices (#3203)
* Use Outstanding amount for shopify order invoices * consider shopify order may have multiple transactions * Use presentment currency not just currency fixes #2683
This commit is contained in:
parent
eeebb99ca3
commit
9b7ca76b99
4 changed files with 11 additions and 6 deletions
|
@ -9,8 +9,12 @@ namespace BTCPayServer.Plugins.Shopify.ApiModels
|
|||
public string Id { get; set; }
|
||||
[JsonProperty("total_price")]
|
||||
public decimal TotalPrice { get; set; }
|
||||
[JsonProperty("total_outstanding")]
|
||||
public decimal TotalOutstanding { get; set; }
|
||||
[JsonProperty("currency")]
|
||||
public string Currency { get; set; }
|
||||
[JsonProperty("presentment_currency")]
|
||||
public string PresentmentCurrency { get; set; }
|
||||
[JsonProperty("financial_status")]
|
||||
public string FinancialStatus { get; set; }
|
||||
[JsonProperty("transactions")]
|
||||
|
|
|
@ -19,9 +19,10 @@ namespace BTCPayServer.Plugins.Shopify
|
|||
{
|
||||
currency = currency.ToUpperInvariant().Trim();
|
||||
var existingShopifyOrderTransactions = (await _client.TransactionsList(orderId)).transactions;
|
||||
var baseParentTransaction = existingShopifyOrderTransactions.FirstOrDefault();
|
||||
if (baseParentTransaction is null ||
|
||||
!_keywords.Any(a => baseParentTransaction.gateway.Contains(a, StringComparison.InvariantCultureIgnoreCase)))
|
||||
|
||||
//if there isn't a record for btcpay payment gateway, abort
|
||||
var baseParentTransaction = existingShopifyOrderTransactions.FirstOrDefault(holder => !_keywords.Any(a => holder.gateway.Contains(a, StringComparison.InvariantCultureIgnoreCase)));
|
||||
if (baseParentTransaction is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace BTCPayServer.Plugins.Shopify
|
|||
public async Task<ShopifyOrder> GetOrder(string orderId)
|
||||
{
|
||||
var req = CreateRequest(_credentials.ShopName, HttpMethod.Get,
|
||||
$"orders/{orderId}.json?fields=id,total_price,currency,transactions,financial_status");
|
||||
$"orders/{orderId}.json?fields=id,total_price,total_outstanding,currency,presentment_currency,transactions,financial_status");
|
||||
|
||||
var strResp = await SendRequest(req);
|
||||
|
||||
|
|
|
@ -189,8 +189,8 @@ namespace BTCPayServer.Plugins.Shopify
|
|||
var invoice = await _invoiceController.CreateInvoiceCoreRaw(
|
||||
new CreateInvoiceRequest()
|
||||
{
|
||||
Amount = amount < order.TotalPrice ? amount : order.TotalPrice,
|
||||
Currency = order.Currency,
|
||||
Amount = amount < order.TotalOutstanding ? amount : order.TotalOutstanding,
|
||||
Currency = order.PresentmentCurrency,
|
||||
Metadata = new JObject {["orderId"] = invoiceOrderId}
|
||||
}, store,
|
||||
Request.GetAbsoluteRoot(), new List<string>() {invoiceOrderId});
|
||||
|
|
Loading…
Add table
Reference in a new issue