public class CustomMonetizationEventBuilder extends MonetizationEventBuilder
The example below demonstrates how to create a monetization event after you receive a purchase confirmation from the IAP framework you are using. You are responsible for storing and making sure that the bare minimum attributes required to build a Custom Purchase Event are available for use at this time. Note that the builder will maintain the values of its internal variables between builds.
Example:
// create a builder that can record purchase events for the IAP Framework you
// are using
CustomMonetizationEventBuilder builder = CustomMonetizationEventBuilder.create(pinpointManager.getAnalyticsClient());
// build the monetization event with at minimum the store, product id, quantity,
// and price information
// The price information can be supplied in either of the following ways:
// - The price as a double (i.e. 1.99) and the currency as a currency code (i.e.
// "USD"). This method is preferred as it provides more accuracy in the
// monetization reports
// - The formatted localized price of the item as a string (i.e. "$1.99")
// You may also build with any additional available attributes that the IAP
// Framework provides such as Transaction ID
// Price and currency
Event purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword")
.withItemPrice(1.99).withCurrency("USD").withQuantity(1).build();
// Formatted Price
purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword")
.withFormattedItemPrice("$1.99").withQuantity(1).build();
// record the monetization event
pinpointManager.getAnalyticsClient().recordEvent(purchaseEvent);
| Modifier | Constructor and Description |
|---|---|
protected |
CustomMonetizationEventBuilder(AnalyticsClient analyticsClient)
Construct a CustomMonetizationEventBuilder with the specified EventClient
|
| Modifier and Type | Method and Description |
|---|---|
static CustomMonetizationEventBuilder |
create(AnalyticsClient analyticsClient)
Create a CustomMonetizationEventBuilder with the specified Event client
|
protected boolean |
isValid()
Determines if all builder methods on this builder have been called
|
CustomMonetizationEventBuilder |
withCurrency(String currency)
Sets the currency of the item being purchased (Required if formatted
localized price is not specified)
|
CustomMonetizationEventBuilder |
withFormattedItemPrice(String formattedItemPrice)
Sets the formatted localized price of the item being purchased (Required
if numerical price and currency are not specified)
|
CustomMonetizationEventBuilder |
withItemPrice(double itemPrice)
Sets the numerical price of the item being purchased (Required if
formatted localized price is not specified)
|
CustomMonetizationEventBuilder |
withProductId(String productId)
Sets the product identifier field of the item being purchased (Required)
|
CustomMonetizationEventBuilder |
withQuantity(Double quantity)
Sets the quantity of the item being purchased (Required)
|
CustomMonetizationEventBuilder |
withStore(String store)
Sets the store in which the transaction is taking place (Required)
|
CustomMonetizationEventBuilder |
withTransactionId(String transactionId)
The transaction identifier of the purchase (Optional)
|
build, getCurrency, getFormattedItemPrice, getItemPrice, getProductId, getQuantity, getStore, getTransactionId, setCurrency, setFormattedItemPrice, setItemPrice, setProductId, setQuantity, setStore, setTransactionIdprotected CustomMonetizationEventBuilder(AnalyticsClient analyticsClient)
analyticsClient - The EventClient to use when building the eventpublic static CustomMonetizationEventBuilder create(AnalyticsClient analyticsClient)
analyticsClient - The event client to use when creating monetization
eventspublic CustomMonetizationEventBuilder withStore(String store)
store - The store in which the transaction is taking placepublic CustomMonetizationEventBuilder withProductId(String productId)
productId - The product id representing the item being purchasedpublic CustomMonetizationEventBuilder withQuantity(Double quantity)
quantity - The quantity of the item being purchasedpublic CustomMonetizationEventBuilder withFormattedItemPrice(String formattedItemPrice)
formattedItemPrice - The formatted localized price of the itempublic CustomMonetizationEventBuilder withItemPrice(double itemPrice)
itemPrice - The numerical price of the itempublic CustomMonetizationEventBuilder withCurrency(String currency)
currency - The currency code of the currency used to purchase this
item (i.e. "USD")public CustomMonetizationEventBuilder withTransactionId(String transactionId)
transactionId - The transaction id of the purchaseprotected boolean isValid()
MonetizationEventBuilderisValid in class MonetizationEventBuilderCopyright © 2016. All rights reserved.