Skip to main content

Overview

The Devdraft Ruby SDK provides a complete client library for integrating payment processing, customer management, and webhook functionality into your Ruby applications.

Ruby Idioms

Follows Ruby conventions with blocks, symbols, and elegant syntax

Gem Package

Easy installation via RubyGems package manager

Comprehensive

Access to all Devdraft API endpoints and features

Rails Compatible

Works seamlessly with Ruby on Rails applications

Installation

Using Bundler

Add to your Gemfile:
Then run:

Using RubyGems

Install from Source

Requirements

  • Ruby 2.7 or higher

Quick Start

API Classes

The SDK is organized into API classes under the Devdraft module:

API Health

Monitor service health and availability.

Methods

health_controller_check_v0()

Authenticated health check endpoint requiring API credentials.
Returns: nil

health_controller_public_health_check_v0()

Public health check endpoint (no authentication required).
Returns: PublicHealthResponseDto

App Balances

Query your application’s stablecoin balances.

Methods

balance_controller_get_all_balances()

Get all stablecoin balances for your application.
Returns: AllBalancesResponse

balance_controller_get_usdc_balance()

Get USDC balance only.
Returns: AggregatedBalanceResponse

balance_controller_get_eurc_balance()

Get EURC balance only.
Returns: AggregatedBalanceResponse

Customers

Manage customer records and KYC information.

Methods

customer_controller_create(create_customer_dto)

Create a new customer.
Parameters:
  • create_customer_dto: CreateCustomerDto - Customer details
Returns: Customer

customer_controller_find_all(opts = {})

Get all customers with optional filters.
Parameters:
  • opts: Hash - Optional parameters
    • page: Integer - Page number (default: 1)
    • limit: Integer - Items per page (default: 20)
    • status: String - Filter by status
Returns: Array<Customer>

customer_controller_find_one(id)

Get a customer by ID.
Parameters:
  • id: String - Customer ID
Returns: Customer

customer_controller_update(id, update_customer_dto)

Update a customer’s information.
Parameters:
  • id: String - Customer ID
  • update_customer_dto: UpdateCustomerDto - Fields to update
Returns: Customer

Exchange Rates

Get real-time currency exchange rates.

Methods

exchange_rate_controller_get_exchange_rate(opts = {})

Get exchange rate between any two supported currencies.
Parameters:
  • opts: Hash - Optional parameters
    • from: String - Source currency code
    • to: String - Target currency code
Returns: ExchangeRateResponseDto

exchange_rate_controller_get_usdto_eur_rate()

Get USD to EUR exchange rate.
Returns: ExchangeRateResponseDto

exchange_rate_controller_get_eurto_usd_rate()

Get EUR to USD exchange rate.
Returns: ExchangeRateResponseDto

Invoices

Create and manage invoices for your customers.

Methods

invoice_controller_create(create_invoice_dto)

Create a new invoice.
Parameters:
  • create_invoice_dto: CreateInvoiceDto - Invoice details
Returns: Invoice

invoice_controller_find_all(opts = {})

Get all invoices.
Parameters:
  • opts: Hash - Optional parameters
    • page: Integer - Page number
    • limit: Integer - Items per page
    • status: String - Filter by status
Returns: Array<Invoice>

invoice_controller_find_one(id)

Get an invoice by ID.
Parameters:
  • id: String - Invoice ID
Returns: Invoice

invoice_controller_update(id, update_invoice_dto)

Update an invoice.
Parameters:
  • id: String - Invoice ID
  • update_invoice_dto: Hash - Fields to update
Returns: Invoice

Liquidation Addresses

Manage cryptocurrency liquidation addresses for customers.

Methods

liquidation_address_controller_create_liquidation_address(customer_id, create_liquidation_address_dto)

Create a new liquidation address for a customer.
Parameters:
  • customer_id: String - Customer ID
  • create_liquidation_address_dto: CreateLiquidationAddressDto - Address details
Returns: LiquidationAddressResponseDto

liquidation_address_controller_get_liquidation_addresses(customer_id)

