{"id":14955852,"url":"https://github.com/bitecraft/coinbase_commerce_client","last_synced_at":"2025-10-06T09:30:31.606Z","repository":{"id":61407609,"uuid":"550684258","full_name":"BiteCraft/coinbase_commerce_client","owner":"BiteCraft","description":"Easily integrate Bitcoin, Ethereum, and other cryptocurrency payments into your Ruby on Rails applications with the Coinbase Commerce Client","archived":false,"fork":false,"pushed_at":"2024-03-31T14:17:18.000Z","size":207,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T21:08:22.769Z","etag":null,"topics":["bitcoin","coinbase","coinbase-api","coinbase-pro","coinbasepro","ethereum","gem","gems","ruby","ruby-gem","ruby-lib","ruby-on-rails","rubygem","rubygems","rubyonrails"],"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/BiteCraft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["BiteCraft"],"patreon":"bitecraft","open_collective":"coinbase_commerce_client","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2022-10-13T06:50:38.000Z","updated_at":"2024-03-29T19:59:51.000Z","dependencies_parsed_at":"2024-03-31T15:26:47.169Z","dependency_job_id":null,"html_url":"https://github.com/BiteCraft/coinbase_commerce_client","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"fbbb29a6553356a371ff56ff35746f4cce594b82"},"previous_names":["bitecraft/coinbase_commerce_client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiteCraft%2Fcoinbase_commerce_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiteCraft%2Fcoinbase_commerce_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiteCraft%2Fcoinbase_commerce_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiteCraft%2Fcoinbase_commerce_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BiteCraft","download_url":"https://codeload.github.com/BiteCraft/coinbase_commerce_client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515428,"owners_count":19002481,"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":["bitcoin","coinbase","coinbase-api","coinbase-pro","coinbasepro","ethereum","gem","gems","ruby","ruby-gem","ruby-lib","ruby-on-rails","rubygem","rubygems","rubyonrails"],"created_at":"2024-09-24T13:11:54.250Z","updated_at":"2025-10-06T09:30:26.237Z","avatar_url":"https://github.com/BiteCraft.png","language":"Ruby","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg width=\"100%\" src=\"https://raw.githubusercontent.com/viniciusborgeis/coinbase_commerce_client/main/assets/banner.png\" alt=\"Coinbase Commerce Client\"\u003e\n  \u003cbr\u003e\n  Coinbase Commerce Client\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA client to handle cryptocurrency payments using \u003ca href=\"https://commerce.coinbase.com/\" target=\"_blank\"\u003eCoinbase Commerce\u003c/a\u003e platform\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://badge.fury.io/rb/coinbase_commerce_client.svg\" alt=\"Coverage\"\u003e\n\t\u003cimg src=\"https://raw.githubusercontent.com/viniciusborgeis/coinbase_commerce_client/main/badge.svg\" alt=\"Coverage\"\u003e\n    \u003cimg src=\"https://img.shields.io/gem/dt/coinbase_commerce_client.svg?type=total\"  alt=\"Total Downloads\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#ruby-version\"\u003eRuby Versions\u003c/a\u003e •\n  \u003ca href=\"#dependencies\"\u003eDependencies\u003c/a\u003e •\n  \u003ca href=\"#documentation\"\u003eDocs\u003c/a\u003e •\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e •\n  \u003ca href=\"#validating-webhook-signatures\"\u003eValidating Webhook\u003c/a\u003e •\n  \u003ca href=\"#testing-and-contributing\"\u003eContributing\u003c/a\u003e\n\u003c/p\u003e\n\u003csub\u003eThis gem is completely inspired by official Coinbase gem \u003ca href=\"https://github.com/coinbase/coinbase-commerce-ruby\"\u003ecoinbase-commerce-ruby\u003c/a\u003e, unfortunately the oficial gem actually is deprecated, and my motivation is to continue support for this gem\u003c/sub\u003e\n\n## Ruby Version\nRuby [2.3 -\u003e 3.2.2] are supported and tested.\n\n## 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\n### On Ruby on Rails\nTo use this gem in Ruby on Rails, first pass your Coinbase API_KEY to an environment variable or credentials. After doing this, create a new initializer called `coinbase_commerce_client.rb` and insert the following code:\n\n```ruby\nCoinbaseCommerceClient.configure do |config|\n  config.api_key = ENV['COINBASE_API_KEY']\n  # or\n  config.api_key = Rails.application.credentials.coinbase[:coinbase_api_key]\nend\n```\n\n### Pure ruby example\n\nNext create a ``Client`` object for interacting with the API:\n```ruby\nrequire 'coinbase_commerce_client'\nAPI_KEY = \"API KEY\"\nclient = CoinbaseCommerceClient::Client.new(api_key: API_KEY)\n```\n\n``Client`` contains links to every Ruby Class representations of the API resources\n``Checkout, Charge, Invoices, Event``\n\nYou can call ``list, auto_paging, create, resolve, cancel, retrieve, modify`` methods from API resource classes\n\n```ruby\n#charges\nclient.charge.list\nclient.charge.auto_paging\nclient.charge.create \u003cpayload\u003e\ncharge = client.charge.retrieve \u003cid\u003e\ncharge.resolve\ncharge.cancel\n\n#checkout\nclient.checkout.list\nclient.checkout.auto_paging\nclient.checkout.create \u003cpayload\u003e\ncheckout = client.checkout.retrieve \u003cid\u003e\ncheckout.refresh\ncheckout.save\ncheckout.modify \u003cpayload\u003e\ncheckout.delete\n\n#events\nclient.event.list\nclient.event.auto_paging\nevent = client.event.retrieve \u003cid\u003e\n\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| 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\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'coinbase_commerce_client'\n```\nThen execute:\n\n```sh\nbundle install\n```\n\nOr install it yourself as:\n\n```sh\ngem install coinbase_commerce_client\n```\n\n## Usage\n* [Checkouts](#checkouts)\n* [Charges](#charges)\n* [Events](#events)\n\n\n```ruby\nrequire 'coinbase_commerce_client'\nclient = CoinbaseCommerceClient::Client.new(api_key: 'your_api_key')\n```\n\n### Checkouts\n[Checkouts API docs](https://commerce.coinbase.com/docs/api/#checkouts)\n\n#### Retrieve\n```ruby\ncheckout = client.checkout.retrieve \u003ccheckout_id\u003e\n```\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# or\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\n#### Update\n```ruby\ncheckout = client.checkout.retrieve \u003ccheckout_id\u003e\ncheckout.name = 'new name'\ncheckout.save\n# or\nclient.checkout.modify(\u003ccheckout_id\u003e, \"local_price\": {\n    \"amount\": \"10000.00\",\n    \"currency\": \"USD\"\n})\n```\n\n#### Delete\n```ruby\ncheckout.delete\n```\n\n#### List\n```ruby\ncheckouts = client.checkout.list\n```\n\n#### Paging list iterations\n```ruby\nclient.checkout.auto_paging  do |ch|\n  puts ch.id\nend\n```\n\n### Charges\n[Charges API docs](https://docs.cloud.coinbase.com/commerce/reference/getcharges)\n\n#### Retrieve\n```ruby\ncharge = client.charge.retrieve \u003ccharge_id\u003e\n```\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# or\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\n#### List\n```ruby\ncharges_list = client.charge.list\n```\n\n#### Paging list iterations\n```ruby\nclient.charge.auto_paging do |charge|\n  puts charge.id\nend\n```\n\n#### Resolve\n```ruby\ncharge = client.charge.retrieve \u003ccharge_id\u003e\ncharge.resolve\n```\n\n#### Cancel\n```ruby\ncharge = client.charge.retrieve \u003ccharge_id\u003e\ncharge.cancel\n```\n\n## Events\n[Events API Docs](https://docs.cloud.coinbase.com/commerce/reference/getevents)\n\n#### Retrieve\n```ruby\nevent = client.event.retrieve \u003cevent_id\u003e\n```\n\n#### List\n```ruby\nevents = client.event.list\n```\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\n```ruby\nWEBHOOK_SECRET = 'your_webhook_secret'\n# Using Sinatra\npost '/webhooks' do\n  request_payload = request.body.read\n  sig_header = request.env['HTTP_X_CC_WEBHOOK_SIGNATURE']\n  begin\n    event = CoinbaseCommerceClient::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 CoinbaseCommerceClient::Errors::SignatureVerificationError =\u003e e\n    puts \"signature verification error\"\n    status 400\n    return\n  rescue CoinbaseCommerceClient::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_client\n    rspec spec\n    \n    # or via Bundle\n    bundle install\n    bundle exec rspec spec","funding_links":["https://github.com/sponsors/BiteCraft","https://patreon.com/bitecraft","https://opencollective.com/coinbase_commerce_client"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitecraft%2Fcoinbase_commerce_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitecraft%2Fcoinbase_commerce_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitecraft%2Fcoinbase_commerce_client/lists"}