Skip to content

Instantly share code, notes, and snippets.

@plashchynski
Last active August 29, 2015 14:16
Show Gist options
  • Save plashchynski/93f07f40dab78d389d15 to your computer and use it in GitHub Desktop.
Save plashchynski/93f07f40dab78d389d15 to your computer and use it in GitHub Desktop.
Android Google Play In-App purchases verification in Ruby
module Android
def self.verify_purchase(receipt_data, signature)
android_inapp_public_key = Rails.application.secrets[:android_inapp_public_key]
public_key = OpenSSL::PKey::RSA.new(Base64.decode64(android_inapp_public_key))
unless public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), receipt_data)
raise "Wrong Android payment"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment