PHPackages                             stallion/finfactor - 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. stallion/finfactor

ActiveLibrary[API Development](/categories/api)

stallion/finfactor
==================

PHP client for the Finfactor WealthScape API. Handles authentication, user subscription, AA consent flow, and financial data retrieval.

1.0.0(today)01↑2900%proprietaryPHPPHP &gt;=8.1

Since Jun 18Pushed todayCompare

[ Source](https://github.com/kmr-varun/finfactor)[ Packagist](https://packagist.org/packages/stallion/finfactor)[ RSS](/packages/stallion-finfactor/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

stallion/finfactor
==================

[](#stallionfinfactor)

PHP client for the Finfactor WealthScape API. Handles authentication, user subscription, AA consent flow, and financial data retrieval for mutual funds and equities via the RBI Account Aggregator framework.

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

[](#requirements)

- PHP 8.1 or higher
- Composer

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

[](#installation)

```
composer require stallion/finfactor
```

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

[](#quick-start)

```
use Stallion\Finfactor\Client;

$client = new Client([
    'pfm_base_url'      => 'https://your-tenant.fiu.finfactor.in/pfm/api/v2',
    'pfm_user_id'       => 'your-pfm-user-id',
    'pfm_password'      => 'your-pfm-password',
    'finsense_base_url' => 'https://your-tenant.fiu.finfactor.in/finsense/API/V2',
    'finsense_user_id'  => 'your-finsense-user-id',
    'finsense_password' => 'your-finsense-password',
    'redirect_url'      => 'https://yourapp.com/portfolio/success',
]);

// Step 1: Subscribe user (call once per new user)
$client->subscription->create($mobile, $mobile);

// Step 2: Get the Account Aggregator redirect URL
$result = $client->consent->request($mobile, uniqid('session_'));

// Step 3: Redirect the user to the AA portal
header('Location: ' . $result['redirect_url']);
```

After the user approves consent on the AA portal and is redirected back to your app:

```
$details = $client->data->userDetails($mobile);
$mf      = $client->data->mutualFundInsights($mobile);
$equity  = $client->data->equityAccounts($mobile);
```

Configuration
-------------

[](#configuration)

Pass a configuration array to the `Client` constructor.

KeyRequiredDescription`pfm_base_url`YesWealthScape PFM API base URL (provided by Finfactor)`pfm_user_id`YesWealthScape PFM API user ID`pfm_password`YesWealthScape PFM API password`finsense_base_url`YesFinsense API base URL (provided by Finfactor)`finsense_user_id`YesFinsense layer user ID`finsense_password`YesFinsense layer password`redirect_url`NoURL to redirect the user to after AA consent`consent_template`NoConsent template name. Default: `bank_statement_sebi``consent_description`NoConsent description. Default: `PFM``aa_id`NoAccount Aggregator ID. Default: `cookiejar-aa@finvu.in``customer_id_suffix`NoSuffix appended to mobile for AA customer ID. Default: `@finvu``timeout`NoRequest timeout in seconds. Default: `30``connect_timeout`NoConnection timeout in seconds. Default: `10`Token Storage
-------------

[](#token-storage)

By default the package stores the auth token in a temp file. You can provide a custom storage path or use a database-backed store for multi-server setups.

### File store with custom path

[](#file-store-with-custom-path)

```
use Stallion\Finfactor\TokenStore\FileTokenStore;

$client = new Client($config, new FileTokenStore('/var/www/storage'));
```

### Database store

[](#database-store)

```
use Stallion\Finfactor\TokenStore\DatabaseTokenStore;

$pdo    = new PDO('mysql:host=localhost;dbname=myapp', 'user', 'pass');
$client = new Client($config, new DatabaseTokenStore($pdo));
```

The database store requires a `finfactor_tokens` table (the table name is configurable):

```
CREATE TABLE finfactor_tokens (
    id         INT AUTO_INCREMENT PRIMARY KEY,
    token      TEXT NOT NULL,
    expires_at INT NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
```

To use a custom table name:

```
new DatabaseTokenStore($pdo, 'my_custom_tokens_table');
```

### Custom store

[](#custom-store)

Implement `Stallion\Finfactor\TokenStore\TokenStoreInterface`:

```
interface TokenStoreInterface
{
    public function get(): ?string;
    public function set(string $token, int $expiresAt): void;
    public function clear(): void;
}
```

API Reference
-------------

[](#api-reference)

### Subscription

[](#subscription)

```
// Register a user before initiating consent. Safe to call multiple times.
$client->subscription->create(string $uniqueIdentifier, string $mobileNumber): bool
```

### Consent

[](#consent)

```
// Submit a consent request. Returns redirect_url, consent_handle, customer_id.
$client->consent->request(string $mobileNumber, string $userSessionId): array

// Check consent status for a given handle.
$client->consent->status(string $consentHandle, string $custId): array

// Get full consent details by consent ID.
$client->consent->details(string $consentId): array
```

### Financial Data

[](#financial-data)

```
// Trigger a data fetch for all consented accounts.
$client->data->triggerFetch(string $uniqueIdentifier): array

// Get user details and FI data summary.
$client->data->userDetails(string $uniqueIdentifier): array

// Get mutual fund insights.
$client->data->mutualFundInsights(string $uniqueIdentifier): array

// Get mutual fund linked accounts with holdings.
$client->data->mutualFundAccounts(string $uniqueIdentifier, bool $filterZero = false): array

// Get mutual fund analysis.
$client->data->mutualFundAnalysis(string $uniqueIdentifier): array

// Get equity linked accounts (demat holdings).
$client->data->equityAccounts(string $uniqueIdentifier, bool $filterZero = false): array

// Get deposit insights.
$client->data->depositInsights(string $uniqueIdentifier): array

// Get ETF insights.
$client->data->etfInsights(string $uniqueIdentifier): array

// Fetch raw AA data for a specific account.
$client->data->rawAccountData(string $uniqueIdentifier, string $accountId, string $fromDate, string $toDate): array
```

Exceptions
----------

[](#exceptions)

All exceptions extend `Stallion\Finfactor\Exceptions\ApiException`.

ExceptionWhen thrown`ApiException`Any API error (4xx, 5xx, network)`AuthException`Authentication failure`\InvalidArgumentException`Missing required config keys```
use Stallion\Finfactor\Exceptions\ApiException;
use Stallion\Finfactor\Exceptions\AuthException;

try {
    $result = $client->consent->request($mobile, $sessionId);
} catch (AuthException $e) {
    // Token or credential issue
} catch (ApiException $e) {
    echo $e->getMessage();
    echo $e->getCode();
    print_r($e->getResponseData());
}
```

Testing
-------

[](#testing)

Set the following environment variables and run the test suite:

```
WS_PFM_BASE_URL=https://your-tenant.fiu.finfactor.in/pfm/api/v2 \
WS_PFM_USER_ID=your-pfm-user-id \
WS_PFM_PASSWORD=your-pfm-password \
WS_FINSENSE_BASE_URL=https://your-tenant.fiu.finfactor.in/finsense/API/V2 \
WS_FINSENSE_USER_ID=your-finsense-user-id \
WS_FINSENSE_PASSWORD=your-finsense-password \
./vendor/bin/phpunit
```

License
-------

[](#license)

Proprietary. All rights reserved. Stallion Asset Private Limited.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117676483?v=4)[Varun Kumar](/maintainers/kmr-varun)[@kmr-varun](https://github.com/kmr-varun)

---

Top Contributors

[![tw-varun](https://avatars.githubusercontent.com/u/282771439?v=4)](https://github.com/tw-varun "tw-varun (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stallion-finfactor/health.svg)

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.9k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1772.4k4](/packages/aimeos-prisma)

PHPackages © 2026

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