Integration Development
Integration Development
Section titled “Integration Development”Learn how to create custom integrations for e-commerce platforms in the Gateway. This guide covers the complete process from seeder configuration to integration class implementation.
Overview
Section titled “Overview”Creating a Gateway integration involves three main steps:
Define integration parameters and resources in ServicesSeeder.php and AppServicesSeeder.php.
Implement OAuth2 authorization if your platform requires it, using AuthorizationServiceTrait.
Create the integration class implementing IntegrationInterface with required methods.
Architecture
Section titled “Architecture”graph TD A[E-commerce Platform] -->|OAuth2| B[Gateway] B -->|Background Jobs| C[Integration Class] C -->|API Calls| A C -->|Map Data| D[Standard Classes] D -->|Send to| E[WMS/App]
F[ServicesSeeder] -->|Configure| B G[AppServicesSeeder] -->|Define Resources| BIntegration Components
Section titled “Integration Components”| Component | Purpose | File Location |
|---|---|---|
| Service Seeder | Define integration metadata & parameters | database/seeders/ServicesSeeder.php |
| App Service Seeder | Define resources & subscriptions | database/seeders/AppServicesSeeder.php |
| Authorization Trait | Implement OAuth2 flows | app/Traits/AuthorizationServiceTrait.php |
| Integration Class | Core integration logic | app/Classes/{Platform}Integration.php |
| Data Mapping Classes | Standardized data structures | app/Classes/{Order,Item,Address}.php |
Quick Start
Section titled “Quick Start”1. Add Service Configuration
Section titled “1. Add Service Configuration”[ 'name' => 'MyPlatform', 'type' => 'myplatform', 'oauth_required' => true, 'params' => [ [ 'name' => 'api_key', 'type' => 'text', 'label' => 'API Key', 'required' => true ] ]]2. Define Resources
Section titled “2. Define Resources”[ 'service_type' => 'myplatform', 'resources' => [ [ 'name' => 'get_orders', 'label' => 'Import Orders', 'schedulable' => true ] ]]3. Create Integration Class
Section titled “3. Create Integration Class”class MyPlatformIntegration implements IntegrationInterface{ public function getOrders(array $request) { // Fetch orders from platform API }
public function mapOrder($orderData) { // Map to Gateway Order class }
// ... other required methods}Required Methods
Section titled “Required Methods”All integrations must implement 6 required methods from IntegrationInterface:
| Method | Purpose | Returns |
|---|---|---|
getOrders() | Fetch orders from platform | Array of mapped orders |
mapOrder() | Convert platform order to Gateway format | Order object |
acknowledgeOrders() | Mark orders as acknowledged | Status response |
updateTracking() | Send tracking updates | Status response |
syncInventory() | Sync inventory levels | Status response |
rules() | Validation rules | Array of validation rules |
View complete IntegrationInterface →
Standardized Data Classes
Section titled “Standardized Data Classes”All integrations use standardized Gateway classes:
Order- Order dataItem- Line item dataAddress- Base address classShippingAddress- Shipping addressBillingAddress- Billing addressShippingService- Shipping optionsProduct- Product/inventory dataShipment- Tracking data
Development Workflow
Section titled “Development Workflow”-
Research Platform API
- Review API documentation
- Identify authentication method
- Map API endpoints to Gateway resources
-
Configure Seeders
- Add service in
ServicesSeeder.php - Define resources in
AppServicesSeeder.php - Run migrations:
php artisan db:seed
- Add service in
-
Implement OAuth2 (if required)
- Add authorization methods
- Implement
missingParameters() - Implement
addParametersRequest()
-
Create Integration Class
- Implement required methods
- Map platform data to Gateway classes
- Add error handling
-
Test Integration
- Install via Gateway UI
- Test order import
- Test tracking updates
- Verify data mapping
-
Deploy
- Commit code
- Deploy to staging
- Run seeders
- Test with real account
Best Practices
Section titled “Best Practices”1. Follow Naming Conventions
Section titled “1. Follow Naming Conventions”✅ Service Type: lowercase, no spaces (shopifyv2, amazon, woocommerce)
✅ Integration Class: PascalCase + Integration (ShopifyV2Integration)
✅ Resource Names: snake_case (get_orders, update_tracking)
2. Use Spec-based Parameters
Section titled “2. Use Spec-based Parameters”[ 'name' => 'order_status', 'type' => 'multiselect', 'label' => 'Order Status', 'required' => true, 'items' => [ ['value' => 'open', 'label' => 'Open'], ['value' => 'closed', 'label' => 'Closed'] ]]3. Implement Robust Error Handling
Section titled “3. Implement Robust Error Handling”try { $orders = $this->apiClient->get('orders');} catch (\Exception $e) { Log::error("Failed to fetch orders: " . $e->getMessage()); return ['error' => $e->getMessage()];}4. Use Token Auto-refresh
Section titled “4. Use Token Auto-refresh”if ($this->accessToken->expires_at < now()->addMinutes(5)) { $this->refreshAccessToken();}Examples
Section titled “Examples”View existing integrations for reference:
- Shopify V2:
app/Classes/ShopifyV2Integration.php - Amazon:
app/Classes/AmazonIntegration.php - WooCommerce:
app/Classes/WooCommerceIntegration.php