How to accept Ethereum (ETH) payments with Ruby

Over the last decade, the way we can receive value over the internet has dramatically shifted from traditional payments to programmable money. Cryptocurrencies like Ethereum have emerged and can be embedded into online shops or e-commerce sites to receive customer payments.

In its simplest form, all that is needed to receive Ethereum (ETH) payments in Ruby is to display an Ethereum address to the customer. Albeit outside of the scope of this document, it is easy to create an Ethereum address programmatically and obtain control of the private key. This is a good starting point if you are a Ruby developer and wish to create your own Ethereum address.

This simple type of Ethereum payment integration is suitable for anonymous donations, but requires a lot of additional overhead to make it play well with accounting systems, compliance, and regulatory requirements. Connecting them with customer information and monitoring the Ethereum Network to detect the correct payment transaction and mark the sale as completed, introduce plenty of additional complexity in Ruby.

Fortunately, Whalestack provides a suite of APIs and a convenient Ruby software development kit (SDK) for online merchants and e-commerce site who wish to accept Ethereum payments. Using Whalestack, it is no longer necessary to continuously monitor various blockchains for payment transactions. Whalestack creates cryptocurrency payment transactions on your behalf and automatically notifies you once the payment has been settled.

Read our SDK guide and learn how to accept Ethereum payments with this tutorial.

Creating a Ethereum payment request is as simple as firing the below API request using the Ruby SDK.

response ='/checkout/hosted', {
    :charge => {
        :billingCurrency => 'EUR', # a billing currency as given by GET /currencies
        :lineItems => [{ # a list of line items included in this charge
            :description => 'PCI Graphics Card',
            :netAmount => 169.99, # denominated in the currency specified above
            :quantity => 1
        :discountItems => [] # an optional list of discounts
        :shippingCostItems => [] # an optional list of shipping and handling costs
        :taxItems => [] # an optional list of taxes
    :settlementAsset => 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN' # your settlement asset as given by GET /assets (or ORIGIN to omit conversion)

The API request returns a list of cryptocurrency payment methods and deposit addresses, including Ethereum. These can be displayed back to a customer to complete payment.

Moreover, the Whalestack platform provides built-in business accounting tools, invoicing and customer management. Most importantly, payments in Ethereum can automatically be settled in your national fiat currency and withdrawn directly into your bank account. Inspect our Ruby SDK on GitHub to get started.

Last Update: Oct 2, 2023