A Laravel-based Shopify app for integrating with EcoFreight shipping services. This app automatically creates shipments, generates labels, and tracks packages when orders are paid.
- Automatic Shipment Creation: Creates EcoFreight shipments when orders are paid
- Label Generation: Downloads and attaches shipping labels to Shopify orders
- Tracking Integration: Syncs tracking status between EcoFreight and Shopify
- Settings Management: Configure EcoFreight connection, ship-from address, and package rules
- Error Handling: Email notifications for failed shipments with retry capabilities
- Embedded App: Runs seamlessly within the Shopify admin interface
- PHP 8.1 or higher
- Laravel 10.x
- MySQL 5.7 or higher
- Composer
- Node.js (for asset compilation)
- SSL certificate (required for Shopify apps)
-
Clone the repository
git clone <repository-url> cd ecofreight-shopify-app
-
Install PHP dependencies
composer install
-
Install Node.js dependencies
npm install
-
Environment setup
cp env.example .env php artisan key:generate
-
Configure environment variables Edit
.envfile with your settings:# Database DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=ecofreight_shopify DB_USERNAME=your_username DB_PASSWORD=your_password # Shopify App Configuration SHOPIFY_API_KEY=your_shopify_api_key SHOPIFY_API_SECRET=your_shopify_api_secret SHOPIFY_SCOPES=write_fulfillments,read_fulfillments,write_orders,read_orders,read_products,write_shipping SHOPIFY_APP_URL=https://your-app-url.com SESSION_SECRET=your_session_secret # EcoFreight Configuration ECOFREIGHT_BASE_URL=https://app.ecofreight.ae/en ECOFREIGHT_SANDBOX_USERNAME=apitesting ECOFREIGHT_SANDBOX_PASSWORD=apitesting # Encryption Key for sensitive data ENCRYPTION_KEY=your_encryption_key_32_chars
-
Run database migrations
php artisan migrate
-
Set up queue worker (for background jobs)
php artisan queue:work
-
Create a Shopify Partner account at https://partners.shopify.com
-
Create a new app in your Partner dashboard:
- App type: Custom app
- App URL:
https://your-app-url.com - Allowed redirection URL:
https://your-app-url.com/auth/callback
-
Configure app settings:
- App name: EcoFreight Shipping
- App URL: Your app's public URL
- Allowed redirection URL: Your app URL +
/auth/callback
-
Get your credentials:
- API key
- API secret key
- Add these to your
.envfile
-
Get EcoFreight API credentials:
- Sandbox credentials are provided:
apitesting/apitesting - Production credentials from EcoFreight
- Sandbox credentials are provided:
-
Configure in app settings:
- Base URL:
https://app.ecofreight.ae/en - Username and password for API access
- Base URL:
-
Install the app on your Shopify store
-
Configure settings:
- EcoFreight connection credentials
- Ship-from address (origin)
- Default package rules
- Services to use (Standard/Express)
- COD settings (if applicable)
- Tracking preferences
- Error notification emails
-
Test connection to verify EcoFreight API access
- Order placed and paid → Webhook triggers
- Shipment created in EcoFreight automatically
- Label generated and attached to Shopify order
- Fulfillment created in Shopify with tracking
- Tracking updates synced automatically
- View shipments: See all shipments and their status
- Retry failed shipments: Manually retry failed operations
- Regenerate labels: Download new labels if needed
- Sync tracking: Force tracking status updates
- Company name and contact person
- Phone, email, and full address
- City/Emirate and postcode
- Country (UAE)
- Default weight and dimensions
- Packing rule: per order or per item
- Fallback values when product data is missing
- Enable/disable Standard service
- Enable/disable Express service
- Service mapping from Shopify shipping rates
- Enable/disable Cash on Delivery
- COD fee amount
- Automatic COD amount calculation
- Auto-polling interval (1-24 hours)
- Stop polling after delivery or time limit
- Custom tracking URL template
- Error notification email addresses
- Include AWB in alerts
- Automatic retry on failures
POST /webhooks/orders/paid- Order payment webhookPOST /webhooks/orders/updated- Order update webhookPOST /webhooks/fulfillments/update- Fulfillment update webhook
GET /app- Main app dashboardGET /app/settings- Settings pagePOST /app/settings- Update settingsPOST /app/test-connection- Test EcoFreight connectionGET /app/shipments- View shipments
- CreateShipmentJob: Creates shipments in EcoFreight
- GenerateLabelJob: Downloads and processes labels
- TrackSyncJob: Syncs tracking status (future)
- Automatic retries with exponential backoff
- Email notifications for persistent failures
- Detailed logging for debugging
- Manual retry options in the app interface
- Encrypted storage of sensitive credentials
- Webhook verification for all incoming requests
- PII redaction in logs and error messages
- HTTPS required for all communications
-
Install ngrok
npm install -g ngrok
-
Start Laravel development server
php artisan serve
-
Expose with ngrok
ngrok http 8000
-
Update app URL in Shopify Partner dashboard to ngrok URL
# Run tests
php artisan test
# Run specific test
php artisan test --filter=CreateShipmentJob- Check logs in
storage/logs/laravel.log - Use Shopify CLI for local development
- Monitor webhook deliveries in Shopify admin
- SSL certificate (required by Shopify)
- Queue worker running continuously
- Database with proper indexing
- File storage for label files
- Email service for notifications
Ensure all required environment variables are set:
- Database credentials
- Shopify app credentials
- EcoFreight API credentials
- Encryption key
- Mail configuration
For issues and questions:
- Check the logs for error details
- Verify EcoFreight API connectivity
- Test with sandbox credentials first
- Contact support with specific error messages
This project is licensed under the MIT License.