
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
android_in_app_billing
Advanced tools
Add this line to your application's Gemfile:
gem 'android_in_app_billing'
And then execute:
$ bundle
Or install it yourself as:
$ gem install android_in_app_billing
AndroidInAppBilling.configure do |config|
config.package_name = 'com.example.android'
config.json_key_path = '/path/to/a/json_key.json'
config.package_public_key = 'RSA public key'
end
purchase_data
and data_signature
are the values android app gets from a purchase request. See https://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent
purchase = AndroidInAppBilling::InappPurchase.new(data: purchase_data, signature: data_signature)
# attribute accessors:
purchase.token # => JWT token
purchase.auto_renewing # => true/false
# ... (other attributes, see `AndroidInAppBilling::InappPurchase` and the link above)
# signature validation:
purchase.signature_valid? # => true/false
To get current subscription state this gem uses android publisher v2 API
client = AndroidInAppBilling::PublisherClient.new
subscription = client.get_subscription_purchase(purchase.product_id, purchase.token)
# attribute accessors:
subscription.payment_state # => 'pending' / 'trial' / 'received'
subscription.expires_at # => some DateTime
# ... (other attributes, see `AndroidInAppBilling::SubscriptionPurchase` and the link above)
This gem provides a factory to generate raw purchase data+signature, which you can use in your tests:
require 'android_in_app_billing/testing'
# See lib/factories/raw_inapp_purchase.rb for the list of attributes
raw = build(:android_in_app_billing_raw_inapp_purchase)
# => { data: "...", signature: "..." }
# Factory signs purchase data using AndroidInAppBilling::Testing::PRIVATE_KEY.
# If you want to verify this signature, you should configure AndroidInAppBilling
# to use correspondent public key
AndroidInAppBilling.config.package_public_key = AndroidInAppBilling::Testing::PUBLIC_KEY
# Then signature verification will pass
inapp = AndroidInAppBilling::InAppPurchase.new(raw)
inapp.signature_valid? # => true
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/SPBTV/android_in_app_billing.
The gem is available as open source under the terms of the Apache 2.0 License.
FAQs
Unknown package
We found that android_in_app_billing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.