flutter_payvessel 1.0.1
flutter_payvessel: ^1.0.1 copied to clipboard
A Flutter SDK for Payvessel Payment Gateway. Supports Bank Transfer and Card payments with simple API.
Flutter Payvessel #
A Flutter SDK for integrating Payvessel Payment Gateway into your mobile app. Works similar to the npm package.
Features #
payvessel-checkout
- π³ Multiple Channels - Bank Transfer and Card payments
- π± Full-screen & Bottom Sheet - Choose how to display checkout
- π Callbacks - onSuccess, onError, onClose support
- π WebView-based - Uses your existing web checkout
Installation #
Add to your pubspec.yaml:
dependencies:
flutter_payvessel: ^1.0.0
Platform Setup #
Android #
Add internet permission in android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
iOS #
No additional setup required.
Usage #
Initialize and Launch Checkout #
Similar to the npm package:
import 'package:flutter_payvessel/flutter_payvessel.dart';
// Create Payvessel instance with your API key
final payvessel = Payvessel(
config: PayvesselConfig(
apiKey: 'YOUR_API_KEY',
),
);
// Launch checkout
Future<void> openCheckout() async {
final result = await payvessel.initializeCheckout(
context: context,
params: CheckoutParams(
customerEmail: 'customer@example.com',
customerPhoneNumber: '08012345678',
amount: '1000',
currency: 'NGN',
customerName: 'John Doe',
channels: [
PaymentChannels.bankTransfer,
PaymentChannels.card,
],
metadata: {
'order_id': '12345',
},
),
onError: (error) => print('Error: $error'),
);
if (result.isSuccessful) {
print('Payment successful!');
print('Reference: ${result.reference}');
} else if (result.isCancelled) {
print('Payment cancelled');
} else {
print('Payment failed: ${result.message}');
}
}
Trigger from a Button #
ElevatedButton(
onPressed: openCheckout,
child: Text('Pay with Payvessel'),
)
Bottom Sheet Mode #
final result = await payvessel.initializeCheckout(
context: context,
params: params,
fullScreen: false, // Shows as bottom sheet
);
Parameters #
PayvesselConfig #
| Parameter | Type | Required | Description |
|---|---|---|---|
| apiKey | String | β | Your Payvessel API key |
| checkoutUrl | String | β | Custom checkout URL (optional) |
CheckoutParams #
| Parameter | Type | Required | Description |
|---|---|---|---|
| customerEmail | String | β | Customer's email |
| customerPhoneNumber | String | β | Customer's phone number |
| amount | String | β | Amount to charge (e.g., "1000") |
| currency | String | β | Currency code (e.g., "NGN") |
| customerName | String | β | Full name of the customer |
| channels | List | β | Payment channels. Defaults to BANK_TRANSFER |
| metadata | Map | β | Custom metadata object |
| reference | String | β | Unique transaction reference |
| redirectUrl | String | β | URL to redirect after payment |
PayvesselResult #
| Property | Type | Description |
|---|---|---|
| status | PayvesselStatus | Transaction status |
| isSuccessful | bool | Whether payment succeeded |
| isFailed | bool | Whether payment failed |
| isCancelled | bool | Whether user cancelled |
| reference | String? | Payment reference |
| paymentId | String? | Payment ID |
| transactionId | String? | Transaction ID |
| message | String? | Error or status message |
Payment Channels #
PaymentChannels.bankTransfer // "BANK_TRANSFER"
PaymentChannels.card // "CARD"
PaymentChannels.all // Both channels
Comparison with npm Package #
| npm Package | Flutter SDK |
|---|---|
Checkout({ api_key }) |
Payvessel(config: PayvesselConfig(apiKey: ...)) |
initializeCheckout({ ... }) |
payvessel.initializeCheckout(params: CheckoutParams(...)) |
onSuccess |
result.isSuccessful |
onError |
onError callback or result.isFailed |
onClose |
result.isCancelled |
Example #
See the example directory for a complete sample app.
License #
MIT License