When you are selling hardware wallets and seed wallets, you can't expect all your customers to pay in fiat money, right? For our client, Cryptherion.io, we developed an integration that allows customers to pay for their products with Cryptocurrency.
This article describes how we integrated crypto payments into Cryptherion's web shop. The shop is, like most of our projects, built with Vendure.io. Vendure is a headless e-commerce framework that we love for its extensibility.
Coinbase hosted checkout
Coinbase Commerce is a platform to accept payments in cryptocurrencies, similar to Stripe or Mollie. The platform allows you to receive payments in Bitcoin, Bitcoin Cash, Dai, Ethereum, Litecoin, and USD Coin.
There are a variety of ways to integrate Coinbase into your shop, and we went ahead with the Coinbase hosted checkout. The hosted checkout integration redirects the customer to a page that is managed by Coinbase, where the customer can settle their payment. Coinbase will post a webhook to your shop's backend when the payment status changes.
The flow is as follows:
- A customer follows the normal shop flow (add product, set address etc.)
- In the payment step, the storefront requests a 'payment link' from Vendure. Vendure creates a payment page on Coinbase and returns a redirect link to the page. The payment page is created with the total amount of the order in fiat (Euro in this case).
- The customer is redirected to the checkout page and chooses the desired cryptocurrency to pay the order. Coinbase handles the conversion from fiat to whatever currency is chosen.
- After payment, the customer is redirected back to the order confirmation page on Cryptherion.io.
Cryptocurrency payments can take longer to settle than regular fiat payments. At the time of writing, a Bitcoin transaction takes around 10 minutes to settle, and Ether anywhere between 15 seconds and 5 minutes.
So, when the customer lands on the order confirmation page, the payment might not be settled yet. In our integration, we don't want to settle our order in Vendure just yet, because the payment could still be rejected for whatever reason. We need to notify the customer about the delay:
This translates to something like "It could take a few minutes for your payment to settle. You will receive an email when your order is confirmed".
Want to know more about the implementation details? Checkout the source here.
Want to use the plugin? Use the plugin for free in your Vendure project
Check it out in real life at Cryptherion.io