Flutter Widget for Swervpay
X (Twitter) · Linkedin · Changelog
Installation
$ flutter pub add swervpay_widget
Configuration
Create a new instance of Swervpay with your secret_key and business_id:
import "package:swervpay_widget/swervpay_widget.dart";
Navigator.of(context).push(
CupertinoPageRoute(
builder: (c) => SwervpayView(
sandbox: true,
publicKey: const String.fromEnvironment('SWERV_PUBLIC_KEY', defaultValue: 'pk_dev_123'),
businessId: const String.fromEnvironment('SWERV_BUSINESS_ID', defaultValue: 'bsn_123'),
//checkoutId: 'hbnbbbbbb',
data: SwervpayCheckoutDataModel(
reference: DateTime.now().toString(),
amount: 10000,
description: 'description',
currency: 'NGN',
),
onSuccess: (response) {
print(response);
},
onClose: () => print('closed'),
onLoad: () => print('loaded'),
),
),
);
// OR
await SwervpayWidget.launchWidget(
context,
sandbox: true,
key: const String.fromEnvironment('SWERV_PUBLIC_KEY', defaultValue: 'pk_dev_123'),
businessId: const String.fromEnvironment('SWERV_BUSINESS_ID', defaultValue: 'bsn_123'),
//checkoutId: 'hbnbbbbbb',
data: SwervpayCheckoutDataModel(
reference: DateTime.now().toString(),
amount: 100,
description: 'description',
currency: 'NGN',
),
onSuccess: (response) {
print(response);
},
onClose: () => print('closed'),
onLoad: () => print('loaded'),
);
Replace <SWERV_PUBLIC_KEY> and <SWERV_BUSINESS_ID> with your actual secret key and business ID.