In App Purchase Listener

A listener interface for In-App Purchase triggered by ads. The ad can trigger an In-App Purchase with an InAppPurchase containing product id(SKU). The application then decides how to conduct the purchase, you can get more info in Google Official Documentation


Note: You will only receive in-app purchase (IAP) ads if you specifically configure an IAP ad campaign in the AdMob front end.

Implement the onInAppPurchase listener, is really easy, all you have to do is to subscribe to ON_AD_IN_APP_REQUEST event

GoogleMobileAd.addEventListener(GoogleMobileAdEvents.ON_AD_IN_APP_REQUEST, OnInAppRequest);

Implement Event data will contain product id. You should start your game purchase flow with this id as soon as you will receive ON_AD_IN_APP_REQUEST event

private void OnInAppRequest(CEvent e) {
//getting product id
string productId = (string);
Debug.Log ("In App Request for product Id: " + productId + " received");
//Start purchase flow with productId here

Once the purchase is complete, you should call RecordInAppResolution with one of the following constants defined in GADInAppResolution:

public enum GADInAppResolution {
 RESOLUTION_SUCCESS = 0, // Purchase was a success
 RESOLUTION_FAILURE = 1, // Error while processing purchase
 RESOLUTION_INVALID_PRODUCT = 2, // Error while looking up product
 RESOLUTION_CANCELLED = 3 // Purchase was cancelled by user

An example of a success call would look like this: