本文整理汇总了Java中com.github.jberkel.pay.me.model.Purchase.getItemType方法的典型用法代码示例。如果您正苦于以下问题:Java Purchase.getItemType方法的具体用法?Java Purchase.getItemType怎么用?Java Purchase.getItemType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.jberkel.pay.me.model.Purchase
的用法示例。
在下文中一共展示了Purchase.getItemType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: consume
import com.github.jberkel.pay.me.model.Purchase; //导入方法依赖的package包/类
/**
* Consumes a given in-app product. Consuming can only be done on an item
* that's owned, and as a result of consumption, the user will no longer own it.
* This method may block or take long to return. Do not call from the UI thread.
* For that, see {@link #consumeAsync}.
*
* @param purchase The PurchaseInfo that represents the item to consume.
* @throws IabException if there is a problem during consumption.
*/
public void consume(Purchase purchase) throws IabException {
checkNotDisposed();
checkSetupDone("consume");
if (purchase.getItemType() != INAPP) {
throw new IabException(IABHELPER_INVALID_CONSUMPTION,
"Items of type '" + purchase.getItemType() + "' can't be consumed.");
}
try {
String token = purchase.getToken();
String sku = purchase.getSku();
if (token == null || token.equals("")) {
logError("Can't consume " + sku + ". No token.");
throw new IabException(IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: "
+ sku + " " + purchase);
}
logDebug("Consuming sku: " + sku + ", token: " + token);
int response = mService.consumePurchase(API_VERSION, mContext.getPackageName(), token);
if (response == OK.code) {
logDebug("Successfully consumed sku: " + sku);
} else {
logDebug("Error consuming consuming sku " + sku + ". " + getDescription(response));
throw new IabException(response, "Error consuming sku " + sku);
}
} catch (RemoteException e) {
throw new IabException(IABHELPER_REMOTE_EXCEPTION, "Remote exception while consuming. PurchaseInfo: " + purchase, e);
}
}