Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Fortumo setup fails if any product is not available in the user's country #225

@codingcaveman

Description

@codingcaveman

If a product is listed in inapps_products.xml, but only available in certain countries, billing setup would fail to complete for users in unsupported countries. Setup fails even if a subset of products are available to such users. This makes it impossible to create items that are only available in certain countries, or which should be removed from sale for cultural reasons. Currently, setup is all-or-nothing.

Setup fails in FortumoBillingService.java in getFortumoInapps(), throwing a "Carrier not supported" exception. Possible solution:

static Map<String, FortumoProduct> getFortumoInapps(Context context, boolean isNook) throws IOException, XmlPullParserException, IabException {
        final Map<String, FortumoProduct> map = new HashMap<String, FortumoProduct>();
        final InappsXMLParser inappsXMLParser = new InappsXMLParser();
        final Pair<List<InappBaseProduct>, List<InappSubscriptionProduct>> parse = inappsXMLParser.parse(context);
        final List<InappBaseProduct> allItems = parse.first;
        final Map<String, FortumoProductParser.FortumoDetails> fortumoSkuDetailsMap = FortumoProductParser.parse(context, isNook);
        int itemsNotSupportedCount = 0;
        for (InappBaseProduct item : allItems) {
            final String productId = item.getProductId();
            final FortumoProductParser.FortumoDetails fortumoDetails = fortumoSkuDetailsMap.get(productId);
            if (fortumoDetails == null) {
                throw new IabException(IabHelper.IABHELPER_ERROR_BASE, "Fortumo inapp product details were not found");
            }
            final String serviceId = isNook ? fortumoDetails.getNookServiceId() : fortumoDetails.getServiceId();
            final String serviceInAppSecret = isNook ? fortumoDetails.getNookInAppSecret() : fortumoDetails.getServiceInAppSecret();
            List fetchedPriceData = MpUtils.getFetchedPriceData(context, serviceId, serviceInAppSecret);
            if (fetchedPriceData == null || fetchedPriceData.size() == 0) {
                final boolean supportedOperator = MpUtils.isSupportedOperator(context, serviceId, serviceInAppSecret);
                if (supportedOperator) {
                    fetchedPriceData = MpUtils.getFetchedPriceData(context, serviceId, serviceInAppSecret);
                } else {
                    if (isDebugLog()) {
                        Log.d(TAG, productId + " not available for this carrier" );
                    }
                    itemsNotSupportedCount++;
                    continue;
                }
            }
            String price = null;
            if (fetchedPriceData != null && !fetchedPriceData.isEmpty()) {
                price = (String) fetchedPriceData.get(0);
            }
            FortumoProduct fortumoProduct = new FortumoProduct(item, fortumoDetails, price);
            map.put(productId, fortumoProduct);
        }

        if ( itemsNotSupportedCount == allItems.size() )
        {
            throw new IabException(IabHelper.IABHELPER_ERROR_BASE, "No inventory available for this carrier/country.");
        }

        return map;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions