• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SkuManager类的典型用法和代码示例

java 2次浏览

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

SkuManager类属于org.onepf.oms包,在下文中一共展示了SkuManager类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

点赞 3

import org.onepf.oms.SkuManager; //导入依赖的package包/类
public static void init() {
        STORE_KEYS_MAP = new HashMap<>();
        STORE_KEYS_MAP.put(OpenIabHelper.NAME_GOOGLE, InAppConfig.GOOGLE_PLAY_KEY);
//        STORE_KEYS_MAP.put(OpenIabHelper.NAME_AMAZON,
//                "Unavailable. Amazon doesn't support RSA verification. So this mapping is not needed");
//        STORE_KEYS_MAP.put(OpenIabHelper.NAME_SAMSUNG,
//                "Unavailable. SamsungApps doesn't support RSA verification. So this mapping is not needed");

        // TODO: Keys are not correct for app stores
        SkuManager.getInstance()
                //Google
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_GOOGLE, "de.dsm.premium")
                .mapSku(SKU_PROFESSIONAL, OpenIabHelper.NAME_GOOGLE, "de.dsm.professional")
                //Amazon
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_AMAZON, "de.dsm.premium")
                .mapSku(SKU_PROFESSIONAL, OpenIabHelper.NAME_AMAZON, "de.dsm.professional")
                //Samsung
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_SAMSUNG, "000000000000/de.dsm.premium")
                .mapSku(SKU_PROFESSIONAL, OpenIabHelper.NAME_SAMSUNG, "000000000000/de.dsm.professional");
    }
 

开发者ID:thomashaertel,
项目名称:android-billing,
代码行数:21,
代码来源:InAppConfig.java

示例2: refreshSKUs

点赞 3

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private void refreshSKUs() {
 		// refresh the identifiers/SKUs: ensures we have the correct mapping in case PurchaseManagerConfig was updated
	if (config == null) return;
 		for (int i = 0; i < config.getOfferCount(); i++) {
		Offer offer = config.getOffer(i);

		// map store-specific identifiers with our default identifier!
		String identifier = offer.getIdentifier();
		Set<Map.Entry<String, String>> identifierForStores = offer.getIdentifierForStores();
		for (Map.Entry<String, String> entry : identifierForStores) {
			String storeNameOpenIAB = storeNameToOpenIAB(entry.getKey());
			if (storeNameOpenIAB != null) {
			    // if the store name is 'null', it doesn't belong to OpenIAB & we ignore (e.g. iOS store!)
   				String identifierForStore = entry.getValue();
   				if (!(SkuManager.getInstance().getStoreSku(storeNameOpenIAB, identifier).equals(identifierForStore))) {
   					SkuManager.getInstance().mapSku(identifier, storeNameOpenIAB, identifierForStore);
   				}
			}
		}
	}
}
 

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

示例3: processPurchasedList

