ExchangeOrderEvent

Package 

1com.salesforce.marketingcloud.sfmcsdk.components.events

Description 

An E-commerce event to manage details of exchanging an order. This class is part of the Salesforce Marketing Cloud Unified SDK and is used to track order exchange activities in your Android application.

Platform 

  • Target: androidJvm
  • SDK Version: 11.0.0 (also available in 10.0.0)
  • SFMC SDK: v3.1.0

Class Declaration 

1class ExchangeOrderEvent : OrderEvent

Inheritance Hierarchy 

1Event (abstract)
2  └── EngagementEvent (sealed)
3      └── OrderEvent (sealed)
4          └── ExchangeOrderEvent

Constructor 

Based on the OrderEvent pattern, the constructor accepts:

1ExchangeOrderEvent(order: Order)

Parameters 

  • order: Order - An Order object containing the details of the order being exchanged

Properties 

Inherited from OrderEvent 

order 

1val order: Order

Contains order information associated with the event.

Inherited from EngagementEvent 

category 

1open override var category: Event.Category

The Event category Name. Category contains list of allowed values.

priority 

1open override val priority: Priority

Priority level for the event.

Inherited from Event 

id 

1@JvmField
2val id: String

Event identifier.

producer 

1val producer: Event.Producer

The Event Producer Name. Producer contains list of allowed values.

Methods 

Inherited from EngagementEvent 

name() 

1open override fun name(): String

Returns the name for the event. This value must match the Event Name used when creating the event in the Marketing Cloud UI for tracking functionality.

Returns: Event name as a String

attributes() 

1open override fun attributes(): Map<String, Any>

The Event attributes for this event.

Returns: A map of attribute names to values

Inherited from Event 

track() 

1fun track(): void

Method to track this Event via EventManager to subscriber EventSubscriber.

toJson() 

1fun toJson(): JSONObject

Converts the event to JSON format.

Returns: JSONObject representation of the event

Related Classes 

Order Data Class 

1@JvmOverloads
2constructor(
3    id: String,
4    lineItems: List<LineItem> = listOf(),
5    totalValue: Double? = null,
6    currency: String? = null,
7    attributes: Map<String, Any> = mapOf()
8)

Properties 

  • id: String (required) - A unique identifier representing the order
  • lineItems: List<LineItem> (default: empty list) - A list of Line Item Data values
  • totalValue: Double? (default: null) - The total value of the order
  • currency: String? (default: null) - The currency of the total value for the order
  • attributes: Map<String, Any> (default: empty map) - A map of user-supplied values

LineItem Data Class 

1@JvmOverloads
2constructor(
3    catalogObjectType: String,
4    catalogObjectId: String,
5    quantity: Int,
6    price: Double? = null,
7    currency: String? = null,
8    attributes: Map<String, Any> = mapOf()
9)

Properties 

  • catalogObjectType: String (required) - A type name representing the catalog object referenced in the line item
  • catalogObjectId: String (required) - A unique identifier representing the catalog object referenced in the line item
  • quantity: Int (required) - The number of catalog objects in this line item
  • price: Double? (optional) - The price of the catalog object referenced in the line item
  • currency: String? (optional) - The currency for the price field
  • attributes: Map<String, Any> (default: empty map) - A map of user-supplied values

Enum Values 

Event.Category 

List of possible Category values for sending Events:

  • APPLICATION
  • ENGAGEMENT
  • IDENTITY
  • SYSTEM
  • BILLING
  • CUSTOM

Event.Producer 

List of possible Producer values for sending Events:

  • CUSTOMER_APP - Represents events from the customer’s application
  • UNIFIED_SDK - Represents events from the unified SDK
  • MCE_MODULE - Represents events from the MCE module
  • DC_MODULE - Represents events from the DC module
  • MAM_MODULE - Represents events from the MAM module
  • PUSH_FEATURE_MODULE - Represents events from the push feature module
  • IAM_FEATURE_MODULE - Represents events from the in-app messaging feature module

Sibling Classes 

Other OrderEvent subclasses for tracking different order lifecycle events:

  • PurchaseOrderEvent - An E-commerce event for when a user makes a purchase
  • PreorderEvent - An E-commerce event for when a user places a preorder
  • CancelOrderEvent - An E-commerce event for when a user cancels an order
  • ShipOrderEvent - An E-commerce event to manage details of an order shipment
  • DeliverOrderEvent - An E-commerce event to manage details of an order delivery
  • ReturnOrderEvent - An E-commerce event to manage details of returning an order

Usage Example 

1// Create line items for the exchange
2val lineItem = LineItem(
3    catalogObjectType = "product",
4    catalogObjectId = "PROD-12345",
5    quantity = 2,
6    price = 49.99,
7    currency = "USD",
8    attributes = mapOf("color" to "blue", "size" to "M")
9)
10
11// Create an order object
12val order = Order(
13    id = "ORDER-98765",
14    lineItems = listOf(lineItem),
15    totalValue = 99.98,
16    currency = "USD",
17    attributes = mapOf("reason" to "size_exchange")
18)
19
20// Create and track the exchange event
21val exchangeEvent = ExchangeOrderEvent(order)
22exchangeEvent.track()

Notes 

  • This is a concrete implementation of the sealed class OrderEvent
  • The @JvmOverloads annotation on Order and LineItem constructors provides Java interoperability with multiple constructor overloads
  • The event name must match the Event Name configured in the Marketing Cloud UI for proper tracking
  • Use the track() method to send the event to the Marketing Cloud SDK for processing