easy_stripe_payment 3.0.8
easy_stripe_payment: ^3.0.8 copied to clipboard
A Flutter package that provides simple and ready stripe payment method.
π¦ Easy Stripe Payment #
Easy Stripe Payment is a simple Flutter library to handle payments using Stripe easily and quickly, without complex setup. This library provides a flexible way to create Payment Intents and present a Payment Sheet directly . you just have to active payment method in your stripe dashboard from here and here you are every think will be perfect >>
π Features #
β
Easy and fast setup with init(secretKey , publishkey)
β
Easily create Payment Intent
β
Open Payment Sheet to complete the payment
β
Multi-currency support
β
Uses Dio for API request handling
β
Compatible with the latest versions of Flutter & Stripe
β
Everything automatically
β
Returns Final Result using Either from dartz:
β
Right β Payment Success π or β Left β Payment Failed (Error Message) β οΈ
β
Supports Refund Payments
π§ Requirements #
Android #
This plugin requires several changes to work on Android devices. Please make sure you follow all these steps:
- Use Android 5.0 (API level 21) and above.
- Use Kotlin version 1.8.0 and above
- Requires Android Gradle plugin 8 and higher: Link
- Use a descendant of
Theme.AppCompatfor your activity: Link , Link - Use
FlutterFragmentActivityinstead ofFlutterActivityinMainActivity.kt: Link - Add the following rules to your
proguard-rules.profile:link-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter -dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider - edit your
gradle.propertiesfile to be like this : link
iOS #
Compatible with apps targeting iOS 13 or above.
To upgrade your iOS deployment target to 13.0, you can either do so in Xcode under your Build
Settings, or by modifying IPHONEOS_DEPLOYMENT_TARGET in your project.pbxproj directly.
You will also need to update your Podfile:
platform :ios, '13.0'
For card scanning, add the following to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>Scan your card to add it automatically</string>
<key>NSCameraUsageDescription</key>
<string>To scan cards</string>
π Installation #
Add the package to pubspec.yaml:
run:
flutter pub add easy_stripe_payment
or :
dependencies:
easy_stripe_payment: ^3.0.8
Then run:
flutter pub get
βοΈ Setup #
Before using the library, initialize it with your Stripe Secret Key:
import 'package:easy_stripe_payment/easy_stripe_payment.dart';
//bring your publishableKey , secretKey
String publishKey = your_publishable_key;
String secretKey = your_secret_key;
//in your main function or DI
//make the main function future by adding async
void main() async {
//add these to line before your runApp
WidgetsFlutterBinding.ensureInitialized();
await EasyStripePayment.instance.init(secretKey: secretKey, publishKey: publishKey);
runApp(const MyApp());
}
β οΈβ οΈβ οΈβ οΈ
IMPORTANT NOTE
β οΈ Security Warning: β οΈ
Do not expose your Stripe Secret Key in the frontend,
use a secure server to fetch it.
β οΈβ οΈβ οΈβ οΈ
π³ Usage #
π Execute Payment #
//you can leave it like this
await EasyStripePayment.instance.makePayment(amount : your_amount , currency: your_currency);
// or use it like in the example
await EasyStripePayment.instance.makePayment(amount : your_amount , currency: your_currency).then((value){
value.fold(
(fail){
//TODO: DO SOMETHING
print("payment fail $fail");
},(success){
//TODO: DO SOMETHING
print("payment success");
}
);
});
// or consider it like variable
paymentResult = await EasyStripePayment.instance.makePayment(amount : your_amount , currency: your_currency);
paymentResult.fold(
(fail){
//TODO: DO SOMETHING
print("payment fail $fail");
},(success){
//TODO: DO SOMETHING
print("payment success");
}
);
π Amount is simple (50.00 USD = 50.00 USD , 50.00 EUR = 50.00 EUR etc..)
π Refund Payment #
1- get the payment charge id #
Sends a request to the Stripe API to refund a specific charge.
You must send the [latest_charge] which you can find in the response of [makePayment].
Example usage: #
final response = EasyStripePayment.instance.makePayment(
amount: 30,
currency: "eur",
description: "my description",
clientEmail: "ahmed@just4prog.com",
);
response.fold(
(fail) {
// TODO: Handle failure
},
(response) async {
// TODO: Handle success
String latestCharge = response.data["latest_charge"];
// Create your refund
await refundPayment(latestCharge: latestCharge);
},
);
2- make refund : #
await EasyStripePayment.instance.refundPayment(latestCharge: "your_charge_id").then((value) {
value.fold(
(fail) {
print("Refund failed: $fail");
},
(success) {
print("Refund success");
}
);
});
β Support My Work #
If you find Easy Stripe Payment useful and would like to support my work, consider buying me a coffee!
A small cup of coffee might not mean much to you, but for me, it means a lotβit fuels my passion and helps me continue building and improving tools for the Flutter community. π
π Buy me a coffee
Your support keeps me motivated to provide more content, updates, and helpful tools. Thank you for being awesome! β€οΈ #
π License #
This library is licensed under the MIT License, which means you are free to use and modify it under the terms of the license.
π Get started now and provide a smooth payment experience for your users! π³π
Contact #
Email: ahmadnahal7@gmail.com
Payment Methods Available #
Cards #
- Cards - Popular globally.
- Cartes Bancaires - Popular in France.
Wallets #
- Alipay - Popular in China.
- Apple Pay - Popular globally.
- Google Pay - Popular globally.
- Link - Customized, popular globally.
- MobilePay - Popular in Denmark and Finland.
- PayPal - Popular globally.
- Revolut Pay - Popular in Europe and the United Kingdom.
- WeChat Pay - Popular in China.
Vouchers #
- Multibanco - Popular in Portugal.
Bank Redirects #
- Bancontact - Popular in Belgium.
- BLIK - Popular in Poland.
- EPS - Popular in Austria.
- giropay - Popular in Germany.
- iDEAL - Popular in the Netherlands.
- Przelewy24 - Popular in Poland.
- Sofort - Popular in Germany, Austria, and Switzerland.
- TWINT - Popular in Switzerland.
Buy Now, Pay Later #
- Klarna - Popular in Europe and the United States.
Bank Debits #
- SEPA Direct Debit - Popular in Europe.
- ACH Direct Debit - Popular in the United States.
Bank Transfers #
- Bank transfer - Popular globally, used for large payments.
Webhooks (Recommended) #
- Webhooks - Recommended for improving transaction security.
Payment Methods by Country #
- South Korea - Includes South Korean cards, Naver Pay, Kakao Pay, Samsung Pay, and Payco.