Skip to content

Switching Providers

The core value of Sanwo is provider portability. Your checkout logic, UI code, and result handling stay identical no matter which payment provider you use. Switching from one provider to another is a one-line change.

Here is a complete provider switch from Paystack to Flutterwave on the web:

import { createSanwo } from "@sanwohq/web";
import { paystackProvider } from "@sanwohq/paystack";
const sanwo = createSanwo({
provider: paystackProvider,
publicKey: "pk_test_xxxxxxxxxxxx",
});

Only two things changed: the import and the public key. The checkout call is exactly the same:

const result = await sanwo({
amount: 500000, // 5,000.00 in minor units
currency: "NGN",
customer: { email: "customer@example.com" },
});
if (result.status === "successful") {
console.log("Paid!", result.reference);
}

This code works identically with Paystack, Flutterwave, Razorpay, Monnify, or Interswitch. You never touch it when switching providers.

Change the provider prop on SanwoReactProvider. Everything inside the tree stays the same.

import { SanwoReactProvider } from "@sanwohq/react";
import { paystackProvider } from "@sanwohq/paystack";
export default function App() {
return (
<SanwoReactProvider provider={paystackProvider} publicKey="pk_test_xxxxxxxxxxxx">
<CheckoutPage />
</SanwoReactProvider>
);
}

Your CheckoutPage component, useSanwoCheckout() calls, and SanwoButton usage remain untouched.

Change the provider import and the Sanwo constructor. Your checkout options and result handling stay identical.

import 'package:sanwo_paystack/sanwo_paystack.dart';
final sanwo = Sanwo(
provider: paystackProvider,
publicKey: 'pk_test_xxxxxxxxxxxx',
);

Your CheckoutOptions, CheckoutResult handling, and event listeners all remain the same.

At the Sanwo API level, you always pass amounts in minor units (kobo, cents, paise). Sanwo auto-converts for providers that expect major units:

  • Paystack, Razorpay, Interswitch use minor units natively – your value is passed through.
  • Flutterwave, Monnify expect major units – Sanwo divides by 100 automatically.

You never need to adjust amounts when switching providers.

Not all providers support the same currencies. Before switching, verify your currency is supported:

Provider Currencies
Paystack NGN, GHS, ZAR, USD, KES
Flutterwave NGN, GHS, KES, ZAR, USD, EUR, GBP, TZS, UGX, RWF, XAF, XOF
Razorpay INR, USD, EUR, GBP, SGD, AED, MYR
Monnify NGN
Interswitch NGN

See the Choosing a Provider page for full details.

Provider-specific options don’t carry over

Section titled “Provider-specific options don’t carry over”

Any options you pass via sanwoProviderOptions are specific to one provider. When you switch providers, those options are silently ignored – no errors, but the feature won’t apply. For example, a Paystack plan field has no meaning to Flutterwave.

Review the Provider-Specific Options guide for what each provider supports.

Each provider issues its own API keys. When you switch providers, you need a new key from the new provider’s dashboard:

Provider Key format Dashboard
Paystack pk_test_... dashboard.paystack.com
Flutterwave FLWPUBK_TEST-... dashboard.flutterwave.com
Razorpay rzp_test_... dashboard.razorpay.com
Monnify MK_TEST_... Monnify Dashboard
Interswitch MX_TEST_... Interswitch Dashboard

A common pattern is choosing the provider at runtime based on an environment variable. This lets you use different providers in different environments or regions without code changes.

import { createSanwo } from "@sanwohq/web";
import { paystackProvider } from "@sanwohq/paystack";
import { flutterwaveProvider } from "@sanwohq/flutterwave";
const provider =
process.env.PAYMENT_PROVIDER === "flutterwave"
? flutterwaveProvider
: paystackProvider;
const publicKey = process.env.PAYMENT_PUBLIC_KEY;
const sanwo = createSanwo({ provider, publicKey });

Set the environment variables in your .env file:

Terminal window
# .env for Paystack
PAYMENT_PROVIDER=paystack
PAYMENT_PUBLIC_KEY=pk_test_xxxxxxxxxxxx
# .env for Flutterwave
PAYMENT_PROVIDER=flutterwave
PAYMENT_PUBLIC_KEY=FLWPUBK_TEST-xxxxxxxxxxxx

This works well for:

  • A/B testing providers to compare conversion rates
  • Regional routing – use Paystack in Nigeria, Razorpay in India
  • Gradual migration – roll out a new provider to a percentage of traffic
  • Fallback strategies – switch to a backup provider during outages