ERP Connect
Integrate your ERP system with Selfimart using one of our two integration methods. Choose between direct API/webhook integration for modern systems, or our plug & play desktop agent for legacy systems.
Choose Your Integration Method
Select the integration approach that best fits your ERP system's capabilities and your technical resources.
Direct API Integration
Webhooks & RESTful API
For modern ERP systems that support webhooks, RESTful APIs, or have accessible source code. This option provides real-time data synchronization and full control over the integration.
Features:
- Real-time webhook notifications
- Bidirectional data sync
- Custom field mapping
- Scheduled polling support
- Source code integration
Plug & Play Middleware
Desktop Agent
For legacy ERP systems running on local servers with no external API access. Install our lightweight desktop agent for automatic, secure data synchronization.
Features:
- No ERP modification required
- Works with local databases
- Automatic data sync
- Cross-platform support
- Auto-update capability
Implementation Examples
<?php
// ERP System: Send product update to Selfimart via webhook
class SelfimartWebhook {
private $apiKey;
private $secretHash;
private $webhookUrl = 'https://selfimart.com/api/v1/middleware/sync/products';
public function __construct($apiKey, $secretHash) {
$this->apiKey = $apiKey;
$this->secretHash = $secretHash;
}
public function sendProductUpdate(array $product) {
$payload = json_encode([
'event_type' => 'product.updated',
'product' => $product,
'timestamp' => date('c'),
]);
// Generate HMAC signature for security
$signature = hash_hmac('sha256', $payload, $this->secretHash);
$ch = curl_init($this->webhookUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Integration-Key: ' . $this->apiKey,
'X-ERP-Signature: ' . $signature,
'X-Timestamp: ' . date('c'),
],
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
}
// Usage
$webhook = new SelfimartWebhook('erp_your_key', 'your_secret_hash');
$result = $webhook->sendProductUpdate([
'id' => 'PROD-001',
'name' => 'Product Name',
'sku' => 'SKU-001',
'price' => 99.99,
'quantity' => 100,
]);
# config.yaml - Desktop Agent Configuration
# Integration Settings
integration:
id: "your-integration-id"
name: "Supermarket ABC"
# API Configuration
api:
base_url: "https://selfimart.com"
key: "erp_your_api_key_here"
secret: "your_secret_hash_here"
timeout: 30
# Local Database Connection
database:
type: "mysql" # mysql, postgresql, sqlserver
host: "localhost"
port: 3306
database: "erp_database"
username: "erp_user"
password: "erp_password"
# Sync Settings
sync:
interval: 5 # minutes
batch_size: 100
retry_attempts: 3
retry_delay: 60 # seconds
# Field Mappings
mapping:
products:
table: "items"
columns:
id: "item_id"
name: "item_name"
sku: "item_code"
price: "selling_price"
quantity: "qty_in_stock"
updated_at: "modified_date"
field_mappings:
item_name: "name"
item_code: "sku"
selling_price: "price"
qty_in_stock: "stock_quantity"
# Pricing Rules
pricing:
markup: 10 # percentage markup to add to ERP prices
tax_inclusive: false
# Agent Settings
agent:
port: 8080 # Local HTTP server for status
log_level: "info"
import requests
import hmac
import hashlib
import json
from datetime import datetime
class SelfimartErpClient:
def __init__(self, api_key: str, secret_hash: str, base_url: str = "https://selfimart.com/api/v1"):
self.api_key = api_key
self.secret_hash = secret_hash
self.base_url = base_url
self.session = requests.Session()
self.session.headers.update({
"Content-Type": "application/json",
"Accept": "application/json",
})
def _generate_signature(self, payload: str) -> str:
"""Generate HMAC signature for request authentication."""
return hmac.new(
self.secret_hash.encode(),
payload.encode(),
hashlib.sha256
).hexdigest()
def _make_request(self, method: str, endpoint: str, data: dict = None) -> dict:
"""Make authenticated API request."""
url = f"{self.base_url}{endpoint}"
payload = json.dumps(data) if data else ""
headers = {
"X-Integration-Key": self.api_key,
"X-Signature": self._generate_signature(payload),
"X-Timestamp": datetime.utcnow().isoformat(),
}
response = self.session.request(
method,
url,
data=payload,
headers=headers
)
response.raise_for_status()
return response.json()
def sync_products(self, products: list) -> dict:
"""Sync products to Selfimart."""
return self._make_request("POST", "/middleware/sync/products", {
"products": products,
"timestamp": datetime.utcnow().isoformat()
})
def sync_inventory(self, inventory: list) -> dict:
"""Sync inventory levels to Selfimart."""
return self._make_request("POST", "/middleware/sync/inventory", {
"inventory": inventory,
"timestamp": datetime.utcnow().isoformat()
})
def get_orders(self, last_sync: str = None) -> dict:
"""Get orders from Selfimart for ERP import."""
params = {"last_sync": last_sync} if last_sync else {}
return self._make_request("GET", "/middleware/sync/orders", params)
# Usage
client = SelfimartErpClient(
api_key="erp_your_key",
secret_hash="your_secret_hash"
)
# Sync products
result = client.sync_products([
{
"id": "PROD-001",
"name": "Product Name",
"sku": "SKU-001",
"price": 99.99,
"quantity": 100
}
])
Sync Configuration Settings
Product Synchronization
Configure how products are synchronized between ERP and Selfimart.
{
"sync_direction": "erp_to_selfimart",
"sync_interval_minutes": 5,
"sync_on_create": true,
"sync_on_update": true,
"sync_on_delete": true,
"field_mapping": {
"erp_field": "selfimart_field",
"item_name": "name",
"item_code": "sku",
"selling_price": "price",
"qty_in_stock": "stock_quantity"
}
}
Inventory Synchronization
Real-time inventory updates from ERP to Selfimart.
{
"sync_interval_minutes": 1,
"batch_updates": true,
"batch_size": 100,
"notify_on_low_stock": true,
"low_stock_threshold": 10
}
Order Synchronization
Sync orders from Selfimart to ERP for fulfillment.
{
"sync_direction": "selfimart_to_erp",
"sync_interval_minutes": 2,
"auto_acknowledge": true,
"status_mapping": {
"pending": "NEW",
"processing": "PROCESSING",
"shipped": "SHIPPED",
"delivered": "DELIVERED"
}
}
Pricing Rules
Apply pricing rules when syncing from ERP.
{
"apply_markup": true,
"markup_percentage": 10,
"rounding": "nearest",
"tax_inclusive": false
}
Integration Architecture
Option 1: Direct API Integration Architecture
Option 2: Desktop Agent Architecture
Start Your ERP Integration
Create an integration and choose your preferred method to connect your ERP system.