Skip to main content

Magento Deposit Ticket To iPaaS

Synchronize Magento Deposit Tickets to iPaaS

Updated over 2 weeks ago

Overview

This document outlines the configuration for automatically synchronizing Deposit Ticket records from the Magento Deposit Ticket entity to the iPaaS Transaction entity. The integration uses an API-based sync that triggers whenever a Deposit Ticket record is created in Magento.

Mapping Collection Status

  • Mapping Status: Enabled.

  • Trigger Events: The sync is triggered by the creation of Deposit Tickets in Magento.

  • ID Format: When manually syncing, the Deposit Ticket ID from iPaaS is used. This can be resolved via an external ID.

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

  • Deposit Ticket Line: Transfers Deposit Ticket line items details.

  • Deposit Payment Line: Transfers Deposit Ticket Payment details.

  • Deposit Ticket Payment - Gift Card: Transfers Deposit Ticket Payment- Gift Card details.

  • Deposit Ticket Tax: Transfers Deposit Ticket Tax details.

System Caveats

Magento Caveats

  • Generates deposit orders ending in “-D”.

  • Excludes gift card (“-GC”) and fraudulent orders.

  • Provides all necessary totals and order details for deposit synchronization.

iPaaS Caveats

  • Receives deposit records with all associated child records (Lines, Payments, Taxes).

  • Sets the deposit record status to Pending by default.

  • Links deposit tickets to their parent transactions via the ParentId field.

Setup Requirements

Magento Configuration

  • IncrementId: Must end with “-D” for deposit.

  • Status: Orders marked as “suspected_fraud” or “fraud” are excluded.

  • Subtotal, TaxAmount, ShippingAmount, DiscountAmount: Required for total calculation.

iPaaS Configuration

  • SystemId: Derived using SpaceportSystemId.

  • ParentId: Retrieved dynamically through lookup for transaction association.

  • Transaction Type: Always set as “Ticket”.

  • Status: Defaults to “Pending” at creation

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. Retrieve Data: Fetch orders from Magento matching the filter conditions.

  2. Apply Filter: Only deposit transactions (IncrementId.EndsWith("-D")) are processed.

  3. Map Fields: Populate fields such as TransactionNumber, Subtotal, Total, and Tax.

  4. Resolve Parent Reference: Fetch related parent transaction via GetSpaceportParentTransactionIdAsync.

  5. Send to iPaaS: Create deposit ticket record with child records (Lines, Payments, and Taxes).

Mappings

Deposit Ticket (Parent)

Filter

IncrementId.EndsWith("-D") && !IncrementId.EndsWith("-GC") && !(Status == "suspected_fraud") && !(Status == "fraud")

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Field

EntityId

Mage Entity ID (custom field)

Dynamic Formula

SpaceportSystemId

SystemId

Field

IncrementId

TransactionNumber

Dynamic Formula

return await GetSpaceportIdAsync(EntityId.Substring(0, EntityId.Length - 2), "Transaction", SpaceportSystemId);

ParentId

Static

Ticket

Type

Static

Pending

Status

Field

CustomerEmail

EmailAddress

Field

DiscountAmount

DiscountAmount

Field

TaxAmount

TaxAmount

Field

ShippingAmount

ShippingAmount

Dynamic Formula

Subtotal - GiftCardSoldTotal(Items)

Subtotal

Dynamic Formula

Subtotal + TaxAmount + ShippingAmount + DiscountAmount - GiftCardSoldTotal(Items)

Total

Dynamic Formula

ProductSoldCount(Items)

TotalQty

Dynamic Formula

DateTimeOffsetFromLocalDateTime(CoalesceToDateTime(CreatedAt))

TransactionCreatedDateTime

Deposit Ticket Line To iPaaS (Child Collection)

Filter

IsEmpty(ParentItemId) && ProductType != "giftvoucher"

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Field

SellUnit

SellingUnit (custom field)

Dynamic Formula

(ProductType == "giftvoucher" ? "Gift Card" : "Product")

