Coinbase Commerce Webhooks & Firebase

James Morgan
Blockchain Manchester
5 min readFeb 19, 2018

Coinbase launched a new service this week with the public opening of Coinbase Commerce.

Coinbase Commerce (CC) represents another great step in the progression of cryptocurrency into the mainstream. CC allows e-commerce sites to sell products and services in cryptocurrency with a simple drop-in HTML snippet.

They are currently supporting Bitcoin (BTC), Bitcoin Cash (BCH), Ethereum (ETH) and Litecoin (LTC). This list could grow in the coming year as Coinbase are planning to add more cryptocurrencies to their platform.

Setting up your merchant account

Once you’ve created a merchant account, you are presented with a dashboard capable of managing the sale of products for crypto as well as being able receive donations to your organisation.

Coinbase Commerce Dashboard

Upon creating your account CC presents you with a wizard to perform two immediate actions:

  • Firstly, “Secure access to your account” — enabling you to configure two-factor authentication — a prudent and wise move when joining any service which requires private and confidential information.
Coinbase Commerce — secure your account
  • Secondly, “Secure your funds” — creating a secure 13 word recover phrase which can be utilised with any of the four types of cryptocurrencies that payments on CC currently accept. By going through this process, Coinbase relinquishes complete control of your wallet as you can recover your funds without the help of CC service.
Coinbase Commerce — secure your funds

Coinbase Commerce accounts are completely separate from Coinbase accounts. Instead of holding cryptocurrency on your behalf we provide a service that makes it easier to accept cryptocurrency. Coinbase Commerce does not have access to your cryptocurrency and/or your private keys.`

From the FAQ

Once setup you can then add products or setup donations. At present you can only add basic requirements such as a product name, picture and price plus organisation name, description and logo for donations.

Coinbase Commerce — add product or donnation

Once this is done you can start accepting payments or donations!

It is as simple as copying the generated HTML and embedding the code into your site (or e-marketing campaign). The generated link then allows a user to complete payment in their preferred cryptocurrency.

The unfortunate fact is that at present there is no documentation regarding how to get feedback on when products & donations are received or purchased.

That being said, I have been in contact with Coinbase support about this and they have said:

We’re currently building out the API along with extensive documentation; we hope to be releasing this in the next few weeks.

Hopefully when the documentation arrives we will have a few more details on how Coinbase envisages users will integrate the payment solution into a site. It’s an obvious move from Coinbase in my opinion with Stripe pulling cryptocurrency payment support cryptocurrencies gaining in adoption in daily life. Coinbase already being a well known and trusted name in the space, having first mover advantage in the merchant space is key. Adding merchant tools looks to be a wise strategic move as they as gaining first-mover advantage.

Using webhooks — adding Firebase to the mix

If you were to integrate Coinbase Commerce into an existing website you would need to get feedback on when things had been purchased otherwise for example you may oversell an item and under order stock. Coinbase Commerce currently provide webhooks which provide a mechanism to react to purchases/donations although there is not much detail on how they work at present.

To test this process and get up and running I chose to use Firebase Cloud Functions, these are cheap and easy to create and give you a secure webhook endpoint for processing transactions. Also at this point in time it gives me the ability to inspect and understand the data structure which will be received after a product has been purchased. There is no reason why you couldn’t use this in a production environment as inside a cloud function you could, for example, integrate with Firebase’s realtime and document storage facilities or simply process and call another web service based on what is required.

Below is an example of the code used to receive webhook data via a http trigger endpoint with firebase cloud functions. This endpoint can be configured via the CC merchant settings:

Once upload you can see the function running in your Firebase console.

Firebase Cloud Functions Console

To test it simple make a small purchase or send a tiny donation to yourself.

The main points are that at present you can subscribe to three types of events, depending on how much information you need, these events are as follows:

Coinbase Commerce Webhook Options

From these three types of event you would in theory know when a product is sold, when a product is in the process of being sold and when a product purchase has failed.

The Future

Since Coinbase Commerce is 1 week old public release I expect a things to improve over the coming months. Below is a list of various improvements we can hope to expect from Coinbase.

  • API & Usage Documentation — we know this is on the cards (see the above response from Coinbase regarding this)
  • API support for uploading products — currently this process is manual, ideally an API could be exposed to provide automated update functionality.
  • Converting to fiat — Coinbase runs GDax, one of the biggest cryptocurrency exchanges in the world. It would be nice to have the facility to cash out cryptocurrency to fiat.
  • The ability to easily move funds — currently in order to do this you must recover your funds with the seed generated at signup time.
  • Further customisation options — the ability to customise more things relating to a product or donation.

A full example JSON blob from a successful purchase can be seen at the end of this post— data has been obfuscated for security.

If you’d like to donate and try out the service, use this link which donates directly to Blockchain Manchester community group. https://commerce.coinbase.com/checkout/5c724f19-ea49-4b9e-9bb1-bfa9f778c242

Hopefully this helps you out, if so please feel to give me a few claps!

To find out more follow my our meetup us on Medium, check our twitter feed at @blockchain_manc and sign up to our meetup page for all the latest news about the next event.

--

--

James Morgan
Blockchain Manchester

Founder of @knownorigin_io @BlockRocketTech @blockchain_manc — NFT nerd, crypto enthusiast, lover of music, humanist, mostly found hacking web3