Skip to content

Commit

Permalink
[Order] Show payment info only if paid via BTCPay Server
Browse files Browse the repository at this point in the history
  • Loading branch information
BitcoinMitchell committed Feb 17, 2024
1 parent c143a6c commit ef1f321
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/btcpay/btcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ef1f321

Please sign in to comment.