Get all liquidation addresses for a customer.
Parameters:
  • customer_id: String - Customer ID
Returns: Array<LiquidationAddressResponseDto>

liquidation_address_controller_get_liquidation_address(customer_id, liquidation_address_id)

Get a specific liquidation address.
Parameters:
  • customer_id: String - Customer ID
  • liquidation_address_id: String - Address ID
Returns: LiquidationAddressResponseDto

Payment Intents

Create payment intents for bank and stablecoin payments.

Methods

payment_intent_controller_create_bank_payment_intent(create_bank_payment_intent_dto)

Create a bank payment intent.
Parameters:
  • create_bank_payment_intent_dto: CreateBankPaymentIntentDto - Intent details
Returns: PaymentIntent

payment_intent_controller_create_stable_payment_intent(create_stable_payment_intent_dto)

Create a stablecoin payment intent.
Parameters:
  • create_stable_payment_intent_dto: CreateStablePaymentIntentDto - Intent details
Returns: PaymentIntent
Generate and manage payment links for easy customer payments.

Methods

Create a new payment link.
Parameters:
  • create_payment_link_dto: CreatePaymentLinkDto - Link details
Returns: PaymentLink Get all payment links.
Parameters:
  • opts: Hash - Optional parameters
    • page: Integer - Page number
    • limit: Integer - Items per page
    • active: Boolean - Filter by active status
Returns: Array<PaymentLink> Get a payment link by ID.
Parameters:
  • id: String - Payment link ID
Returns: PaymentLink Update a payment link.
Parameters:
  • id: String - Payment link ID
  • update_payment_link_dto: Hash - Fields to update
Returns: PaymentLink

Products

Manage your product catalog.

Methods

product_controller_create(create_product_dto)

Create a new product.
Parameters:
  • create_product_dto: Hash - Product details
Returns: Product

product_controller_find_all(opts = {})

Get all products.
Parameters:
  • opts: Hash - Optional parameters
    • category: String - Filter by category
    • active: Boolean - Filter by active status
Returns: Array<Product>

product_controller_find_one(id)

Get a product by ID.
Parameters:
  • id: String - Product ID
Returns: Product

product_controller_update(id, update_product_dto)

Update a product.
Parameters:
  • id: String - Product ID
  • update_product_dto: Hash - Fields to update
Returns: Product

product_controller_remove(id)

Delete a product.
Parameters:
  • id: String - Product ID
Returns: nil

product_controller_upload_image(id, images)

Upload images for a product.
Parameters:
  • id: String - Product ID
  • images: Array<File> - Image files
Returns: Product

Taxes

Configure and manage tax settings.

Methods

tax_controller_create(create_tax_dto)

Create a new tax configuration.
Parameters:
  • create_tax_dto: CreateTaxDto - Tax details
Returns: Tax

tax_controller_find_all(opts = {})

Get all tax configurations.
Parameters:
  • opts: Hash - Optional parameters
    • country: String - Filter by country
Returns: Array<Tax>

tax_controller_find_one(id)

Get a tax configuration by ID.
Parameters:
  • id: String - Tax ID
Returns: Tax

tax_controller_update(id, update_tax_dto)

Update a tax configuration.
Parameters:
  • id: String - Tax ID
  • update_tax_dto: UpdateTaxDto - Fields to update
Returns: Tax

tax_controller_remove(id)

Delete a tax configuration.
Parameters:
  • id: String - Tax ID
Returns: nil

Test Payments

Process test payments in sandbox environment.

Methods

test_payment_controller_create_payment_v0(payment_request_dto)

Create a test payment.
Parameters:
  • payment_request_dto: PaymentRequestDto - Payment details
Returns: PaymentResponseDto

test_payment_controller_get_payment_v0(id)

Get test payment details by ID.
Parameters:
  • id: String - Payment ID
Returns: PaymentResponseDto

test_payment_controller_refund_payment_v0(id, opts = {})

