Accept crypto payments in Ruby on Rails | Shieldz

Accept crypto payments in Ruby on Rails

Add non-custodial crypto checkout to your Ruby on Rails app: create an invoice, send the buyer to the hosted checkout, and fulfill on a signed webhook. Funds settle straight to your own wallet, $0 platform fees.

Install

# uses Net::HTTP (no extra gem needed)

Create an invoice and redirect to checkout

require "net/http"; require "json"
res = Net::HTTP.post(
  URI("https://shieldz.cash/api/v1/invoices"),
  { amount_usd_cents: 5000, memo: "Order" }.to_json,
  { "Authorization" => "Bearer #{ENV['SHIELDZ_API_KEY']}", "Content-Type" => "application/json" }
)
invoice = JSON.parse(res.body)
redirect_to invoice["pay_url"]

Verify the webhook

# Verify HMAC over "#{t}.#{raw_body}"
def shieldz_paid?(raw, header, secret)
  t = header[/t=(\d+)/, 1]; return false unless t
  expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{t}.#{raw}")
  header.scan(/v1=([0-9a-f]+)/).flatten.any? { |s| Rack::Utils.secure_compare(s, expected) }
end

Full reference: API docs, SDKs, API reference.

Explore Shieldz

Accept a coin: Bitcoin, USDC, USDT, Zcash.

Compare: vs Coinbase Commerce, vs BTCPay Server, vs CryptAPI, vs NOWPayments.

Use cases: For freelancers, For creators, For open-source projects, For online stores.

Build: SDKs, API reference, quickstart. Learn: overview, blog, how it works, supported coins, pricing, is it safe, verify it yourself.