Background
With Shopify and NextEngine's standard integration, orders are automatically transferred to NextEngine when they come in. However, when you add multiple locations (warehouses) to Shopify, this standard integration stops working.
This article explains the mechanism we built to maintain order integration even in multi-location environments.
Why Custom Implementation Is Needed
The reason standard integration becomes unavailable is that Shopify's NextEngine integration app is designed with a single location in mind.
Order placed
Stops working with multi-location
Order registration
Order placed
Works with multi-location
Order registration
How Order Transfer Works
Real-time Reception via Webhook
Shopify has a "Webhook" mechanism that can send notifications to external servers the moment an order is placed. This system receives these Webhooks and handles the transfer process to NextEngine.
Like standard integration, when a customer clicks the purchase button, order information reaches NextEngine in real-time.
Duplicate Order Prevention
Webhooks can sometimes send the same data multiple times due to temporary network issues. With standard integration, this duplicate handling is done internally, but with custom implementation, we need to handle it ourselves.
We assign a unique ID to each order and check whether it's already registered. Even if the same data is sent multiple times, it's only registered once.
Automatic Filtering of Special Orders
Not all orders should be transferred as-is. Orders with deferred payment or invoice payment require waiting for credit approval results before processing.
We implemented a feature to automatically identify these special payment method orders and exclude them from the normal flow.
Overall Data Flow
Receive data when order placed on Shopify
Verify signature to prevent spoofing
Exclude drafts and deferred payment orders
Check for processing/completed orders
Convert to 41-column CSV format
Send to NextEngine API
Record processing result
Processing Details
Signature Verification Mechanism
Webhook data sent from Shopify includes a "signature." This is generated using a pre-shared secret key.
By verifying this signature on the integration app side, spoofed data from third parties can be reliably rejected. Data with non-matching signatures is refused without processing.
Duplicate Prevention Logic
The processing flow when the same order is sent multiple times:
Check the received order number
Determine processing state
Filtering Conditions
Orders excluded from the normal flow:
| Condition | Detection Method | Reason |
|---|---|---|
| Draft order | draft flag | Unconfirmed orders not transferred |
| Deferred payment | "net30" tag | Individual handling after credit approval |
Data Items in CSV Conversion
NextEngine API upload requires a specific CSV format. Order data is converted to CSV format containing 41 items.
Order Information
- Store receipt number, order date, payment method, shipping method
Amount Information
- Product total, tax, shipping fee, handling fee, points, grand total
Customer Information
- Postal code, address, name, phone number, email address
Shipping Destination
- Postal code, address, name, phone number
Product Information
- Product name, product code, price, quantity, options
Other
- Gift flag, time slot specification, date specification, notes
Conversion Techniques
Timezone Conversion
Shopify times are recorded in UTC (Coordinated Universal Time). By automatically converting to Japan Standard Time (JST), the correct order datetime displays on the NextEngine side.
Address Concatenation
Shopify stores addresses separated into "prefecture," "city," and "street address." We combine these appropriately to match NextEngine's format.
Phone Number Normalization
Phone numbers entered by customers may contain hyphens or parentheses. These are removed and converted to a unified format.
Payment Method Mapping
Shopify payment names (e.g., "Credit Card," "Cash on Delivery") are converted to NextEngine's category codes. When new payment methods are added, only the mapping table needs updating.
Differences from Standard Integration
| Item | Standard Integration | This System |
|---|---|---|
| Multi-Location | × Doesn't work | ○ Works |
| Duplicate Prevention | Internal handling | Explicit implementation |
| Filtering | Limited | Customizable |
| Data Format | Fixed | Adjustable to requirements |
| Logs | Hard to check | Detailed recording |
Considerations
Orders Requiring Credit Approval
Deferred and invoice payment orders are excluded from automatic integration. These are processed manually after confirming credit approval results, or handled through a separate dedicated flow.
Network Outages
Temporary network outages may prevent Webhooks from arriving. For such cases, it's reassuring to have a separate mechanism that periodically reconciles with Shopify's order list.
Summary
In multi-location environments, standard integration becomes unavailable, but by utilizing Webhooks and NextEngine API, equivalent automatic integration can be achieved.
The benefit of custom implementation is the freedom to customize filtering conditions and data formats. This enables flexible integration tailored to business requirements.