Type

Static

Pending

Status

Dynamic Formula

SkuFromOrderLine(Sku.Replace("/", "-"))

Sku

Field

Description

Description

Field

QtyOrdered

Qty

Dynamic Formula

Price - (DiscountAmount / QtyOrdered.Value)

UnitPrice

Field

RowTotal

ExtendedPrice

Field

OriginalPrice

OriginalUnitPrice

Field

DiscountAmount

DiscountAmount

Field

DiscountPercent

DiscountPercent

Field

TaxPercent

TaxPercent

Field

Weight

Weight

Deposit Ticket Payment To iPaaS (Child Collection)

Filter

Method != "giftcard"

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Lookup Translation

Method

Field

Method

Description

Dynamic Formula

(Parent.Status == "pending" ? (ConvertToDecimal(AmountOrdered)-GiftCardSoldTotal(Parent.Items)) : (ConvertToDecimal(AmountPaid)-GiftCardSoldTotal(Parent.Items)))

Amount

Dynamic Formula

(CoalesceToDecimal(BaseAmountPaid,0) > 0 ? "Complete" : "Authorized")

Status

Deposit Ticket Payment To iPaaS -Gift Card (Child Collection)

Filter

Method=="giftcard"

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Field

authcode (custom field)

AuthCode (custom field)

Field

giftcardnumber (custom field)

Giftcard Number (custom field)

Dynamic Formula

var gcNumber = await iPaaSGiftCardIdAsync(giftcardnumber); return JSONToDictionary("{\"GiftCardId\":\"" + gcNumber + "\"}");

MethodInfo

Lookup Translation

Method

Field

Method

Description

Dynamic Formula

(Parent.Status == "pending" ? (ConvertToDecimal(AmountOrdered)-GiftCardSoldTotal(Parent.Items)) : (ConvertToDecimal(AmountPaid)-GiftCardSoldTotal(Parent.Items)))

Amount

Static

Complete

Status

Deposit Ticket Tax To iPaaS -Gift Card (Child Collection)

Filter

Method=="giftcard"

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Dynamic Formula

(Parent.ExtensionAttributes != null && Parent.ExtensionAttributes.AppliedTaxes != null && Parent.ExtensionAttributes.AppliedTaxes.Count > 0 ? Parent.ExtensionAttributes.AppliedTaxes[0].Title : "Avalara")

Authority

Dynamic Formula

Parent.TaxAmount

Amount

Lookup Translations

M2 Transaction Payment Method To iPaaS

Source Field (Magento)

Destination Field (iPaaS)

authnetcim

CASH

authorizenet

CASH

braintree

CASH

checkmo

CASH

paypal_express

CASH

purchaseorder

CASH

giftcard

GC

Error Handling

Collection: Deposit Ticket (Parent)

Missing Parent Reference

  • Description: Unable to resolve parent transaction ID.

  • Resolution: Ensure parent transaction exists in iPaaS.

Invalid Amount Calculation

  • Description: One or more financial fields contain invalid data types.

  • Resolution: Validate numeric values in Subtotal, Tax, and Discount fields.

Collection: Deposit Ticket Line (Child)

Missing SKU or Product Type

  • Resolution: Ensure all line items contain valid SKU and product type fields.

Collection: Payment (Child)

Payment Method Lookup Failure

Validation Rules & Testing

Validation Rules

  • Transaction number ends with “-D”.

  • Fraudulent and gift card orders excluded.

  • All totals (Subtotal, Tax, Shipping, Discount) correctly computed.

  • Payment and line details correctly linked to parent ticket.

Test Scenarios

  1. Create a valid “-D” order: Deposit record should appear in iPaaS.

  2. Send order with “-GC”: Skipped by filter.

  3. Include invalid totals: Mapping should throw validation error.

  4. Send payment with gift card: Routed to Gift Card Payment child mapping

Additional Notes

  • All child records (Line, Payment, Tax) must reference a valid parent via ParentId.

Did this answer your question?