Skip to content

allenan/coinbase_commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coinbase Commerce

An Elixir library for working with the Coinbase Commerce API (Documentation)

Hex.pm

Installation

Install by adding coinbase_commerce to your list of dependencies in mix.exs:

def deps do
  [
    {:coinbase_commerce, "~> 0.2.0"}
  ]
end

Configure your API key and webhook shared secret:

config :coinbase_commerce,
  api_key: "YOUR-API-KEY",
  webhook_shared_secret: "YOUR-WEBHOOK-SHARED-SECRET" # optional unless using webhooks

Usage

Full API documentation is available at https://hexdocs.pm/coinbase_commerce. For details on the Coinbase Commerce API, see the official documentation.

Charges

# Create a charge
{:ok, %CoinbaseCommerce.Charge{}} = CoinbaseCommerce.Charge.create(%{
  name: "The Sovereign Individual",
  description: "Mastering the Transition to the Information Age",
  local_price: {
    amount: "100.00",
    currency: "USD"
  },
  pricing_type: "fixed_price",
  metadata: {
    customer_id: "id_1005",
    customer_name: "Satoshi Nakamoto"
  }
})

# View a charge
{:ok, %CoinbaseCommerce.Charge{}} = CoinbaseCommerce.Charge.show("some-charge-id")

# List all charges
{:ok, charges} = CoinbaseCommerce.Charge.list()

Checkouts

# Create a checkout
{:ok, %CoinbaseCommerce.Checkout{}} = CoinbaseCommerce.Checkout.create(%{
  name: "The Sovereign Individual",
  description: "Mastering the Transition to the Information Age",
  local_price: {
    amount: "100.00",
    currency: "USD"
  },
  pricing_type: "fixed_price",
  requested_info: ["email"]
})

# View a checkout
{:ok, %CoinbaseCommerce.Checkout{}} = CoinbaseCommerce.Checkout.show("some-checkout-id")

# List all checkouts
{:ok, checkouts} = CoinbaseCommerce.Checkout.list()

# Update a checkout
{:ok, %CoinbaseCommerce.Checkout{}} = CoinbaseCommerce.Checkout.update(%{
  local_price: {
    amount: "200.00",
    currency: "USD"
  }
})

# Delete a checkout
:ok = CoinbaseCommerce.Checkout.delete("some-checkout-id")

Events

# List events
{:ok, events} = CoinbaseCommerce.Event.list()

# Show an event
{:ok, %CoinbaseCommerce.Event{}} = CoinbaseCommerce.Event.show("some-event-id")

Webhooks

# Verify an incoming webhook's signature
true = CoinbaseCommerce.Webook.verify_signature(signature, request_body)

Contributing

Feedback, feature requests, and fixes are welcomed and encouraged. Please make appropriate use of Issues and Pull Requests.

License

Please see LICENSE for details.

About

Simple Elixir wrapper for the Coinbase Commerce API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages