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.
gem install sanwoOr add to your Gemfile:
gem"sanwo"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")Add the gem to your Gemfile and configure an initializer:
# config/initializers/sanwo.rbRails.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><%= sanwo_custom_amount(
email: current_user.email,
min_amount: 10000,
max_amount: 1000000,
placeholder: "Enter donation amount"
) %>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>")Apache 2.0 — see LICENSE for details.