Created
March 18, 2015 00:58
-
-
Save yalab/76576966c9475aa2510e to your computer and use it in GitHub Desktop.
cocos2d-x でピンポイントに GooglePlay の課金を消費させる関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void clearPurchases() { | |
mHelper = new IabHelper(getContext(), "GOOGLE_TOKEN"); | |
mHelper.enableDebugLogging(true); | |
Log.v(TAG, "mHelper.startSetup"); | |
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { | |
public void onIabSetupFinished(IabResult result) { | |
if (!result.isSuccess()) { | |
// 失敗した時の処理 | |
} | |
List additionalSkuList = new ArrayList(); | |
additionalSkuList.add("IAP_ID"); | |
mHelper.queryInventoryAsync(true, additionalSkuList, new IabHelper.QueryInventoryFinishedListener() { | |
public void onQueryInventoryFinished(IabResult result, Inventory inventory) { | |
if (result.isFailure()) { | |
// エラー時のハンドリング | |
return; | |
} | |
Purchase purchase = inventory.getPurchase("IAP_ID"); | |
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = | |
new IabHelper.OnConsumeFinishedListener() { | |
public void onConsumeFinished(Purchase purchase, IabResult result) { | |
if (result.isSuccess()) { | |
Log.v(TAG, "consume Success" + purchase.getSku()); | |
} | |
else { | |
Log.v(TAG, "consume failure" + purchase.getSku()); | |
} | |
} | |
}; | |
mHelper.consumeAsync(purchase, mConsumeFinishedListener); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment