Rapyd (rapyd v1.0.0)

Copy Markdown View Source

Production-grade Elixir SDK for the Rapyd fintech-as-a-service platform.

Quick Start

client = Rapyd.new!(
  access_key: System.fetch_env!("RAPYD_ACCESS_KEY"),
  secret_key: System.fetch_env!("RAPYD_SECRET_KEY"),
  sandbox: true
)

{:ok, payment} = Rapyd.Services.Collect.create_payment(client, %{
  amount: 100.00,
  currency: "USD",
  payment_method: %{
    type: "us_visa_card",
    fields: %{
      number: "4111111111111111",
      expiration_month: "12",
      expiration_year: "2026",
      cvv: "123"
    }
  }
})

Services

All API interaction is routed through domain-aligned service modules:

ServiceDescription
Rapyd.Services.CollectAccept payments, refunds, subscriptions, customers
Rapyd.Services.DisburseSend payouts to beneficiaries worldwide
Rapyd.Services.WalletManage eWallets, contacts, virtual accounts, KYC
Rapyd.Services.IssuingIssue and manage physical and virtual cards
Rapyd.Services.PartnerPayFac / KYB onboarding for sub-merchants
Rapyd.Services.WebhookVerify and route incoming Rapyd webhook events
Rapyd.Services.ResourceReference data: FX rates, countries, currencies

Error Handling

All API calls return {:ok, result} or {:error, %Rapyd.Error{}}.

case Rapyd.Services.Collect.create_payment(client, req) do
  {:ok, payment} ->
    IO.inspect(payment.id)

  {:error, %Rapyd.Error{type: :insufficient_funds}} ->
    # prompt customer for another payment method

  {:error, %Rapyd.Error{type: :rate_limit}} ->
    # back off and retry

  {:error, %Rapyd.Error{} = err} ->
    Logger.error("payment failed", code: err.error_code, op: err.operation_id)
end

Configuration

Options accepted by new/1 and new!/1:

OptionTypeDefaultDescription
:access_keyString.t()requiredRapyd access key
:secret_keyString.t()requiredRapyd secret key
:sandboxboolean()trueUse sandbox (true) or production (false)
:base_urlString.t()autoOverride the API base URL
:max_retriesnon_neg_integer()4Max request attempts (1 = no retries)
:timeoutnon_neg_integer()30_000Request timeout in milliseconds
:http_clientmoduleRapyd.HTTP.ClientSwappable HTTP client module

Summary

Functions

Builds a new Rapyd.Client from the given options.

Builds a new Rapyd.Client from the given options, raising on error.

Returns the SDK version string.

Functions

new(opts)

@spec new(keyword()) :: {:ok, Rapyd.Client.t()} | {:error, String.t()}

Builds a new Rapyd.Client from the given options.

Returns {:ok, client} or {:error, reason}.

Examples

{:ok, client} = Rapyd.new(
  access_key: "your_key",
  secret_key: "your_secret",
  sandbox: true
)

new!(opts)

@spec new!(keyword()) :: Rapyd.Client.t()

Builds a new Rapyd.Client from the given options, raising on error.

Examples

client = Rapyd.new!(
  access_key: System.fetch_env!("RAPYD_ACCESS_KEY"),
  secret_key: System.fetch_env!("RAPYD_SECRET_KEY")
)

version()

@spec version() :: String.t()

Returns the SDK version string.