Comments (8)
So what was the problem?
from androidinapppurchase.
I really don't know.. I had class PurchaseManager with static functions and iap was static variable. Then I had changed code and made this class a singletone, so all static methods became non-static. After that all works. Earlier I also had problem with other ANE (for push notifications) when using static variables... Maybe that was a problem..
from androidinapppurchase.
I have same problem. Can anyone to say me why don't work events?
from androidinapppurchase.
plazom, show your code please
from androidinapppurchase.
I have a simple test class. Init works correctly. But when i call doPurchase function i don't have the result.
package com.cnk.ltp {
import com.pozirk.payment.android.InAppPurchase;
import com.pozirk.payment.android.InAppPurchaseEvent;
import com.pozirk.payment.android.InAppPurchaseDetails;
import flash.external.ExtensionContext;
import flash.system.Security;
import flash.text.TextField;
public class AppPurchase {
public var _iap:InAppPurchase;
protected var _ctx:ExtensionContext;
private var inited:Boolean = false;
private var successFunc:Function;
private var errorFunc:Function;
private var canPay:Boolean = true;
private var _instance:AppPurchase;
public function AppPurchase():void
{
_iap = new InAppPurchase();
_iap.addEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess, false, 0, true);
_iap.addEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError, false, 0, true);
_iap.init("mykey");
}
protected function onInitSuccess(event:InAppPurchaseEvent):void
{
//you can restore previously purchased items here
inited = true;
_iap.removeEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess);
_iap.removeEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_SUCCESS, onPurchaseSuccess);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_ALREADY_OWNED, onPurchaseSuccess);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_ERROR, onPurchaseError);
}
protected function onInitError(event:InAppPurchaseEvent):void
{
_iap.removeEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess);
_iap.removeEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError);
trace(event.data); //trace error message
}
public function doPurchase(idProduct:String, _successFunc:Function, _errorFunc:Function=null):void
{
if(inited && canPay){
successFunc = _successFunc;
errorFunc = _errorFunc;
canPay = false;
_iap.purchase(idProduct, InAppPurchaseDetails.TYPE_INAPP);
}
}
protected function onPurchaseSuccess(event:InAppPurchaseEvent):void
{
if(successFunc!=null)
successFunc();
canPay = true;
trace(event.data); //product id
}
protected function onPurchaseError(event:InAppPurchaseEvent):void
{
trace(event.data); //trace error message
if(errorFunc!=null)
errorFunc();
canPay = true;
}
}
}
from androidinapppurchase.
Hmm.. When I analyze my mistake by two version of my purchasemanager from Dropbox, I found, that my error was calling event.target.data instead of event.data. So you don't have such error.. I can advice you following (if you didn't make it): set up uncaughterror event listener on the main class of app. Then add console to project where you can see debug messages on device (I use junkbyte console). And then log messages there. Especially place log code to uncaughterror listener. Maybe there is some error.
And of course check your appdescriptor xml if there is BILLING permission.
from androidinapppurchase.
Misha, can you send me a class which you know that it works correctly? Can this problem be in the settings of the device? In the xml i have billing.
from androidinapppurchase.
Code looks ok, so check that you have correctly integrated the ane, see device logs for any errors.
Try with test item first: http://developer.android.com/google/play/billing/billing_testing.html
from androidinapppurchase.
Related Issues (20)
- Problems rebuilding the ane HOT 1
- Application crashes after fold/unfold when extension android activity is active
- Suspned/Resume make the system dialog appears twice HOT 2
- getPurchaseDetails returning NULL HOT 3
- How to get a login page to appear if the account hasn't been logged in? HOT 2
- Small typo in the readme
- Item you are attempting to purchase could not be found HOT 1
- TypeError #1009 at InAppPurchase/onStatus() : 171 HOT 1
- Error #3500 HOT 6
- Var _iap was reading as undefined property HOT 1
- InAppPurchaseDetails._time overflows
- Error Refreshing Inventory HOT 1
- Inventory Is Returning Null For Purchases & SkuDetails HOT 4
- x86 Arch Support?
- isSupported()? HOT 2
- Error : Authentication required. HOT 1
- App crashes after successful purchase
- Can someone please help me figure out how to correctly set up ANE?
- in app purchase with test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidinapppurchase.