MIT License

项目介绍

bufferapp/ReactivePlayBilling 是一个托管在 GitHub 上的开源项目,主要使用 Kotlin 编写,采用 MIT License 许可证,目前获得 116 个 Star、11 次 Fork。

仓库全名
bufferapp/ReactivePlayBilling
开源许可证
MIT License
Star 数
116
Fork 数
11
未关闭 Issue
2

README 摘要

Reactive Play Billing This project acts us a simple wrapper for the Play Billing Library from Google for Android. This allows you to interact with the library in a reactive manner and use it within your reactive streams. Functionality Reactive Play Billing currently supports most of the operations that you will find within the library itself. Connecting to Play Billing You can connect to Play Billing by using the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

ReactivePlayBilling 用什么语言开发?

主要使用 Kotlin 编写,采用 MIT License 许可证,目前有 116 个 Star。

ReactivePlayBilling 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 ReactivePlayBilling 的源码?

可以直接克隆仓库:git clone https://github.com/bufferapp/ReactivePlayBilling.git,默认分支为 main;安装与运行步骤见仓库 README。

ReactivePlayBilling 最近还在维护吗?

仓库最近一次更新为 2020年6月23日,当前有 2 个未关闭 Issue;Star 数为 116,可作为社区活跃度的参考。

关于

An RxJava wrapper for the Google Play Billing Library

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

语言占比

Kotlin

README

Reactive Play Billing

This project acts us a simple wrapper for the Play Billing Library from Google for Android. This allows you to interact with the library in a reactive manner and use it within your reactive streams.

Functionality

Reactive Play Billing currently supports most of the operations that you will find within the library itself.

Connecting to Play Billing

You can connect to Play Billing by using the connect() method and subscribing to changes in the connection status.

reactiveBilling.connect()
        .subscribe({
                // Play billing connection successful
        }, {
                // Play billing connection failed / disconnected
        })

Observing purchase changes

You can observe purchase change by using the observePurchaseUpdates() method. This will be called when the user purchases and item / subscription to provide you with the status of the change. You must subbscribe to this method if you are carrying our purchases.

reactiveBilling.observePurchaseUpdates()
        .subscribe({
                // Purchase complete, handle result
        }, {
                // Purchase failed, handle result
        })

Querying in-app items for purchase

You can query items that are available for purchase using the queryItemsForPurchase() method. When calling, you need to pass in a list of SKU ids that you wish to retrieve the details for. If successful this will return you a list of SkuDetail instances. Otherwise, a QueryItemsForPurchaseError will be returned.

reactiveBilling.queryItemsForPurchase(skuList)
        .subscribe({
                // Handle items returned
        }, {
                // Handle item retrieval failure
        })

Querying subscriptions for purchase

You can query subscriptions that are available for purchase using the querySubscriptionsForPurchase() method. When calling, you need to pass in a list of SKU ids that you wish to retrieve the details for. If successful this will return you a list of SkuDetail instances. Otherwise, a QueryItemsForSubscriptionError will be returned.

reactiveBilling.querySubscriptionsForPurchase(skuList)
        .subscribe({
                // Handle items returned
        }, {
                // Handle item retrieval failure
        })

Purchasing an in-app Item

You can purchase in-app items by calling the purchaseItem() method. When calling this you need to pass in the SKU of the item which you wish to perform the purchase request on, followed by a reference to the current activity - this is required for activity result events.

A succesfull request will return an instance of the PurchaseResponse class. An unsuccessful request will return an ItemsForPurchaseQueryError.

reactiveBilling.purchaseItem(sku, activity)
        .subscribe({
                // Handle purchase success
        }, {
                // Handle purchase failure
        })

Purchasing a subscription

You can purchase subcsriptions by calling the purchaseSubscription() method. When calling this you need to pass in the SKU of the subscription which you wish to perform the purchase request on, followed by a reference to the current activity - this is required for activity result events.

A succesfull request will return an instance of the SubscriptionResponse class. An unsuccessful request will return an SubscriptionError.

reactiveBilling.purchaseSubscription(sku, activity)
        .subscribe({
                // Handle subscription success
        }, {
                // Handle subscription failure
        })

Querying purchases

You can query previous purchases for the current user by using the queryPurchaseHistory() observable. This will return you a list of Purchase instances upona successful request, but a QueryPurchasesError if the request fails.

reactiveBilling.queryPurchaseHistory()
        .subscribe({
                // Handle purchase history
        }, {
                // Handle failure
        })

Querying subscriptions

You can query subscriptions for the current user by using the querySubscriptionHistory() observable. This will return you a list of Purchase instances upona successful request, but a QuerySubscriptionsError if the request fails.

reactiveBilling.querySubscriptionHistory()
        .subscribe({
                // Handle purchase history
        }, {
                // Handle failure
        })

Consuming a purchase

You can consume an item that has been purchases by using consumeItem(). When calling this you need to pass in a reference to the purchase token for the desired item. A successful call will return a ConsumptionResponse instance and upon a failure a ConsumptionError will be returned.

reactiveBilling.consumePurchase()
        .subscribe({
                // Handle consumption success
        }, {
                // Handle consumption failure
        })

Installing

Until we get this onto maven central (we will do once the library has had some more usage for a v1 release) you will need to use Jitpack. This can be done like so:

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
dependencies {
    compile 'com.github.bufferapp:ReactivePlayBilling:-SNAPSHOT'
}

评论

暂无评论