Skip to main content

Magento Order from iPaaS

Transfer Magento orders from iPaaS

Updated over 2 weeks ago

Overview

Magento Order can be transferred from iPaaS.com using an Update sync method. This mapping supports the automated synchronization of Order records from iPaaS into Magento via the Order API (Transactions).

Mapping Collection Status

  • Mapping Status: Enabled.

  • Trigger Events: The sync is triggered by the update of Order in iPaaS.

  • ID Format: When manually syncing, the Transaction ID from iPaaS is used.

  • Conflicting Mappings: This mapping applies only to Order. Ensure no other mappings target the same Magento entity to prevent data from being overwritten.

Supported Child Collections

The integration supports the synchronization of the parent Order and its related child collections:

  • Order Line: Maps individual product line items.

  • Shipment Track: Maps shipments.

System Caveats

Magento

  • Updates are applied only to existing orders identified by their EntityId.

  • Order financial totals are not recalculated from iPaaS; these values are managed internally by Magento.

  • Comments and visibility settings are applied directly to order history.

iPaaS.com

  • Ensures valid order references through EntityId resolution before update.

Setup Requirements

Magento Configuration

  • Orders must already exist in Magento before updates are processed.

  • Status values sent from iPaaS must correspond to valid Magento order statuses.

iPaaS.com Configuration

  • Must provide EntityId for the order being update

Authentication & Security

  • Magento2 API UserName: Used to access iPaaS API for fetching Company and related data.

  • Magento2 API Key: Used to access iPaaS API for fetching Company and related data

Integration Flow

  1. Trigger & Retrieve Data: iPaaS triggers the mapping when a transaction with Type == "Order" is identified.

  2. Determine Order Operation:

  3. If IsOrderUpdate == true, the mapping updates an existing Magento Order.

  4. Otherwise, a new Order record is created.

  5. Set Financial Flags: Configure Capture and Notify options dynamically.

  6. Apply Comments: Insert or update Order comments with visibility and notification preferences.

  7. Sync Line Items: For each Order item, map quantities, SKUs, and unique identifiers to Magento.

Mappings

Parent Collection: Order Update From iPaaS

Mapping Filter

var orderType = Type == "Order" ? true : false;
var hasOrder = true;
var transactionExternalId = await GetExternalIdAsync(Id, "Transaction", SpaceportSystemId);
if(transactionExternalId != null){
hasOrder = true;
}
if(orderType && hasOrder) {
return true;
}
else {
return false; }

Description:

The fields GrandTotal, Shipping Amount, SubTotal, and TotalQtyOrdered will not be honored during an order update from iPaaS. If incorrect values are populated in these fields, it may lead to issues with the order.

Mapping Type

Source (iPaaS.com)

Destination (Magento)

Description

Dynamic Formula

DiscountAmount

DiscountAmount

Dynamic Formula

var transactionExternalId = await GetExternalIdAsync(Id, "Transaction", SpaceportSystemId); return transactionExternalId;

EntityId

It retrieves the external ID of the created transaction and returns the sales order ID associated with that transaction, which we had previously saved as the external ID.

Dynamic Formula

var orderStatus = "pending"; if(Status == "Pending") { orderStatus = "processing"; } if(Status == "Complete") { orderStatus = "complete"; } if(Status == "Cancelled") { orderStatus = "canceled"; } return orderStatus;

Status

The code snippet defines a variable orderStatus with a default value of "pending". It then checks the value of the Status variable and updates orderStatus based on specific conditions. If Status is "Pending", orderStatus is set to "processing". If Status is "Complete", it changes to "complete", and if Status is "Cancelled", it becomes "canceled". Finally, the function returns the updated value of orderStatus.

Dynamic Formula

TaxAmount

TaxAmount

Dynamic Formula

var orderStatusComment = GetCustomFieldValue(CustomFields, "Order Status Comment"); if(orderStatusComment != null){ return orderStatusComment; } return null;

Comment_Value

This mapping assigns a comment that will be appended to the original order’s comment section to provide order details. Note: If the comment value is null, no comment will be added to the order.

Dynamic Formula