点赞 3

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private void processPurchasedList(@NotNull final ArrayList<String> purchasedDataList, @NotNull final Inventory inventory) {
    Logger.i("NokiaStoreHelper.processPurchasedList");

    for (final String data : purchasedDataList) {
        try {
            final JSONObject obj = new JSONObject(data);
            final Purchase purchase = new Purchase(OpenIabHelper.NAME_NOKIA);
            purchase.setItemType(IabHelper.ITEM_TYPE_INAPP);
            purchase.setSku(SkuManager.getInstance().getSku(OpenIabHelper.NAME_NOKIA, obj.getString("productId")));
            purchase.setToken(obj.getString("purchaseToken"));
            purchase.setPackageName(getPackageName());
            purchase.setPurchaseState(0);
            purchase.setDeveloperPayload(obj.optString("developerPayload", ""));
            inventory.addPurchase(purchase);
        } catch (JSONException e) {
            Logger.e(e, "Exception: ", e);
        }
    }
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:20,
代码来源:NokiaStoreHelper.java

示例4: getSkuDetails

点赞 3

import org.onepf.oms.SkuManager; //导入依赖的package包/类
@NotNull
private SkuDetails getSkuDetails(@NotNull final Product product) {
    final String sku = product.getSku();
    final String price = product.getPrice().toString();
    final String title = product.getTitle();
    final String description = product.getDescription();
    final ProductType productType = product.getProductType();
    Logger.d(String.format("Item: %s\n Type: %s\n SKU: %s\n Price: %s\n Description: %s\n",
            title, productType, sku, price, description));

    final String openIabSkuType = productType == ProductType.SUBSCRIPTION
            ? IabHelper.ITEM_TYPE_SUBS
            : IabHelper.ITEM_TYPE_INAPP;
    final String openIabSku = SkuManager.getInstance().getSku(OpenIabHelper.NAME_AMAZON, sku);
    return new SkuDetails(openIabSkuType, openIabSku, title, price, description);
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:17,
代码来源:AmazonAppstoreBillingService.java

示例5: purchaseProduct

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private void purchaseProduct(final String sku, final String developerPayload, final CallbackContext callbackContext) {
    if (!checkInitialized(callbackContext)) return;

    Log.d(TAG, "SKU: " + SkuManager.getInstance().getStoreSku(OpenIabHelper.NAME_GOOGLE, sku));

    cordova.setActivityResultCallback(this);
    cordova.getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            _helper.launchPurchaseFlow(cordova.getActivity(), sku, RC_REQUEST, new BillingCallback(callbackContext), developerPayload);
        }
    });
}
 

开发者ID:onepf,
项目名称:OpenIAB-Cordova-Plugin,
代码行数:14,
代码来源:OpenIabCordovaPlugin.java

示例6: onConsumeFinished

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
public void onConsumeFinished(Purchase purchase, IabResult result) {
    Log.d(TAG, "Consumption finished. Purchase: " + purchase + ", result: " + result);
    purchase.setSku(SkuManager.getInstance().getSku(purchase.getAppstoreName(), purchase.getSku()));
    if (result.isFailure()) {
        Log.e(TAG, "Error while consuming: " + result);
        mCallbackContext.error(IABConst.CONSUME_PURCHASE_FAILED_CALLBACK + result.getMessage());
        return;
    }
    Log.d(TAG, "Consumption successful. Provisioning.");
    String jsonPurchase = purchase.ToJsonString();
    mCallbackContext.success(IABConst.CONSUME_PURCHASE_SUCCEEDED_CALLBACK + jsonPurchase);
}
 

开发者ID:ClausKinz,
项目名称:CommonIAB,
代码行数:13,
代码来源:CommonIAB.java

示例7: mapSku

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
/**
 * Does association between local SKU, store name and store SKU
 * It does simplification of operations between different stores(each store has own rules for SKU) and
 * application logic in your application.
 * @param sku       Local SKU(product id).
 * @param storeName Android store name, @see #ConfigIAB.StoreNameEnum
 * @param storeSku  SKU in android store
 * @return          if sku is added, resul will be returned by success callback, otherwise will be returned by
 *                  error callback
 */
public void mapSku(String sku, String storeName, String storeSku)  {
    try {
        SkuManager.getInstance().mapSku(sku, storeName, storeSku);
        mCallbackContext.success(IABConst.MAP_SKU_SUCCEEDED_CALLBACK);
    //TODO: need to change openiab implementation, remove wrong exception approuch
    } catch (Exception e) {
        Log.d(TAG, e.toString());
        mCallbackContext.error(IABConst.MAP_SKU_FAILED_CALLBACK + e.toString());
    }
}
 

开发者ID:ClausKinz,
项目名称:CommonIAB,
代码行数:21,
代码来源:CommonIAB.java

