Skip to main content

Magento Invoice from iPaaS

Transfer invoices from iPaaS to Magento

Updated over 2 weeks ago

Overview

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

Mapping Collection Status

  • Mapping Status: Enabled.

  • Trigger Events: The sync is triggered by the creation or update of an invoice iPaaS.

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

  • Conflicting Mappings: This mapping applies only to Invoice. 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 Invoice and its related child collections:

  • Invoice Line: Maps individual product line items.

System Caveats

Magento Caveats

  • Automatically creates or updates invoices linked to the original order.

  • Supports customer notification and visibility of invoice comments.

  • Allows automatic capture for authorized payments if configured.

iPaaS.com Caveats

  • Sends invoice data with structured metadata (capture, notify, comment, and visibility flags).

  • Determines whether to create a new invoice or update an existing one through IsInvoiceUpdate.

Setup Requirements

Magento Configuration

  • OriginalOrderId: Must correspond to a valid Magento order.

  • Invoice Entity: Must exist when updating; otherwise, iPaaS triggers creation.

  • Comment Fields: Must align with Magento’s order comment visibility and notification fields.

iPaaS.com Configuration

  • Type: Must be explicitly set to "Invoice".

  • Qty: Specifies the number of units invoiced per line item.

  • TransactionLineEntityId: Used for unique identification of invoice lines.

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 == "Invoice" is identified.

  2. Determine Invoice Operation:

  3. If IsInvoiceUpdate == true, the mapping updates an existing Magento invoice. Otherwise, a new invoice record is created.

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

  5. Apply Comments: Insert or update invoice comments with visibility and notification preferences.

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

Mappings

Parent Collection: Magento Invoice From iPaaS

Mapping Filter:

Type == "Invoice"

Mapping Type

Source (iPaaS.com)

Destination (Magento)

Description

Dynamic Formula

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

IsInvoiceUpdate

This mapping determines whether the transaction should be treated as an invoice. If the isInvoiceUpdate field is not explicitly set, it defaults to true, meaning the transaction is considered an invoice by default.

Dynamic Formula

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

Capture

This field indicates whether to capture invoices; if true, the invoice will be captured.

Dynamic Formula

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

Notify

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

Dynamic Formula

return GetCustomFieldValue(CustomFields, "Adobe Commerce Order Id");

OriginalOrderId

This mapping contains the original Magento order ID for which the invoice will be created. This field is mandatory and must be provided.

Dynamic Formula

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

AppendComment

This mapping links the appendComment field to the invoice. If it is set to true, the comment will be appended.

Dynamic Formula

var commentValue = GetCustomFieldValue(CustomFields, "Comment Value"); if(commentValue != null) { return commentValue; } return "Order invoiced by iPaaS.com";

Comment_Value

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

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

Dynamic Formula

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

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 commentValue = GetCustomFieldValue(CustomFields, "Order Comment Value"); if(commentValue != null) { return commentValue; } return "Order invoiced by iPaaS.com";

Order_Comment_Value

This mapping assigns the comment that will be appended to the original order’s comment section. 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 null;

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: Due to a defect in the Magento API, it is currently not possible to set custom order statuses with the "processing" state, even though the UI allows it. Custom statuses with the "processing" state should not be used in this mapping until the API issue is resolved.

Magento Invoice Line items From iPaaS (Child Collection)

Mapping Type

Source (iPaaS.com)

Destination (Magento)

Dynamic Formula

var orderId = GetCustomFieldValue(Parent.CustomFields,"Adobe Commerce Order Id"); if(orderId != null) { var iPaaSTransactionId = await GetSpaceportIdAsync(orderId, "Transaction", SpaceportSystemId); if(iPaaSTransactionId != null) { return await GetLineItemIdByOrderIdSku(orderId,Sku,iPaaSTransactionId.ToString(),"SellingUnit"); } } return null;

ParentItemId

Field

Qty

OrderQty

Dynamic Formula

var orderId = GetCustomFieldValue(Parent.CustomFields,"Adobe Commerce Order Id"); if(orderId != null) { var iPaaSTransactionId = await GetSpaceportIdAsync(orderId, "Transaction", SpaceportSystemId); if(iPaaSTransactionId != null) { return await GetFormattedSku(Sku, iPaaSTransactionId.ToString(), "SellingUnit"); } } return Sku;

Sku

Dynamic Formula

var transactionLineExternalId = await GetExternalIdAsync(Id, "Transaction Line", SpaceportSystemId); var externalId = 0; if(transactionLineExternalId != null) { var externalIdSplit = transactionLineExternalId.ToString().Split("|").length > 1 ? transactionLineExternalId.ToString().Split("|")[1] : transactionLineExternalId.ToString().Split("|")[0]; externalId = Int32.Parse(externalIdSplit); } return externalId;

InvoiceItemEntityId

Error Handling

Collection: Invoice (Parent)

Missing OriginalOrderId

  • Description: The parent order reference is not provided or invalid.

  • Resolution: Ensure that OriginalOrderId corresponds to an existing Magento order.

Invalid Comment Visibility Flag

  • Description: Comment visibility flag contains a non-boolean value.

  • Resolution: Validate comment visibility fields as true/false.

Collection: Invoice Line Items (Child)

Missing SKU or Parent Reference

  • Resolution: Verify that SKU and ParentItemId fields are correctly mapped in the iPaaS payload.

Invalid Quantity

  • Resolution: Ensure that Qty is numeric and greater than zero for all invoice lines.

Validation Rules & Testing

Validation Checklist

  • Type is set to "Invoice".

  • OriginalOrderId correctly references a valid order in Magento.

  • Invoice update/create operation correctly determined by IsInvoiceUpdate.

  • All comments, notifications, and captures configured as per business rules.

  • Line-level data (Qty, Sku) mapped successfully.

Test Scenarios

  1. Create New Invoice: Send transaction with IsInvoiceUpdate = false: A new invoice should be created in Magento.

  2. Update Existing Invoice: Send transaction with IsInvoiceUpdate = true: Existing invoice is updated.

  3. Invoice with Comment: Send invoice with Comment_Value and Comment_Is_Visible_On_Front = true: Comment should appear in customer portal.

  4. Invalid Order Reference: Send transaction with incorrect OriginalOrderId: Mapping should fail validation.

Additional Notes

  • The Capture field determines whether the invoice will automatically capture funds for payment transactions.

Did this answer your question?