var orderCommentIsVisible = GetCustomFieldValue(CustomFields, "Order Comment Is Visible"); if(orderCommentIsVisible != null){ return orderCommentIsVisible; } return null;

Comment_Is_Visible_On_Front

This mapping assigns the value that controls whether the comment is shown on the front end for the original order. If it is true, the comment will be displayed; otherwise, it will not be shown.

Shipment Track From iPaaS (Child Collection)

Filter

var orderType = Type == "Order" ? true : false;
var hasOrder = true;
var transactionExternalId = await GetExternalIdAsync(Id, "Transaction", SpaceportSystemId);
if(transactionExternalId != null){
hasOrder = true;
}
if(orderType && hasOrder) {
return true;
}
else {
return false; }

Description

If the ShipmentItems mapping is not provided, the tracking process will assume all items should be shipped. To ship the entire order without specifying individual items, simply remove the ShipmentItems mapping and any associated filters.

Configuring Shipment Items

You can specify shipment item values using preset settings:

  • Shipment Items Field Separator – defines how individual field values (e.g., SKU and quantity) are separated within a record.

  • Shipment Items Record Delimiter – defines how multiple shipment item records are separated.

Example Configuration:

  • Shipment Items Record Delimiter: ,

  • Shipment Items Field Separator: |

  • Format: {Sku1}|{Quantity1},{Sku2|{Quantity2}

  • Example: DEMO1234|3,TEST5678|2

Mapping Type

Source (iPaaS.com)

Destination (Magento)

Description

Field

return await GetOrderIdByOrderNumber(Parent.TransactionNumber);

OrderId

The statement asynchronously calls the function GetOrderIdByOrderNumber, passing in the TransactionNumber from the Parent object as an argument. It waits for the function to return a result, which is expected to be the corresponding order ID, and then returns that value. This ensures the calling process receives the correct order ID that matches the given transaction number.

Field

TrackingNumber

TrackingNumber

Dynamic Formula

ShippingMethodDescription

Title

Dynamic Formula

return ShippingMethod.ToLower();

CarrierCode

Magento Adobe Commerce allows the following tracking carrier codes: custom, fedex, dhl, ups, and usps.

Dynamic Formula

var commentValue = GetCustomFieldValue(CustomFields, "Comment Value"); if(commentValue != null) { return commentValue; } return null;

Comment_Value

This mapping assigns the comment that will be appended to the shipment.

Note: If the comment value is null, no comment will be added to the shipment.

Dynamic Formula

var isVisible = GetCustomFieldValue(CustomFields, "Comment Is Visible On Front"); if(isVisible != null) { return isVisible; } return 1;

Comment_Is_Visible_On_Front

This mapping assigns the value to control whether the comment is shown on the front end. If it is true, the comment will be displayed; otherwise, it will not be shown.

Dynamic Formula

var notify = GetCustomFieldValue(CustomFields, "Notify"); if(notify != null) { return notify; } return true;

Notify

This field indicates whether to notify the customer about shipments. If set to true, an email will be sent to the customer when the shipment is captured.

Dynamic Formula

var orderId = await GetOrderIdByOrderNumber(Parent.TransactionNumber); if(orderId == null) { orderId = await GetExternalIdAsync(Parent.Id, "Transaction", SpaceportSystemId); } var shipmentItems = GetCustomFieldValue(CustomFields, "Shipment Items"); if(shipmentItems != null && orderId != null) { return await GetLineItemIdByOrderSku(orderId,shipmentItems,Parent.Id.ToString(),"SellingUnit"); } return null;

ShipmentItems

If the ShipmentItems mapping is not provided, the tracking process will assume all items should be shipped. To ship the entire order without specifying individual items, simply remove the ShipmentItems mapping and any associated filters. Configuring Shipment Items: You can specify shipment item values using preset settings: Shipment Items Field Separator – defines how individual field values (e.g., SKU and quantity) are separated within a record. Shipment Items Record Delimiter – defines how multiple shipment item records are separated. Example Configuration: Shipment Items Record Delimiter: , Shipment Items Field Separator: | Format: {Sku1}|{Quantity1},{Sku2}|{Quantity2} Example: DEMO1234|3,TEST5678|2

Dynamic Formula

var sourceToShipFrom = GetCustomFieldValue(CustomFields, "Source To Ship From"); if(sourceToShipFrom != null) { return sourceToShipFrom; } return "MAIN";

Atrributes_SourceCode

This value represents a "source to ship" location, which may be defined in a custom field. The corresponding code for each "source to ship" location can be found in Magento under Stores → Inventory → Sources.

Dynamic Formula

var commentValue = GetCustomFieldValue(CustomFields, "Order Comment Value"); if(commentValue != null) { return commentValue; } return "Shipment Created";

Order_Comment_Value

This mapping assigns a comment that will be appended to the original order’s comment section to provide shipment details. Note: If the comment value is null, no comment will be added to the order.

Dynamic Formula

var commentIsVisible = GetCustomFieldValue(CustomFields, "Order Comment Is Visible"); if(commentIsVisible != null) { return commentIsVisible; } return 1;

Order_Comment_Is_Visible_On_Front

This mapping assigns the value that controls whether the comment is shown on the front end for the original order. If it is true, the comment will be displayed; otherwise, it will not be shown.

Dynamic Formula

var commentIsNotified = GetCustomFieldValue(CustomFields, "Order Comment Is Notified"); if(commentIsNotified != null) { return commentIsNotified; } return null;

Order_Comment_Is_Customer_Notified

This field indicates whether to notify the customer when an invoice has been added to the order. If set to true, an email will be sent to the customer when the invoice is captured for that order.

Dynamic Formula

var commentStatus = GetCustomFieldValue(CustomFields, "Order Comment Status"); if(commentStatus != null) { return commentStatus; } return null;

Order_Comment_Status

This mapping assigns the order status, which can be a custom status defined in Magento, such as "Complete," "Cancelled," or "Processing." Note: A defect in the Magento API does not allow setting custom order statuses with the "processing" state, despite the UI offering the same ability. Custom statuses should not be provided to this mapping until the API is corrected.

Magento Transaction Line From iPaaS (Child Collection)

Mapping Type

Source (iPaaS.com)

Destination (Magento)

Field

DiscountAmount

DiscountAmount

Field

DiscountPercent

DiscountPercent

Dynamic Formula

OriginalUnitPrice

OriginalPrice

Dynamic Formula

Qty

QtyOrdered

Field

ExtendedPrice

RowTotal

Dynamic Formula

var unit = GetCustomFieldValue(CustomFields, "SellingUnit"); if(unit != null) { return Sku+"^"+unit; } return Sku;

Sku

Field

EstimatedTaxAmount

TaxAmount

Field

TaxPercent

TaxPercent

Field

Weight

Weight

Error Handling

Collection: Order (Parent)

Invalid or Missing EntityId

  • Resolution: Ensure EntityId correctly references an existing Magento order.

Invalid Financial Field Update

  • Resolution: Exclude GrandTotal, SubTotal, Shipping Amount, and TotalQtyOrdered fields from updates.

Collection: Shipment Track (Child)

Missing Order Reference

  • Resolution: Ensure OrderId is resolved successfully before shipment creation.

Invalid Carrier Code

  • Resolution: Validate the shipping method’s mapping to Magento’s carrier codes.

Validation Rules & Testing

Validation Checklist

  • Orders exist in Magento before updates.

  • EntityId is correctly resolved.

  • Shipment track and transaction lines are properly linked.

  • Comments and visibility flags align with customer communication rules.

Test Scenarios

  1. Update Order Status: Send an order update to change the order status: Verify status updated in Magento.

  2. Add Comment: Send order update with a new comment: Confirm comment appears in order history.

  3. Create Shipment with Tracking: Send shipment data with tracking number: Verify tracking details appear in Magento.

  4. Invalid Carrier Mapping: Send shipment with unrecognized shipping method: Expect “Invalid Carrier Code” error.

Additional Notes

Partial updates are supported: Only mapped fields will be updated, and all others remain unchanged.

Did this answer your question?