The “Notify Purchase Event” is used to describe a purchase made by the customer. It sends a notification via Mobile SDK when a user completes a purchase using the sendPurchase method.
How to Use
The purchase information notification uses the Connectif.sendPurchase(purchase: Purchase) method, where you add the purchase property containing all the purchase details.
Notify Purchase Information
This object represents the Shopping Cart model and includes the following properties:
Name | Required | Type | Description |
---|---|---|---|
purchaseId | Yes | String | Unique identifier for the purchase. |
cartId | No | String | Unique identifier of the cart from which this purchase originated. |
totalQuantity | Yes | Int | Total number of products in the purchase (including duplicates). For example: if a cart has 3 units of one product and 7 units of another, totalQuantity will be 10. |
totalPrice | Yes | BigDecimal | Total price of the purchase. |
purchaseDate | No | Date | Date of the purchase. |
paymentMethod | No | String | Payment method. |
products | Yes | Product Basket Item | Items in the purchase, including the quantity and price of each. |
This type of event automatically collects the following information:
- Operating system: Android or iOS.
- App version.
- Operating system version.
- Connectif SDK version.
Example
The notification will look like this:
val purchase = Purchase( purchaseId = "purchase-e3418b5a-8709-4593-a7c8-d8a7f12df737", products = listOf( ProductBasketItem( productDetailUrl = "https://example.com/product/12345", productId = "59a31949a1a562d4979fbca2", name = "Example Product", unitPrice = BigDecimal("51.88"), description = "This is an example product", imageUrl = "https://example.com/product/images/12345.jpg", categories = listOf("Electronics", "Gadgets"), tags = listOf("Trending", "New Arrival"), brand = "ExampleBrand", reviewCount = 150, rating = BigDecimal("4.5"), ratingCount = 124, thumbnailUrl = "https://example.com/product/thumbnails/12345.jpg", unitPriceOriginal = BigDecimal("120.00"), unitPriceWithoutVAT = BigDecimal("80.00"), discountedAmount = BigDecimal("20.00"), discountedPercentage = BigDecimal("16.67"), publishedAt = Date(), customField1 = "Special Edition", customField2 = "Limited Stock", customField3 = "Online Only", price = BigDecimal("51.88"), quantity = 1 ) ), totalQuantity = 1, totalPrice = BigDecimal("51.88"), cartId = "cart-0098caf9-42f4-44e9-afdd-45eafe892293", paymentMethod = "Credit Card", purchaseDate = Date() ) Connectif.sendPurchase(purchase)
Callbacks (Optional)
If you want feedback on potential errors when sending events, you can add an EventCallbacks when using our method.
object : EventCallbacks { override fun onSuccess() { //Handle success } override fun onError(message: String?) { //Handle error } }
Keep Learning!
To fully unlock the potential of your Connectif account, we recommend continuing with the following articles:
- Android SDK Get Started, to add Connectif Mobile SDK to your Android project.
- Firebase Cloud Messaging Setup, to enable push sending and receiving via the Android Mobile SDK.
- iOS SDK Get Started, to add Connectif Mobile SDK to your iOS project.
- Apple Push Notifications Service Setup, to enable push sending and receiving via the iOS Mobile SDK.