Sanwo Ruby SDK
Add Sanwo payments to your Ruby application — Rails or standalone.
Full documentation at docs.sanwo.dev — guides, examples, and API reference for every SDK and provider.
Install
gem install sanwo
Or add to your Gemfile:
gem "sanwo"
Standalone Usage
require "sanwo"
client = Sanwo::Client.new(
provider: "paystack",
public_key: "pk_test_xxx"
)
# Include the CDN script tag in your <head>
client.render_script
# => '<script src="https://cdn.jsdelivr.net/npm/@sanwohq/embed/dist/sanwo.global.js"></script>'
# Render a checkout button (amount in minor units)
client.render_checkout(
amount: 50000,
email: "user@example.com",
description: "Premium plan",
button_text: "Subscribe"
)
Rails Setup
Add the gem to your Gemfile and configure an initializer:
# config/initializers/sanwo.rb
Rails.application.config.sanwo_client = Sanwo::Client.new(
provider: "paystack",
public_key: ENV["PAYSTACK_PUBLIC_KEY"],
currency: "NGN"
)
Then use the view helpers in your templates:
<head>
<%= sanwo_scripts %>
</head>
<body>
<%= sanwo_checkout(amount: 50000, email: current_user.email) %>
</body>
Custom Amount Input
<%= sanwo_custom_amount(
email: current_user.email,
min_amount: 10000,
max_amount: 1000000,
placeholder: "Enter donation amount"
) %>
Custom Provider Template
client = Sanwo::Client.new(
provider: "custom",
public_key: "pk_xxx",
template_url: "https://example.com/my-template.html"
)
Or with an inline template:
client = Sanwo::Client.new(
provider: "custom",
public_key: "pk_xxx",
template: "<div>Your custom checkout HTML</div>"
)
License
Apache 2.0 — see LICENSE for details.