Skip to content

Commit

Permalink
FIX: Ensure client is available in validation.php
Browse files Browse the repository at this point in the history
  • Loading branch information
BitcoinMitchell committed Nov 15, 2023
1 parent 05f4108 commit c9eecba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/btcpay/btcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct()
{
$this->name = 'btcpay';
$this->tab = 'payments_gateways';
$this->version = '6.0.0';
$this->version = '6.0.1';
$this->author = 'BTCPay Server';
$this->ps_versions_compliancy = ['min' => Constants::MINIMUM_PS_VERSION, 'max' => _PS_VERSION_];
$this->controllers = ['payment', 'validation', 'webhook'];
Expand Down
17 changes: 9 additions & 8 deletions modules/btcpay/controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use BTCPay\Constants;
use BTCPay\Invoice\Processor;
use BTCPay\LegacyBitcoinPaymentRepository;
use BTCPay\Server\Client;
use PrestaShop\PrestaShop\Adapter\Configuration;

class BTCPayValidationModuleFrontController extends ModuleFrontController
Expand All @@ -29,18 +30,12 @@ class BTCPayValidationModuleFrontController extends ModuleFrontController
*/
private $repository;

/**
* @var Processor
*/
private $processor;

public function __construct()
{
parent::__construct();

$this->configuration = new Configuration();
$this->repository = new LegacyBitcoinPaymentRepository();
$this->processor = new Processor($this->module, $this->configuration, $this->client);
}

/**
Expand Down Expand Up @@ -104,8 +99,14 @@ public function postProcess(): void
return;
}

// User was quicker than the callback, deal with the actual invoice now
$this->processor->paymentReceivedCreateAfter($bitcoinPayment);
// Ensure the client is ready for use
if (null === ($client = Client::createFromConfiguration($this->configuration)) || false === $client->isValid()) {
throw new RuntimeException('Expected the client to be available');
}

// User was quicker than the callback, so we deal with the actual invoice now
$processor = new Processor($this->module, $this->configuration, $client);
$processor->paymentReceivedCreateAfter($bitcoinPayment);

// Grab the (now existing) order
$order = Order::getByCartId($bitcoinPayment->getCartId());
Expand Down

0 comments on commit c9eecba

Please sign in to comment.