LoginSignup
2
2

More than 5 years have passed since last update.

Cordova(PhoneGap)でアプリ内課金を実装

Posted at

こちらのプラグインを使用します。
https://github.com/j3k0/cordova-plugin-purchase

README翻訳

概要

このプラグインは、CordovaとPhoneGapから作られたAndroid/iOS/Windowsアプリのアプリ内課金を可能にします。
シングルコードで全てのプラットフォームを操作できます。

インストール

Cordovaの場合

cordova plugin add cc.fovea.cordova.purchase

・Androidも作る場合

cordova plugin add cc.fovea.cordova.purchase  --variable BILLING_KEY="<BILLING_KEY>"

Billingキーの取得方法はこちら
https://github.com/j3k0/cordova-plugin-purchase/wiki/HOWTO#add-android-billing-key

PhoneGap Buildの場合

<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="6.0.0" />

・Androidも作る場合

<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="6.0.0">
   <param name="BILLING_KEY" value="MIIB...."/>
</gap:plugin>

機能

consumable purchases (e.g. virtual currencies)
non consumable purchases (e.g. features unlocking)
paid and free subscriptions
receipts validation
restoring of purchases made on other devices
downloadable content (iOS)

サポート端末

iOS 6.0以上
Android 2.2 (APIレベル8)以上、Google Play 3.9.16以上
Windows Store/Phone 8.1以上

Minimam Exsample


// We must wait for the "deviceready" event to fire
// before we can use the store object.
document.addEventListener('deviceready', initializeStore, false);

function initializeStore() {

    // 多くのものをみるために、高い冗長レベルで設定
    // コンソール内で (何が起きているかわかるので)
    store.verbosity = store.INFO;

    // ダミー商品を登録
    store.register({
        id:    "com.example.app.inappid1",
        alias: "100 coins",
        type:  store.CONSUMABLE
    });

    // Storeを準備完了にする
    store.ready(function() {
        console.log("\\o/ STORE READY \\o/");
    });

    // セットアップが終わったらリフレッシュする
    store.refresh();
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2