Key Features
- Maintain customer wallet balances.
- Record wallet transactions and an audit trail.
- Support customer wallet operations such as deposits, withdrawals, and transfers where enabled.
- Integrate wallet usage with order processing through hooks.
- Provide balance notifications and alerts.
- Categorize transactions by type.
Package Structure
How It Works
- The wallet is created or initialized according to the configured customer policy.
- Wallet transactions are recorded when a supported wallet operation occurs.
- Order hooks connect wallet usage to order processing and payment workflows.
- The wallet balance reflects posted transactions.
- Customers and administrators can review transaction history and balance notifications.
Components
- Wallet model stores customer wallet data.
- Transaction model records wallet movements.
walletCustomerHook.tscontains customer wallet operations and hooks.walletOrderHook.tsconnects wallet operations with order processing.- Repositories and services manage wallet records and operations.
- Migrations create wallet and transaction tables.
Configuration
Configure the following settings after the add-on has been discovered and enabled. Only apply settings supported by the supplied package version.- Set initial wallet balance rules for new customers if applicable.
- Define the transaction types supported by the business.
- Configure balance notification thresholds.
- Review order integration and wallet payment rules.
Installation (Pre-built Premium Add-on)
This add-on is delivered as a pre-built JavaScript package by SpurtCommerce. Install the supplied compiled files; you do not need to run a TypeScript build.Before you begin
- Confirm that the add-on package is intended for the SpurtCommerce version and edition installed in your project.
- Back up the application files and database before installing a new add-on or applying its migrations.
- Extract the supplied add-on archive. The package normally contains
index.js(which exports thespurtcommerceAddonmanifest), compiled folders such ascontrollers/,models/,repositories/,services/,migrations/, and may include an optional hook file andpackage.json. - Work from the SpurtCommerce project root - the directory containing the application’s
main.jsandpackage.json.
Step 1: Place the add-on in add-ons/
Create an add-ons/ directory in the project root if it does not already exist. Copy the supplied add-on folder into it. Use the folder name provided with the add-on package and retain the supplied internal file structure.
There are two supported layouts.
Layout A - compiled files directly inside the add-on folder
dist/ directory inside the add-on folder
package.json that points to the compiled entry file. For example:
add-ons/<addon-name>/index.js with this content:
dist/ directory as a package entry by itself. When retaining dist/, provide the root-level package.json or index.js entry point shown above.
Step 2: Add add-on-specific environment settings
Check the add-on’s configuration section and the README or handover notes included with the supplied package. If the add-on requires environment variables - for example, a Redis connection, socket port, payment gateway credentials, or an external service key - add the exact variables to the SpurtCommerce project’s.env file.
Do not add placeholder values to production. Keep credentials private and do not commit real secrets to source control. If the add-on does not specify additional environment variables, no add-on-specific .env change is required.
Step 3: Install only additional dependencies required by the add-on
The SpurtCommerce application already provides its core dependencies, such as TypeORM,routing-controllers, and typedi. Install an additional third-party package only when it is explicitly listed as a requirement in the supplied add-on documentation or package manifest.
Run any required command from the project root:
Step 4: Start or restart SpurtCommerce
Start the application using the normal command for your project. For example:.env values. No manual edits to main.js or SpurtCommerce core loader files are required when the project has the supported add-on registry.
Step 5: Allow the core loaders to register the add-on
During startup, SpurtCommerce performs the add-on integration through its loader lifecycle:- Discovery (
addonRegistry): Scans theadd-ons/directory, loads the add-on entry file, and validates/caches itsspurtcommerceAddonmanifest. - Database and migrations (
typeormLoader): Registers the add-on’s TypeORM entities and migrations, runs the migrations, seeds the add-on’s plugin record where defined, and callsmanifest.initialize(dataSource)when provided. - Plugin registration (
pluginLoader): Registers the add-on’spluginNamein the application’s plugin module. - API routes (
expressLoader): Mounts the add-on’s store, vendor, and admin controllers under the/api/*route space. - Hooks (
HookUtil): Registers the event hooks included with the add-on so relevant core events can invoke them.
Step 6: Verify add-on discovery and activation
After startup, check the application console for a discovery message similar to:plugin_status is 1. If the add-on is disabled, enable it through the Admin application where supported, or follow your platform’s plugin administration procedure.
Finally, test the add-on’s documented API routes and its corresponding Admin, Vendor, or Store workflow. Test in a development or staging environment before enabling the add-on for production users.
Installation troubleshooting
Version and delivery note: Premium add-ons are supplied as compiled packages for a compatible SpurtCommerce release. Use the package delivered for your project version. Do not substitute source-build instructions, rename internal files, or mix compiled packages from different releases unless SpurtCommerce confirms compatibility.
Operational Notes
Treat wallet operations as financial ledger changes. Test deposit, withdrawal, transfer, order payment, refunds or reversals if supported, and transaction audit history. Restrict wallet adjustments to authorized roles.Summary
The Wallet add-on extends SpurtCommerce with the capabilities described above. It is delivered as a compiled premium package and is loaded by the SpurtCommerce add-on registry when installed according to the steps above.API Endpoints
The endpoint definitions below are derived from the supplied controller files. All routes are mounted under the SpurtCommerce/api prefix. Each entry describes the operation and lists the path, query, body, or file inputs identified by the controller annotations.
Controller routes documented: 17.
Store API
StoreWalletController
GET /api/store-wallet
Definition: Retrieves the my Wallet.
Authorization: The controller applies the customer access context.
GET /api/store-wallet/details
Definition: Retrieves the my Wallet With Transactions.
Inputs
Authorization: The controller applies the
customer access context.
GET /api/store-wallet/transactions
Definition: Retrieves the my Wallet Transactions.
Inputs
Authorization: The controller applies the
customer access context.
POST /api/store-wallet/add-fund
Definition: Processes initiate Wallet Top-up.
Inputs
Authorization: The controller applies the
customer access context.
GET /api/store-wallet/add-fund/process/:token
Definition: Processes wallet Top-up.
Inputs
GET /api/store-wallet/add-fund/paypal-proceed/:token
Definition: Retrieves the payPal Wallet Top-up Proceed.
Inputs
GET /api/store-wallet/add-fund/paypal-success
Definition: Handles the success callback for payPal Wallet Top-up Success.
GET /api/store-wallet/add-fund/success
Definition: Handles the success callback for wallet Top-up Success Callback.
GET /api/store-wallet/add-fund/cancel
Definition: Handles the cancellation callback for wallet Top-up Cancel Callback.
GET /api/store-wallet/settings
Definition: Retrieves the wallet Settings.
Headers: The controller documentation lists Authorization.
GET /api/store-wallet/transactions/export
Definition: Exports my Transactions.
Inputs
Headers: The controller documentation lists
Authorization.
Vendor API
VendorWalletController
GET /api/vendor-wallet
Definition: Retrieves the all Customer Wallets.
Inputs
Authorization: The controller applies the
vendor access context.
GET /api/vendor-wallet/customer/:customerId
Definition: Retrieves the customer Wallet Details.
Inputs
Authorization: The controller applies the
vendor access context.
PUT /api/vendor-wallet/customer/:customerId/status
Definition: Updates the status of the selected record using the submitted status value.
Inputs
Authorization: The controller applies the
vendor access context.
GET /api/vendor-wallet/transactions
Definition: Retrieves the all wallet transactions for this tenant.
Inputs
Authorization: The controller applies the
vendor access context.
GET /api/vendor-wallet/settings
Definition: Retrieves the wallet settings.
Authorization: The controller applies the vendor access context.
POST /api/vendor-wallet/settings
Definition: Creates /Update Wallet Settings.
Inputs
Request model:
CreateWalletSettingsRequest is used by the controller for payload validation.
Authorization: The controller applies the vendor access context.