Sub-Module 19.2

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.

Option 1

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.

Medium
Complexity
1-3 Days
Setup Time

Features:

  • Real-time webhook notifications
  • Bidirectional data sync
  • Custom field mapping
  • Scheduled polling support
  • Source code integration
Best For
Best for cloud-based ERPs, modern POS systems, and platforms with API capabilities.
Option 2

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.

Low
Complexity
30 Min
Setup Time

Features:

  • No ERP modification required
  • Works with local databases
  • Automatic data sync
  • Cross-platform support
  • Auto-update capability
Best For
Best for on-premise ERPs, legacy POS systems, and closed-source platforms.

Implementation Examples

Webhook Integration Example
<?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,
]);

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

Your ERP System
Webhooks / REST API
HTTPS
HMAC Signature
Selfimart Cloud
API Gateway

Option 2: Desktop Agent Architecture

Local ERP Database
MySQL / PostgreSQL / SQL Server
Desktop Agent
Sync Engine
Selfimart Cloud
Middleware API

Start Your ERP Integration

Create an integration and choose your preferred method to connect your ERP system.