Hi folks,
I successfully implemented InApp purchases for Android. What a stupid thing compared with iOS. I can share my experiences and problems if somebody has a needs for it.
However, I still have a question regarding GoogleBilling:setPublicKey(publicKey). I read several Pages on google, but wasn't able to fully understand the need of this function. Can anyone explain? InApp purchases still work without calling this function.
thanks in advance!
Michael
Comments
> What a stupid thing compared with iOS.
Exactly I've read these pages https://developer.android.com/google/play/billing/index.html again and again to grasp the logic behind. And probably now I've forgotten everything.
http://www.giderosmobile.com/forum/discussion/2229/android-in-app-usage-on-gideros#Item_1
Hope I can put it together...
best regards
Michael
Likes: atilim
btw, I realized that the reference manual isn't really enough to implement google billing inside your applications
CONFIRM_NOTIFICATIONS
This request acknowledges that your application received the details of a purchase state change. Google Play sends purchase state change notifications to your application until you confirm that you received them.
and
Keep in mind, you must send a confirmation when you receive transaction information from Google Play (step 8 in figure 2). If you don't send a confirmation message, Google Play will continue sending IN_APP_NOTIFY messages for the transactions you have not confirmed. As a best practice, you should not send a CONFIRM_NOTIFICATIONS request for a purchased item until you have delivered the item to the user. This way, if your application crashes or something else prevents your application from delivering the product, your application will still receive an IN_APP_NOTIFY broadcast intent from Google Play indicating that you need to deliver the product.
It's very similar to the StoreKit:finishTransaction function.
Honestly, documentation of StoreKit function finishTransaction() says:
Your application should call this function only after it has successfully processed the transaction and unlocked the functionality purchased by the user.
Sample code in documenation is implemented that way, that finishTransaction is called if purchase failed or succeeded... correct?
Same to your code above...
Michael
But you should call finishTransaction even if your transaction is failed. If you look at this documentation: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/AddingaStoretoYourApplication/AddingaStoretoYourApplication.html finishTransaction is called in step 8 (completeTransaction), step 9 (restoreTransaction) and step 10 (failedTransaction).
The only requirement for a failed purchase is that your application remove it from the queue. Therefore you should call finishTransaction to remove it from queue when your transaction fails.
As a best practice, you should not send a CONFIRM_NOTIFICATIONS request for a purchased item until you have delivered the item to the user.
So if it failed, I have not delivered it to the user and should not call
googlebilling:confirmNotification(event.notificationId)
Is that correct? Thanks for your quick replies!
Michael
To summarize, If the transaction fails or user cancels, don't deliver to user but send CONFIRM_NOTIFICATIONS request.
Event.REQUEST_PURCHASE_COMPLETE
Dispatched when requestPurchase function completes. It contains event.responseCode, event.productId, event.productType and event.developerPayload fields.
There isn't event.notificationId in request purchase. There is a problem in my phone now i can not access it. So i can not try. Will it work although it doesnt contain event.notificationId??
Likes: mertocan
Whenever I click on "OK" to buy an item, Application crashed. Function onPurchaseStateChange() never called executed, although I set an Event Listener.
Right now, I figure out that you have to set the PublicKey to get this event. So finally I answered my question myself. After setting the publicKey, App no longer crashes and onPurchaseStateChange() function is called correctly.
regards
Michael
java.lang.RuntimeException: Unable to start service com.giderosmobile.android.plugins.googlebilling.BillingService@41591608 with Intent { act=com.android.vending.billing.PURCHASE_STATE_CHANGED cmp=.....
As already mentioned, purchaseStateChanged() was never called in LUA (I added Alert boxes), but after I added the public key in googlebilling, there was no Android error any longer and also function got called correctly.
Reproducable and just for you as a hint...
best regards
Michael
@Atilim, that raises the question gideros SDK shouldn't be upgraded to v3? Google suggests to upgrade to version 3 (not sure about this).
best regards
Michael
Likes: atilim, mertocan