com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization
Class GooglePlayMonetizationEventBuilder

java.lang.Object
  extended by com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.MonetizationEventBuilder
      extended by com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.GooglePlayMonetizationEventBuilder

public class GooglePlayMonetizationEventBuilder
extends MonetizationEventBuilder

Builds monetization events representing a Google Play purchase. This Builder automatically sets the store attribute to "Google Play". This Builder will return null if the ProductId, Formatted Localized Price, Quantity, or TransactionId are not set.

The example below demonstrates how to create a monetization event after you receive the purchase org.json.JSONObject on the completion of a purchase using Google's In App Billing API. Since Google does not give you any product information in the purchase object, you must have a way to access your store inventory when the purchase is being finalized. In the example below, we use a org.json.JSONObject that was returned by a request to Google's In App Billing API for product skus.

Example:
    // get the event client from your MobileAnalyticsManager instance
    EventClient eventClient = mobileAnalyticsManager.getEventClient();
    
    // create a builder that can record purchase events for Google Play IAP
    GooglePlayMonetizationEventBuilder builder = GooglePlayMonetizationEventBuilder.create(eventClient);
    
    // build the monetization event with the product id, formatted item price, transaction id, and quantity
    // product id and formatted item price can be obtained from the JSONObject returned by a product sku request to Google's In App Billing API
    // transaction id is obtained from the Purchase object that is returned upon the completion of a purchase
    // Google IAP currently only supports a quantity of 1
    Event purchaseEvent = builder.withProductId(sku).withFormattedItemPrice(price).withTransactionId(purchase.getOrderId()).withQuantity(1).build();
    
    // record the monetization event
    eventClient.recordEvent(purchaseEvent);
 


Method Summary
static GooglePlayMonetizationEventBuilder create(EventClient eventClient)
          Create a GooglePlayMonetizationEventBuilder with the specified Event client
 GooglePlayMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
          Sets the formatted localized item price of the item being purchased (accessed from the product item details price field after calling getSkuDetails()).
 GooglePlayMonetizationEventBuilder withProductId(java.lang.String productId)
          Sets the product identifier field of the item being purchased.
 GooglePlayMonetizationEventBuilder withQuantity(java.lang.Double quantity)
          Sets the quantity of the item purchased.
 GooglePlayMonetizationEventBuilder withTransactionId(java.lang.String transactionId)
          The transaction identifier of the purchase.
 
Methods inherited from class com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.MonetizationEventBuilder
build
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static GooglePlayMonetizationEventBuilder create(EventClient eventClient)
Create a GooglePlayMonetizationEventBuilder with the specified Event client

Parameters:
eventClient - The event client to use when creating monetization events
Returns:
a GooglePlayMonetizationEventBuilder to build monetization events from the Google Play IAB API

withProductId

public GooglePlayMonetizationEventBuilder withProductId(java.lang.String productId)
Sets the product identifier field of the item being purchased.

Parameters:
productId - The product id representing the item being purchased
Returns:
this for chaining

withFormattedItemPrice

public GooglePlayMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
Sets the formatted localized item price of the item being purchased (accessed from the product item details price field after calling getSkuDetails()).

Parameters:
formattedItemPrice - The localized formatted price of the item
Returns:
this for chaining

withQuantity

public GooglePlayMonetizationEventBuilder withQuantity(java.lang.Double quantity)
Sets the quantity of the item purchased.

Parameters:
quantity - Currently, Google Play only supports purchasing 1 item at a time.
Returns:
this for chaining

withTransactionId

public GooglePlayMonetizationEventBuilder withTransactionId(java.lang.String transactionId)
The transaction identifier of the purchase.

Parameters:
transactionId - The orderId found in the INAPP_PURCHASE_DATA of a purchase request
Returns:
this for chaining


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.