diff --git a/src/IAPHandler.hx b/src/IAPHandler.hx index 13b9d69..bfd3a71 100644 --- a/src/IAPHandler.hx +++ b/src/IAPHandler.hx @@ -20,6 +20,7 @@ class IAPHandler public var requestProductListCall:Dynamic; public var getProductListIDsCall:Dynamic; public var requestReceiptsCall:Dynamic; + public var requestGamerInfoCall:Dynamic; public var getReceiptProductIDsCall:Dynamic; public var requestPurchaseCall:Dynamic; public var getLastPurchasedProductIDCall:Dynamic; @@ -35,6 +36,8 @@ class IAPHandler trace("=================== JNI linking methods..."); initCall = openfl.utils.JNI.createStaticMethod ("com.jarnik.iaptest.OUYA_IAP", "init", "(Lorg/haxe/lime/HaxeObject;Ltv/ouya/console/api/OuyaFacade;Ljava/lang/String;)V", true); + requestGamerInfoCall = openfl.utils.JNI.createStaticMethod + ("com.jarnik.iaptest.OUYA_IAP", "requestGamerInfo", "()V", true); requestProductListCall = openfl.utils.JNI.createStaticMethod ("com.jarnik.iaptest.OUYA_IAP", "requestProductList", "([Ljava/lang/String;)V", true); getProductListIDsCall = openfl.utils.JNI.createStaticMethod @@ -89,6 +92,22 @@ class IAPHandler // ==================================== CALLBACKS - OVERRIDE THESE! ======================= + // === get username + public function onGamerInfoReceived(username:String) + { + trace("=== onGamerInfoReceived! " + username); + } + + public function onGamerInfoFailed(error:String) + { + trace("=== onGamerInfoFailed! " + error); + } + + public function onGamerInfoCanceled() + { + trace("=== onGamerInfoCanceled! " ); + } + // ==== Product List public function onProductListReceived() { diff --git a/src/java/com/jarnik/iaptest/OUYA_IAP.java b/src/java/com/jarnik/iaptest/OUYA_IAP.java index c32e084..4f2a296 100644 --- a/src/java/com/jarnik/iaptest/OUYA_IAP.java +++ b/src/java/com/jarnik/iaptest/OUYA_IAP.java @@ -65,7 +65,31 @@ public static void init(final HaxeObject callback, OuyaFacade ouyaFacade, String Log.e("IAP", "Unable to create encryption key", e); } } + // ======================================== GAMER INFO ====================================== + public static void requestGamerInfo() + { + mOuyaFacade.requestGamerInfo(new GamerInfoLister()); + } + public static class GamerInfoLister implements OuyaResponseListener + { + @Override + public void onSuccess(GamerInfo gamerInfoResponse) { + mCallback.call("onGamerInfoReceived", new Object[] { gamerInfoResponse.getUsername() } ); + } + + @Override + public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { + mCallback.call("onGamerInfoFailed", new Object[] { errorCode+": "+errorMessage } ); + } + + @Override + public void onCancel() { + mCallback.call("onGamerInfoCanceled", new Object[] {} ); + } + } + + // ======================================= PRODUCT LIST ===================================================== public static void requestProductList(String[] products)