question

Scott Befield avatar image
Scott Befield asked

Testing IAP in Adobe Air app

I am adding IAP to an Adobe Air app for Android and am unable to get a successful result when testing IAP using the Amazon Test Client app. I have the app installed and the JSON file at the root of the SDCard. I am calling loadItemData as shown in teh sample app: function loadItemData():void { debugText.appendText("\nrequesting item data..."); AmazonPurchase.amazonPurchase.loadItemData(["com.berfield.egyptslots.cash1000000"]); } My JSON data looks like: { "com.berfieldproductions.egyptslots.1000000": { "description":"Add $1,000,000 credit to your bankroll. Credit is used as you play and cannot be restored.", "itemType":"CONSUMABLE", "title":"$1,000,000 Game Credit", "price":1.99,"smallIconUrl":"http://"} } The code does not appear to ever get to the events for either load or fail. I see the load being called, but the code never gets to the event handlers.
iap
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Scott, Thank you for the post. Have you followed the steps mentioned in below link to modify your Application Descriptor XML? https://developer.amazon.com/sdk/in-app-purchasing/documentation/adobe-building.html#Section1 You need to register a receiver named "com.amazon.inapp.purchasing.ResponseReceiver" in your android manifest file (generated from Air Application Descriptor xml file) in order to get the callback events. If you follow the steps mentioned in above link, you should be able to get IAP working in your app. Hope this helps. If you are unable to solve this problem, please let us know which SDK (Flash CS5/6 or Flash Builder 4.5/4.6) you are using in your development.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helpmeplease12 avatar image
helpmeplease12 answered
Hi there. I'm not connected to the person who started this thread, but since I'm working on IAP for Adobe AIR, this seemed like a good place to post. I set up my test JSON file and stored it in the root folder of my Kindle. (By the way, your documentation refers to /mnt/sdcard, but this doesn't exist when you connect to a PC - at least, it doesn't for me.) When I click on the purchase button in my app, it brings up the SDK Tester purchase window, and I click on the "Buy" button, but then the thing just sits there. It never comes back, even when I click on the X close button in the upper right corner. If I click on the bottom of the device, I get a "Sorry" box that comes up telling me that my application has stopped unexpectedly. I know the app never got the notification of the purchase because my server never got the information. Before you ask, yes, I have my application.xml set up right: ----- irrelevant stuff removed ----- <manifest android:installLocation="auto"> <uses-sdk android:targetSdkVersion="12" /> <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="com.android.vending.BILLING" /> <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch" /> <application> <activity android:name="com.milkmangames.extensions.android.PurchaseWrapActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <receiver android:name="com.amazon.inapp.purchasing.ResponseReceiver"> <intent-filter> <action android:name="com.amazon.inapp.purchasing.NOTIFY" android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" /> </intent-filter> </receiver> </application> </manifest> As you can see, I'm using both the Amazon IAP ANE and the Milkman ANE for regular Google Play. Milkman support has told me that this should be fine, and the two won't interfere with each other. Any idea of what might be wrong? Thanks!
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Thank you for posting. 1. /mnt/sdcard directory is a valid path for all kindle devices. When you coneect your device with windows machine, it shows the contents of /mnt/sdcard if you browse through explorer. But if you connect through command line by running "adb shell" command and then "ls -l" linux command in shell, you should be able to find the actual root directory and /mnt/sdcard there as well. So placing the json file in the root directory through windows explorer means you are actually placing it in /mnt/sdcard and that's correct. 2. Have you tried to setup an Actionscript Android project and run it with the given sample code along with the sdk zip (Apps-SDK\InAppPurchasing\plugins\adobe\example-src\ AmazonExample.as)? It seems that your app is getting force closed. Do you see any error stack trace in logcat at that time? To track the purchase you are supposed to have these in you class AmazonPurchase.amazonPurchase.addEventListener(AmazonPurchaseEvent.PURCHASE_ALREADY_ENTITLED,onAlreadyEntitled); AmazonPurchase.amazonPurchase.addEventListener(AmazonPurchaseEvent.PURCHASE_FAILED,onPurchaseFailed); AmazonPurchase.amazonPurchase.addEventListener(AmazonPurchaseEvent.PURCHASE_SKU_INVALID,onInvalidSku); AmazonPurchase.amazonPurchase.addEventListener(AmazonPurchaseEvent.PURCHASE_SUCCEEDED,onPurchaseSuccess); Could you please see the callback is coming to any of these method by putting trace() in these methods? Please provide these information to clarify your issue. Thanks.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helpmeplease12 avatar image
helpmeplease12 answered
Thanks for the quick response. I do implement those events. Here's some output from amazon.sdktester.info.log: PurchaseActivity: Attempting to purchase (d96d7a8e-67cd-4ccc-bb18-8384535cc7d5, DefaultTestUser, c180k, {"title":"180,000 chips","price":0.99,"description":"180,000 chips immediately added to your bankroll","smallIconUrl":"http:\/\/some\/image.jpg","itemType":"CONSUMABLE"}, air.air.A1on1poker) Initializing Purchase Flow. on line 16 of file:///android_asset/web/js/purchase.js Purchasing consumable (c180k) Completing purchase. on line 35 of file:///android_asset/web/js/purchase.js Broadcasting purchase response for c180k, air.air.A1on1poker ({"requestId":"d96d7a8e-67cd-4ccc-bb18-8384535cc7d5","receipt":{"sku":"c180k","token":"eyJ0eXBlIjoiQ09OU1VNQUJMRSIsInNrdSI6ImMxODBrIn0","itemType":"CONSUMABLE"},"purchaseStatus":"SUCCESSFUL","userId":"DefaultTestUser"}) Sending Purchase Response Broadcast ({"requestId":"d96d7a8e-67cd-4ccc-bb18-8384535cc7d5","receipt":{"sku":"c180k","token":"eyJ0eXBlIjoiQ09OU1VNQUJMRSIsInNrdSI6ImMxODBrIn0","itemType":"CONSUMABLE"},"purchaseStatus":"SUCCESSFUL","userId":"DefaultTestUser"}) Sending UserId Response Broadcast ({"status":"SUCCESSFUL","requestId":"f7895916-4dda-4e62-8683-2f9f2d7d6554","userId":"DefaultTestUser"}) Sending UserId Response Broadcast ({"status":"SUCCESSFUL","requestId":"3a68c1d8-ed03-43a9-b8bc-c8fb847f4f56","userId":"DefaultTestUser"}) Sending UserId Response Broadcast ({"status":"SUCCESSFUL","requestId":"2f475c57-abde-4b2f-9e5c-83445eb85f6b","userId":"DefaultTestUser"}) Sending Purchase Updates Response Broadcast ({"offset":"1371171834434","status":"SUCCESSFUL","requestId":"f5897154-6388-4ffc-93c1-090fb0756a09","isMore":false,"userId":"DefaultTestUser"}) Sending Purchase Updates Response Broadcast ({"offset":"1371171834484","status":"SUCCESSFUL","requestId":"3d7d7c6b-f6b0-4c2f-832c-7ccd7acf9250","isMore":false,"userId":"DefaultTestUser"}) Sending Purchase Updates Response Broadcast ({"offset":"1371171834498","status":"SUCCESSFUL","requestId":"0f2a6f4e-ae2f-48e2-a33f-051bd132650a","isMore":false,"userId":"DefaultTestUser"}) PurchaseActivity: Attempting to purchase (beb57258-c8a1-49f0-a32e-8367887a4e05, DefaultTestUser, c180k, {"title":"180,000 chips","price":0.99,"description":"180,000 chips immediately added to your bankroll","smallIconUrl":"http:\/\/some\/image.jpg","itemType":"CONSUMABLE"}, air.air.A1on1poker) Initializing Purchase Flow. on line 16 of file:///android_asset/web/js/purchase.js Purchasing consumable (c180k)Completing purchase. on line 35 of file:///android_asset/web/js/purchase.js Broadcasting purchase response for c180k, air.air.A1on1poker ({"requestId":"beb57258-c8a1-49f0-a32e-8367887a4e05","receipt":{"sku":"c180k","token":"eyJ0eXBlIjoiQ09OU1VNQUJMRSIsInNrdSI6ImMxODBrIn0","itemType":"CONSUMABLE"},"purchaseStatus":"SUCCESSFUL","userId":"DefaultTestUser"}) Sending Purchase Response Broadcast ({"requestId":"beb57258-c8a1-49f0-a32e-8367887a4e05","receipt":{"sku":"c180k","token":"eyJ0eXBlIjoiQ09OU1VNQUJMRSIsInNrdSI6ImMxODBrIn0","itemType":"CONSUMABLE"},"purchaseStatus":"SUCCESSFUL","userId":"DefaultTestUser"}) The other odd thing is that if I go into the SDK Tester and click on Interactive Mode, if I change the Purchase API setting to something like "Invalid SKU", it does seem to call my event, but not in the way I would expect. I would expect that it would still take me to the button to purchase first, and then give me an error, but that's not how it works. When I set this value to "Invalid SKU", my event for PURCHASE_FAILED is raised immediately when I click on the Buy button in my app (which is calling AmazonPurchase.amazonPurchase.purchaseItem(). The problem is that I don't know if the problem is with the tester or my app. Unfortunately, this tester is the only way I can try this out.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helpmeplease12 avatar image
helpmeplease12 answered
Sujoy, does this log output help you understand what might be happening?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi, Regarding your first problem. Logs seem to be fine. I can see the there is a broadcast from tester about the purchase successful event in the log. Now your app is supposed to get a callback on "onPurchaseSuccess" method. Could you add a trace() over there and see in the console whether the method is being called or not? If not, please write back. For INVALID_SKU, you would get a instant failure callback since the target SKU you have sent with purchaseItem(), that does not exist in the json definition file/portal. So there is no point of showing the confirmation dialog with a buy button.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.