Well so here it is. An InApp purchase module! Tested with Monkey v72a.
At the moment it is only available for Android (it uses Google's API v3) and you need to do some tweaks to trans to make it compile.
The source: https://github.com/Xaron/iap
Copy the folders "target" and "modules_ext" to your monkey pro folder. There will be a new custom target called Android_IAP_Game.
Now you have to change trans which shouldn't be necessary in one of the next versions I hope!
Open MonkeyPro/src/transcc/builders/android.monkey and look for the following lines:
If GetCfgVar( "ANDROID_NATIVE_GL_ENABLED" )="1"
CopyDir "nativegl/libs","libs",True
CreateDir "src/com"
CreateDir "src/com/monkey"
CopyFile "nativegl/NativeGL.java","src/com/monkey/NativeGL.java"
Endif
Replace them with:
If GetCfgVar( "ANDROID_NATIVE_GL_ENABLED" )="1"
CopyDir "nativegl/libs","libs",True
CreateDir "src/com"
CreateDir "src/com/monkey"
CopyFile "nativegl/NativeGL.java","src/com/monkey/NativeGL.java"
Endif
If GetCfgVar( "IN_APP_BILLING" )="1"
Print "Copy in app billing..."
DeleteDir "src/com/android", True
CreateDir "src/com/android"
CreateDir "src/com/android/vending"
CreateDir "src/com/android/vending/billing"
CopyFile "iap/IInAppBillingService.aidl", "src/com/android/vending/billing/IInAppBillingService.aidl"
Endif
Now compile transcc using the C++_Tool target and replace your /bin/transcc_winnt.exe with the new compiled one.
You should be able to compile the example.monkey file for Android.
Replace in the example the string APP_KEY with a unique identifier for your app. The string ITEM_ID has the value "android.test.purchased" and should be replaced by real items as soon as you have some. The current value is a Google test value which you can use to test any purchases without really buying anything!
Regarding the Google API and how billing works, look here: http://developer.android.com/google/play/billing/billing_overview.html
I hope the source is somewhat self explanatory. Feel free to ask any questions here! It might still have some bugs!
iOS comes next!
|