GuidesAPI Reference
DocumentationLog In

Accepting Crypto Payments

Accepting cryptocurrency payments with the Coinbase Commerce API

To start accepting cryptocurrency payments you need to create a request for payment, also known as a charge.

Creating a Charge

When you create a charge, we generate payment addresses on your behalf for each cryptocurrency that’s enabled. We provide you with a hosted page that you can send to customers to complete the payment.

Here’s an example of dynamically creating a charge:

curl -X POST https://api.commerce.coinbase.com/charges/ \
-H "Content-Type: application/json" \
-H "X-CC-Api-Key: YOUR_API_KEY" \
-H "X-CC-Version: 2018-03-22" \
-d "@data.json"

Where data.json is simply a JSON object:

{
  "name":"The Human Fund",
  "description":"Money For People",
  "pricing_type":"no_price"
}

A charge object is returned with payment addresses for each currency plus a URL to a hosted page where a customer can complete their payment.

📘

When you don't specify a price, as in this example, the customer can send any amount.

Accepting a Payment

Unlike credit cards where merchants must obtain payment credentials in order to charge a customer, cryptocurrencies are more like digital cash and rely on the customer explicitly sending money to the merchant.

After creating a charge, Coinbase Commerce continuously monitors each blockchain network for a payment. As cryptocurrencies are push payments, we set an expiration time for the charge, which is currently 1 hour after the creation date. If the customer does not make a payment within that timeframe, we consider the charge to be expired.

Once a payment has been sent, we update your Dashboard with the payment information. To get more information about the payment, simply retrieve the charge by supplying the unique charge code that was returned when the charge was created.

Here’s an example of retrieving a charge:

curl https://api.commerce.coinbase.com/charges/2E8YCQWQ \
-H "X-CC-Version: 2018-03-22"

A charge object is returned with specific information about the payment including, but not limited to, the transaction hash and the number of confirmations that have been received. Learn more.


**See Also:**