Marcius Studio
Published in

Marcius Studio

Accept cryptocurrency payments with Coinbase Commerce

If you are planning to connect cryptocurrency payments and are not yet familiar with Coinbase Commerce, it is worth spending 5 minute of your time. I’ll talk about connecting, configuring and sharing ready-made open source solutions for Nodejs.

Coinbase Commerce is a crypto-payments service without fees, passports, great API with your personal account.

Hello World!

For the application, my team and I chose crypto acquiring from several options. All companies take a commission, have a mediocre API and differ in terms of conditions, this is a standard set for accepting funds.

The main issue was the choice of a service that is suitable for the target audience. In our case, the target audience is USA. As you know, there is America and there is the rest of the world, so the number of services that suit us has rapidly decreased.

List of available cryptocurrencies: USD Coin, Dai, Bitcoin, Bitcoin Cash, Ethereum, Litecoin.

Coinbase Commerce (next — CC).

Статья на русском языке: https://habr.com/ru/post/520416/

Pros and cons

  1. Quick setup
  2. No commissions — the client transfers money directly to your account
  3. Accepts stablecoins USD Coin & DAI and many others
  4. Global service — America’s priority is the Coinbase exchange, it has a factor of trust even on the part of government. For the rest of the world it doesn’t matter
  5. There are no middlemen. Only your wallet and your account
  6. No chargebacks. Of course, the client can return the funds on demand, but this is at your discretion
  7. Webhook testing — you can send test webhooks from the service panel

There are almost no minuses, apart from one and it is weighty. To fully test the operation of the application, you need to use your own money.

Registration

The process takes place in 5 steps:

  1. Account registration email + password
  2. 2-step verification
  3. Setting up a wallet
  4. Wallet backup
  5. Accessing the interface and accepting payments

2-step verification

Setting up a wallet

When creating a wallet, CC generates seed-phrases that need to be saved.

After manually entering the seed phrases, CC suggests using Google Drive to back up the wallet.

Accessing the interface and accepting payments

Acceptance of payments

There are two ways to accept payments, we will cover both.

  1. Using interface — a fixed payment for a product / service or donation. No programming skills required, suitable for everyone.
  2. Using API — a more complex option that requires setting up the backend. Allows you to create dynamic payments.

Using interface

Product and Donation checkout

The last step, CC offers to choose what information about the user will collect.

After creating checkout, system offers us integration options (link or script).

// link
// https://commerce.coinbase.com/checkout/<id>
<a href="https://commerce.coinbase.com/checkout/<id>" target="_blank">
// embed
<div>
<a class="buy-with-crypto" href="https://commerce.coinbase.com/checkout/<id>">Buy with Crypto</a>
<script src="https://commerce.coinbase.com/v1/checkout.js?version=201807"></script>
</div>

Using API

The API option generates a payment url manually and it is active for a limited time.

Scheme of work

From client-side, need send information about amount of payment to server-side, then we create “checkout” and return the link https://commerce.coinbase.com/checkout/<id> to client-side, by which the user goes to payment page or is automatically redirected.

In case of successful payment, cancel, or if the payment time expires, CC will send information to the webhook.

Setting up WebHook

You need to add the url of the public Webhook Settings => Webhook subscriptions.

You can test webhook using free Webhook.site service.

For local development, you need to use a module that will make the local access point public, for example, the Ngrok module.

// install 
$ npm install ngrok -g
// `http://localhost:3000/coinbase-webhook` => `https://<ngrok-host>/coinbase-webhook`
$ ngrok http 3000

Alternatively, you can use an example webhook response from Webhook.site and then send it via Postman to a local access point.

After adding a webhook, you can test it. The interface allows changing only events: charge:created, charge:confirmed, charge: failed, charge:delayed, charge:pending, charge:resolved.

Webhook Documentation

Open Source

Create full-stack using Coinbase Commerce API example.

Conclusion

Overall, I liked the Coinbase Commerce integrations. Share your experience of connecting payments for apps.

Thank you for attention!

Marcius Studiohello@marcius.studioDiscordTelegram

If the post was helpful, “hit” the “claps” button, and show how u like it. “Follow” @marcius-studio, we publish interesting and useful cases!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store