{"id":15597358,"url":"https://github.com/flagbug/saneinappbillinghandler","last_synced_at":"2025-04-24T00:42:42.602Z","repository":{"id":33565361,"uuid":"37211617","full_name":"flagbug/SaneInAppBillingHandler","owner":"flagbug","description":"A sane wrapper over the Xamarin.InAppBilling library","archived":false,"fork":false,"pushed_at":"2016-05-17T16:11:41.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T09:54:57.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/flagbug.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-06-10T17:25:01.000Z","updated_at":"2017-07-24T16:07:33.000Z","dependencies_parsed_at":"2022-09-12T17:11:15.742Z","dependency_job_id":null,"html_url":"https://github.com/flagbug/SaneInAppBillingHandler","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/flagbug%2FSaneInAppBillingHandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flagbug%2FSaneInAppBillingHandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flagbug%2FSaneInAppBillingHandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flagbug%2FSaneInAppBillingHandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flagbug","download_url":"https://codeload.github.com/flagbug/SaneInAppBillingHandler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540939,"owners_count":21447426,"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":[],"created_at":"2024-10-03T01:21:31.716Z","updated_at":"2025-04-24T00:42:42.584Z","avatar_url":"https://github.com/flagbug.png","language":"C#","readme":"# Overview\nSaneInAppBillingHandler is a sane wrapper over the [Xamarin.InAppBilling](http://components.xamarin.com/gettingstarted/xamarin.inappbilling) component. Note that you have to install the Xamarin.InAppBilling component manually from the Xamarin component store, and the [SaneInAppBillingHandler package](https://www.nuget.org/packages/SaneInAppBillingHandler/) from NuGet\n\n## Why\n\nThe Xamarin.InAppBilling API is, let's say, a bit strange to use.\n\nFor example: to buy a product through the API, you have to handle the following events:\n\n- `OnProductPurchased`\n- `OnProductPurchasedError`\n- `BuyProductError`\n- `InAppBillingProcesingError` [sic!]\n- `OnUserCanceled`\n- `OnPurchaseFailedValidation`\n\nSaneInAppBillingHandler exposes a convenient asynchronous method instead.\n\n## Quickstart\n\n### Creating the billing handler\n\n```csharp\nusing SaneInAppBillingHandler;\n\nvar handler = new SaneInAppBillingHandler(yourActivity, \"API key that you receive from Google\");\n\n// Call this method when creating your activity\ntry\n{\n  await handler.Connect();\n}\n\ncatch (InAppBillingException ex)\n{\n  // Thrown if the commection fails for whatever reason (device doesn't support In-App billing, etc.)\n  // All methods (except for Disconnect()) may throw this exception, \n  // handling it is omitted for brevity in the rest of the samples\n}\n```\n\n### Getting available purchases\n\n```csharp\n// Retrieve the product infos for \"myItem1\" and \"myItem2\" \n// (these are the IDs that you give your products in the Google Play Developer Console)\n// The second argument specifies if those products are subscriptions or normal one-time purchases\nIReadOnlyList\u003cProduct\u003e products = await handler.QueryInventory(new[]{\"myItem1\", \"myItem2\", ItemType.Product);\n```\n\n### Getting a list of products that the user has purchased\n\n```csharp\nIReadOnlyList\u003cPurchase\u003e purchases = await handler.GetPurchases(ItemType.Product);\n```\n\n### Buying a product\n\n```csharp\n// Buys the product and returns a billing result. Look this up in the BillingResult class.\nint result = await handler.BuyProduct(product);\n```\n\n### Consuming a purchase\n\n```csharp\nawait handler.ConsumePurchase(purchase);\n```\n\n### Disconnecting the handler\n\n```csharp\n// Call this method when destroying your activity\nhandler.Disconnect();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagbug%2Fsaneinappbillinghandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflagbug%2Fsaneinappbillinghandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagbug%2Fsaneinappbillinghandler/lists"}