Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure BTCPayServer 2.0 compatibility #170

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Please ensure that you meet the following requirements before installing this pl
### Tested successfully
- Prestashop v8.0, v8.0.1, v8.0.4, v8.1.0, v8.1.3 and v8.1.4
- BTCPay server v1.7.0, v1.7.3.0, v1.12.5, v1.13.0 and v1.13.5
- BTCPay server v2 should be supported as of module version v6.2.0.
- BTCPay server v2 should be supported as of module version v6.3.0.

### Multistore

Expand Down
8 changes: 1 addition & 7 deletions modules/btcpay/btcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct()
{
$this->name = 'btcpay';
$this->tab = 'payments_gateways';
$this->version = '6.2.1';
$this->version = '6.3.0';
$this->author = 'BTCPay Server';
$this->ps_versions_compliancy = ['min' => Constants::MINIMUM_PS_VERSION, 'max' => _PS_VERSION_];
$this->controllers = ['payment', 'validation', 'webhook'];
Expand Down Expand Up @@ -411,12 +411,6 @@ public function hookPaymentOptions(): array
return [];
}

// Prepare smarty
$this->context->smarty->assign([
BitcoinMitchell marked this conversation as resolved.
Show resolved Hide resolved
'onChain' => $client->onChain()->getPaymentMethods($storeID),
'offChain' => $client->offChain()->getPaymentMethods($storeID),
]);

return [
(new PaymentOption())
->setModuleName($this->name)
Expand Down
2 changes: 1 addition & 1 deletion modules/btcpay/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"btcpayserver/btcpayserver-greenfield-php": "^2.6.0",
"btcpayserver/btcpayserver-greenfield-php": "^2.8.1",
"composer/semver": "^3.4.2",
"stechstudio/backoff": "^1.4"
},
Expand Down
375 changes: 212 additions & 163 deletions modules/btcpay/composer.lock

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions modules/btcpay/src/Server/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use BTCPayServer\Client\Server as ServerClient;
use BTCPayServer\Client\Store as StoreClient;
use BTCPayServer\Client\StorePaymentMethod;
use BTCPayServer\Client\StorePaymentMethodLightningNetwork;
use BTCPayServer\Client\StorePaymentMethodOnChain;
use PrestaShop\PrestaShop\Adapter\Configuration;
use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface;

Expand Down Expand Up @@ -46,16 +44,6 @@ class Client extends AbstractClient
*/
private $payment;

/**
* @var StorePaymentMethodOnChain
*/
private $onChain;

/**
* @var StorePaymentMethodLightningNetwork
*/
private $offChain;

/**
* @var Webhook
*/
Expand All @@ -77,8 +65,6 @@ public function __construct(string $baseUrl, string $apiKey)
$this->server = new ServerClient($baseUrl, $apiKey, $httpClient);
$this->store = new StoreClient($baseUrl, $apiKey, $httpClient);
$this->payment = new StorePaymentMethod($baseUrl, $apiKey, $httpClient);
$this->onChain = new StorePaymentMethodOnChain($baseUrl, $apiKey, $httpClient);
$this->offChain = new StorePaymentMethodLightningNetwork($baseUrl, $apiKey, $httpClient);
$this->webhook = new Webhook($baseUrl, $apiKey, $httpClient);

$this->configuration = new Configuration();
Expand Down Expand Up @@ -127,16 +113,6 @@ public function payment(): StorePaymentMethod
return $this->payment;
}

public function onChain(): StorePaymentMethodOnChain
{
return $this->onChain;
}

public function offChain(): StorePaymentMethodLightningNetwork
{
return $this->offChain;
}

public function webhook(): Webhook
{
return $this->webhook;
Expand Down
9 changes: 3 additions & 6 deletions modules/btcpay/views/templates/admin/configure.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,9 @@

<dt><span class="text-muted mb-0"><strong>{{ 'Supported payment methods'|trans({}, 'Modules.Btcpay.Front') }}</strong></span></dt>
<dd>
<ul class="list-unstyled px-1">
{% for paymentMethod in client.offChain().getPaymentMethods(storeId) %}
<li>{{ paymentMethod.cryptoCode }} Lightning ⚡</li>
{% endfor %}
{% for paymentMethod in client.onChain().getPaymentMethods(storeId) %}
<li>{{ paymentMethod.cryptoCode }} On-Chain</li>
<ul>
{% for paymentMethod in client.payment().getPaymentMethods(storeId) %}
<li>{{ paymentMethod.cryptoCode }} {% if 'LNURL' in paymentMethod.paymentMethod %}LNURL ⚡{% elseif 'LN' in paymentMethod.paymentMethod or 'Lightning' in paymentMethod.paymentMethod %}Lightning ⚡{% else %}(On-Chain){% endif %}</li>
{% endfor %}
</ul>
</dd>
Expand Down
10 changes: 0 additions & 10 deletions modules/btcpay/views/templates/hooks/payment_option.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<section class="mb-2">
<p class="mb-1">{l s='Please pay the exact amount (including transaction fees when paying on-chain).' d='Modules.Btcpay.Front'}</p>
<hr class="mb-1"/>
<p class="mb-1"><strong>{l s='Supported payment methods' d='Modules.Btcpay.Front'}</strong>:</p>
<dl>
{foreach $offChain as $paymentMethod}
<dt>{$paymentMethod.cryptoCode|escape:'htmlall':'UTF-8'} Lightning ⚡</dt>
{/foreach}
{foreach $onChain as $paymentMethod}
<dt>{$paymentMethod.cryptoCode|escape:'htmlall':'UTF-8'} (On-Chain)</dt>
{/foreach}
</dl>
</section>