Giter VIP home page Giter VIP logo

Comments (8)

pozirk avatar pozirk commented on August 11, 2024

So what was the problem?

from androidinapppurchase.

Mihail-Afanasiev avatar Mihail-Afanasiev commented on August 11, 2024

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.

plazom avatar plazom commented on August 11, 2024

I have same problem. Can anyone to say me why don't work events?

from androidinapppurchase.

Mihail-Afanasiev avatar Mihail-Afanasiev commented on August 11, 2024

plazom, show your code please

from androidinapppurchase.

plazom avatar plazom commented on August 11, 2024

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.

Mihail-Afanasiev avatar Mihail-Afanasiev commented on August 11, 2024

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.

plazom avatar plazom commented on August 11, 2024

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.

pozirk avatar pozirk commented on August 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.