{"id":19146675,"url":"https://github.com/tslamic/premiumer","last_synced_at":"2025-04-15T21:23:34.786Z","repository":{"id":57723740,"uuid":"44012469","full_name":"tslamic/premiumer","owner":"tslamic","description":"Premiumer makes removing ads with a single in-app purchase on Android as easy as pie.","archived":false,"fork":false,"pushed_at":"2017-09-17T16:00:44.000Z","size":150,"stargazers_count":153,"open_issues_count":1,"forks_count":22,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T01:24:17.217Z","etag":null,"topics":["android","billing","billing-service","iap","purchase"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tslamic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-10T13:50:43.000Z","updated_at":"2024-04-15T00:55:01.000Z","dependencies_parsed_at":"2022-09-14T02:01:16.985Z","dependency_job_id":null,"html_url":"https://github.com/tslamic/premiumer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslamic%2Fpremiumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslamic%2Fpremiumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslamic%2Fpremiumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslamic%2Fpremiumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tslamic","download_url":"https://codeload.github.com/tslamic/premiumer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155161,"owners_count":21221550,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","billing","billing-service","iap","purchase"],"created_at":"2024-11-09T07:47:41.911Z","updated_at":"2025-04-15T21:23:34.754Z","avatar_url":"https://github.com/tslamic.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![premiumer](http://i.imgur.com/lg5cEE3.png)\n\nShowing ads in your app? Wanna offer a single in-app purchase to remove them? Premiumer does just that!\n\n[![Build Status](https://travis-ci.org/tslamic/premiumer.svg?branch=master)](https://travis-ci.org/tslamic/premiumer)\n[![codecov](https://codecov.io/gh/tslamic/premiumer/branch/master/graph/badge.svg)](https://codecov.io/gh/tslamic/premiumer)\n\n# How?\nUsing Premiumer is incredibly easy. First, add the following dependency:\n\n```groovy\ncompile 'com.github.tslamic:premiumer2:1.0'\n```\n\nThen, create an instance:\n\n```java\nPremiumer premiumer = PremiumerBuilder.with(context)\n    .sku(billingSku)\n    .listener(premiumerListnener)\n    .build();\n```\n\nNext, bind to the underlying in-app billing service. This should usually follow the `Activity` or `Fragment` lifecycle. Also, ensure `premiumer` can handle purchase results by overriding `onActivityResult`. For example:\n\n```java\n@Override protected void onStart() {\n  super.onStart();\n  premiumer.bind();\n}\n\n@Override protected void onStop() {\n  super.onStop();\n  premiumer.unbind();\n}\n\n@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n  if (!premiumer.handleActivityResult(requestCode, resultCode, data)) {\n    super.onActivityResult(requestCode, resultCode, data);\n  }\n}\n```\n\nIf the in-app billing service is availabe and `premiumer` was successfully bound, `onBillingAvailable()` will be invoked on the listener you provided in the builder, `onBillingUnavailable()` otherwise.\n\nYou're now all set! :tada:\n\nTo perform a purchase, invoke `premiumer.purchase(Activity)`. This should be the same `Activity` overriding `onActivityResult`. Just before a purchase is shipped over to in-app billing service for processing, you'll receive a `onPurchaseRequested(String)` callback.\n\nThe `String` argument is a developer-specified payload, uniquely identifying a purchase. By default, Premiumer will use a randomly generated UUID, but you can easily provide your own `PayloadGenerator` when building a Premiumer instance:\n\n```java\nPremiumerBuilder.with(context)\n    .sku(billingSku)\n    .listener(premiumerListnener)\n    .payloadGenerator(customGenerator); // custom generator\n    .build();\n```\n\nOnce a purchase is processed, the in-app billing service will return a result to the `Activity` triggering the purchase. If you've properly overriden `onActivityResult`, Premiumer will notify you what happened:\n\n| Callback | Meaning |\n| ------------: |:-------------|\n| `onPurchaseBadResult (int, Intent)` | purchase result was not OK, e.g. the user cancelled the purchase flow |\n| `onPurchaseBadResponse(Intent)` | in-app billing response was incomplete or missing information |\n| `onPurchaseFailedVerification() ` | purchase verification failed |\n| `onPurchaseSuccessful(Purchase)` | purchase succeeded |\n\nBy default, no purchase verification is done. You can change that, however, by providing a `PurchaseVerifier` instance when building Premiumer:\n\n```java\nPremiumerBuilder.with(context)\n    .sku(billingSku)\n    .listener(premiumerListnener)\n    .purchaseVerifier(verifier); // custom verifier\n    .build();\n```\n\nWhen a purchase is successful, Premiumer will, by default, store the purchase information in plain text to `SharedPreferences`. You can provide a different caching mechanism by specifying `PurchaseCache` when building Premiumer:\n\n```java\nPremiumerBuilder.with(context)\n    .sku(billingSku)\n    .listener(premiumerListnener)\n    .purchaseCache(cache); // custom cache\n    .build();\n```\n\nYou can always obtain the information about the item you're about to purchase by invoking `premiumer.skuDetails()`. This will return `onSkuDetails(SkuDetails)` callback.\n\nSimilarly, once a purchase has been made, you can retrieve it by invoking `premiumer.purchaseDetails()`. This will invoke `onPurchaseDetails(Purchase` callback.\n\nIf, for any reason, you wish to consume a purchase, invoke `premiumer.consumeSku()`. If successful, `onSkuConsumed()` will be invoked, `onFailedToConsumeSku()` otherwise.\n\n# Callbacks\n\nAs you might have guessed, all `Premiumer` interaction results in a `PremiumerListener` callback. Here's the complete list:\n\n| Method name   | Meaning      |\n| ------------: |:-------------|\n| `onShowAds()` | Invoked if ads should be visible. |\n| `onHideAds()` | Invoked if ads should be hidden. |\n| `onBillingAvailable()` | Invoked if in-app Billing is available. |\n| `onBillingUnavailable()` | Invoked if in-app Billing is unavailable. |\n| `onSkuDetails(SkuDetails)` | Invoked when `SkuDetails` information is retireved. |\n| `onSkuConsumed()` | Invoked if sku has been successfully consumed. |\n| `onFailedToConsumeSku()` | Invoked if sku has not been successfully consumed. |\n| `onPurchaseRequested(String)` | Invoked on a purchase request. |\n| `onPurchaseDetails(Purchase)` | Invoked when purchase details are retrieved. |\n| `onPurchaseSuccessful(Purchase)` | Invoked on a successful purchase. |\n| `onPurchaseBadResult(int, Intent)` | Invoked when the sku purchase is unsuccessful. |\n| `onPurchaseBadResponse(Intent)` | Invoked when the sku purchase returns bad data. |\n| `onPurchaseFailedVerification()`| Invoked if a purchase has failed verification. |\n\nIf you feel that's too much, you can cherry pick the methods by extending `SimplePremiumerListener`.\n\nContribution\n---\n\nImprovement suggestions, bug reports, pull requests, etc. are very welcome and greatly appreciated!\n\nLicense\n---\n\n\tCopyright 2017 Tadej Slamic\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t    http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftslamic%2Fpremiumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftslamic%2Fpremiumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftslamic%2Fpremiumer/lists"}