Giter Club home page Giter Club logo

opfiab's Introduction

Dear friends

Currently our small team doesn't have enough time to support and develop the project. I hope in the nearest future we will continue the work. Thank you!

OPFIab

Android Arsenal

OPFIab is a next step from OpenIAB. It's an Android library intended to make in-app billing integration easy while supporting multiple billing providers (Appstores).

Dependencies

Library is designed to be extensible and cosists of separate modules.

Add core dependency:

  dependencies {
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'org.onepf:opfutils:x.x.x'
    compile 'org.onepf:opfiab:x.x.x@aar'
  }

Or grab our latest release.

You'll also whant to add one or few BillingProvider modules. Check supported providers for details.

Documentation

Full documentaion is available on our wiki.

Samples

FAQ

####How is this library different from OpenIAB? Why should I bother migrating?

OPFIab is an attempt to implement universal, extensible billing library that OpenIAB should've been from the start.

Unfortunately OpenIAB has some fundamental flaws.

It carries heavy burden of legacy architecture from Google's IabHelper it was initially based on. It adopted unfinished concept of OpenStores and encapsulated a lot of different app stores in one bundle which made it really difficult to maintain.

Most notable advantages for using OPFIab:

  • Modular architecture One appstore - one module. Use only modules you need. It's easy to extend existing modules and change their behaviour if you need to.
  • Straightforward library configuration It should only be setup once and preferably from Application#onCreate since this is the only code guaranteed to be executed if app was started from BroadcastReceiver.
  • Simple listeners API Library offers one global listener to handle all billing events which is useful to save persistent changes (DataBase, SharedPreferences etc.) as well as dynamic listeners intended to simplify UI updates.
  • Overall better quality code with more android-friendly architecture and less concurrency pitfalls.

Thanks

License

Copyright 2012-2015 One Platform Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

opfiab's People

Contributors

akarimova avatar antongitname avatar romanzhilich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opfiab's Issues

Remove dependency on EventBus

I'm not sure if this is the right forum for discussing this, but I would like to propose completely removing the dependency on EventBus.

While EB is a nice library for some use cases, I disagree with the forced dependency for the following reasons:

  • The project might already be using another bus library (e.g. Otto)
  • Architecture policy might disallow event busses altogether
  • The functionality afforded by EventBus can be completely replaced with a standard Observable / Listener pattern
  • Projects which use EventBus might have problems if their EB version differs from OPFIab's
  • It's generally preferable for libraries to include as few dependencies as possible - follow the Unix principle of doing one thing and doing it well

AIDL & openStore

I'm getting this exception for yandexBillingProvider (looks like something is wrong related to AIDL).
Did I do someting wrong in my code ?
(I'm using the latest 0.4 artefacts from mavenCentral and I looked at trivialDrive to implement the skumaps..)

Caused by: java.lang.IllegalStateException: Couldn't extract Stub implementation from AIDL class.
at org.onepf.opfiab.billing.AidlBillingHelper.(AidlBillingHelper.java:101)
at org.onepf.opfiab.openstore.OpenStoreBillingHelper$OpenAppstoreHelper.(OpenStoreBillingHelper.java:211)
at org.onepf.opfiab.openstore.OpenStoreBillingHelper.(OpenStoreBillingHelper.java:56)
at org.onepf.opfiab.openstore.OpenStoreBillingProvider.(OpenStoreBillingProvider.java:84)
at org.onepf.opfiab.openstore.OpenStoreBillingProvider$Builder.build(OpenStoreBillingProvider.java:397)
at org.lakedaemon.android.InAppBuy.yandexBillingProvider(InAppBuy.kt:60)
at org.lakedaemon.android.InAppBuy.billingConfiguration(InAppBuy.kt:100)
at org.lakedaemon.dictionary.DictionaryApp.onCreate(DictionaryApp.kt:83)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4775)
            at android.app.ActivityThread.access$1600(ActivityThread.java:171)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5679)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)

OPFIab: Appropriate SKU(s) should always be available from BillingResponse

Library can't rely on static memory when handling billing request, moreover billing response is not even guaranteed by successfully handled billing request. Because of this BillingResponse only contains information returned by BillingProvider.

For more convenient API BillingResponse should contain all relevant information from corresponding BillingRequest, foremost SKU(s).

OPFIab: rename setup()

Current name OPFIab.setup() is confusing. This method should be renamed to better represents its function - picking BillingProvider.
Also this method should probably be called automatically from OPFIab.init(). However it should be possible to disable this behaviour in Configuration.

OPFIab: check process in OPFIab.init()

Current implementation might not work properly with multiprocess applications. Easiest way to work around it is probably to allow only main process to make init() call.

Amazon: Billing request handling must be blocking

AmazonBilling provider uses Service\BroadcastReceiver flow to handle requests. Current implementation is a little bit unreliable and somewhat confusing - there's no way to distinguish one purchase response from another.

Best way to workaround it is probably make billing request handling a blocking operation. However Amazon doesn't guarantee callback after posted request - there should be some failsafe so library won't get stuck waiting for callback that will never arrive.

Solution likely requires quite a bit of decompiled code reading.

Mandatory orderId field for Google provider

There is a check in dev library version, that requires purchase json to have orderId field, if library is not in debug mode.
https://github.com/onepf/OPFIab/blob/dev/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/GoogleBillingProvider.java#L164

However, in-app purchases can be tested from PlayStore Beta distribution channel, which will contain app in release build type, obviously. And google sends empty orderId for test purhases.

In that manner, test purchase can never complete in app, downloaded from Beta channel.

I think this check should be removed from library and how about you, devs?

Amazon - No Billing Provider

