logPurchase

abstract fun logPurchase(productId: String?, currencyCode: String?, price: BigDecimal?)
abstract fun logPurchase(productId: String?, currencyCode: String?, price: BigDecimal?, properties: BrazeProperties?)

In order to log a purchase, switch to logPurchase. Using this method will by default log a purchase with a quantity of one.

See also


abstract fun logPurchase(productId: String?, currencyCode: String?, price: BigDecimal?, quantity: Int)

In order to log a purchase, switch to logPurchase.

See also


abstract fun logPurchase(productId: String?, currencyCode: String?, price: BigDecimal?, quantity: Int = 1, properties: BrazeProperties? = null)

Reports that the current user made an in app purchase. Useful for tracking and segmenting users more likely to make purchases.

Note: The productId and currencyCode are trimmed of any whitespace characters before being sent to Braze.

Note: Querying the Google Play store for SKU details may return the price of a in-app purchases in micros. Therefore, a purchase of price 0.99USD will be returned as 9900000. To pass this value to Braze, be sure to convert it to a BigDecimal before attempting to convert it from micros to a decimal value in order to avoid integer division rounding errors.

val priceInMicro = BigDecimal(9900000L);
val priceInDecimal = priceInMicro.divide(new BigDecimal(10e6));

Parameters

productId

The String identifier for the product purchased. Usually the Google Play SKU.

currencyCode

Currencies should be represented as an ISO 4217 currency code. Supported currency symbols can be found in com.braze.support.ValidationUtils. Any other provided currency symbol will result in a logged warning and no other action taken by the SDK.

price

The price paid. Base units depend on the currency. As an example, USD should be reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided BigDecimal values will have RoundingMode.HALF_UP rounding applied such that a maximum of two digits exist after the decimal point. May be negative.

quantity

The quantity of items purchased expressed as a whole number. Must be greater than zero.

properties

A map of key-value properties describing this purchase. Property names are non-empty strings <= 255 characters, with no leading dollar signs. Property values can be integers, floats, booleans, dates (of the formats "%FT%T%z", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d", "%m/%d/%Y"), or strings <= 255 characters.