{"id":28497986,"url":"https://github.com/spreedly/gala","last_synced_at":"2025-07-11T08:33:53.417Z","repository":{"id":26045874,"uuid":"29489173","full_name":"spreedly/gala","owner":"spreedly","description":"Ruby library for decrypting Apple Pay payment tokens","archived":false,"fork":false,"pushed_at":"2023-12-15T21:16:15.000Z","size":44,"stargazers_count":41,"open_issues_count":8,"forks_count":26,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-07-03T10:39:16.179Z","etag":null,"topics":["apple-pay","payments","ruby","spreedly"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spreedly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-19T20:01:14.000Z","updated_at":"2023-03-15T14:53:05.000Z","dependencies_parsed_at":"2023-02-19T17:45:51.841Z","dependency_job_id":null,"html_url":"https://github.com/spreedly/gala","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/spreedly/gala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spreedly%2Fgala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spreedly%2Fgala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spreedly%2Fgala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spreedly%2Fgala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spreedly","download_url":"https://codeload.github.com/spreedly/gala/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spreedly%2Fgala/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264765661,"owners_count":23660609,"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":["apple-pay","payments","ruby","spreedly"],"created_at":"2025-06-08T13:30:41.127Z","updated_at":"2025-07-11T08:33:53.411Z","avatar_url":"https://github.com/spreedly.png","language":"Ruby","readme":"# Gala\n\n[![CircleCI](https://circleci.com/gh/spreedly/gala.svg?style=svg)](https://circleci.com/gh/spreedly/gala)\n\nNamed after the [Gala apple](http://en.wikipedia.org/wiki/Gala_(apple)), Gala is a Ruby library for decrypting [Apple Pay payment tokens](https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html).\n\nGala is available under the MIT License.\n\n## Ruby support\n\n* For Ruby v2.3 and below, please use the [legacy-ruby branch](https://github.com/spreedly/gala/commits/legacy-ruby), or specify gala v0.3.2.\n* For Ruby \u003e= 2.4, use the master branch or specify gala v0.4 and above\n\n## Install\n\nAdd `gala` to your `Gemfile`.\n\n```ruby\ngem \"gala\", \"~\u003e 0.4.0\"\n```\n\nIf you need to track a development branch or reference functionality not yet contained in the RubyGem release you can specify the gala repo directly.\n\n```ruby\ngem \"gala\", git: \"https://github.com/spreedly/gala.git\", ref: :master\n```\n\nThen `bundle install` to fetch Gala into your local environment.\n\n## Usage\n\nGala works by:\n\n1. Initializing an instance of `Gala::PaymentToken` with the hash of values present in the Apple Pay token string (a JSON representation of [this data](https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html)).\n2. Decrypting the token using the PEM formatted merchant certificate and private key (the latter of which, at least, is managed by a third-party such as a gateway or independent processor like [Spreedly](https://spreedly.com)).\n\n```ruby\nrequire \"gala\"\n\n# token_json = raw token string you get from your iOS app\ntoken_attrs = JSON.parse(token_json)\ntoken = Gala::PaymentToken.new(token_attrs)\n\ncertificate_pem = File.read(\"mycert.pem\")\nprivate_key_pem = File.read(\"private_key.pem\")\n\ndecrypted_json = token.decrypt(certificate_pem, private_key_pem)\nJSON.parse(decrypted_json)\n# =\u003e\n{\n  \"applicationPrimaryAccountNumber\"=\u003e\"4109370251004320\",\n  \"applicationExpirationDate\"=\u003e\"200731\",\n  \"currencyCode\"=\u003e\"840\",\n  \"transactionAmount\"=\u003e100,\n  \"deviceManufacturerIdentifier\"=\u003e\"040010030273\",\n  \"paymentDataType\"=\u003e\"3DSecure\",\n  \"paymentData\"=\u003e {\n    \"onlinePaymentCryptogram\"=\u003e\"Af9x/QwAA/DjmU65oyc1MAABAAA=\",\n    \"eciIndicator\"=\u003e\"5\"\n  }\n}\n```\n\n## Testing\n\n```session\n$ rake test\nStarted\n......\n\nFinished in 0.017918 seconds.\n```\n\n## Releasing\n\nTo cut a new gem:\n\n### Setup RubyGems account\n\nMake sure you have a [RubyGems account](https://rubygems.org) and have setup your local gem credentials with something like this:\n\n```bash\n$ curl -u rwdaigle https://rubygems.org/api/v1/api_key.yaml \u003e ~/.gem/credentials; chmod 0600 ~/.gem/credentials\n\u003center rubygems account password\u003e\n```\n\nIf you are not yet listed as a gem owner, you will need to [request access](http://guides.rubygems.org/command-reference/#gem-owner) from @rwdaigle.\n\n### Release\n\nBuild and release the gem with (all changes should be committed and pushed to Github):\n\n```bash\n$ rake release\n```\n\n## Changelog\n\n### v0.5.0\n\n*Update Openssl to support Ruby 3\n\n### v0.4.0\n\n* Remove unmaintained `aead` gem dependency\n* Rely on Ruby 2.4 openssl support for aes-256-gcm ciphers (and specifying the initialization vector length).\n\n### v0.3.2\n\n* Setup CircleCI for more comprehensive Ruby version/compatibility testing\n* Use Minitest instead of TestUnit to more seamlessly support higher Ruby versions\n* Last planned release that supports \u003c Ruby 2.4\n\n### v0.3.1\n\n* Use Shopify aead library for compatibility w/ Ruby \u003e= v2.2\n\n### v0.3.0\n\n* Verify payment token signature\n\n## Contributors\n\n* [dankimio](https://github.com/dankimio)\n* [davidsantoso](https://github.com/davidsantoso)\n* [mrezentes](https://github.com/mrezentes)\n* [jnormore](https://github.com/jnormore)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspreedly%2Fgala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspreedly%2Fgala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspreedly%2Fgala/lists"}