HyperPay Flutter
A Flutter plugin for integrating HyperPay payment gateway with enhanced features including Apple Pay and card payments.
Features
- π³ Credit Card Payments
- π¦ MADA Support
- π Apple Pay Integration
- π Automatic Checkout ID Creation
- π¨ Beautiful UI Components
- β¨ Type-safe API
- π Secure Payment Processing
- π± Example App Included
Installation
Add this to your package's pubspec.yaml file:
dependencies:
hyperpay_flutter: ^0.1.0+1
Usage
Initialize HyperPay
await HyperPay.init(
config: HyperPayConfig.test( // or HyperPayConfig.live for production
merchantIdentifier: 'YOUR_MERCHANT_ID',
companyName: 'YOUR_COMPANY_NAME',
authToken: 'YOUR_AUTH_TOKEN',
entityId: 'YOUR_ENTITY_ID',
),
);
Process a Payment
try {
final result = await HyperPay.I.pay(
amount: 100.0,
currency: 'SAR',
method: PaymentMethod.card, // or PaymentMethod.applePay
);
switch (result.status) {
case PaymentStatus.success:
print('Payment successful! Transaction ID: ${result.transactionId}');
case PaymentStatus.failed:
print('Payment failed: ${result.error}');
case PaymentStatus.canceled:
print('Payment was canceled');
case PaymentStatus.pending:
print('Payment is pending');
}
} catch (e) {
print('Error processing payment: $e');
}
Check Apple Pay Availability
if (await HyperPay.I.hasApplePay) {
// Show Apple Pay button
}
Test Cards
Credit Cards (Success)
Card Number: 4440 0000 0990 0010
Cardholder Name: Any Name
Expiry Date: 01/39
CVV: 100
Result: Success
Card Number: 5123 4500 0000 0008
Cardholder Name: Any Name
Expiry Date: 01/39
CVV: 100
Result: Success
Credit Cards (Failure)
Card Number: 5204 7300 0000 2514
Cardholder Name: Any Name
Expiry Date: 01/39
CVV: 251
Result: Fail
MADA Cards
Card Number: 5360 2301 5942 7034
Cardholder Name: Any Name
Expiry Date: 11/24
CVV: 850
Example App
Check out the example directory for a complete sample app demonstrating all features.
API Documentation
HyperPay
The main class for interacting with the payment gateway.
HyperPay.I- Singleton instanceHyperPay.init()- Initialize the SDKHyperPay.isInitialized- Check if SDK is initializedHyperPay.config- Current configuration
Payment Methods
enum PaymentMethod {
applePay,
card,
mada,
}
Payment Status
enum PaymentStatus {
success,
failed,
canceled,
pending,
}
Configuration
// Test Environment
final config = HyperPayConfig.test(
merchantIdentifier: 'YOUR_MERCHANT_ID',
companyName: 'YOUR_COMPANY_NAME',
authToken: 'YOUR_AUTH_TOKEN',
entityId: 'YOUR_ENTITY_ID',
);
// Live Environment
final config = HyperPayConfig.live(
merchantIdentifier: 'YOUR_LIVE_MERCHANT_ID',
companyName: 'YOUR_COMPANY_NAME',
authToken: 'YOUR_LIVE_AUTH_TOKEN',
entityId: 'YOUR_LIVE_ENTITY_ID',
);
Contributing
Contributions are welcome! Please read our contributing guidelines to get started.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- hyperpay_flutter
- HyperPay Flutter plugin for integrating HyperPay payment gateway with enhanced features including Apple Pay and card payments.