本文整理汇总了Java中com.amazon.device.iap.model.PurchaseUpdatesResponse.getRequestStatus方法的典型用法代码示例。如果您正苦于以下问题:Java PurchaseUpdatesResponse.getRequestStatus方法的具体用法?Java PurchaseUpdatesResponse.getRequestStatus怎么用?Java PurchaseUpdatesResponse.getRequestStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazon.device.iap.model.PurchaseUpdatesResponse
的用法示例。
在下文中一共展示了PurchaseUpdatesResponse.getRequestStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPurchaseUpdatesResponse
import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入方法依赖的package包/类
@SuppressWarnings({"ConstantConditions", "ToArrayCallWithZeroLengthArrayArgument"})
@Override
public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse response) {
logDebug("onPurchaseUpdatesResponse " + response.getRequestStatus());
if (response == null)
return;
if (response.getRequestStatus() == PurchaseUpdatesResponse.RequestStatus.SUCCESSFUL) {
Receipt[] receipts = response.getReceipts().toArray(new Receipt[0]);
for (Receipt receipt : receipts) {
if (receipt != null && !receipt.isCanceled()) {
if (receipt.getProductType() == ProductType.ENTITLED) {
amazonBillingService.productOwned(receipt.getSku(), true);
logDebug("onPurchaseUpdatesResponse productOwned: " + receipt.getSku());
} else if (receipt.getProductType() == ProductType.SUBSCRIPTION) {
amazonBillingService.subscriptionOwned(receipt.getSku(), true);
logDebug("onPurchaseUpdatesResponse subscriptionOwned: " + receipt.getSku());
}
}
}
}
}
示例2: onEventAsync
import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入方法依赖的package包/类
/**
* Handles inventory response from Amazon.
*
* @param response Response to handle.
*/
public void onEventAsync(@NonNull final PurchaseUpdatesResponse response) {
final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();
switch (status) {
case SUCCESSFUL:
final Collection<Purchase> inventory = AmazonUtils.getInventory(response);
final boolean hasMore = response.hasMore();
postResponse(new InventoryResponse(SUCCESS, getName(), inventory, hasMore));
break;
case FAILED:
case NOT_SUPPORTED:
OPFLog.e("Purchase updates request failed: %s", response);
postResponse(new InventoryResponse(handleFailure(), getName()));
break;
default:
OPFLog.e("Unknown status: " + status);
postResponse(new InventoryResponse(UNKNOWN_ERROR, getName()));
break;
}
}
示例3: onPurchaseUpdatesResponse
import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入方法依赖的package包/类
@Override
public void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse purchaseUpdatesResponse) {
final PurchaseUpdatesResponse.RequestStatus requestStatus = purchaseUpdatesResponse.getRequestStatus();
final RequestId requestId = purchaseUpdatesResponse.getRequestId();
Logger.d("onPurchaseUpdatesResponse() reqStatus: ", requestStatus,
"reqId: ", requestId);
switch (requestStatus) {
case SUCCESSFUL:
for (final String sku : inventory.getAllOwnedSkus()) {
inventory.erasePurchase(sku);
}
final UserData userData = purchaseUpdatesResponse.getUserData();
final String userId = userData.getUserId();
if (!userId.equals(currentUserId)) {
Logger.w("onPurchaseUpdatesResponse() Current UserId: ", currentUserId,
", purchase UserId: ", userId);
break;
}
for (final Receipt receipt : purchaseUpdatesResponse.getReceipts()) {
inventory.addPurchase(getPurchase(receipt));
}
if (purchaseUpdatesResponse.hasMore()) {
PurchasingService.getPurchaseUpdates(false);
Logger.d("Initiating Another Purchase Updates with offset: ");
return;
}
break;
case FAILED:
break;
}
final CountDownLatch countDownLatch = inventoryLatchQueue.poll();
if (countDownLatch != null) {
countDownLatch.countDown();
}
}
示例4: onPurchaseUpdatesResponse
import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入方法依赖的package包/类
/**
* This is the callback for {@link PurchasingService#getPurchaseUpdates}.
*
* You will receive Entitlement receipts from this callback.
*
*/
@Override
public void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse response) {
showMessage(LOGTYPELOG, "onPurchaseUpdatesResponse: requestId (" + response.getRequestId()
+ ") purchaseUpdatesResponseStatus ("
+ response.getRequestStatus()
+ ") userId ("
+ response.getUserData().getUserId()
+ ")");
final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();
switch (status) {
case SUCCESSFUL:
updateUserData(response.getUserData());
// for (final Receipt receipt : response.getReceipts()) {
// handleReceipt(response.getRequestId().toString(), receipt, response.getUserData());
// }
// send result to observer --------
List<Transaction> transactions = new ArrayList<Transaction>(response.getReceipts().size());
Array<Receipt> consumables = new Array<Receipt>(response.getReceipts().size());
for (int i = 0; i < response.getReceipts().size(); i++) {
Receipt receipt = response.getReceipts().get(i);
// Memoize consumables for later check
if (receipt.getProductType() == ProductType.CONSUMABLE)
consumables.add(receipt);
transactions.add(AmazonTransactionUtils.convertReceiptToTransaction(i, response.getRequestId().toString(), receipt, response.getUserData()));
}
// send inventory to observer
observer.handleRestore(transactions.toArray(new Transaction[transactions.size()]));
// Automatically consume consumables if this was not previously the case
for (int i = 0; i < consumables.size; i++) {
Receipt consumable = consumables.get(i);
PurchasingService.notifyFulfillment(consumable.getReceiptId(), FulfillmentResult.FULFILLED);
}
//---- check if there are more receipts -------
if (response.hasMore()) {
PurchasingService.getPurchaseUpdates(false);
}
break;
case FAILED:
showMessage(LOGTYPEERROR, "onPurchaseUpdatesResponse: FAILED, should retry request");
observer.handleRestoreError(new Throwable("onPurchaseUpdatesResponse: FAILED, should retry request"));
break;
case NOT_SUPPORTED:
showMessage(LOGTYPEERROR, "onPurchaseUpdatesResponse: NOT_SUPPORTED, should retry request");
observer.handleRestoreError(new Throwable("onPurchaseUpdatesResponse: NOT_SUPPORTED, should retry request"));
break;
}
}