示例8: init

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
public static void init() {
        STORE_KEYS_MAP = new HashMap<>();
        STORE_KEYS_MAP.put(OpenIabHelper.NAME_GOOGLE, InAppConfig.GOOGLE_PLAY_KEY);
        STORE_KEYS_MAP.put(OpenIabHelper.NAME_YANDEX, InAppConfig.YANDEX_PUBLIC_KEY);
        STORE_KEYS_MAP.put(OpenIabHelper.NAME_APPLAND, InAppConfig.APPLAND_PUBLIC_KEY);
        STORE_KEYS_MAP.put(OpenIabHelper.NAME_SLIDEME, InAppConfig.SLIDEME_PUBLIC_KEY);
//        STORE_KEYS_MAP.put(OpenIabHelper.NAME_AMAZON,
//                "Unavailable. Amazon doesn't support RSA verification. So this mapping is not needed");
//        STORE_KEYS_MAP.put(OpenIabHelper.NAME_SAMSUNG,
//                "Unavailable. SamsungApps doesn't support RSA verification. So this mapping is not needed");

        SkuManager.getInstance()
                .mapSku(SKU_GAS, OpenIabHelper.NAME_GOOGLE, "sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_GOOGLE, "sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_GOOGLE, "sku_infinite_gas")
                //Yandex.Store
                .mapSku(SKU_GAS, OpenIabHelper.NAME_YANDEX, "org.onepf.sample.trivialdrive.sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_YANDEX, "org.onepf.sample.trivialdrive.sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_YANDEX, "org.onepf.sample.trivialdrive.sku_infinite_gas")
                        //Nokia store
                .mapSku(SKU_GAS, OpenIabHelper.NAME_NOKIA, "1290250")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_NOKIA, "1290315")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_NOKIA, "1290302")
                        //Amazon
                .mapSku(SKU_GAS, OpenIabHelper.NAME_AMAZON, "org.onepf.sample.trivialdrive.sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_AMAZON, "org.onepf.sample.trivialdrive.sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_AMAZON, "org.onepf.sample.trivialdrive.subscription.sku_infinite_gas")
                        //Appland
                .mapSku(SKU_GAS, OpenIabHelper.NAME_APPLAND, "appland.sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_APPLAND, "appland.sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_APPLAND, "appland.sku_infinite_gas") //todo check is it supported
                        //SlideME
                .mapSku(SKU_GAS, OpenIabHelper.NAME_SLIDEME, "slideme.sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_SLIDEME, "slideme.sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_SLIDEME, "slideme.sku_infinite_gas")
                        //Samsung
                .mapSku(SKU_GAS, OpenIabHelper.NAME_SAMSUNG, "100000104947/org.onepf.trivialdrivegame.sku_gas")
                .mapSku(SKU_PREMIUM, OpenIabHelper.NAME_SAMSUNG, "100000104947/org.onepf.trivialdrivegame.sku_premium")
                .mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_SAMSUNG, "100000104947/org.onepf.trivialdrivegame.sku_infinite_gas");
    }
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:41,
代码来源:InAppConfig.java

示例9: processPurchaseSuccess

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
/**
 * Called if purchase has been successful
 *
 * @param purchaseData Response code for IabResult
 */
private void processPurchaseSuccess(final String purchaseData) {
    Logger.i("NokiaStoreHelper.processPurchaseSuccess");
    Logger.d("purchaseData = ", purchaseData);

    Purchase purchase;
    try {
        final JSONObject obj = new JSONObject(purchaseData);

        final String sku = SkuManager.getInstance().getSku(OpenIabHelper.NAME_NOKIA, obj.getString("productId"));

        Logger.d("sku = ", sku);

        purchase = new Purchase(OpenIabHelper.NAME_NOKIA);

        purchase.setItemType(IabHelper.ITEM_TYPE_INAPP);
        purchase.setOrderId(obj.getString("orderId"));
        purchase.setPackageName(obj.getString("packageName"));
        purchase.setSku(sku);
        purchase.setToken(obj.getString("purchaseToken"));
        purchase.setDeveloperPayload(obj.getString("developerPayload"));

    } catch (JSONException e) {
        Logger.e(e, "JSONException: ", e);

        final IabResult result = new NokiaResult(IabHelper.IABHELPER_BAD_RESPONSE, "Failed to parse purchase data.");
        if (mPurchaseListener != null) {
            mPurchaseListener.onIabPurchaseFinished(result, null);
        }

        return;
    }

    if (mPurchaseListener != null) {
        mPurchaseListener.onIabPurchaseFinished(new NokiaResult(RESULT_OK, "Success"), purchase);
    }

}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:43,
代码来源:NokiaStoreHelper.java

