Order Integration

Order data transfer from Webhook to NextEngine in multi-location environments

Order IntegrationWebhookNextEngineMulti-LocationCSV Conversion
5 min read

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.

Standard Integration (Single Location)
Shopify

Order placed

NextEngine Integration App

Stops working with multi-location

NextEngine

Order registration

This System (Multi-Location Compatible)
Shopify

Order placed

Webhook
This App

Works with multi-location

API
NextEngine

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

Order Processing Flow
Webhook Received

Receive data when order placed on Shopify

Signature Verification

Verify signature to prevent spoofing

Order Validation

Exclude drafts and deferred payment orders

Duplicate Check

Check for processing/completed orders

CSV Conversion

Convert to 41-column CSV format

API Upload

Send to NextEngine API

Log Recording

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:

Duplicate Detection Flow
Search by Order Number

Check the received order number

Check Status

Determine processing state

Processing exists
Skip (wait for completion)
Completed exists
Skip (prevent double registration)
Not found
Start new processing

Filtering Conditions

Orders excluded from the normal flow:

Draft order
Detection Methoddraft flag
ReasonUnconfirmed orders not transferred
Deferred payment
Detection Method"net30" tag
ReasonIndividual 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

Multi-Location
Standard Integration× Doesn't work
This System○ Works
Duplicate Prevention
Standard IntegrationInternal handling
This SystemExplicit implementation
Filtering
Standard IntegrationLimited
This SystemCustomizable
Data Format
Standard IntegrationFixed
This SystemAdjustable to requirements
Logs
Standard IntegrationHard to check
This SystemDetailed 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.

Related Topics