• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PurchaseUpdatesResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazon.device.iap.model.PurchaseUpdatesResponse的典型用法代码示例。如果您正苦于以下问题:Java PurchaseUpdatesResponse类的具体用法?Java PurchaseUpdatesResponse怎么用?Java PurchaseUpdatesResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PurchaseUpdatesResponse类属于com.amazon.device.iap.model包,在下文中一共展示了PurchaseUpdatesResponse类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
                }
            }
        }
    }
}
 
开发者ID:eggheadgames,项目名称:android-in-app-payments,代码行数:22,代码来源:AmazonBillingListener.java


示例2: onPurchaseUpdatesResponse

import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入依赖的package包/类
@Override
public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse response) {

    if (response.getRequestId().equals(mAlreadyPurchasedRequestId)) {
        for (Receipt receipt: response.getReceipts()) {
            if (receipt.getSku().equals(mAlreadyPurchasedProductId)) {

                final PurchaseCallback callback = mPurchaseCallbacks.get(response.getRequestId());
                if (callback != null) {
                    mPurchaseCallbacks.remove(response.getRequestId());
                }

                validatePurchase(receipt, response.getUserData().getUserId(), callback);
            }
        }
        mAlreadyPurchasedProductId = null;
        mAlreadyPurchasedRequestId = null;
    }
}
 
开发者ID:ludei,项目名称:atomic-plugins-inapps,代码行数:20,代码来源:AmazonInAppService.java


示例3: 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;
    }
}
 
开发者ID:onepf,项目名称:OPFIab,代码行数:25,代码来源:AmazonBillingProvider.java


示例4: getInventory

import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入依赖的package包/类
@NonNull
public static Collection<Purchase> getInventory(
        @NonNull final PurchaseUpdatesResponse response) {

    final List<Receipt> receipts = response.getReceipts();
    final Collection<Purchase> purchases = new ArrayList<>(receipts.size());
    for (final Receipt receipt : receipts) {
        final Purchase purchase = convertPurchase(receipt);
        if (purchase != null) {
            purchases.add(purchase);
        }
    }

    return purchases;
}
 
开发者ID:onepf,项目名称:OPFIab,代码行数:16,代码来源:AmazonUtils.java


示例5: 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();
    }
}
 
开发者ID:onepf,项目名称:OpenIAB,代码行数:37,代码来源:AmazonAppstoreBillingService.java


示例6: 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;
        }

    }
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:65,代码来源:PurchaseManagerAndroidAmazon.java


示例7: onPurchaseUpdatesResponse

import com.amazon.device.iap.model.PurchaseUpdatesResponse; //导入依赖的package包/类
@Override
public void onPurchaseUpdatesResponse(
        @NonNull final PurchaseUpdatesResponse purchaseUpdatesResponse) {
    OPFIab.post(purchaseUpdatesResponse);
}
 
开发者ID:onepf,项目名称:OPFIab,代码行数:6,代码来源:AmazonBillingHelper.java



注:本文中的com.amazon.device.iap.model.PurchaseUpdatesResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GraphEdge类代码示例发布时间:2022-05-22
下一篇:
Java EventDeserializer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap