Skip to content
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
569 changes: 430 additions & 139 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"require-dev": {
"phpunit/phpunit": "^9",
"mockery/mockery": "^1.4",
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"php-vcr/php-vcr": "^1.5"
},
"scripts": {
"lint": "./vendor/bin/phpcs .",
Expand Down
4 changes: 2 additions & 2 deletions examples/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Cryptopay\Cryptopay;

$config = (new Config())
->withApiKey('API_KEY_VALUE')
->withApiSecret('YOUR_SECRET_VALUE')
->withApiKey(getenv('CRYPTOPAY_API_KEY'))
->withApiSecret(getenv('CRYPTOPAY_API_SECRET'))
->withBaseUrl('https://business-sandbox.cryptopay.me')
->withCallbackSecret('YOUR_CALLBACK_SECRET_VALUE')
->withTimeout(10);
Expand Down
18 changes: 18 additions & 0 deletions examples/Invoices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Cryptopay\Exceptions\CryptopayException;

require_once dirname(__DIR__) . '/examples/Init.php';

try {
$response = $cryptopay->invoices->create([
'price_amount' => '100',
'price_currency' => 'EUR',
'pay_currency' => 'BTC'
]);
} catch (CryptopayException $exception) {
echo sprintf("Unable to create Invoice. %s \n", $exception->getMessage());
die();
}

print_r($response);
16 changes: 16 additions & 0 deletions examples/Transactions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Cryptopay\Exceptions\CryptopayException;

require_once dirname(__DIR__) . '/examples/Init.php';

try {
$response = $cryptopay->transactions->all([
'status' => 'unresolved'
]);
} catch (CryptopayException $exception) {
echo sprintf("Unable to get transactions list. %s \n", $exception->getMessage());
die();
}

print_r($response);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions examples/deprecated/Init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

// path to autoload
require_once dirname(__DIR__) . "/../vendor/autoload.php";

use Cryptopay\Config\Config;
use Cryptopay\Cryptopay;

$config = (new Config())
->withApiKey(getenv('CRYPTOPAY_API_KEY'))
->withApiSecret(getenv('CRYPTOPAY_API_SECRET'))
->withBaseUrl('https://business-sandbox.cryptopay.me')
->withCallbackSecret('YOUR_CALLBACK_SECRET_VALUE')
->withTimeout(10);

$cryptopay = new Cryptopay($config);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed phpcbf.phar
Binary file not shown.
Binary file removed phpcs.phar
Binary file not shown.
Empty file modified phpunit.xml
100755 → 100644
Empty file.
26 changes: 26 additions & 0 deletions src/AbstractApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Cryptopay;

use Cryptopay\Connector\ConnectorInterface;

abstract class AbstractApi
{
/**
* @var \Cryptopay\Connector\ConnectorInterface
*/
private $connector;

/**
* @param \Cryptopay\Connector\ConnectorInterface $connector
*/
public function __construct(ConnectorInterface $connector)
{
$this->connector = $connector;
}

protected function request(string $method, string $path, array $params = null)
{
return $this->connector->request($method, $path, $params);
}
}
41 changes: 41 additions & 0 deletions src/Api/AccountsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

// Auto-generated file
// DO NOT EDIT

namespace Cryptopay\Api;

use Cryptopay\AbstractApi;

class AccountsApi extends AbstractApi
{
/**
* List accounts
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function all(array $params = null)
{
return $this->request('GET', '/api/accounts', $params);
}

/**
* List account transactions
*
* @param string $accountId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function allTransactions(string $accountId, array $params = null)
{
$path = '/api/accounts/{account_id}/transactions';
$path = str_replace('{account_id}', rawurlencode($accountId), $path);

return $this->request('GET', $path, $params);
}
}
124 changes: 124 additions & 0 deletions src/Api/ChannelsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

// Auto-generated file
// DO NOT EDIT

namespace Cryptopay\Api;

use Cryptopay\AbstractApi;

class ChannelsApi extends AbstractApi
{
/**
* List channels
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function all(array $params = null)
{
return $this->request('GET', '/api/channels', $params);
}

/**
* Create a channel
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function create(array $params = null)
{
return $this->request('POST', '/api/channels', $params);
}

/**
* List channel payments
*
* @param string $channelId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function allPayments(string $channelId, array $params = null)
{
$path = '/api/channels/{channel_id}/payments';
$path = str_replace('{channel_id}', rawurlencode($channelId), $path);

return $this->request('GET', $path, $params);
}

/**
* Retrieve a channel
*
* @param string $channelId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function retrieve(string $channelId, array $params = null)
{
$path = '/api/channels/{channel_id}';
$path = str_replace('{channel_id}', rawurlencode($channelId), $path);

return $this->request('GET', $path, $params);
}

/**
* Retrieve a channel by custom id
*
* @param string $customId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function retrieveByCustomId(string $customId, array $params = null)
{
$path = '/api/channels/custom_id/{custom_id}';
$path = str_replace('{custom_id}', rawurlencode($customId), $path);

return $this->request('GET', $path, $params);
}

/**
* Retrieve a channel payment
*
* @param string $channelId
* @param string $channelPaymentId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function retrievePayment(string $channelId, string $channelPaymentId, array $params = null)
{
$path = '/api/channels/{channel_id}/payments/{channel_payment_id}';
$path = str_replace('{channel_id}', rawurlencode($channelId), $path);
$path = str_replace('{channel_payment_id}', rawurlencode($channelPaymentId), $path);

return $this->request('GET', $path, $params);
}

/**
* Update a channel
*
* @param string $channelId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function update(string $channelId, array $params = null)
{
$path = '/api/channels/{channel_id}';
$path = str_replace('{channel_id}', rawurlencode($channelId), $path);

return $this->request('PATCH', $path, $params);
}
}
101 changes: 101 additions & 0 deletions src/Api/CoinWithdrawalsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

// Auto-generated file
// DO NOT EDIT

namespace Cryptopay\Api;

use Cryptopay\AbstractApi;

class CoinWithdrawalsApi extends AbstractApi
{
/**
* List withdrawals
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function all(array $params = null)
{
return $this->request('GET', '/api/coin_withdrawals', $params);
}

/**
* Commit a withdrawal
*
* @param string $coinWithdrawalId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function commit(string $coinWithdrawalId, array $params = null)
{
$path = '/api/coin_withdrawals/{coin_withdrawal_id}/commit';
$path = str_replace('{coin_withdrawal_id}', rawurlencode($coinWithdrawalId), $path);

return $this->request('POST', $path, $params);
}

/**
* Create a withdrawal
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function create(array $params = null)
{
return $this->request('POST', '/api/coin_withdrawals', $params);
}

/**
* List network fees
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function allNetworkFees(array $params = null)
{
return $this->request('GET', '/api/coin_withdrawals/network_fees', $params);
}

/**
* Retrieve a withdrawal
*
* @param string $coinWithdrawalId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function retrieve(string $coinWithdrawalId, array $params = null)
{
$path = '/api/coin_withdrawals/{coin_withdrawal_id}';
$path = str_replace('{coin_withdrawal_id}', rawurlencode($coinWithdrawalId), $path);

return $this->request('GET', $path, $params);
}

/**
* Retrieve a withdrawal by custom id
*
* @param string $customId
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function retrieveByCustomId(string $customId, array $params = null)
{
$path = '/api/coin_withdrawals/custom_id/{custom_id}';
$path = str_replace('{custom_id}', rawurlencode($customId), $path);

return $this->request('GET', $path, $params);
}
}
24 changes: 24 additions & 0 deletions src/Api/CoinsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

// Auto-generated file
// DO NOT EDIT

namespace Cryptopay\Api;

use Cryptopay\AbstractApi;

class CoinsApi extends AbstractApi
{
/**
* List supported coins
*
* @param null|array $params
*
* @throws \Cryptopay\Exceptions\RequestException
* @return object
*/
public function all(array $params = null)
{
return $this->request('GET', '/api/coins', $params);
}
}
Loading