sadovojav / bitcart-sdk-php
Bitcart API PHP client library.
Requires
- php: >=8.1
- ext-bcmath: *
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- cuyz/valinor: ^0.16.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-11-25 14:21:12 UTC
README
This library makes it easier to integrate Bitcart in your PHP application.
- Package is under development. The main code can completely change
Approach
This library takes an opinionated approach to 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:
- First the required parameters => method arguments with NULL not allowed
- Recommended parameters => method arguments with NULL as default
- Optional parameters => arguments with NULL as default
- Lastly the advanced parameters => Inside an extra class
How to use
composer require sadovojav/bitcart-sdk-php
// Require the autoload file.
require __DIR__ . '/../src/autoload.php';
// Example to create user.
$baseUrl = ''; // e.g. https://your.bitract-server.tld
try {
// POST /users
$user = (new \Bitcart\Client\User($baseUrl))->createUser(\Bitcart\DTO\UserDto::fromArray([
'email' => 'user@example.com',
'password' => 'some_password',
'settings' => (new \Bitcart\DTO\SettingsDto()),
]));
var_dump($user);
} catch (\Throwable $e) {
echo "Error: " . $e->getMessage();
}
Checklist
Open
USERS
- GET /users/stats
- GET /users/me
- POST /users/me/settings
- GET /users/count
- GET /users/{model_id}
- DELETE /users/{model_id}
- PATCH /users/{model_id}
- GET /users
- POST /users
- POST /users/batch
WALLETS
- GET /wallets/history/all
- GET /wallets/history/{model_id}
- GET /wallets/balance
- GET /wallets/{model_id}/balance
- GET /wallets/{model_id}/checkin
- GET /wallets/{model_id}/channels
- POST /wallets/{model_id}/channels/open
- POST /wallets/{model_id}/channels/close
- POST /wallets/{model_id}/inpay
- GET /wallets/count
- GET /wallets/{model_id}
- DELETE /wallets/{model_id}
- PATCH /wallets/{model_id}
- GET /wallets
- POST /wallets POST /wallets/batch
STORES
- GET /stores/{model_id}/ping
- PATCH /stores/{model_id}/checkout_settings
- PATCH /stores/{model_id}/theme_settings
- PATCH /stores/{model_id}/plugin_settings
- GET /stores/count
- GET /stores/{model_id}
- DELETE /stores/{model_id}
- PATCH /stores/{model_id}
- GET /stores
- POST /stores
- POST /stores/batch
- GET /stores/{store_id}/integrations/shopify/{order_id}
INVOICES
- GET /invoices/order_id/{order_id}
- GET /invoices/export
- PATCH /invoices/{model_id}/customer
- PATCH /invoices/{model_id}/details
- GET /invoices/count
- GET /invoices/{model_id}
- DELETE /invoices/{model_id}
- PATCH /invoices/{model_id}
- GET /invoices
- POST /invoices
- POST /invoices/batch
PRODUCTS
- GET /products/maxprice
- GET /products/categories
- GET /products/count
- GET /products/{model_id}
- DELETE /products/{model_id}
- PATCH /products/{model_id}
- GET /products
- POST /products
- POST /products/batch
PAYOUTS
- GET /payouts/count
- GET /payouts/{model_id}
- DELETE /payouts/{model_id}
- PATCH /payouts/{model_id}
- GET /payouts
- POST /payouts
- POST /payouts/batch
TOKEN
- GET /token
- POST /token
- GET /token/current
- GET /token/count
- DELETE /token/{model_id}
- PATCH /token/{model_id}
CRYPTOS
- GET /cryptos
- GET /cryptos/supported
- GET /cryptos/rate
- GET /cryptos/fiatlist
- GET /cryptos/tokens/{currency}
- GET /cryptos/tokens/{currency}/abi
- GET /cryptos/explorer/{currency}
- GET /cryptos/rpc/{currency}
Best practices
- Always use an API key with as little permissions as possible.
Contribute
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.
Codestyle
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.