Skip to main content

Migration from Prime31 to AndApp IAP

Overview​

This document is a migration guide to replace Prime31 In-App Billing Plugin processing for Android using the AndApp IAP flow. See this guide for the transition from Prime31 to AndApp IAP.

The result of comparison between processing of Prime31 In-App Billing Plugin and processing of AndApp IAP is as follows:

Processing

Prime31 In-App Billing Plugin

AndApp IAP

Initialization, Payment support check

QueryInventoryGoogleIAB.init

GoogleIABEventListener.billingSupportedEvent

GoogleIABEventListener.billingNotSupportedEvent

AndApp.Payment.IsBillingSupported

Inquiry about product Information and

purchased product

GoogleIAB.queryInventory

GoogleIABEventListener.queryInventorySucceededEvent
GoogleIABEventListener.queryInventoryFailedEvent

AndApp.Payment.GetProducts

AndApp.Payment.GetPurchases

 

Payment Processing

GoogleIAB.purchaseProduct

GoogleIABEventListener.purchaseSucceededEvent

GoogleIABEventListener.purchaseFailedEvent

AndApp.Payment.RequestPurchase

AndApp.Payment.PurchaseSucceededEvent

AndApp.Payment.PurchaseFailedEvent

Consumption processing

GoogleIAB.consumeProduct / GoogleIAB.consumeProducts

GoogleIABEventListener.consumePurchaseSucceededEvent

GoogleIABEventListener.consumePurchaseFailedEvent

AndApp.Payment.ConsumePurchase

Initialization, Payment support check​

Prime31 In-App Billing Plugin​

void Start(){
string publicKey = "";
GoogleIAB.init (publicKey);
GoogleIABManager.billingSupportedEvent += billingSupportedEvent;
GoogleIABManager.billingNotSupportedEvent += billingNotSupportedEvent;
}
void billingSupportedEvent(){
// When Payment is supported
}

void billingNotSupportedEvent(string error){
// When Payment is not supported
}

AndApp IAP​

void Start(){
// initialization is done by calling AndApp.SDK.Initialize.
// After SDK was initialized, initialize the Payment module
if(AndApp.Payment.IsBillingSupported){
// When Payment is supported
}else{
// When Payment is not supported
}
}

Inquiry about product information and purchased product​

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 )){
// purchases: purchased product
// skus: product information
}
void queryInventoryFailedEvent( string error ) {
// when an error has occurred
}

AndApp IAP​

void QueryInventory(){
string[] productIds = { "pid100", "pid500", "pid1000" };
AndApp.Payment.GetProducts (productIds, (products, error) => {
// products: product information
AndApp.Payment.GetPurchases(productIds, (purchases, errorPurchase) => {
// purchases: purchased product
});
});
}

Payment Processing​

Prime31 In-App Billing Plugin​

void PurchaseProduct() {
GoogleIABManager.purchaseSucceededEvent += purchaseSucceededEvent;
GoogleIABManager.purchaseFailedEvent += purchaseFailedEvent;
GoogleIAB.purchaseProduct (productId);
}
void purchaseSucceededEvent(GooglePurchase purchase) {
// when payment is completed
}

void purchaseFailedEvent(string error) {
// when an error has occurred
}

AndApp IAP​

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

AndApp.Payment.RequestPurchase (productId, (error) => {
// Although Payment is not yet established, this is called when payment processing has completed and UI has closed.
});
}

void OnPurchaseSucceeded (AndApp.Purchase purchase) {
// when payment is completed
sendReceipt(purchase.Receipt);
}

void OnPurchaseFailed (AndApp.Error error){
// when an error has occurred
}

Consumption Processing​

Prime31 In-App Billing Plugin​

void ConsumePurchase(string productId) {
GoogleIAB.consumeProduct(productId);
GoogleIABManager.purchaseSucceededEvent += consumePurchaseSucceededEvent;
GoogleIABManager.purchaseFailedEvent += consumePurchaseFailedEvent;
}
void consumePurchaseSucceededEvent( GooglePurchase purchase ) {
// When a consumption request has succeeded
}
void consumePurchaseFailedEvent( string error ) {
// When an error has occurred at the time of a consumption request
}

AndApp IAP​

void ConsumePurchase(string productId){
AndApp.Payment.ConsumePurchase(productId, (AndApp.Error error) => {
if(error == null){
// When a consumption request has succeeded
} else {
// When an error has occurred at the time of a consumption request
}
});
}

Update History​

  • June 6, 2016
    • Newly created