Download the PHP package apna-payment/settlement-sdk without Composer

On this page you can find all versions of the php package apna-payment/settlement-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package settlement-sdk

ApnaPayment Settlement SDK

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

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

composer require apna-payment/settlement-sdk

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=

SETTLEMENT_API_TOKEN=

Usage

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

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

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

Fetch all settlements

$accounts = Settlement::getAllSettlements();

Fetch settlements for specific accounts

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

Handle an invalid account ID

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

Create settlement

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

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

$balance = Settlement::getBalance();

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

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:

Callbacks V1

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.

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:

1. {base_url}/settlement/status :
    {
        'id':  '<settlement_id>',
        'status':'completed'
    }
2. {base_url}/settlement/status :
    {
        'id':  '<settlement_id>',
        ‘status’:’failed’
    }
3. {base_url}/settlement_account/approval :
    { 
        'id':  '<settlement_account_id>',
        'status':'rejected'
    }
4.{base_url}/settlement_account/approval :
    {
        'id':  '<settlement_account_id>',
        'status':'approved'
    }

Querying the status of a settlement

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

$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



All versions of settlement-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
guzzlehttp/guzzle Version ^7.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package apna-payment/settlement-sdk contains the following files

Loading the files please wait ...