メインコンテンツまでスキップ

Prime31 から AndApp IAP への移行ガイド

概要​

Android 向けの Prime31 In App Billing Plugin の処理を AndApp IAP フローに置き換えるための移行ガイドです。Prime31 から AndApp IAP へ移行する際には本ガイドを参考にしてください。

Prime31 In App Billing Plugin と AndApp IAP の処理の対比として記載しています。

処理Prime31 In App Billing PluginAndApp IAP
初期化、決済可能チェック

QueryInventoryGoogleIAB.init

GoogleIABEventListener.billingSupportedEvent

GoogleIABEventListener.billingNotSupportedEvent

AndApp.Payment.IsBillingSupported

プロダクト情報&

購入済みプロダクト問い合わせ

GoogleIAB.queryInventory

GoogleIABEventListener.queryInventorySucceededEvent
GoogleIABEventListener.queryInventoryFailedEvent

AndApp.Payment.GetProducts

AndApp.Payment.GetPurchases

 

決済処理

GoogleIAB.purchaseProduct

GoogleIABEventListener.purchaseSucceededEvent

GoogleIABEventListener.purchaseFailedEvent

AndApp.Payment.RequestPurchase
AndApp.Payment.PurchaseSucceededEvent
AndApp.Payment.PurchaseFailedEvent
消費処理

GoogleIAB.consumeProduct / GoogleIAB.consumeProducts

GoogleIABEventListener.consumePurchaseSucceededEvent

GoogleIABEventListener.consumePurchaseFailedEvent

AndApp.Payment.ConsumePurchase

初期化、決済可能チェック​

Prime31 In App Billing Plugin​

void Start(){
string publicKey = "";
GoogleIAB.init (publicKey);
GoogleIABManager.billingSupportedEvent += billingSupportedEvent;
GoogleIABManager.billingNotSupportedEvent += billingNotSupportedEvent;
}
void billingSupportedEvent(){
//決済利用可能時
}

void billingNotSupportedEvent(string error){
// 決済利用不可時
}

AndApp IAP​

void Start(){
// 初期化はAndApp.SDK.Initializeの呼び出しによって行われます
// SDK の初期化完了後に決済モジュールの初期化を行ってください
if(AndApp.Payment.IsBillingSupported){
// 決済利用可能時
}else{
// 決済利用不可時
}
}

プロダクト情報、購入済みプロダクト問い合わせ​

Prime31 In App Billing Plugin​

void QueryInventory(){
string[] skus = { "pid100", "pid500", "pid1000" };
GoogleIAB.queryInventory(skus);
GoogleIABManager.queryInventorySucceededEvent += queryInventorySucceededEvent;
GoogleIABManager.queryInventoryFailedEvent += queryInventoryFailedEvent;
}
 
void queryInventorySucceededEvent(List<GooglePurchase> purchases, List<GoogleSkuInfo> skus )){
// puchases に購入済みプロダクト
// skus にプロダクト情報
}
void queryInventoryFailedEvent( string error ) {
// エラー発生時
}

AndApp IAP​

void QueryInventory(){
string[] productIds = { "pid100", "pid500", "pid1000" };
AndApp.Payment.GetProducts (productIds, (products, error) => {
// products にプロダクト情報
AndApp.Payment.GetPurchases(productIds, (purchases, errorPurchase) => {
// purchases に購入済みプロダクト
});
});
}

決済処理​

Prime31 In App Billing Plugin​

void PurchaseProduct() {
GoogleIABManager.purchaseSucceededEvent += purchaseSucceededEvent;
GoogleIABManager.purchaseFailedEvent += purchaseFailedEvent;
GoogleIAB.purchaseProduct (productId);
}
void purchaseSucceededEvent(GooglePurchase purchase) {
// 支払い完了時
}

void purchaseFailedEvent(string error) {
// エラー発生時
}

AndApp IAP​

void purchaseProduct() {
AndApp.Payment.PurchaseSucceededEvent += OnPurchaseSucceeded;
AndApp.Payment.PurchaseFailedEvent += OnPurchaseFailed;

AndApp.Payment.RequestPurchase (productId, (error) => {
// 支払いはまだ確定していないものの、 支払い手続きが完了し、UI が閉じたタイミングで呼ばれます
});
}

void OnPurchaseSucceeded (AndApp.Purchase purchase) {
// 支払い完了時
sendReceipt(purchase.Receipt);
}

void OnPurchaseFailed (AndApp.Error error){
// エラー発生時
}

消費処理​

Prime31 In App Billing Plugin​

void ConsumePurchase(string productId) {
GoogleIAB.consumeProduct(productId);
GoogleIABManager.purchaseSucceededEvent += consumePurchaseSucceededEvent;
GoogleIABManager.purchaseFailedEvent += consumePurchaseFailedEvent;
}
void consumePurchaseSucceededEvent( GooglePurchase purchase ) {
// 消費リクエストが成功した場合
}
void consumePurchaseFailedEvent( string error ) {
// 消費リクエスト時にエラーが発生した場合
}

AndApp IAP​

void ConsumePurchase(string productId){
AndApp.Payment.ConsumePurchase(productId, (AndApp.Error error) => {
if(error == null){
// 消費リクエストが成功した場合
} else {
// 消費リクエスト時にエラーが発生した場合
}
});
}

更新履歴​

  • 2016/06/06
    • 新規作成