InApp purchase module

Monkey Targets Forums/Android/InApp purchase module

Xaron(Posted 2012) [#1]
Hi all,

has anyone tried an InApp purchase for Android yet? If not I have to make one. ;)


maverick69(Posted 2012) [#2]
I'm currently working on In-App-Billing for Android. As soon if I have packed it in a fancy Monkey Module I'll let you know.


maverick69(Posted 2012) [#3]
Hi, I just commited a first draft on github of my android payment module (its not perfect, but it's already tested with the andoird.test.purchased item).

Here you'll find the source files:

https://github.com/JochenHeizmann/Horizon-for-Monkey/blob/master/native/payment/payment.android.java

https://github.com/JochenHeizmann/Horizon-for-Monkey/blob/master/payment.monkey

https://github.com/JochenHeizmann/Horizon-for-Monkey/blob/master/payment/product.monkey

https://github.com/JochenHeizmann/Horizon-for-Monkey/blob/master/payment/service.monkey

My destination is that I can use the module for ios and android without changing anything in the monkey code. Here is an example:

Import horizon.payment

Class MyProduct Extends PaymentProduct
	Method GetAppleId$()
		Return "my.apple.product.identifier"
	End

	Method GetAndroidId$()
		Return "android.test.purchased"
	End
End

[...]

myProduct = New MyProduct()

paymentService = New PaymentService()

paymentService.SetBundleId("myapplebundleidentifier")
paymentService.SetPublicKey("myandroidpublickey")

paymentService.AddProduct(myProduct)
paymentService.StartService()
myProduct.UpdatePurchasedState()

[...]

Method OnUpdate:Void()
	If (paymentService.IsPurchaseInProgress())
	' Do something
	End

	If (SomeButtonIsPressed()) Then myProduct.Buy()

	If (myProduct.IsProductPurchased()) Then Print "Yay! Product is available!"
End



Xaron(Posted 2012) [#4]
That's awesome, thanks for that, will try it out!