示例10: processDetailsList

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private void processDetailsList(@NotNull final List<String> detailsList, @NotNull final Inventory inventory)
        throws JSONException {

    Logger.i("NokiaStoreHelper.processDetailsList");

    for (final String detailString : detailsList) {
        final JSONObject obj = new JSONObject(detailString);
        inventory.addSkuDetails(new SkuDetails(
                IabHelper.ITEM_TYPE_INAPP,
                SkuManager.getInstance().getSku(OpenIabHelper.NAME_NOKIA, obj.getString("productId")),
                obj.getString("title"),
                obj.getString("price"),
                obj.getString("shortdescription")));
    }
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:16,
代码来源:NokiaStoreHelper.java

示例11: getPurchase

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
@NotNull
private Purchase getPurchase(@Nullable final Receipt receipt) {
    final Purchase purchase = new Purchase(OpenIabHelper.NAME_AMAZON);
    if (receipt == null) {
        return purchase;
    }

    final String storeSku = receipt.getSku();
    purchase.setSku(SkuManager.getInstance().getSku(OpenIabHelper.NAME_AMAZON, storeSku));
    purchase.setToken(receipt.getReceiptId());

    switch (receipt.getProductType()) {
        case CONSUMABLE:
            // TODO Make sure this behavior is intended
        case ENTITLED:
            purchase.setItemType(IabHelper.ITEM_TYPE_INAPP);
            Logger.d("Add to inventory SKU: ", storeSku);
            break;
        case SUBSCRIPTION:
            // TODO Make sure cancelDate is always available
            purchase.setItemType(IabHelper.ITEM_TYPE_SUBS);
            purchase.setSku(SkuManager.getInstance().getSku(OpenIabHelper.NAME_AMAZON, storeSku));
            Logger.d("Add subscription to inventory SKU: ", storeSku);
            break;
    }
    return purchase;
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:28,
代码来源:AmazonAppstoreBillingService.java

示例12: mapSku

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private void mapSku(String sku, String storeName, String storeSku) {
    SkuManager.getInstance().mapSku(sku, storeName, storeSku);
}
 

开发者ID:onepf,
项目名称:OpenIAB-Cordova-Plugin,
代码行数:4,
代码来源:OpenIabCordovaPlugin.java

示例13: handleActivityResult

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
@Override
public boolean handleActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (requestCode == options.getSamsungCertificationRequestCode()) {
        if (resultCode == Activity.RESULT_OK) {
            bindIapService();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            setupListener.onIabSetupFinished(new IabResult(IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED,
                    "Account certification canceled"));
        } else {
            setupListener.onIabSetupFinished(new IabResult(IabHelper.BILLING_RESPONSE_RESULT_ERROR,
                    "Unknown error. Result code: " + resultCode));
        }
        return true;
    }
    if (requestCode != mRequestCode) {
        return false;
    }
    int errorCode = IabHelper.BILLING_RESPONSE_RESULT_ERROR;
    String errorMsg = "Unknown error";
    Purchase purchase = new Purchase(OpenIabHelper.NAME_SAMSUNG);
    if (data != null) {
        Bundle extras = data.getExtras();
        if (extras != null) {
            int statusCode = extras.getInt(KEY_NAME_STATUS_CODE);
            errorMsg = extras.getString(KEY_NAME_ERROR_STRING);
            String itemId = extras.getString(KEY_NAME_ITEM_ID);
            switch (resultCode) {
                case Activity.RESULT_OK:
                    switch (statusCode) {
                        case IAP_ERROR_NONE:
                            errorCode = IabHelper.BILLING_RESPONSE_RESULT_OK;
                            break;
                        case IAP_ERROR_ALREADY_PURCHASED:
                            errorCode = IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED;
                            break;
                        case IAP_ERROR_PRODUCT_DOES_NOT_EXIST:
                            errorCode = IabHelper.BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE;
                            break;
                    }
                    break;
                case Activity.RESULT_CANCELED:
                    errorCode = IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED;
                    break;
            }
            String purchaseData = extras.getString(KEY_NAME_RESULT_OBJECT);
            try {
                JSONObject purchaseJson = new JSONObject(purchaseData);

                purchase.setOriginalJson(purchaseData);
                purchase.setOrderId(purchaseJson.getString(JSON_KEY_PAYMENT_ID));
                purchase.setPurchaseTime(Long.parseLong(purchaseJson.getString(JSON_KEY_PURCHASE_DATE)));
                purchase.setToken(purchaseJson.getString(JSON_KEY_PURCHASE_ID));
            } catch (JSONException e) {
                Logger.e("JSON parse error: ", e);
            }

            purchase.setItemType(purchasingItemType);
            purchase.setSku(SkuManager.getInstance().getSku(OpenIabHelper.NAME_SAMSUNG, mItemGroupId + '/' + itemId));
            purchase.setPackageName(activity.getPackageName());
            purchase.setPurchaseState(0);
            purchase.setDeveloperPayload(mExtraData);
        }
    }
    Logger.d("Samsung result code: ", errorCode, ", msg: ", errorMsg);
    mPurchaseListener.onIabPurchaseFinished(new IabResult(errorCode, errorMsg), purchase);
    return true;
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:68,
代码来源:SamsungAppsBillingService.java

示例14: processItemsBundle

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
private boolean processItemsBundle(@Nullable Bundle itemsBundle, String itemGroupId, @NotNull Inventory inventory, boolean querySkuDetails, boolean addPurchase, boolean addConsumable, @Nullable Set<String> queryItemIds) {
    if (itemsBundle == null || itemsBundle.getInt(KEY_NAME_STATUS_CODE) != IAP_ERROR_NONE) {
        return false;
    }

    ArrayList<String> nameResults = itemsBundle.getStringArrayList(KEY_NAME_RESULT_LIST);
    for (String nameResult : nameResults) {
        try {
            JSONObject item = new JSONObject(nameResult);
            String itemId = item.getString(JSON_KEY_ITEM_ID);
            if (queryItemIds == null || queryItemIds.contains(itemId)) {
                String rawType = item.getString(JSON_KEY_TYPE);
                // Do not add consumable item into inventory
                if (rawType.equals(ITEM_TYPE_CONSUMABLE) && !addConsumable) {
                    continue;
                }
                String itemType = rawType.equals(ITEM_TYPE_SUBSCRIPTION) ? IabHelper.ITEM_TYPE_SUBS : IabHelper.ITEM_TYPE_INAPP;

                if (addPurchase) {
                    Purchase purchase = new Purchase(OpenIabHelper.NAME_SAMSUNG);
                    purchase.setItemType(itemType);
                    purchase.setSku(SkuManager.getInstance()
                            .getSku(OpenIabHelper.NAME_SAMSUNG, itemGroupId + '/' + itemId));
                    purchase.setPackageName(activity.getPackageName());
                    purchase.setPurchaseState(0);
                    purchase.setDeveloperPayload("");

                    purchase.setOrderId(item.getString(JSON_KEY_PAYMENT_ID));
                    purchase.setPurchaseTime(Long.parseLong(item.getString(JSON_KEY_PURCHASE_DATE)));
                    purchase.setToken(item.getString(JSON_KEY_PURCHASE_ID));

                    inventory.addPurchase(purchase);
                }
                if (!addPurchase || querySkuDetails) {
                    String name = item.getString(JSON_KEY_ITEM_NAME);
                    String price = item.getString(JSON_KEY_ITEM_PRICE_STRING);
                    String desc = item.getString(JSON_KEY_ITEM_DESC);
                    inventory.addSkuDetails(new SkuDetails(itemType,
                            SkuManager.getInstance().getSku(OpenIabHelper.NAME_SAMSUNG, itemGroupId + '/' + itemId),
                            name, price, desc));
                }
            }
        } catch (JSONException e) {
            Logger.e("JSON parse error", e);
        }
    }
    return nameResults.size() == ITEM_RESPONSE_COUNT;
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:49,
代码来源:SamsungAppsBillingService.java

示例15: queryPurchases

点赞 2

import org.onepf.oms.SkuManager; //导入依赖的package包/类
int queryPurchases(@NotNull Inventory inv, String itemType) throws JSONException, RemoteException {
    // Query purchases
    Logger.d("Querying owned items, item type: ", itemType);
    Logger.d("Package name: ", getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;

    do {
        Logger.d("Calling getPurchases with continuation token: ", continueToken);
        if (mService == null) {
            Logger.d("getPurchases() failed: service is not connected.");
            return BILLING_RESPONSE_RESULT_ERROR;
        }
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), itemType, continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        Logger.d("Owned items response: ", response);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            Logger.d("getPurchases() failed: ", getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            Logger.e("In-app billing error: Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            String sku = ownedSkus.get(i);

            if (isValidDataSignature(mSignatureBase64, purchaseData, signature)) {
                Logger.d("Sku is owned: ", sku);
                Purchase purchase = new Purchase(itemType, purchaseData, signature, appstore.getAppstoreName());
                String storeSku = purchase.getSku();
                purchase.setSku(SkuManager.getInstance().getSku(appstore.getAppstoreName(), storeSku));

                if (TextUtils.isEmpty(purchase.getToken())) {
                    Logger.w("In-app billing warning: BUG: empty/null token!");
                    Logger.d("Purchase data: ", purchaseData);
                }

                // Record ownership and token
                inv.addPurchase(purchase);
            } else {
                Logger.w("In-app billing warning: Purchase signature verification **FAILED**. Not adding item.");
                Logger.d("   Purchase data: ", purchaseData);
                Logger.d("   Signature: ", signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        Logger.d("Continuation token: ", continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}
 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:65,
代码来源:IabHelper.java

示例16: queryPurchases

点赞 1

import org.onepf.oms.SkuManager; //导入依赖的package包/类
int queryPurchases(@NotNull Inventory inv, String itemType) throws JSONException, RemoteException {
        // Query purchases
        Logger.d("Querying owned items, item type: ", itemType);
        Logger.d("Package name: ", getPackageName());
        boolean verificationFailed = false;
        String continueToken = null;

        do {
            Logger.d("Calling getPurchases with continuation token: ", continueToken);
            if (mService == null) {
                Logger.d("getPurchases() failed: service is not connected.");
                return RESULT_ERROR;
            }
            Bundle ownedItems = mService.getPurchases(1, getPackageName(), itemType, continueToken);

            int response = getResponseCodeFromBundle(ownedItems);
            Logger.d("Owned items response: ", response);
            if (response != RESULT_OK) {
                Logger.d("getPurchases() failed: ", getResponseDesc(response));
                return response;
            }
            if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                    || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                    || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
                Logger.e("In-app billing error: Bundle returned from getPurchases() doesn't contain required fields.");
                return IABHELPER_BAD_RESPONSE;
            }

            ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
            ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = purchaseDataList.get(i);
                String signature = signatureList.get(i);
                String sku = ownedSkus.get(i);

                if (isValidDataSignature(mSignatureBase64, purchaseData, signature)) {
                    Logger.d("Sku is owned: ", sku);
                    Purchase purchase = new Purchase(itemType, purchaseData, signature, mAppstore.getAppstoreName());
                    String storeSku = purchase.getSku();
                    purchase.setSku(SkuManager.getInstance().getSku(mAppstore.getAppstoreName(), storeSku));

                    if (TextUtils.isEmpty(purchase.getToken())) {
                        Logger.w("In-app billing warning: BUG: empty/null token!");
                        Logger.d("Purchase data: ", purchaseData);
                    }

                    // Record ownership and token
                    inv.addPurchase(purchase);
                } else {
                    Logger.w("In-app billing warning: Purchase signature verification **FAILED**. Not adding item.");
                    Logger.d("   Purchase data: ", purchaseData);
                    Logger.d("   Signature: ", signature);
                    verificationFailed = true;
                }
            }

            continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
            Logger.d("Continuation token: ", continueToken);
        } while (!TextUtils.isEmpty(continueToken));

        return verificationFailed ? IABHELPER_VERIFICATION_FAILED : RESULT_OK;
    } 

开发者ID:onepf,
项目名称:OpenIAB,
代码行数:65,
代码来源:SkubitIabHelper.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)