<commit_before># php-sdk
A PHP wrapper for Coinify merchant API and callbacks

This PHP-SDK consists of two classes, `CoinifyApi` and `CoinifyCallback`, which are designed to make it easier for you,
the developer, to utilize the [Coinify API](https://coinify.com/docs/api) and validate [IPN callbacks](https://coinify.com/docs/api/#callbacks) from Coinify, respectively. 

## CoinifyAPI

### Creating an instance
The `CoinifyAPI` class is instantiated as follows:

```php
$api_key = "<my_api_key>";
$api_secret = "<my_api_secret>";
$api = new CoinifyAPI($api_key, $api_secret);
```

### Response format
The `CoinifyAPI` returns responses as they are described in [Response format](https://coinify.com/docs/api/#response-format) in the API documentation.

The JSON responses are automatically decoded into PHP associative arrays, so you can for example do the following:

```php
$response = $api->invoicesList();
if ( $response === false ) {
    /*
     * A false response means a curl error
     */
    return "cURL error: " . $api->last_curl_error . " (" . $api->last_curl_errno . ")";
}

if ( !$response['success'] ) {
    $api_error = $response['error'];
    return "API error: " . $api_error['message'] . " (" . $api_error['code'] . ")";
}

$invoices = $response['data'];
```

### Rates
With the [Coinify rates API](https://coinify.com/docs/api/#rates) you can *list* the buy and sell rates between Bitcoin and all currencies supported by us.
It is a public end-point and no API key and secret are required.

`buy` is the rate for buying (asking for)  a single unit of Bitcoins for the particular currency.
`sell` is the rate for selling (bidding for) a single unit of Bitcoins for the particular currency.

#### Listing rates for all currencies
```php
$response = $api->ratesGet();
```

#### Listing rates for a specific currency
```php
// f.e. $currency = 'USD';
$response = $api->ratesGet($currency);<commit_msg>COIN-782 Update php sdk docs<commit_after># php-sdk
A PHP wrapper for Coinify merchant API and callbacks

This PHP-SDK consists of two classes, `CoinifyApi` and `CoinifyCallback`, which are designed to make it easier for you,
the developer, to utilize the [Coinify API](https://coinify.com/docs/api) and validate [IPN callbacks](https://coinify.com/docs/api/#callbacks) from Coinify, respectively. 

## CoinifyAPI

### Creating an instance
The `CoinifyAPI` class is instantiated as follows:

```php
$api_key = "<my_api_key>";
$api_secret = "<my_api_secret>";
$api = new CoinifyAPI($api_key, $api_secret);
```

### Response format
The `CoinifyAPI` returns responses as they are described in [Response format](https://coinify.com/docs/api/#response-format) in the API documentation.

The JSON responses are automatically decoded into PHP associative arrays, so you can for example do the following:

```php
$response = $api->invoicesList();
if ( $response === false ) {
    /*
     * A false response means a curl error
     */
    return "cURL error: " . $api->last_curl_error . " (" . $api->last_curl_errno . ")";
}

if ( !$response['success'] ) {
    $api_error = $response['error'];
    return "API error: " . $api_error['message'] . " (" . $api_error['code'] . ")";
}

$invoices = $response['data'];
```

### Rates
With the [Coinify rates API](https://coinify.com/docs/api/#rates) you can *list* the buy and sell rates between Bitcoin and all currencies supported by us.
It is a public end-point and no API key and secret are required.

`buy` is the rate for buying one bitcoin for the particular currency.
`sell` is the rate for selling one bitcoin for the particular currency.

#### Listing rates for all currencies
```php
$response = $api->ratesGet();
```

#### Listing rates for a specific currency
```php
// f.e. $currency = 'USD';
$response = $api->ratesGet($currency);
{'fraction_non_alphanumeric': 0.13879378456676322, 'fraction_numerical': 0.0007900974453515934, 'mean_word_length': 4.3872340425531915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4164286', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1139, 'n_words': 425}