Stefan Holm Olsen

Bitcoins as a payment option in EPiServer Commerce

This post is a little special, as it is about something I thought would be interesting to play with and then I implemented it for fun.

I have heard a lot about Bitcoins and Altcoins (all the other cryptocurrencies out there). About what they are, what they can do and how much they will revolutionize payments and money transfers. I do hear and see businesses (digital as well as physical stores) slowly embracing Bitcoin as a supplemental payment option. So I became interested in experimenting with a Bitcoin payment gateway, and chose to integrate with Coinify. I also looked briefly at a few others, such as Coinbase, Coingate and Bitpay.

I ended up creating an open-sourced payment plugin for EPiServer Commerce (in this Git repository).

Introducing Coinify

Coinify is a Danish payment gateway, serving the same purpose as a regular credit card payment gateway, except this one only accepts Bitcoin and a number of other cryptocurrencies (such as Litecoin and Namecoin). It makes accepting these digital currencies very easy for an online merchant.

For a user the interaction with the Coinify payment window is very simple (see image of a payment window below). A customer can scan the QR code with mobile wallet app, copy the hash into a wallet app, or just click the blue button (which opens an installed wallet app). Other cryptocurrencies can be selected from a dropdown list, which causes the amount to be converted.

Screenshot of a Coinify payment window

When the customer pays, using any of the three methods, the payment is immediately settled and the customer is returned to the Commerce website, where the usual processes is executed (like recording the payment, converting the cart to a purchase order etc.).

While working on this, I used the CoPay wallet apps on Windows and iPhone. Just two seconds after I scanned the QR code with my iPhone, the payment window changed and it redirected me to the webshop.

There are some technical differences compared to a regular card payment gateway:

  • The payable amount gets converted from a regular currency to a Bitcoin amount, as soon as a Coinify invoice is created by the webshop (happens before showing the payment window).
  • Due to the nature of cryptocurrencies, transfers are immediately settled, meaning there are no authorization/capture process.

How does the merchant withdraw their money?

A Coinify account can be set up as a Bitcoin account or as a regular currency account. They will do the necessary currency exchanges, and immediately transfer the converted amount to a Bitcoin address, a bank account or a PayPal account.

What about the price for using this service?

Accepting payments using Coinify is free. So are payouts to bank accounts in 34 European countries. However, fees apply to payouts to PayPal accounts and international bank accounts.

Implementation approach

For experimenting with a Coinify payment plugin for EPiServer Commerce, I ended up creating a payment plugin. The source code is available on GitHub (I might be adding more payment plugins in the future).

My implementation of the payment plugin follows this flow, step by step:

  1. A webshop customer selects Coinify as the payment option, and proceeds to the payment step.
  2. The plugin creates an invoice in Coinify and receives an invoice object, including the URL to that invoice, the calculated Bitcoin amount as well as other information.
  3. The plugin redirects the browser to the specific invoice.
  4. Within 15 minutes the customer has to pay the invoice.
  5. The payment window directs the browser back to the site.
    1. If the 15 minutes passed without any payment received, the browser will be sent to a cancellation page, and the flow ends here.
    2. If the payment went through, the browser will be sent to a return page
  6. The return page reactivates the plugin. This time it loads the invoice from Coinify and verifies the current payment status.
  7. If the invoice is paid, the payment is recorded, the cart is converted to a purchase order and the browser is directed to a success page.
  8. The success page action redirects the browser to the normal confirmation page, with additional query parameters.

The implementation is simpler than it sounds. At least that was what I was striving for.

All-in all, I think Coinify (and platforms like it) provides a very flexible solution for accepting digital currencies and for quickly receiving payments. It will be exciting to follow the development of Bitcoins and the other cryptocurrencies.