PHPackages                             itechsection/salesprosdk - 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. [API Development](/categories/api)
4. /
5. itechsection/salesprosdk

ActiveLibrary[API Development](/categories/api)

itechsection/salesprosdk
========================

Enterprise-grade PHP SDK for the SalesPro / SectionERP API — with full CodeIgniter 3 &amp; 4 integration

1.0.3(2mo ago)03MITPHPPHP ^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3

Since May 8Pushed 2mo agoCompare

[ Source](https://github.com/SectionLLC/SalesProSDK-PHP)[ Packagist](https://packagist.org/packages/itechsection/salesprosdk)[ RSS](/packages/itechsection-salesprosdk/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

SalesPro PHP SDK
================

[](#salespro-php-sdk)

[![PHP Version](https://camo.githubusercontent.com/28c51220390759320b3ba46a21b2f00575a0593b6c8f7c760985dd5adf713236/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e34253230253743253230382e782d626c7565)](https://php.net)[![CI](https://github.com/itechsection/salespro-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/itechsection/salespro-sdk/actions)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

Enterprise-grade PHP SDK for the **SalesPro / SectionERP API** with first-class support for **CodeIgniter 3** and **CodeIgniter 4**.

---

Features V 1.0.0
----------------

[](#features-v-100)

- ✅ Full coverage of every SalesPro API endpoint
- ✅ OAuth2 password-grant token management with auto-refresh
- ✅ Personal access token support
- ✅ Automatic retry with exponential back-off (via Polly-equivalent Guzzle middleware)
- ✅ Rate-limit handling with `Retry-After` header awareness
- ✅ PSR-16 response caching for read-only endpoints
- ✅ PSR-3 logging support
- ✅ Strongly typed response objects
- ✅ Automatic pagination helper (`getAllPages`)
- ✅ CodeIgniter 3 Library
- ✅ CodeIgniter 4 Service + Config class
- ✅ Multi-tenant support via `X-Tenant-Id` header
- ✅ Full PHPUnit test suite

---

Requirements
------------

[](#requirements)

RequirementVersionPHP7.4, 8.0, 8.1, 8.2, 8.3Guzzle^7.0ext-curl\*ext-json\*---

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

[](#installation)

```
composer require itechsection/salesprosdk
```

---

Quick Start
-----------

[](#quick-start)

### Plain PHP

[](#plain-php)

```
use ITechSection\SalesPro\SalesProClient;

$client = SalesProClient::create([
    'base_url'      => 'https://salespro.itechsection.com/',
    'client_id'     => 'YOUR_CLIENT_ID',
    'client_secret' => 'YOUR_CLIENT_SECRET',
    'username'      => 'admin@yourcompany.com',
    'password'      => 'your-password',
]);

// List products
$products = $client->products->list(['per_page' => 20]);
foreach ($products->data as $product) {
    echo $product['name'] . "\n";
}

// Create a contact
$contact = $client->contacts->create([
    'type'       => 'customer',
    'first_name' => 'John',
    'last_name'  => 'Doe',
    'email'      => 'john@example.com',
]);

// Create a sale
$sell = $client->sales->create([
    'location_id'      => 1,
    'contact_id'       => $contact->data['id'],
    'transaction_date' => date('Y-m-d H:i:s'),
    'sell_lines' => [
        ['product_id' => 1, 'quantity' => 2, 'unit_price' => 50.00],
    ],
    'payments' => [
        ['method' => 'cash', 'amount' => 100.00],
    ],
]);

echo "Invoice: " . $sell->data['invoice_no'];
```

---

CodeIgniter 3 Integration
-------------------------

[](#codeigniter-3-integration)

### 1. Publish the library and config

[](#1-publish-the-library-and-config)

```
# Copy the library
cp vendor/itechsection/salesprosdk/src/CodeIgniter3/Salespro.php \
   application/libraries/Salespro.php

# Copy the config stub
cp vendor/itechsection/salesprosdk/src/CodeIgniter3/config/salesproconf.php \
   application/config/salespro.php
```

### 2. Edit `application/config/salespro.php`

[](#2-edit-applicationconfigsalesprophp)

```
$config['salespro_base_url']      = 'https://salespro.itechsection.com/';
$config['salespro_client_id']     = 'YOUR_CLIENT_ID';
$config['salespro_client_secret'] = 'YOUR_CLIENT_SECRET';
$config['salespro_username']      = 'admin@yourcompany.com';
$config['salespro_password']      = 'your-password';
```

### 3. Use in your controllers

[](#3-use-in-your-controllers)

```
class Products extends CI_Controller
{
    public function index()
    {
        $this->load->library('salespro');

        $products = $this->salespro->products->list(['per_page' => 20]);
        $this->load->view('products/index', ['products' => $products->data]);
    }

    public function create()
    {
        $this->load->library('salespro');

        try {
            $result = $this->salespro->contacts->create([
                'type'       => 'customer',
                'first_name' => $this->input->post('first_name'),
                'email'      => $this->input->post('email'),
            ]);

            redirect('products');

        } catch (\ITechSection\SalesPro\Exceptions\ValidationException $e) {
            // $e->getErrors() returns ['field' => ['error message', ...]]
            $this->session->set_flashdata('errors', $e->getErrors());
            redirect('products/create');
        }
    }
}
```

---

CodeIgniter 4 Integration
-------------------------

[](#codeigniter-4-integration)

### 1. Publish config files

[](#1-publish-config-files)

```
# Copy CI4 config class
cp vendor/itechsection/salesprosdk/src/CodeIgniter4/Config/SalesPro.php \
   app/Config/SalesPro.php

# Copy services registration
cp vendor/itechsection/salesprosdk/src/CodeIgniter4/Config/SalesProServices.php \
   app/Config/SalesProServices.php
```

### 2. Edit `app/Config/SalesPro.php`

[](#2-edit-appconfigsalesprophp)

```
public string $baseUrl      = 'https://salespro.itechsection.com/';
public string $clientId     = 'YOUR_CLIENT_ID';
public string $clientSecret = 'YOUR_CLIENT_SECRET';
public string $username     = 'admin@yourcompany.com';
public string $password     = 'your-password';
```

### 3. Use in your controllers

[](#3-use-in-your-controllers-1)

```
use CodeIgniter\Controller;

class ProductController extends Controller
{
    public function index()
    {
        $client   = \Config\Services::salespro();
        $products = $client->products->list(['per_page' => 20]);

        return view('products/index', ['products' => $products->data]);
    }
}
```

---

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

[](#authentication)

### Password Grant (default)

[](#password-grant-default)

```
$client = SalesProClient::create([
    'base_url'      => '...',
    'client_id'     => '...',
    'client_secret' => '...',
    'username'      => 'admin@example.com',
    'password'      => 'secret',
]);
```

### Static Token (personal access token)

[](#static-token-personal-access-token)

```
$client = SalesProClient::withToken(
    'https://salespro.itechsection.com/',
    'your-personal-access-token'
);
```

### Managing Personal Access Tokens

[](#managing-personal-access-tokens)

```
// Create
$tokenData = $client->auth->createPersonalAccessToken('my-app', ['*']);
echo $tokenData['accessToken']; // save this — shown only once

// List
$tokens = $client->auth->listPersonalAccessTokens();

// Delete
$client->auth->deletePersonalAccessToken($tokenData['id']);
```

---

All Available Services &amp; Methods
------------------------------------

[](#all-available-services--methods)

ServicePropertyKey MethodsAttendance`$client->attendance``getAttendance($userId)`, `clockIn($data)`, `clockOut($data)`, `listHolidays($filters)`Brands`$client->brands``list()`, `get($id)`Business Locations`$client->businessLocations``list()`, `get($id)`Business`$client->business``getDetails()`, `getProfitLossReport($filters)`, `getNotifications()`, `getPaymentAccounts()`, `getPaymentMethods()`Cash Registers`$client->cashRegisters``list()`, `create($data)`, `get($id)`Contacts`$client->contacts``list($params)`, `create($data)`, `get($id)`, `update($id, $data)`, `addPayment($data)`CRM`$client->crm``listFollowUps()`, `addFollowUp($data)`, `getFollowUp($id)`, `updateFollowUp($id, $data)`, `listLeads()`, `saveCallLog($data)`Expenses`$client->expenses``list()`, `create($data)`, `get($id)`, `update($id, $data)`, `listRefunds()`, `listCategories()`Field Force`$client->fieldForce``listVisits()`, `createVisit($data)`, `updateVisitStatus($id, $data)`Products`$client->products``list($params)`, `get($id)`, `listVariations($id)`, `listSellingPriceGroups()`, `getStockReport($params)`Sales`$client->sales``list()`, `create($data)`, `get($id)`, `update($id, $data)`, `delete($id)`, `addReturn($data)`, `listReturns()`, `updateShippingStatus($data)`Superadmin`$client->superadmin``getActiveSubscription()`, `getPackages()`Tables`$client->tables``list()`, `get($id)`Taxes`$client->taxes``list()`, `get($id)`Taxonomies`$client->taxonomies``list()`, `get($id)`Types of Service`$client->typesOfService``list()`, `get($id)`Units`$client->units``list()`, `get($id)`Users`$client->users``getLoggedIn()`, `register($data)`, `list()`, `get($id)`, `updatePassword($data)`, `forgotPassword($data)`---

Pagination
----------

[](#pagination)

Every `list()` method returns an `ApiListResponse` with a `$meta` property:

```
$result = $client->contacts->list(['page' => 1, 'per_page' => 15]);

echo $result->total();          // total records
echo $result->meta->lastPage;   // last page number
echo $result->meta->currentPage;

if ($result->hasMorePages()) {
    $page2 = $client->contacts->list(['page' => 2, 'per_page' => 15]);
}

// Or fetch ALL pages automatically:
$allContacts = $client->httpClient->getAllPages('connector/api/contactapi');
```

---

Error Handling
--------------

[](#error-handling)

```
use ITechSection\SalesPro\Exceptions\AuthenticationException;
use ITechSection\SalesPro\Exceptions\AuthorizationException;
use ITechSection\SalesPro\Exceptions\NotFoundException;
use ITechSection\SalesPro\Exceptions\ValidationException;
use ITechSection\SalesPro\Exceptions\RateLimitException;
use ITechSection\SalesPro\Exceptions\ServerException;
use ITechSection\SalesPro\Exceptions\NetworkException;
use ITechSection\SalesPro\Exceptions\SalesProException;

try {
    $result = $client->contacts->create($data);

} catch (ValidationException $e) {
    // Field-level validation failures (HTTP 422)
    foreach ($e->getErrors() as $field => $messages) {
        echo "{$field}: " . implode(', ', $messages) . "\n";
    }

} catch (AuthenticationException $e) {
    // 401 — credentials invalid or token expired
    echo "Auth error: {$e->getMessage()}\n";

} catch (NotFoundException $e) {
    // 404
    echo "Not found: {$e->getMessage()}\n";

} catch (RateLimitException $e) {
    // 429
    echo "Rate limited. Retry after {$e->getRetryAfter()} seconds.\n";

} catch (ServerException $e) {
    // 5xx
    echo "Server error ({$e->getCode()}): {$e->getMessage()}\n";

} catch (NetworkException $e) {
    // DNS / timeout / connection refused
    echo "Network error: {$e->getMessage()}\n";

} catch (SalesProException $e) {
    // Any other SDK error
    echo "SDK error: {$e->getMessage()}\n";
}
```

---

Configuration Reference
-----------------------

[](#configuration-reference)

KeyTypeDefaultDescription`base_url`string—SalesPro instance URL (required)`client_id`string—OAuth2 client ID (required)`client_secret`string—OAuth2 client secret (required)`username`string—Login username`password`string—Login password`static_access_token`string|nullnullPersonal access token (skips password grant)`timeout`int30HTTP timeout (seconds)`max_retries`int3Retry attempts on transient errors`retry_delay_ms`int500Base retry delay (milliseconds, exponential)`verify_ssl`booltrueSSL certificate verification`enable_cache`boolfalseIn-memory GET response caching`cache_ttl`int60Cache TTL (seconds)`enable_logging`boolfalseRequest/response debug logging`tenant_id`string|nullnullSent as `X-Tenant-Id` header`default_headers`array\[\]Extra headers on every request---

Running Tests
-------------

[](#running-tests)

```
composer install
vendor/bin/phpunit
```

---

How To Use
----------

[](#how-to-use)

```
composer require itechsection/salesprosdk
```

---

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~5 days

Total

2

Last Release

72d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cfe820e17015e8a76ae97522db5cdc51f796c5c350b85782e71708a8c28bf2c?d=identicon)[modyali2](/maintainers/modyali2)

---

Top Contributors

[![MrPoP](https://avatars.githubusercontent.com/u/24279437?v=4)](https://github.com/MrPoP "MrPoP (9 commits)")

---

Tags

apisdkcodeigniterposERPcodeigniter4salesproitechsection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/itechsection-salesprosdk/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.5k](/packages/laravel-framework)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M162](/packages/algolia-algoliasearch-client-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k46](/packages/civicrm-civicrm-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[nutgram/nutgram

The Telegram bot library that doesn't drive you nuts

737290.3k8](/packages/nutgram-nutgram)

PHPackages © 2026

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