In App Purchase Listener

A listener interface for In-App Purchase is triggered by ads. The ad can trigger an In-App Purchase with an InAppPurchase containing product id(SKU). Then the application 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.

Implemention of 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);

Implemention of the Event data will contain a product id. You should start your game purchase to flow with this id as soon as you  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 completed, 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 successful call will look like this: