PHPackages                             chalker777/testingmypack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. chalker777/testingmypack

ActiveLibrary[Testing &amp; Quality](/categories/testing)

chalker777/testingmypack
========================

v2.9.1(7y ago)014Apache-2.0PHPPHP &gt;=5.6.0

Since May 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/chalk777/coinbase-php)[ Packagist](https://packagist.org/packages/chalker777/testingmypack)[ Docs](http://test.com)[ RSS](/packages/chalker777-testingmypack/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (4)Versions (25)Used By (0)

Coinbase Wallet PHP Library
===========================

[](#coinbase-wallet-php-library)

[![Build Status](https://camo.githubusercontent.com/7a9bb7b2efadc86a9fd44092739b1461b6765634e79bf805110a297c4e18d05b/68747470733a2f2f7472617669732d63692e6f72672f636f696e626173652f636f696e626173652d7068702e737667)](https://travis-ci.org/coinbase/coinbase-php)[![Latest Stable Version](https://camo.githubusercontent.com/666893d9d7c3df54c3c1f3400688f7e7c30bce1f0f9aa6ea23376711ea8f46ac/68747470733a2f2f706f7365722e707567782e6f72672f636f696e626173652f636f696e626173652f762f737461626c65)](https://packagist.org/packages/coinbase/coinbase)[![Total Downloads](https://camo.githubusercontent.com/debe7c7abda27ea692b4b364ab283d6ebd75e9b7bd934749e6a938500e316d82/68747470733a2f2f706f7365722e707567782e6f72672f636f696e626173652f636f696e626173652f646f776e6c6f616473)](https://packagist.org/packages/coinbase/coinbase)[![Latest Unstable Version](https://camo.githubusercontent.com/64b18632ff168b98795ded1b66a071e8564db83fbebdab78c7978fa073d57bac/68747470733a2f2f706f7365722e707567782e6f72672f636f696e626173652f636f696e626173652f762f756e737461626c65)](https://packagist.org/packages/coinbase/coinbase)[![License](https://camo.githubusercontent.com/dd979398a2c48bbb8de47cd939e00aac3b0d93d0cfc9af546f1830e9a15be541/68747470733a2f2f706f7365722e707567782e6f72672f636f696e626173652f636f696e626173652f6c6963656e7365)](https://packagist.org/packages/coinbase/coinbase)

This is the official client library for the [Coinbase Wallet API v2](https://developers.coinbase.com/api/v2). We provide an intuitive, stable interface to integrate Coinbase Wallet into your PHP project.

*Important:* As this library is targeted for newer API v2, it requires v2 permissions (i.e. `wallet:accounts:read`). If you're still using v1, please use the [older version](https://packagist.org/packages/coinbase/coinbase) of this library.

Installation
------------

[](#installation)

Install the library using Composer. Please read the [Composer Documentation](https://getcomposer.org/doc/01-basic-usage.md) if you are unfamiliar with Composer or dependency managers in general.

```
"require": {
    "coinbase/coinbase": "~2.0"
}
```

Authentication
--------------

[](#authentication)

### API Key

[](#api-key)

Use an API key and secret to access your own Coinbase account.

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
```

### OAuth2

[](#oauth2)

Use OAuth2 authentication to access a user's account other than your own. This library does not handle the handshake process, and assumes you have an access token when it's initialized. You can handle the handshake process using an [OAuth2 client](https://packagist.org/search/?q=oauth2%20client) such as [league/oauth2-client](https://packagist.org/packages/league/oauth2-client).

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

// with a refresh token
$configuration = Configuration::oauth($accessToken, $refreshToken);

// without a refresh token
$configuration = Configuration::oauth($accessToken);

$client = Client::create($configuration);
```

### Two factor authentication

[](#two-factor-authentication)

The send money endpoint requires a 2FA token in certain situations (read more [here](https://developers.coinbase.com/docs/wallet/coinbase-connect#two-factor-authentication)). A specific exception is thrown when this is required.

```
use Coinbase\Wallet\Enum\Param;
use Coinbase\Wallet\Exception\TwoFactorRequiredException;
use Coinbase\Wallet\Resource\Transaction;

$transaction = Transaction::send([
    'toEmail' => 'test@test.com',
    'bitcoinAmount' => 1
]);

$account = $client->getPrimaryAccount();
try {
    $client->createAccountTransaction($account, $transaction);
} catch (TwoFactorRequiredException $e) {
    // show 2FA dialog to user and collect 2FA token

    // retry call with token
    $client->createAccountTransaction($account, $transaction, [
        Param::TWO_FACTOR_TOKEN => '123456',
    ]);
}
```

### Pagination

[](#pagination)

Several endpoints are [paginated](https://developers.coinbase.com/api/v2#pagination). By default, the library will only fetch the first page of data for a given request. You can easily load more than just the first page of results.

```
$transactions = $client->getAccountTransactions($account);
while ($transactions->hasNextPage()) {
    $client->loadNextTransactions($transactions);
}
```

You can also use the `fetch_all` parameter to have the library issue all the necessary requests to load the complete collection.

```
use Coinbase\Wallet\Enum\Param;

$transactions = $client->getAccountTransactions($account, [
    Param::FETCH_ALL => true,
]);
```

### Warnings

[](#warnings)

It's prudent to be conscious of warnings. The library will log all warnings to a standard PSR-3 logger if one is configured.

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$configuration->setLogger($logger);
$client = Client::create($configuration);
```

### Resource references

[](#resource-references)

In some cases the API will return resource references in place of expanded resource objects. These references can be expanded by refreshing them.

```
$deposit = $this->client->getAccountDeposit($account, $depositId);
$transaction = $deposit->getTransaction();
if (!$transaction->isExpanded()) {
    $this->client->refreshTransaction($transaction);
}
```

You can also request that the API return an expanded resource in the initial request by using the `expand` parameter.

```
use Coinbase\Wallet\Enum\Param;

$deposit = $this->client->getAccountDeposit($account, $depositId, [
    Param::EXPAND = ['transaction'],
]);
```

Resource references can be used when creating new resources, avoiding the overhead of requesting a resource from the API.

```
use Coinbase\Wallet\Resource\Deposit;
use Coinbase\Wallet\Resource\PaymentMethod;

$deposit = new Deposit([
    'paymentMethod' => PaymentMethod::reference($paymentMethodId)
]);

// or use the convenience method
$deposit = new Deposit([
    'paymentMethodId' => $paymentMethodId
]);
```

### Responses

[](#responses)

There are multiple ways to access raw response data. First, each resource object has a `getRawData()` method which you can use to access any field that are not mapped to the object properties.

```
$data = $deposit->getRawData();
```

Raw data from the last HTTP response is also available on the client object.

```
$data = $client->decodeLastResponse();
```

### Active record methods

[](#active-record-methods)

The library includes support for active record methods on resource objects. You must enable this functionality when bootstrapping your application.

```
$client->enableActiveRecord();
```

Once enabled, you can call active record methods on resource objects.

```
use Coinbase\Wallet\Enum\Param;

$transactions = $account->getTransactions([
    Param::FETCH_ALL => true,
]);
```

Usage
-----

[](#usage)

This is not intended to provide complete documentation of the API. For more detail, please refer to the [official documentation](https://developers.coinbase.com/api/v2).

### [Market Data](https://developers.coinbase.com/api/v2#data-api)

[](#market-data)

**List supported native currencies**

```
$currencies = $client->getCurrencies();
```

**List exchange rates**

```
$rates = $client->getExchangeRates();
```

**Buy price**

```
$buyPrice = $client->getBuyPrice('BTC-USD');
```

**Sell price**

```
$sellPrice = $client->getSellPrice('BTC-USD');
```

**Spot price**

```
$spotPrice = $client->getSpotPrice('BTC-USD');
```

**Current server time**

```
$time = $client->getTime();
```

### [Users](https://developers.coinbase.com/api/v2#users)

[](#users)

**Get authorization info**

```
$auth = $client->getCurrentAuthorization();
```

**Lookup user info**

```
$user = $client->getUser($userId);
```

**Get current user**

```
$user = $client->getCurrentUser();
```

**Update current user**

```
$user->setName('New Name');
$client->updateCurrentUser($user);
```

### [Accounts](https://developers.coinbase.com/api/v2#accounts)

[](#accounts)

**List all accounts**

```
$accounts = $client->getAccounts();
```

**List account details**

```
$account = $client->getAccount($accountId);
```

**List primary account details**

```
$account = $client->getPrimaryAccount();
```

**Set account as primary**

```
$client->setPrimaryAccount($account);
```

**Create a new bitcoin account**

```
use Coinbase\Wallet\Resource\Account;

$account = new Account([
    'name' => 'New Account'
]);
$client->createAccount($account);
```

**Update an account**

```
$account->setName('New Account Name');
$client->updateAccount($account):
```

**Delete an account**

```
$client->deleteAccount($account);
```

### [Addresses](https://developers.coinbase.com/api/v2#addresses)

[](#addresses)

**List receive addresses for account**

```
$addresses = $client->getAccountAddresses($account);
```

**Get receive address info**

```
$address = $client->getAccountAddress($account, $addressId);
```

**List transactions for address**

```
$transactions = $client->getAddressTransactions($address);
```

**Create a new receive address**

```
use Coinbase\Wallet\Resource\Address;

$address = new Address([
    'name' => 'New Address'
]);
$client->createAccountAddress($account, $address);
```

### [Transactions](https://developers.coinbase.com/api/v2#transactions)

[](#transactions)

**List transactions**

```
$transactions = $client->getAccountTransactions($account);
```

**Get transaction info**

```
$transaction = $client->getAccountTransaction($account, $transactionId);
```

**Send funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$transaction = Transaction::send([
    'toBitcoinAddress' => 'ADDRESS',
    'amount'           => new Money(5, CurrencyCode::USD),
    'description'      => 'Your first bitcoin!',
    'fee'              => '0.0001' // only required for transactions under BTC0.0001
]);

try { $client->createAccountTransaction($account, $transaction); }
catch(Exception $e) {
     echo $e->getMessage();
}
```

**Transfer funds to a new account**

```
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Resource\Account;

$fromAccount = Account::reference($accountId);

$toAccount = new Account([
    'name' => 'New Account'
]);
$client->createAccount($toAccount);

$transaction = Transaction::transfer([
    'to'            => $toAccount,
    'bitcoinAmount' => 1,
    'description'   => 'Your first bitcoin!'
]);

$client->createAccountTransaction($fromAccount, $transaction);
```

**Request funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$transaction = Transaction::request([
    'amount'      => new Money(8, CurrencyCode::USD),
    'description' => 'Burrito'
]);

$client->createAccountTransaction($transaction);
```

**Resend request**

```
$account->resendTransaction($transaction);
```

**Cancel request**

```
$account->cancelTransaction($transaction);
```

**Fulfill request**

```
$account->completeTransaction($transaction);
```

### [Buys](https://developers.coinbase.com/api/v2#buys)

[](#buys)

**List buys**

```
$buys = $client->getAccountBuys($account);
```

**Get buy info**

```
$buy = $client->getAccountBuy($account, $buyId);
```

**Buy bitcoins**

```
use Coinbase\Wallet\Resource\Buy;

$buy = new Buy([
    'bitcoinAmount' => 1
]);

$client->createAccountBuy($account, $buy);
```

**Commit a buy**

You only need to do this if you pass `commit=false` when you create the buy.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountBuy($account, $buy, [Param::COMMIT => false]);
$client->commitBuy($buy);
```

### [Sells](https://developers.coinbase.com/api/v2#sells)

[](#sells)

**List sells**

```
$sells = $client->getAccountSells($account);
```

**Get sell info**

```
$sell = $client->getAccountSell($account, $sellId);
```

**Sell bitcoins**

```
use Coinbase\Wallet\Resource\Sell;

$sell = new Sell([
    'bitcoinAmount' => 1
]);

$client->createAccountSell($account, $sell);
```

**Commit a sell**

You only need to do this if you pass `commit=false` when you create the sell.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountSell($account, $sell, [Param::COMMIT => false]);
$client->commitSell($sell);
```

### [Deposit](https://developers.coinbase.com/api/v2#deposits)

[](#deposit)

**List deposits**

```
$deposits = $client->getAccountDeposits($account);
```

**Get deposit info**

```
$deposit = $client->getAccountDeposit($account, $depositId);
```

**Deposit funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Deposit;
use Coinbase\Wallet\Value\Money;

$deposit = new Deposit([
    'amount' => new Money(10, CurrencyCode::USD)
]);

$client->createAccountDeposit($account, $deposit);
```

**Commit a deposit**

You only need to do this if you pass `commit=false` when you create the deposit.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountDeposit($account, $deposit, [Param::COMMIT => false]);
$client->commitDeposit($deposit);
```

### [Withdrawals](https://developers.coinbase.com/api/v2#withdrawals)

[](#withdrawals)

**List withdrawals**

```
$withdrawals = $client->getAccountWithdrawals($account);
```

**Get withdrawal**

```
$withdrawal = $client->getAccountWithdrawal($account, $withdrawalId);
```

**Withdraw funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Withdrawal;
use Coinbase\Wallet\Value\Money;

$withdrawal = new Withdrawal([
    'amount' => new Money(10, CurrencyCode::USD)
]);

$client->createAccountWithdrawal($account, $withdrawal);
```

**Commit a withdrawal**

You only need to do this if you pass `commit=true` when you call the withdrawal method.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountWithdrawal($account, $withdrawal, [Param::COMMIT => false]);
$client->commitWithdrawal($withdrawal);
```

### [Payment Methods](https://developers.coinbase.com/api/v2#payment-methods)

[](#payment-methods)

**List payment methods**

```
$paymentMethods = $client->getPaymentMethods();
```

**Get payment method**

```
$paymentMethod = $client->getPaymentMethod($paymentMethodId);
```

### [Merchants](https://developers.coinbase.com/api/v2#merchants)

[](#merchants)

#### Get merchant

[](#get-merchant)

```
$merchant = $client->getMerchant($merchantId);
```

### [Orders](https://developers.coinbase.com/api/v2#orders)

[](#orders)

#### List orders

[](#list-orders)

```
$orders = $client->getOrders();
```

#### Get order

[](#get-order)

```
$order = $client->getOrder($orderId);
```

#### Create order

[](#create-order)

```
use Coinbase\Wallet\Resource\Order;
use Coinbase\Wallet\Value\Money;

$order = new Order([
    'name' => 'Order #1234',
    'amount' => Money::btc(1)
]);

$client->createOrder($order);
```

#### Refund order

[](#refund-order)

```
use Coinbase\Wallet\Enum\CurrencyCode;

$client->refundOrder($order, CurrencyCode::BTC);
```

### Checkouts

[](#checkouts)

#### List checkouts

[](#list-checkouts)

```
$checkouts = $client->getCheckouts();
```

#### Create checkout

[](#create-checkout)

```
use Coinbase\Wallet\Resource\Checkout;

$params = array(
    'name'               => 'My Order',
    'amount'             => new Money(100, 'USD'),
    'metadata'           => array( 'order_id' => $custom_order_id )
);

$checkout = new Checkout($params);
$client->createCheckout($checkout);
$code = $checkout->getEmbedCode();
$redirect_url = "https://www.coinbase.com/checkouts/$code";
```

#### Get checkout

[](#get-checkout)

```
$checkout = $client->getCheckout($checkoutId);
```

#### Get checkout's orders

[](#get-checkouts-orders)

```
$orders = $client->getCheckoutOrders($checkout);
```

#### Create order for checkout

[](#create-order-for-checkout)

```
$order = $client->createNewCheckoutOrder($checkout);
```

### [Notifications webhook and verification](https://developers.coinbase.com/docs/wallet/notifications)

[](#notifications-webhook-and-verification)

```
$raw_body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_CB_SIGNATURE'];
$authenticity = $client->verifyCallback($raw_body, $signature); // boolean
```

Contributing and testing
------------------------

[](#contributing-and-testing)

The test suite is built using PHPUnit. Run the suite of unit tests by running the `phpunit` command.

```
phpunit

```

There is also a collection of integration tests that issues real requests to the API and inspects the resulting objects. To run these tests, you must copy `phpunit.xml.dist` to `phpunit.xml`, provide values for the `CB_API_KEY` and `CB_API_SECRET` variables, and specify the `integration` group when running the test suite.

```
phpunit --group integration

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~48 days

Total

19

Last Release

2824d ago

Major Versions

1.1.x-dev → v2.0.0-beta12015-07-29

v1.9 → v2.9.12018-08-22

PHP version history (3 changes)1.0.0PHP &gt;=5.2.0

v2.0.0-beta1PHP &gt;=5.5.0

2.7.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6cccc7b432614d38504f36bd891161813ea750b00f2297277755da2a4af56bd?d=identicon)[chalk777](/maintainers/chalk777)

---

Top Contributors

[![imeleshko](https://avatars.githubusercontent.com/u/1286265?v=4)](https://github.com/imeleshko "imeleshko (1 commits)")[![kriswallsmith](https://avatars.githubusercontent.com/u/33886?v=4)](https://github.com/kriswallsmith "kriswallsmith (1 commits)")

---

Tags

test

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chalker777-testingmypack/health.svg)

```
[![Health](https://phpackages.com/badges/chalker777-testingmypack/health.svg)](https://phpackages.com/packages/chalker777-testingmypack)
```

###  Alternatives

[php-coveralls/php-coveralls

PHP client library for Coveralls API

51413.7M3.4k](/packages/php-coveralls-php-coveralls)[growthbook/growthbook

PHP SDK for GrowthBook, the feature flagging and A/B testing platform

202.9M3](/packages/growthbook-growthbook)[colinodell/psr-testlogger

PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!

1712.1M47](/packages/colinodell-psr-testlogger)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[leanphp/behat-code-coverage

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-code-coverage)[ubirak/rest-api-behat-extension

Rest Api Extension for Behat

41327.0k2](/packages/ubirak-rest-api-behat-extension)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
