Skip to main content

Magento Gift Card Ticket To iPaaS

Synchronize Magento gift card records to iPaaS transactions

Updated over 2 weeks ago

Overview

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

Mapping Collection Status

  • Mapping Status: Enabled.

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

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

  • Conflicting Mappings: This mapping applies only to GiftCard 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 Gift Card Ticket and its related child collections:

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

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

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

  • GiftCard Ticket Tax: Transfers GiftCard 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 GiftCard Tickets to their parent transactions via the ParentId field.

Setup Requirements

Magento Configuration

  • IncrementId: Must end with “-D”.

  • 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 GiftCard Ticket record with child records (Lines, Payments, and Taxes).

Mappings

GiftCard Ticket (Parent)

Filter

IncrementId.EndsWith("-GC")

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 - 3), "Transaction", SpaceportSystemId);

ParentId

Static

Ticket

Type

Lookup Translation

Status

Field

CustomerEmail

EmailAddress

Field

DiscountAmount

DiscountAmount

Field

TaxAmount

TaxAmount

Field

ShippingAmount

ShippingAmount

Dynamic Formula

GiftCardSoldTotal(Items)

Subtotal

Dynamic Formula

GiftCardSoldTotal(Items)

Total

Dynamic Formula

GiftCardSoldCount(Items)

TotalQty

Dynamic Formula

DateTimeOffsetFromLocalDateTime(CoalesceToDateTime(CreatedAt, "01/01/2000"))

TransactionCreatedDateTime

GiftCard Ticket Line To iPaaS (Child Collection)

Filter

ProductType == "giftvoucher"

Mapping Type

Source Field (Magento)

Destination Field (iPaaS)

Field

giftcardshippedtorecipient (custom field)

Giftcard Shippedto Recipient (custom field)

Field

giftcardnumber (custom field)

Giftcard Number (custom field)

Field

giftcardcustommessage (custom field)

Giftcard Message (custom field)

Dynamic Formula

var gcNumber = await GetSpaceportIdAsync(giftcardnumber, "Gift Card", SpaceportSystemId); (ProductType == "giftvoucher" ? return JSONToDictionary("{\"GiftCardId\":\"" + gcNumber + "\"}"); : return null;)

LineInfo

Dynamic Formula

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

Type

Static

Complete

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

Gift Card 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

GiftCardSoldTotal(Parent.Items)

Amount

Dynamic Formula

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

Status

GiftCard 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

GiftCardSoldTotal(Parent.Items)

Amount

Static

Captured

Status

GiftCard 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

M2 Transaction Status To iPaaS

Source Field (Magento)

Destination Field (iPaaS)

pending

Pending

processing

Pending

complete

Complete

canceled

Cancelled

completing

Complete

ready_for_completion

Pending

Error Handling

Collection: GiftCard 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: GiftCard 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

  • Resolution: Verify the payment method exists in the M2 Transaction Payment Method Lookup mapping.

Validation Rules & Testing

Validation Rules

  • Transaction number ends with “-GC”.

  • 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 “-GC” order: GiftCard 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?