Welcome to AdInMo’s SDK docume...
...
IAPBoost
Custom Integration
9 min
it is recommended to report all in app purchase events , to optimize targeting and campaign delivery implement the following callbacks when enabling iapboost campaigns static public void setinapppurchasecallback(inapppurchasecallback pfn); this callback is used to tell the game that the player has requested to purchase an iap using adinmo’s iapboost interface and the developer is required to handle the iap process and call inapppurchasesuccess or inapppurchasefailed after the process has completed delegate is defined as below, where iap id is the store id of the iap delegate inapppurchasecallback(string iap id); public static void inapppurchasesuccess(string id, string isocurrencycode, float localizedprice, string transactionid,iapsource purchasesource=iapsource unknown); call this to indicate to the sdk that a successful in app purchase has been made, where id is the store id of the iap, isocurrencycode is the currency code eg usd, localisedprice is the price of the iap in local currency, and transactionid is the transactionid of the purchase, (for anti fraud purposes) iapsource can be used to inform us of the source of the purchase unknown, adinmo or other (in game store etc) it defaults to unknown if not set where possible please use standard google or apple reason codes public static void inapppurchasefailed(string id, string isocurrencycode, float localizedprice, string failurereason, iapsource purchasesource = iapsource unknown); call this to indicate to the sdk that a failed attempt has been made to make an in app purchase, where id is the store id of the iap, isocurrencycode is the currency code eg usd, localisedprice is the price of the iap in local currency, and failurereason is a reason why the purchase failed iapsource can be used to inform us of the source of the purchase unknown, adinmo or other (in game store etc) it defaults to unknown if not set where possible please use standard google or apple reason codes price localization you can show localized prices in the magnifier cta button to set this up you need to add this callback adinmomanager setinapppurchasegetpricecallback(getprice); in the store start method where getprice is defined as public string getprice(string item) { if (storecontroller != null) { foreach (var product in storecontroller products all) { if (product definition id == item) { return product metadata localizedpricestring; } } } return null; } existing purchases the following callback can be used to confirm whether or not a non consumable iap has already been purchased adinmomanager setinapppurchasedalreadycallback(inapppurchasedalreadycallback pfn); where inapppurchasedalreadycallback is a delegate of format bool inapppurchasedalreadycallback(string iap id); in our example scenes docid 4kjrnwi1d2 uldxncvjqd you can find a working example of a iapboost setup with the price localization included the code can be directly copied and adapted to your game here is an example of the above callbacks in a script using unityengine; /// \<summary> /// a fake store used to demonstrate how to test basic store actions /// \</summary> class storehandler monobehaviour { \[serializefield] gameobject storecanvas; \[serializefield] text purchasebutton; string iapid; void start() { adinmomanager setinapppurchasecallback(purchaseitem); adinmomanager setinapppurchasegetpricecallback(getstoreprice); adinmomanager setinapppurchasedalreadycallback(checkalreadypurchased); } void purchaseitem(string iap id) { iapid = iap id; storecanvas setactive(true); purchasebutton text = "purchase " + iapid + "?"; } public void makepurchase() { adinmomanager inapppurchasesuccess(iapid, "gbp", 0 00f, "testtransaction", iapsource adinmo); storecanvas setactive(false); } public void refusepurchase() { adinmomanager inapppurchasefailed(iapid, "gbp", 0 00f, "declined purchase", iapsource adinmo); storecanvas setactive(false); } public string getstoreprice(string item) { if (storecontroller != null) { foreach (var product in storecontroller products all) { if (product definition id == item) { return product metadata localizedpricestring; } } } return null; } public inappalreadypurchasedreply checkalreadypurchased(string iap id) { foreach (var product in storecontroller products all) { if (product definition id == iap id) { bool isowned = product hasreceipt; if (isowned) { float price = (float)product metadata localizedprice; string currency = product metadata isocurrencycode; return new inappalreadypurchasedreply(true, price, currency); } } } return inappalreadypurchasedreply(false); } } you can add the callbacks to any script you wish or create a separate script solely for the iapboost callbacks and attach it to an empty object if this function is not set and an iap is sent to the sdk, expect the following warning in the logs inapppurchasedalreadycallback is not set adinmo uses this to confirm whether a buy once iap hasn't been purchased before showing setup adinmomanager setinapppurchasedalreadycallback(inapppurchasedalreadycallback pfn) to set a function that handle checking with the app store whether a buy once iap has already been purchased