PHPackages                             apna-payment/settlement-sdk - 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. [Payment Processing](/categories/payments)
4. /
5. apna-payment/settlement-sdk

ActiveLibrary[Payment Processing](/categories/payments)

apna-payment/settlement-sdk
===========================

A PHP SDK for managing settlements between Laravel backends.

1.3.4(1y ago)0433MITPHPPHP &gt;=8.0

Since Dec 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/g2dgaming/settlement-sdk)[ Packagist](https://packagist.org/packages/apna-payment/settlement-sdk)[ RSS](/packages/apna-payment-settlement-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

ApnaPayment Settlement SDK
==========================

[](#apnapayment-settlement-sdk)

Overview
--------

[](#overview)

This PHP SDK allows you to integrate ApnaPayment's settlement system into your application. You can use it to create settlement accounts, create settlements, check settlement statuses, and more.

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

[](#installation)

To use the ApnaPayment Settlement SDK, first install it via Composer:

composer require apna-payment/settlement-sdk

### Configuration

[](#configuration)

After installation, publish the configuration file:

```
php artisan vendor:publish --provider="ApnaPayment\Settlements\SettlementServiceProvider" --tag="config"

```

This will publish a `settlement-sdk.php` configuration file to the `config` folder of your Laravel project.

In your `.env` file, set your API token:

SETTLEMENT\_BASE\_URL=&lt;base\_url\_depending\_on\_env&gt;

SETTLEMENT\_API\_TOKEN=&lt;your\_api\_token\_here&gt;

Usage
-----

[](#usage)

#### Create a VPA-based settlement account

[](#create-a-vpa-based-settlement-account)

```
try{
    $account = (new SettlementAccountBuilder())
    ->setAccountHolderName("My Name")
    ->setType(SettlementAccountBuilder::$TYPE_VPA)
    ->setVirtualAddress("testvpa@hdfcbank")
    ->setNickname("My Temp account test");
    $accountId = Settlement::createAccount($account);
}
catch (\ApnaPayment\Settlements\Exceptions\DuplicationAccountException $e){
    //Account already exists
}

```

#### Create a bank account-based settlement account

[](#create-a-bank-account-based-settlement-account)

```
try{
    $account = (new SettlementAccountBuilder())
    ->setType(SettlementAccountBuilder::$TYPE_BANK_ACCOUNT)
    ->setAccountNumber("988231872481874")
    ->setAccountHolderName("My Name")
    ->setIfscCode("IFSCTEST001")
    ->setNickname("My Name");
    $accountId = Settlement::createAccount($account);
}
catch (\ApnaPayment\Settlements\Exceptions\DuplicationAccountException $e){
    //Account already exists
}

```

#### Delete a settlement account

[](#delete-a-settlement-account)

```
$is_deleted=Settlement::removeAccount($accountId); //returns boolean
if($is_deleted){
    //Account deleted successfully
}
else{
//Something went wrong
}

```

#### Fetch all settlements

[](#fetch-all-settlements)

```
$accounts = Settlement::getAllSettlements();

```

#### Fetch settlements for specific accounts

[](#fetch-settlements-for-specific-accounts)

```
$accounts = Settlement::getSettlementsByAccount($accountId);

```

#### Handle an invalid account ID

[](#handle-an-invalid-account-id)

```
try {
    $settlements = Settlement::getSettlementsByAccount("InvalidId");
}
catch (\ApnaPayment\Settlements\Exceptions\InvalidAccountException) {
    $message = "Invalid Account";
}

```

#### Create settlement

[](#create-settlement)

```
$settlementBuilder = (new SettlementBuilder())
->setAmount(200.25)
->setRemarks("Test Payment")
->setSettlementAccountId($accountId);
$settlement = Settlement::createNewSettlement($settlementBuilder);

```

Exception Handling
------------------

[](#exception-handling)

```
try {
    $settlement = (new Settlement(config('settlement-sdk.api_token')))
->createSettlement($settlementBuilder);
}
catch (\ApnaPayment\Settlements\Exceptions\DuplicateTransactionException $e) {
    $message = "Duplicate";
}
catch (\ApnaPayment\Settlements\Exceptions\InvalidAccountException $e) {
    $message = "Invalid account";
} catch (\ApnaPayment\Settlements\Exceptions\LimitExceededException $e) {
    $message = "Limit exceeded";
}

```

Fetch account balance
---------------------

[](#fetch-account-balance)

```
$balance = Settlement::getBalance();

```

Find a settlement by ID
-----------------------

[](#find-a-settlement-by-id)

```
try{
    $settlement = Settlement::find($settlementId); //settlement id is always returned from creating a settlement (static or from object)
    // Now the 'data' attribute has status in it
    $arrayData=$settlement->toArray();
}
catch (\ApnaPayment\Settlements\Exceptions\SettlementNotFound $e){
    //Invalid settlement id
}

```

Find a settlement by TxnId
--------------------------

[](#find-a-settlement-by-txnid)

```
try{
    $settlement = Settlement::findByTxnId($txnId);
    $arrayData=$settlement->toArray();
    $pending=$settlement->isPending(); //call any instance methods

}
catch (\ApnaPayment\Settlements\Exceptions\SettlementNotFound $e){
//Invalid txnId
}

```

Usage of Webhook Base URL:
--------------------------

[](#usage-of-webhook-base-url)

### Callbacks V1

[](#callbacks-v1)

#### Note:

[](#note)

###### All Endpoints when triggered will expect 200-299 http response code, even if in the case 500,400 is thrown, there will always be one time updates to balance server load.

[](#all-endpoints-when-triggered-will-expect-200-299-http-response-code-even-if-in-the-case-500400-is-thrown-there-will-always-be-one-time-updates-to-balance-server-load)

After our backend receives a valid web hook url for updates relating to following events:

1. Settlement status: {'completed','failed'}
2. Account Approval Update : { 'approved','rejected' }

### Our Backend triggers an HTTP/HTTPS POST request to following endpoints:

[](#our-backend-triggers-an-httphttps-post-request-to-following-endpoints)

##### 1. {base\_url}/settlement/status :

[](#1-base_urlsettlementstatus-)

```
    {
        'id':  '',
        'status':'completed'
    }

```

##### 2. {base\_url}/settlement/status :

[](#2-base_urlsettlementstatus-)

```
    {
        'id':  '',
        ‘status’:’failed’
    }

```

##### 3. {base\_url}/settlement\_account/approval :

[](#3-base_urlsettlement_accountapproval-)

```
    {
        'id':  '',
        'status':'rejected'
    }

```

##### 4.{base\_url}/settlement\_account/approval :

[](#4base_urlsettlement_accountapproval-)

```
    {
        'id':  '',
        'status':'approved'
    }

```

Querying the status of a settlement
-----------------------------------

[](#querying-the-status-of-a-settlement)

#### Suppose you have the settlementId returned from Settlement::createSettlemen($settlementBuilder)

[](#suppose-you-have-the-settlementid-returned-from-settlementcreatesettlemensettlementbuilder)

```
$settlement = new Settlement();
// Load the settlement data

$settlement->getSettlementById($settlementId)

// Now the 'data' attribute has status in it

if($settlement->isPending()){
    // Pending
}
else if($settlement->isProcessing()){
    // Processing
}
else if($settlement->isCompleted()){
    // Completed
}
else if( $settlement->isFailed()){
    // Failed
}

```

Methods Overview
----------------

[](#methods-overview)

- **createAccount(SettlementAccountBuilder $builder)**: Creates a new settlement account using the provided builder.
- **createNewSettlement(SettlementBuilder $builder)**: Creates a new settlement using the provided builder.
- **allSettlements()**: Retrieves all settlements for the authenticated user.
- **settlementsByAccount(string $accountId)**: Retrieves settlements for a specific settlement account.
- **find(string $settlementId)**: Finds a specific settlement by its ID.
- **checkBalance()**: Retrieves the balance associated with the authenticated user.
- **isPending()**: Checks if the settlement is in the 'pending' state.
- **isProcessing()**: Checks if the settlement is in the 'processing' state.
- **isCompleted()**: Checks if the settlement is in the 'completed' state.
- **isFailed()**: Checks if the settlement has 'failed' status.

---

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance47

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~8 days

Recently: every ~0 days

Total

17

Last Release

396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a1e51074772c696615f7c2db416d1a3ca3fbf0eb38958886772bee8b32e1411?d=identicon)[samarth\_srivastava](/maintainers/samarth_srivastava)

---

Top Contributors

[![g2dgaming](https://avatars.githubusercontent.com/u/62881246?v=4)](https://github.com/g2dgaming "g2dgaming (37 commits)")

### Embed Badge

![Health badge](/badges/apna-payment-settlement-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/apna-payment-settlement-sdk/health.svg)](https://phpackages.com/packages/apna-payment-settlement-sdk)
```

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

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