Refund a test payment.
Parameters:
  • id: String - Payment ID
  • opts: Hash - Optional parameters
    • refund_amount: Float - Amount to refund (defaults to full amount)
Returns: RefundResponseDto

Transfers

Initiate and manage fund transfers between different payment rails.

Methods

transfer_controller_create_direct_bank_transfer(create_direct_bank_transfer_dto)

Create a direct bank transfer.
Parameters:
  • create_direct_bank_transfer_dto: CreateDirectBankTransferDto - Transfer details
Returns: Transfer See also: Direct Bank Transfer Guide

transfer_controller_create_direct_wallet_transfer(create_direct_wallet_transfer_dto)

Create a direct wallet transfer.
Parameters:
  • create_direct_wallet_transfer_dto: CreateDirectWalletTransferDto - Transfer details
Returns: Transfer See also: Direct Wallet Transfer Guide

transfer_controller_create_external_bank_transfer(create_external_bank_transfer_dto)

Create an external bank transfer (from your wallet to external bank).
Parameters:
  • create_external_bank_transfer_dto: CreateExternalBankTransferDto - Transfer details
Returns: Transfer

transfer_controller_create_external_stablecoin_transfer(create_external_stablecoin_transfer_dto)

Create an external stablecoin transfer (from your wallet to external wallet).
Parameters:
  • create_external_stablecoin_transfer_dto: CreateExternalStablecoinTransferDto - Transfer details
Returns: Transfer

transfer_controller_create_stablecoin_conversion(create_stablecoin_conversion_dto)

Convert between different stablecoins or networks.
Parameters:
  • create_stablecoin_conversion_dto: CreateStablecoinConversionDto - Conversion details
Returns: Conversion See also: Stablecoin Conversion Guide

Wallets

Manage wallets and query balances.

Methods

wallet_controller_get_wallets()

Get all wallets for your application.
Returns: nil
The response contains wallet IDs that you can use for transfers and other operations. In a future SDK version, this will return typed wallet objects.

Webhooks

Configure webhooks to receive real-time event notifications.

Methods

webhook_controller_create(create_webhook_dto)

Create a new webhook.
Parameters:
  • create_webhook_dto: CreateWebhookDto - Webhook configuration
Returns: WebhookResponseDto See also: Webhooks Overview

webhook_controller_find_all(opts = {})

Get all webhooks.
Parameters:
  • opts: Hash - Optional parameters
    • page: Integer - Page number
    • limit: Integer - Items per page
    • active: Boolean - Filter by active status
Returns: Array<WebhookResponseDto>

webhook_controller_find_one(id)

Get a webhook by ID.
Parameters:
  • id: String - Webhook ID
Returns: WebhookResponseDto

webhook_controller_update(id, update_webhook_dto)

Update a webhook.
Parameters:
  • id: String - Webhook ID
  • update_webhook_dto: UpdateWebhookDto - Fields to update
Returns: WebhookResponseDto

webhook_controller_remove(id)

Delete a webhook.
Parameters:
  • id: String - Webhook ID
Returns: nil

Error Handling

All SDK methods may raise Devdraft::ApiError. Handle them appropriately:

Best Practices

1

Use Configuration Block

Set up configuration once at the start of your application.
2

Use Environment Variables

Store credentials in environment variables, never in source code.
3

Proper Exception Handling

Always wrap API calls in begin/rescue blocks.
4

Use Symbols for Hash Keys

Follow Ruby conventions by using symbols for hash keys.
5

Use Blocks for Iteration

Use Ruby blocks for clean iteration over collections.
6

Implement Logging

Use Ruby’s built-in Logger or Rails logger.

Testing with RSpec

Example RSpec test for SDK integration:

Rails Integration

Configuration

Create an initializer for Rails applications:

Service Object Pattern

Create service objects for cleaner Rails integration:

Controller Example

Use the service in your Rails controllers:

Background Jobs

Process API calls in background jobs:

Next Steps

SDK Quickstart

Complete integration guide with examples

Transfers

Learn about initiating transfers

Webhooks

Set up webhook notifications

API Reference

Complete REST API documentation