The library works properly with Google Play but not with the Amazon Store App.
I have downloaded the latest Amazon App and tested with my app and also the Trivial Drive.
These are the logs and results:

06-04 13:13:05.774: D/d(2307): In App Purchasing SDK - Sandbox Mode: PurchasingListener registered: org.onepf.opfiab.amazon.AmazonBillingHelper@b3486198
06-04 13:13:05.774: D/d(2307): In App Purchasing SDK - Sandbox Mode: PurchasingListener Context: org.myklos.inote.SettingsView@b33ef490
06-04 13:13:05.814: D/OPF(2307): --> SetupManager.newResponse(org.onepf.opfiab.model.event.SetupStartedEvent@b339aec0);
06-04 13:13:05.814: D/OPF(2307): --> GoogleBillingHelper.isBillingSupported();
06-04 13:13:05.814: D/OPF(2307): Can't bind to service: class com.android.vending.billing.IInAppBillingService$Stub
06-04 13:13:05.844: D/OPF(2307): Check if billing supported: null
06-04 13:13:05.844: D/OPF(2307): Package installer: null
06-04 13:13:06.094: D/OPF(2307): --> BillingEventDispatcher.onSetupResponse({
06-04 13:13:06.094: D/OPF(2307): "authorized": false,
06-04 13:13:06.094: D/OPF(2307): "status": "FAILED",
06-04 13:13:06.094: D/OPF(2307): "provider": null
06-04 13:13:06.094: D/OPF(2307): });

06-04 13:13:55.095: D/org.myklos.inote.LicenseClass(2307): Purchase
06-04 13:13:55.115: D/OPF(2307): --> BillingEventDispatcher.onResponse({
06-04 13:13:55.115: D/OPF(2307): "purchase": null,
06-04 13:13:55.115: D/OPF(2307): "provider_info": null,
06-04 13:13:55.115: D/OPF(2307): "verification_result": null,
06-04 13:13:55.115: D/OPF(2307): "type": "PURCHASE",
06-04 13:13:55.115: D/OPF(2307): "status": "NO_BILLING_PROVIDER"
06-04 13:13:55.115: D/OPF(2307): });
06-04 13:13:55.115: D/org.myklos.inote.LicenseClass(2307): PURCHASE NO_BILLING_PROVIDER

It seems the library does not detect the Amazon App installed.

The initialization of the library is as follows:

            // Init configuration
            Configuration configuration = new Configuration.Builder()
                .addBillingProvider(newGoogleProvider())
                .addBillingProvider(newAmazonProvider())
                .setBillingListener(myListener)
                .build();       

            OPFLog.setEnabled(true, true);
            OPFIab.init(mActivity.getApplication(), configuration);

                iabHelper = OPFIab.getAdvancedHelper();
                iabHelper.register();

                OPFIab.setup();

where the newAmazonProvider method is:

    private BillingProvider newAmazonProvider() {
        final MapSkuResolver skuResolver = new MapSkuResolver();
        skuResolver.add(ITEM_SKU, AMAZON_ITEM_SKU);

        return new AmazonBillingProvider.Builder(mContext)
                .setSkuResolver(skuResolver)
                .build();
    }

Please, let me know what else you need from me.
Thank you,
Jakub

verification_result

Hello,
I have a problem with test inApps. I use sku "android.test.purchased"

BaseBillingProvider.handleRequest({
    "type": "PURCHASE",
    "sku": "android.test.purchased"
    });
BillingEventDispatcher.onResponse({
    "type": "PURCHASE",
    "status": "SUCCESS",
    "provider_info": {
    "name": "Google",
    "package_name": "com.google.play",
    "installer": "com.android.vending"
    },
    "purchase": {
    "sku": "android.test.purchased",
    "type": "ENTITLEMENT",
    "provider_info": {
    "name": "Google",
    "package_name": "com.google.play",
    "installer": "com.android.vending"
    },
    "original_json": {
    "packageName": "***",
    "orderId": "transactionId.android.test.purchased",
    "productId": "android.test.purchased",
    "developerPayload": "",
    "purchaseTime": 0,
    "purchaseState": 0,
    "purchaseToken": "inapp:***:android.test.purchased"
    },
    "token": "inapp:***:android.test.purchased",
    "purchaseTime": 0,
    "canceled": false
    },
    "verification_result": "ERROR"
    });

From logs i get "Either data or signature is empty."

 private static BillingProvider newGoogleProvider() {
        final GoogleMapSkuResolver skuResolver = new GoogleMapSkuResolver();
        skuResolver.add("android.test.purchased", SkuType.ENTITLEMENT);

        return new GoogleBillingProvider.Builder(context)
                .setPurchaseVerifier(new SimpleGooglePurchaseVerifier(getPublicLicenseKey()))
                .setSkuResolver(skuResolver)
                .build();
    }

    public static Configuration getRelevantConfiguration(final Context context) {
        final Configuration.Builder builder = new Configuration.Builder();
        builder.setBillingListener(new StoreManagerListener(context));
        builder.addBillingProvider(newGoogleProvider());
        return builder.build();
    }

FragmentIabHelper does not work with native Fragments prior api 17

Hello,

The current version of FragmentIabHelperImpl does not work with native fragments (and PreferenceFragment) prior api level 17. This is because the method getChildFragmentManager() isnt available there. This makes it not possible to use this Helper in PreferenceFragment, which also lacks an official supportversion.
As a workarround I implemented the Activity version and forwarded calls to my settings fragment.

The reason why I opened this issue is because I think this should be pointed out somewhere in the wiki or javadoc. Right now, you have to read the source or find it out the hard way (by exception :p )

Regards,
danijoo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.