From ef1f321ed9cec676f540c2bf887dc45e001ed1fe Mon Sep 17 00:00:00 2001 From: BitcoinMitchell Date: Sat, 17 Feb 2024 22:32:32 +0100 Subject: [PATCH] [Order] Show payment info only if paid via BTCPay Server --- modules/btcpay/btcpay.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/btcpay/btcpay.php b/modules/btcpay/btcpay.php index cf9a9a2..96f3199 100644 --- a/modules/btcpay/btcpay.php +++ b/modules/btcpay/btcpay.php @@ -334,12 +334,23 @@ public function hookDisplayOrderDetail(array $params): ?string $storeID = $this->configuration->get(Constants::CONFIGURATION_BTCPAY_STORE_ID); try { + // Get the payment methods + $paymentMethods = $client->invoice()->getPaymentMethods($storeID, $invoiceId); + + // Determine if any payments have been made via BTCPay Sever + $hasPayments = array_reduce($paymentMethods, static fn ($hasPayments, $paymentMethod) => $hasPayments || !empty($paymentMethod->getPayments()), false); + + // If not, there is no need to show anything + if (!$hasPayments) { + return null; + } + // Prepare smarty $this->context->smarty->assign([ 'serverURL' => $serverUrl, 'storeCurrency' => Currency::getCurrencyInstance($cart->id_currency)->getSymbol(), 'invoice' => $client->invoice()->getInvoice($storeID, $invoiceId), - 'paymentMethods' => $client->invoice()->getPaymentMethods($storeID, $invoiceId), + 'paymentMethods' => $paymentMethods, ]); return $this->display(__FILE__, 'views/templates/hooks/order_detail.tpl');