registerPurchaseEvent method
Future<Map<String, dynamic> ?>
registerPurchaseEvent({
- required String cliUbid,
- required int sales,
- required String orderId,
- required List<
Product> products, - TrackingParams? trackingParams,
override
Registers a purchase event.
Parameters:
cliUbid: The unique client ID for the user.sales: The total sales amount of the purchase.orderId: The ID of the order being purchased.products: A list of products purchased.trackingParams: Additional parameters for the event (optional).
Returns: A Future that resolves to a Map<String, dynamic>?, indicating the result of registering the "purchase" event.
Example:
var response = await RegisterEvent.registerPurchaseEvent(
cliUbid: "dfbfee0554bf1de6dfe801dc32d91ab9f15c534ee396a00e7fcbc5930769d109",
sales: 100,
orderId: "11082669",
products: [
Product(
skuId: "2777510___Astore___Anet",
price: "50",
product_quantities: "1",
merchantId: "whitakers",
),
Product(
skuId: "2777503___Astore___Anet",
price: "50",
product_quantities: "2",
merchantId: "whitakers",
),
],
trackingParams: {"store_id": "1", "source": "online"},
);
Implementation
@override
Future<Map<String, dynamic>?> registerPurchaseEvent({
required String cliUbid,
required int sales,
required String orderId,
required List<Product> products,
TrackingParams? trackingParams,
}) async {
final result = await MethodHandler.invokeNativeMethod(
'registerPurchaseEvent',
arguments: {
'cliUbid': cliUbid,
'sales': sales,
'orderId': orderId,
'products': products.map((product) => product.toMap()).toList(),
'trackingParams': convertTrackingParamsToMap(trackingParams) ?? {},
});
return Map<String, dynamic>.from(result ?? {});
}