btcpayserver-php-client
btcpayserver-php-client copied to clipboard
Port is null using legitimate payserver URL
Given a BTCPay instance URL of: https://testnet.demo.btcpayserver.org/
then the logic in Client.php:639
will return null
. One can argue that PHP's port sniffing capabilities leave something to be desired, or we can workaround this:
#> php -a
php > var_dump(parse_url('https://testnet.demo.btcpayserver.org/', PHP_URL_PORT));
NULL
Assuming port acquisition is really needed, then some simple logic to determine the correct port to use from the scheme should be implemented, or a suitable default e.g. 443
.
public function getPort(): int
{
if ($this->port) {
return $this->port;
}
return parse_url($this->uri, PHP_URL_SCHEME) === 'https' ? 443 : 80;
}
Otherwise, some hints in the docs that a port should be included in the host URL in library config, should be added. Having said that, it is possible (but not probable) that userland https schemes might be used while stipulating port 80...
I am currently developing a BTCPay extension for CiviCRM and I am having this exact same issue. Are there any updates on this? Are you interested in making a pull request for it or should I?
I am currently developing a BTCPay extension for CiviCRM and I am having this exact same issue. Are there any updates on this? Are you interested in making a pull request for it or should I?
Feel free. The maintainers are aware that the PHP setup scripts need to be overhauled.