Skip to main content

Android

This method should be called to complete a purchase when a user has selected a product. The developers should tell the product type before calling this method and then pass the productType to complete the purchase.

Market.getInstance().purchaseProduct(ProductDetailActivity.this, mProduct, new InitiatePurchaseListener() {
@Override
public void onVerifying(boolean isVerifying) {
// Callback of onging verification in the backend
}

@Override
public void onPurchaseSuccess(MTGPurchase purchase) {
//Purchase success callback
}

@Override
public void onOwnedGoods(MTGPurchase purchase) {
//Purchased status callback
}

@Override
public void onPurchaseError(int errorCode) {
//Callback of abnormal purchases
}
});

Parameters:

  • product: Products to be purchased

Consumption

Description:

The paymentType for INAPP products is 2 and there is no need to use this interface for subscription products. If the purchased INAPP products are not consumed, then cannot be purchased again until they are consumed.

Market.getInstance().consumePurchaseFlow(purchase, new ConsumeResponseListener() {
@Override
public void onConsumeResponse(int resultCode) {
if(resultCode == Types.BillingResponseCode.OK){
BillingLog.i(TAG , "consumeMembership Success -" + purchase.getProductId());
}
}
});

Parameters:

  • purchase: MTGPurchase type. Please choose the corresponding purchase value according to the products you need.

Next Steps

Restoring Purchases