守望者--AIR技术交流

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: ANE FlasCC 炼金术
查看: 1131|回复: 0

AndroidInAppPurchase

[复制链接]
  • TA的每日心情
    擦汗
    2018-4-10 15:18
  • 签到天数: 447 天

    [LV.9]以坛为家II

    1742

    主题

    2094

    帖子

    13万

    积分

    超级版主

    Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

    威望
    562
    贡献
    29
    金币
    52620
    钢镚
    1422

    开源英雄守望者

    发表于 2015-1-29 15:18:45 | 显示全部楼层 |阅读模式
    应用下载
    应用名称: AndroidInAppPurchase
    支持64位:
    当前版本: 未知
    运行平台: Android 
    开发语言: ActionScript 3 JAVA 
    应用类别: ANE-JAVA
    应用简介: Adobe AIR native extension (ANE) for Android to purchase virtual items
    About

    AndroidInAppPurchase is an Adobe AIR native extension (ANE) for Android to purchase virtual items.
    It uses Google Play In-app Billing version 3 API.
    Supported functionality:

    • purchase of items;
    • restoration of previously purchased items;
    • consumption of items;
    • subscriptions (not tested).
    Docs

    Please, read docs and try ANE before asking any questions.
    http://developer.android.com/google/play/billing/index.html
    http://help.adobe.com/en_US/air/extensions/index.html

    Installation

    Extension ID: com.pozirk.AndroidInAppPurchase
    Add "InAppPurchase.ane" and "air\InAppPurchase\bin\InAppPurchase.swc" to your AIR project.
    Add the following lines to your AIR Aplication-app.xml file inside <manifestAdditions> section:


    1. <uses-permission android:name="com.android.vending.BILLING" />
    2. <application android:enabled="true">
    3. <activity android:name="com.pozirk.payment.BillingActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" android:background="#30000000" />
    4. </application>
    复制代码
    Examples
    1. import com.pozirk.payment.android.InAppPurchase;
    2. import com.pozirk.payment.android.InAppPurchaseEvent;
    3. import com.pozirk.payment.android.InAppPurchaseDetails;

    4. ...

    5. protected var _iap:InAppPurchase = new InAppPurchase();

    6. ...

    7. //> initialization of InAppPurchase
    8. _iap.addEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess);
    9. _iap.addEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError);

    10. _iap.init("YOUR_LICENSE_KEY_FOR_THE_APPLICATION");

    11. ...

    12. protected function onInitSuccess(event:InAppPurchaseEvent):void
    13. {
    14.     //you can restore previously purchased items here
    15. }

    16. protected function onInitError(event:InAppPurchaseEvent):void
    17. {
    18.     trace(event.data); //trace error message
    19. }
    20. //<


    21. //> making the purchase, _iap should be initialized first
    22. _iap.addEventListener(InAppPurchaseEvent.PURCHASE_SUCCESS, onPurchaseSuccess);
    23. _iap.addEventListener(InAppPurchaseEvent.PURCHASE_ALREADY_OWNED, onPurchaseSuccess);
    24. _iap.addEventListener(InAppPurchaseEvent.PURCHASE_ERROR, onPurchaseError);
    25. _iap.purchase("my.product.id", InAppPurchaseDetails.TYPE_INAPP);

    26. protected function onPurchaseSuccess(event:InAppPurchaseEvent):void
    27. {
    28.     trace(event.data); //product id
    29. }

    30. protected function onPurchaseError(event:InAppPurchaseEvent):void
    31. {
    32.     trace(event.data); //trace error message
    33. }
    34. //<


    35. //> getting purchased product details, _iap should be initialized first
    36. _iap.addEventListener(InAppPurchaseEvent.RESTORE_SUCCESS, onRestoreSuccess);
    37. _iap.addEventListener(InAppPurchaseEvent.RESTORE_ERROR, onRestoreError);
    38. _iap.restore(); //restoring purchased in-app items and subscriptions

    39. ...

    40. protected function onRestoreSuccess(event:InAppPurchaseEvent):void
    41. {
    42.     //getting details of purchase: time, etc.
    43.     var purchase:InAppPurchaseDetails = _iap.getPurchaseDetails("my.product.id");
    44. }

    45. protected function onRestoreError(event:InAppPurchaseEvent):void
    46. {
    47.     trace(event.data); //trace error message
    48. }
    49. //<

    50. //> getting purchased and not purchased product details
    51. _iap.addEventListener(InAppPurchaseEvent.RESTORE_SUCCESS, onRestoreSuccess);
    52. _iap.addEventListener(InAppPurchaseEvent.RESTORE_ERROR, onRestoreError);

    53. var items:Array<String> = ["my.product.id1", "my.product.id2", "my.product.id3"];
    54. var subs:Array<String> = ["my.subs.id1", "my.subs.id2", "my.subs.id3"];
    55. _iap.restore(items, subs); //restoring purchased + not purchased in-app items and subscriptions

    56. ...

    57. protected function onRestoreSuccess(event:InAppPurchaseEvent):void
    58. {
    59.     //getting details of product: time, etc.
    60.     var skuDetails1:InAppSkuDetails = _iap.getSkuDetails("my.product.id1");

    61.     //getting details of product: time, etc.
    62.     var skuDetails2:InAppSkuDetails = _iap.getSkuDetails("my.subs.id1");

    63.     //getting details of purchase: time, etc.
    64.     var purchase:InAppPurchaseDetails = _iap.getPurchaseDetails("my.purchased.product.id");
    65. }

    66. protected function onRestoreError(event:InAppPurchaseEvent):void
    67. {
    68.     trace(event.data); //trace error message
    69. }
    70. //<


    71. //> consuming purchased item
    72. //>> need to retrieve purchased items first
    73. _iap.addEventListener(InAppPurchaseEvent.RESTORE_SUCCESS, onRestoreSuccess);
    74. _iap.addEventListener(InAppPurchaseEvent.RESTORE_ERROR, onRestoreError);
    75. _iap.restore();
    76. //<<

    77. ...

    78. protected function onRestoreSuccess(event:InAppPurchaseEvent):void
    79. {
    80.     _iap.addEventListener(InAppPurchaseEvent.CONSUME_SUCCESS, onConsumeSuccess);
    81.     _iap.addEventListener(InAppPurchaseEvent.CONSUME_ERROR, onConsumeError);
    82.     _iap.consume("my.product.id");
    83. }
    84. //<
    复制代码
    Testinghttp://developer.android.com/google/play/billing/billing_testing.htmlMiscANE is build for AIR3.6+, in order to rebuild for another version do the following:
    • edit "air\extension.xml" and change 3.6 in very first line to any 3.X you need;
    • edit "build.bat" and in the very last line change path from AIR3.X SDK to any AIR3.X SDK you need;
    • execute "build.bat" to repack the ANE.







    相关链接:

    https://github.com/pozirk/AndroidInAppPurchase

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    守望者AIR技术交流社区(www.airmyth.com)
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    
    关闭

    站长推荐上一条 /4 下一条

    QQ|手机版|Archiver|网站地图|小黑屋|守望者 ( 京ICP备14061876号

    GMT+8, 2024-3-29 07:21 , Processed in 0.045835 second(s), 36 queries .

    守望者AIR

    守望者AIR技术交流社区

    本站成立于 2014年12月31日

    快速回复 返回顶部 返回列表