Inttegro Ruby SDK

OpenSSF Scorecard

The official Ruby client for building server-side Inttegro integrations.

API documentation ยท Integration guides

Fastest, most modern path: connect an agent to Inttegro MCP at https://mcp.inttegro.com, then ask it to run design_integration. It will produce an implementation and test plan for your application. Use this SDK when you are ready to connect that plan to your Ruby service.

All official Inttegro SDKs expose the same API capabilities. This gem adds strict Sorbet types and Ruby-native resource methods.

Install

Requires Ruby 3.0 or newer.

bundle add inttegro

Store your secret key in the server environment:

export INTTEGRO_API_KEY="your_secret_key"

Never put the key in browser code, a mobile app, or source control. The client uses https://api.inttegro.com by default.

Create a hosted checkout

Create and finalize an order, then send the customer to its hosted invoice URL:

# typed: strict

require "inttegro"

inttegro = Inttegro::Client.new(api_key: ENV.fetch("INTTEGRO_API_KEY"))

begin
  order = inttegro.orders.create(
    request_meta: { idempotency_key: "checkout-cart-123" },
    customer_data: {
      name: "Akua Mensah",
      email_address: "akua@example.com",
      phone_number: "+233544998605"
    },
    finalize: true,
    checkout_settings: {
      redirect_url: "https://example.com/orders/complete",
      cancel_url: "https://example.com/cart"
    },
    line_items: [{
      type: "product",
      product: {
        type: Inttegro::ProductType::DIGITAL,
        name: "Monthly subscription",
        quantity: 1,
        price: Inttegro::PriceParams.new(
          currency: Inttegro::Money::Currency::GHS,
          value: 5000
        )
      }
    }]
  )

  checkout_url = order.invoice&.format_value&.web&.url
  raise "Order did not include a checkout URL" unless checkout_url
  puts "#{order.id} #{checkout_url}"
rescue Inttegro::APIError => error
  warn "#{error.code || 'api_error'}: #{error.detail || error.message}"
  raise
end

Amounts use integer minor units: 5000 GHS is GHS 50.00. Reuse the same idempotency key when retrying the same logical write. If you omit one, the SDK generates a UUIDv7 key for mutating calls.

Observe SDK operations

The SDK emits vendor-neutral OpenTelemetry spans through your application's provider. It never configures an exporter or sends telemetry by itself. Configure OpenTelemetry before creating the client:

require "opentelemetry/sdk"
require "inttegro"

OpenTelemetry::SDK.configure
inttegro = Inttegro::Client.new(api_key: ENV.fetch("INTTEGRO_API_KEY"))

Spans are named after logical operations such as inttegro.orders.create. HTTP attempts, response receipt, and decoding are span events. API keys, bodies, resource IDs, dynamic URLs, and exception messages are never recorded. See SDK observability for the complete contract and set telemetry_enabled: false when needed.

Report SDK failures

Provide an application-owned reporter to receive one immutable, typed, privacy-safe report after an SDK operation finally fails. The default :unexpected policy reports transport, timeout, decoding, SDK, unknown_error, and server-side failures while leaving normal 4xx API errors alone:

inttegro = Inttegro::Client.new(
  api_key: ENV.fetch("INTTEGRO_API_KEY"),
  error_reporter: ->(report) { ErrorCollector.enqueue(report.serialize) }
)

Use error_reporting_policy: :all to include expected API failures; cancellations are never reported. Reports contain the logical operation, static route, server host, status and request IDs when available, duration, safe API error codes, SDK identity, stable fingerprint, exception type, and trace IDs when tracing is active. They exclude credentials, headers, bodies, resource IDs, dynamic URLs, exception messages, and stack traces. Reporter failures are isolated and the original SDK error is still raised.

Error reporting is completely opt-in. Without error_reporter, the SDK does not calculate report metadata, create an event ID or timestamp, allocate a report, or serialize a payload.

Work with the API

The SDK covers orders and checkout, customers, products and prices, purchase intents, payment methods, balances, payouts and refunds, notifications, files, application settings, keys, and country specifications. Resources use snake-case readers such as purchase_intents and payment_methods.

Ruby-specific features:

  • typed: strict throughout the gem with signatures on every method.
  • OpenAPI-generated T::Struct request and domain models for exact resource shapes.
  • OpenAPI-generated T::Enum classes for public API values.
  • Typed resource methods, binary downloads, and public RBI files included in the gem.
  • Configurable connection/read timeouts and an injectable adapter for tests.

Hash request payloads remain available for concise Ruby code. Sorbet applications can use the generated classes under Inttegro when they want construction-time field checks.

See the API reference for request fields and lifecycle rules, errors for recovery guidance, and idempotency for safe retries.

Verify a release

The GitHub release for each version is the canonical record. It contains the exact gem uploaded to RubyGems.org, SHA-256 checksums, and GitHub and RubyGems Sigstore attestations tied to the source commit and release workflow.

sha256sum --check SHA256SUMS
gh attestation verify inttegro-4.2.2.gem \
  --repo zebodotdev/inttegro-sdk-ruby

Develop

bundle install
bundle exec rake test
bundle exec rake sorbet
bundle exec rake openapi:check