This library makes it easier to integrate BTCPay Server in your PHP application.
This library takes an opinionated approach to Greenfield API with the aim of making your developer life as easy and convenient as possible. For this reason, we have decided to structure arguments a bit differently, but still allow full and advanced use cases.
The general reasoning behind the arguments an API client takes are in this order:
Methods that return a Unix timestamp always end with Timestamp
like getReceivedTimestamp()
to avoid format and timezone confusion. These are always in seconds (not milliseconds).
composer require btcpayserver/btcpayserver-greenfield-php
If you use some framework or other project you likely are ready to go. If you start from scratch make sure to include Composer autoloader.
require __DIR__ . '/../vendor/autoload.php';
In the src
directory we have a custom autoload.php
which you can require and avoid using composer if needed.
// Require the autoload file.
require __DIR__ . '/../src/autoload.php';
// Example to get all stores.
$apiKey = '';
$host = ''; // e.g. https://your.btcpay-server.tld
try {
$client = new \BTCPayServer\Client\Store($host, $apiKey);
var_dump($client->getStores());
} catch (\Throwable $e) {
echo "Error: " . $e->getMessage();
}
The API keys for Greenfield API are not on the store level "Access Tokens" anymore. You need to go to your account profile: "My Settings" (user profile icon) -> "API Keys" instead. You can even redirect the users to generate the API keys there.
We run static analyzer Psalm and PHP-CS-fixer for codestyle when you open a pull-request. Please check if there are any errors and fix them accordingly.
We use PSR-12 code style to ensure proper formatting and spacing. You can test and format your code using composer commands. Before doing a PR you can run composer cs-check
and composer cs-fix
which will run php-cs-fixer.
Currently implemented functionality is tracked in this sheet and will be updated sporadically. Check to see which areas still need work in case you want to contribute.