Thanks for visiting my GitHub account!
This document describes the complete Shippo integration implemented for Sustainable Trades.
The purpose of this documentation is to provide a complete reference for current and future developers so the integration can be maintained, extended, and deployed without confusion.
This integration uses Shippo's Partner OAuth (Grey Label) flow combined with Shippo Order Sync APIs.
- Introduction
- Integration Architecture
- Shippo Partner Account Setup
- Shippo Credentials Setup
- Environment Configuration
- Database Structure
- OAuth Authentication Flow
- API Endpoints
- Carrier Account Synchronization
- Shipping Rate Preferences
- Order Synchronization
- Webhook Integration
- Tracking Lifecycle
- Postman Testing Guide
- Common Issues
- Production Deployment Checklist
- Future Enhancements
Shippo is a shipping platform that provides:
- Shipping label creation
- Carrier account management
- Shipping rate comparison
- Package tracking
- Shipment notifications
- Return label support
Official Website:
Official Documentation:
Sustainable Trades uses a Hybrid Integration Strategy.
Users connect their own Shippo account through Sustainable Trades.
Benefits:
- Users manage their own Shippo account.
- Users manage their own Shippo billing.
- Sustainable Trades does not handle shipping invoices.
- Sustainable Trades acts on behalf of connected users.
Orders are created inside Sustainable Trades and synchronized to Shippo.
Flow:
Customer Creates Order ↓ Order Stored In Sustainable Trades ↓ Order Synced To Shippo ↓ Vendor Uses Shippo Dashboard ↓ Label Created ↓ Tracking Generated ↓ Tracking Updates Returned Through Webhooks
Create an account at:
After registration, verify your email address.
Partner OAuth credentials are not available automatically.
Contact Shippo:
Technical Support:
General Support:
Example Request:
Subject: OAuth Partner Integration Request
Hello Shippo Team,
We would like to integrate Shippo OAuth into our platform using the Grey Label Integration approach.
Please provide:
- Client ID
- Client Secret
- Redirect URL Registration Instructions
Thank you.
Shippo will provide:
Client ID
6e67e42c6aad40308f2a3e5357eaa110
Client Secret
****************************
Example only.
Never commit credentials to Git.
Provide Shippo with your callback URL.
Example:
https://api.sustainabletrades.com/shippo/oauth/callback
Shippo must whitelist this URL.
OAuth will fail if the callback URL is not registered.
Add credentials to environment variables.
SHIPPO_CLIENT_ID=
SHIPPO_CLIENT_SECRET=
SHIPPO_REDIRECT_URL=
SHIPPO_FRONTEND_REDIRECT_URL=Example:
SHIPPO_CLIENT_ID=xxxxxxxxxxxxxxxx
SHIPPO_CLIENT_SECRET=xxxxxxxxxxxxxxxx
SHIPPO_REDIRECT_URL=https://api.example.com/shippo/oauth/callback
SHIPPO_FRONTEND_REDIRECT_URL=https://app.example.com/settings/shippingconfig/services.php
'shippo' => [
'client_id' => env('SHIPPO_CLIENT_ID'),
'client_secret' => env('SHIPPO_CLIENT_SECRET'),
'redirect_url' => env('SHIPPO_REDIRECT_URL'),
]Stores Shippo connection information.
| Column | Description |
|---|---|
| shippo_access_token | OAuth access token |
| shippo_connected | Connection status |
| shippo_connected_at | Connection timestamp |
| carriers_accounts_synced_at | Last sync timestamp |
Stores vendor carrier accounts.
| Column | Description |
|---|---|
| shop_info_id | Shop reference |
| carrier | usps, ups, fedex |
| carrier_name | Display name |
| shippo_object_id | Shippo carrier account ID |
| active | Enabled status |
Stores vendor shipping preferences.
| Column | Description |
|---|---|
| shop_info_id | Shop reference |
| rate_type | cheapest / fastest |
| active | Status |
Additional Shippo fields.
| Column | Description |
|---|---|
| shippo_order_id | Shippo order ID |
| tracking_number | Tracking number |
| carrier | Carrier name |
| shipping_status | Tracking status |
| delivered_at | Delivery timestamp |
Frontend calls:
POST /shippo/connectResponse:
{
"success": true,
"data": {
"url": "https://goshippo.com/oauth/authorize?..."
}
}User is redirected to:
https://goshippo.com/oauth/authorize
User signs in or creates Shippo account.
Shippo redirects:
GET /shippo/oauth/callbackExample:
https://api.example.com/shippo/oauth/callback?code=AUTH_CODE&state=ENCRYPTED_USER
Exchange Authorization Code.
Request:
POST https://goshippo.com/oauth/access_tokenPayload:
{
"grant_type": "authorization_code",
"client_id": "CLIENT_ID",
"client_secret": "CLIENT_SECRET",
"code": "AUTH_CODE"
}Response:
{
"access_token": "oauth.xxxxxxxxx",
"token_type": "Bearer",
"scope": "*"
}Store access token securely.
encrypt($accessToken)Automatically:
- Sync carriers
- Create shipping preferences
- Redirect user back to frontend
POST /shippo/connectPOST /shippo/disconnectGET /shippo/access-tokenDevelopment use only.
Should be removed or restricted in production.
POST /shippo/sync-carriers-accounts/{user}GET /shippo/carriersPOST /shippo/carrier/{carrierAccount}Request:
{
"active": true
}GET /shippo/rate-preferencesPOST /shippo/rate-preference/{ratePreference}Request:
{
"active": true
}Shippo API:
GET https://api.goshippo.com/carrier_accounts/Authorization:
Bearer ACCESS_TOKENSupported Carriers:
- USPS
- UPS
- FedEx
The system guarantees all three records exist locally.
Example:
| Carrier | Active | Shippo Object ID |
|---|---|---|
| USPS | false | null |
| UPS | true | e14621fc896 |
| FedEx | false | null |
Supported options:
- Cheapest
- Fastest
Default creation:
Cheapest = Active
Fastest = Inactive
Business Rule:
Only one rate preference can be active at a time.
When one is activated, all others are automatically deactivated.
Purpose:
Push Sustainable Trades orders into Shippo.
Shippo Endpoint:
POST https://api.goshippo.com/orders/Authorization:
Bearer ACCESS_TOKENExample Payload
{
"order_number": "ORD123456",
"order_status": "PAID",
"currency": "USD",
"subtotal_price": "100.00",
"total_price": "110.00",
"metadata": {
"local_order_id": 100
}
}Example Response
{
"object_id": "abcdef123456"
}Store:
shippo_order_id
inside orders table.
Webhook Route
POST /webhooks/shippoCurrent Events:
- transaction_created
- transaction_updated
- track_updated
Purpose:
Capture tracking number after label purchase.
Stores:
tracking_number
carrier
Purpose:
Update shipping status.
Supported Status Mapping:
| Shippo | Local |
|---|---|
| PRE_TRANSIT | label_created |
| TRANSIT | in_transit |
| OUT_FOR_DELIVERY | out_for_delivery |
| DELIVERED | delivered |
| RETURNED | returned |
| FAILURE | failed |
Order Created ↓ Order Synced To Shippo ↓ Vendor Creates Label In Shippo ↓ Transaction Created ↓ Tracking Number Generated ↓ Webhook Received ↓ Tracking Number Stored ↓ Package Moves Through Carrier Network ↓ Tracking Updates Received ↓ Delivered
GET https://api.goshippo.com/carrier_accounts/Headers:
Authorization: Bearer ACCESS_TOKENPOST https://api.goshippo.com/orders/Headers:
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json- Call connect endpoint.
- Open returned URL.
- Complete Shippo authorization.
- Capture callback code.
- Verify token storage.
- Verify carrier sync.
Cause:
Redirect URL not registered with Shippo.
Solution:
Ask Shippo support to whitelist callback URL.
Cause:
Expired or revoked authorization.
Solution:
Reconnect Shippo account.
Cause:
No carriers configured in Shippo.
Solution:
Configure carrier accounts in Shippo dashboard.
Cause:
Missing required order data.
Solution:
Verify payload structure matches Shippo documentation.
- Shippo Partner Account Approved
- Client ID Received
- Client Secret Received
- Redirect URL Registered
- Webhook URL Configured
- SSL Enabled
- Environment Variables Configured
- Token Encryption Verified
- Carrier Sync Tested
- Order Sync Tested
- Tracking Updates Tested
- Delivery Updates Tested
The following features are not yet implemented:
- Shipment Creation API
- Label Purchase API
- Shipping Rate Retrieval API
- Automated Tracking Registration
- Return Labels
- Delivery Notifications
- Shipment Insurance
- In-App Shipping Dashboard
Project: Sustainable Trades Integration Type: Shippo OAuth + Order Sync Integration Backend Framework: Laravel Last Updated: June 2026
Developed and maintained by MD. Rahatul Rabbi.
#learnwithfair #rahtulrabbi #rahatul-rabbi #learn-with-fair