Android Mobile SDK: Notify Purchase Event

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.

 

This object represents the Shopping Cart model and includes the following properties:

Name Required Type Description
purchaseId Yes String Unique identifier of the purchase.
cartId Yes String Unique identifier of the cart from which the purchase originated.
totalQuantity Yes Int Total number of products in the purchase (including duplicates).
For example: if a cart contains 3 units of one product and 7 of another, totalQuantity will be 10.
totalPrice Yes BidDecimal Total amount of the purchase.
purchaseDate No Date Purchase date.
paymentMethod No String The payment method.
products Yes Product Basket Item Items in the purchase, including quantity and price.
source_name No String The source name, for additional context or details about the purchase channel.
source_type No String Name of the source where the purchase was made. Possible values: "marketplace", "digital-store", "point-of-sale", "third-party", and "other".

Organization of source values (source_type)

Below are explanations of each possible value for the purchase source (source_type):

Value Description Example
third-party Sales through distributors, retailers, or partner networks (not marketplaces). Wholesale, Distributors, Affiliates…
other Special cases or channels that do not fit into the other categories. Telemarketing, Trade fairs and events, Social commerce…
marketplace Third-party e-commerce platforms where you publish your products. Amazon Marketplace, eBay, Zalando…
digital-store Sales from the retailer’s own e-commerce website or app. Direct, Organic search, Paid search, Email Marketing…
point-of-sale In-store purchases processed via a POS system. In-store checkout, In-store kiosk, Pop-up stores…

 

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(),
        sourceName = "amazon",
        sourceType = "marketplace"
    )
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
    }
}

 

 

Congratulations!
You've reached the end of the lesson.

  

Do you still have unresolved questions?
Remember that our Connectif specialists are available to assist you. To contact them, simply open a support ticket by clicking on the blue "Help" button in your dashboard.


Keep Learning!

To fully unlock the potential of your Connectif account, we recommend continuing with the following articles: