{"id":18542776,"url":"https://github.com/coinbase/coinbase-commerce-ruby","last_synced_at":"2025-04-09T18:32:14.694Z","repository":{"id":46916476,"uuid":"137250712","full_name":"coinbase/coinbase-commerce-ruby","owner":"coinbase","description":"Coinbase Commerce Ruby Gem","archived":false,"fork":false,"pushed_at":"2024-02-07T22:26:44.000Z","size":31,"stargazers_count":35,"open_issues_count":9,"forks_count":33,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-24T10:38:47.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-13T17:45:22.000Z","updated_at":"2024-12-25T21:23:56.000Z","dependencies_parsed_at":"2024-11-06T20:20:41.766Z","dependency_job_id":null,"html_url":"https://github.com/coinbase/coinbase-commerce-ruby","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/coinbase%2Fcoinbase-commerce-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/coinbase-commerce-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248087868,"owners_count":21045604,"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-11-06T20:10:38.500Z","updated_at":"2025-04-09T18:32:09.684Z","avatar_url":"https://github.com/coinbase.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/coinbase/coinbase-commerce-ruby.svg?style=svg)](https://circleci.com/gh/coinbase/coinbase-commerce-ruby)\n\n# coinbase-commerce-ruby\n**Note: This repository is not actively maintained.**\n\nCoinbase Commerce Ruby Gem\n\n# Table of contents\n\n\u003c!--ts--\u003e\n   * [Ruby Versions](#ruby-version)\n   * [Third Party Libraries and Dependencies](#third-party-libraries-and-dependencies)\n   * [Documentation](#documentation)\n   * [Installation](#installation)\n   * [Usage](#usage)\n      * [Checkouts](#checkouts)\n      * [Charges](#charges)\n      * [Events](#events)\n   * [Validating webhook signatures](#validating-webhook-signatures)\n   * [Testing and Contributing](#testing-and-contributing)\n\u003c!--te--\u003e\n\n## Ruby Version\nRuby 2.3, 2.4, 2.5, 2.6RC are supported and tested.\n\n## Third Party Libraries and Dependencies\n\nThe following libraries will be installed when you install the client library:\n* [faraday](https://github.com/lostisland/faraday)\n\n## Documentation\n\nFor more details visit [Coinbase API docs](https://commerce.coinbase.com/docs/api/).\n\nTo start using library, you'll need to [create a Coinbase Commmerce account](https://commerce.coinbase.com/signup).\nOnce you've created your Coinbase Commerce account, create an ``API_KEY`` in Settings.\n\nNext create a ``Client`` object for interacting with the API:\n```ruby\nrequire 'coinbase_commerce'\n\nAPI_KEY = \"API KEY\"\nclient = CoinbaseCommerce::Client.new(api_key: API_KEY)\n\n```\n\n``Client`` contains links to every Ruby Class representations of the API resources\n``Checkout, Charge, Event``\n\nYou can call ``list, auto_paging, create, retrieve, modify`` methods from API resource classes\n\n```ruby\nclient.charge.create\nclient.checkout.auto_paging \nclient.event.list\nclient.charge.retrieve\nclient.checkout.modify\n```\nas well as ``save, delete, refresh`` methods from API resource class instances.\n```python\ncheckout = client.checkout.retrieve \u003cid\u003e\ncheckout.refresh\ncheckout.save\ncheckout.delete\n```\n\nEach API method returns an ``APIObject`` representing the JSON response from the API, all of the models support hash and JSON representation.\\\nAlso when the response data is parsed into Ruby objects, the appropriate ``APIObject`` subclasses will be used automatically.\nAll subclasses of ``APIResource`` class support ``refresh`` method. This will update their attributes and all nested data by making a fresh ``GET`` request to the relevant API endpoint.\n\nThe client supports handling of common API errors and warnings.\nAll errors occuring during the interaction with the API will be raised as exceptions.\n\n\n| Error                    | Status Code |\n|--------------------------|-------------|\n| APIError                 |      *      |   \n| InvalidRequestError      |     400     |   \n| ParamRequiredError       |     400     |  \n| ValidationError          |     400     |  \n| AuthenticationError      |     401     |  \n| ResourceNotFoundError    |     404     |\n| RateLimitExceededError   |     429     |\n| InternalServerError      |     500     |\n| ServiceUnavailableError  |     503     |\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'coinbase_commerce'\n```\nThen execute:\n\n```sh\nbundle install\n```\n\nOr install it yourself as:\n\n```sh\ngem install coinbase_commerce\n```\n\n## Usage\n```ruby\nrequire 'coinbase_commerce'\n\nclient = CoinbaseCommerce::Client.new(api_key: 'your_api_key')\n```\n## Checkouts \n[Checkouts API docs](https://commerce.coinbase.com/docs/api/#checkouts)\n### Retrieve\n```ruby\ncheckout = client.checkout.retrieve \u003ccheckout_id\u003e\n```\n### Create\n```ruby\ncheckout_info = {\n    \"name\": \"The Sovereign Individual\",\n    \"description\": \"Mastering the Transition to the Information Age\",\n    \"pricing_type\": \"fixed_price\",\n    \"local_price\": {\n        \"amount\": \"1.00\",\n        \"currency\": \"USD\"\n    },\n    \"requested_info\": [\"name\", \"email\"]\n}\ncheckout = client.checkout.create(checkout_info)\n\n# or\n\ncheckout = client.checkout.create(:name=\u003e'The Sovereign Individual',\n                                  :description=\u003e'Mastering the Transition to the Information Age',\n                                  :pricing_type=\u003e'fixed_price',\n                                  :local_price=\u003e{\n                                          \"amount\": \"100.00\",\n                                          \"currency\": \"USD\"\n                                          },\n                                  :requested_info=\u003e[\"name\", \"email\"])                            \n```\n### Update\n```ruby\ncheckout = client.checkout.retrieve \u003ccheckout_id\u003e\ncheckout.name = 'new name'\ncheckout.save\n\n# or\n\nclient.checkout.modify(\u003ccheckout_id\u003e, \"local_price\": {\n    \"amount\": \"10000.00\",\n    \"currency\": \"USD\"\n})\n```\n### Delete\n```ruby\ncheckout.delete\n```\n### List\n```ruby\ncheckouts = client.checkout.list\n```\n### Paging list iterations\n```ruby\nclient.checkout.auto_paging  do |ch|\n  puts ch.id\nend\n```\n## Charges\n[Charges API docs](https://commerce.coinbase.com/docs/api/#charges)\n### Retrieve\n```ruby\ncharge = client.charge.retrieve \u003ccharge_id\u003e\n```\n### Create\n```ruby\ncharge_info = {\n    \"name\": \"The Sovereign Individual\",\n    \"description\": \"Mastering the Transition to the Information Age\",\n    \"pricing_type\": \"fixed_price\",\n    \"local_price\": {\n        \"amount\": \"1.00\",\n        \"currency\": \"USD\"\n    },\n    \"requested_info\": [\"name\", \"email\"]\n}\ncharge = client.charge.create(charge_info)\n\n# or\n\ncharge = client.charge.create(:name=\u003e'The Sovereign Individual',\n                              :description=\u003e'Mastering the Transition to the Information Age',\n                              :pricing_type=\u003e'fixed_price',\n                              :local_price=\u003e{\n                                  \"amount\": \"100.00\",\n                                  \"currency\": \"USD\"\n                              })\n```\n### List\n```ruby\ncharges_list = client.charge.list\n```\n### Paging list iterations\n```ruby\nclient.charge.auto_paging do |charge|\n  puts charge.id\nend\n```\n## Events\n[Events API Docs](https://commerce.coinbase.com/docs/api/#events)\n### Retrieve\n```ruby\nevent = client.event.retrieve \u003cevent_id\u003e\n```\n### List\n```ruby\nevents = client.event.list\n```\n### Paging list iterations\n```ruby\nclient.event.auto_paging do |event|\n  puts event.id\nend\n```\n\n## Validating webhook signatures\nYou should verify the webhook signatures using our library.\nTo perform the verification you'll need to provide the event data, a webhook signature from the request header, and the endpoint’s secret.\nIn case of an invalid request signature or request payload, you will receive an appropriate error message.\n```ruby\nWEBHOOK_SECRET = 'your_webhook_secret'\n\n# Using Sinatra\npost '/webhooks' do\n  request_payload = request.body.read\n  sig_header = request.env['HTTP_X_CC_WEBHOOK_SIGNATURE']\n\n  begin\n    event = CoinbaseCommerce::Webhook.construct_event(request_payload, sig_header, WEBHOOK_SECRET)\n    # event handle\n    puts \"Received event id=#{event.id}, type=#{event.type}\"\n    status 200\n  # errors handle\n  rescue JSON::ParserError =\u003e e\n    puts \"json parse error\"\n    status 400\n    return\n  rescue CoinbaseCommerce::Errors::SignatureVerificationError =\u003e e\n    puts \"signature verification error\"\n    status 400\n    return\n  rescue CoinbaseCommerce::Errors::WebhookInvalidPayload =\u003e e\n    puts \"missing request or headers data\"\n    status 400\n    return\n  end\nend\n```\n\n### Testing and Contributing\nAny and all contributions are welcome! The process is simple: fork this repo, make your changes, add tests, run the test suite, and submit a pull request. Tests are run via rspec. To run the tests, clone the repository and then:\n\n    # Install the requirements\n    gem install coinbase_commerce\n    rspec spec\n    \n    # or via Bundle\n    bundle install\n    bundle exec rspec spec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-ruby/lists"}