easy_stripe_payment 4.0.0
easy_stripe_payment: ^4.0.0 copied to clipboard
A Flutter package that provides simple and ready stripe payment method.
π³ EasyStripePayment for Flutter #
A lightweight yet powerful Flutter package that makes Stripe payments integration a breeze.
It supports full payment flows including payment intent creation, payment sheet UI, charge verification, full & partial refunds, and charge detail retrieval β all with a clean API and modern Flutter standards.
you just have to active payment method in your stripe
dashboard from here
β 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! β€οΈ #
π Features #
- β Easy Stripe initialization with publishable key
- π§Ύ Create Payment Intents from backend
- π§ Collect user billing info (email, address, etc.)
- π³ Show Stripe Payment Sheet with all payment method
- β Verify payment status via backend
- πΈ Full or partial refunds
- π Retrieve charge details (including receipt URL)
- π Secure integration with your backend API
- π‘ Uses
dartzfor functional error handling - π οΈ State managed with
ChangeNotifier
π§ͺ Quick Test Mode with EasyStripePaymentTest For testing purposes, you can use EasyStripePaymentTest which allows initializing directly with both your publishableKey and secretKey (for local test only β οΈ). This skips the need for a backend during development:
π§ 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 - edit your
gradle.propertiesfile to be like this : 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
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: ^4.0.8
Test Mode : #
await EasyStripePaymentTest.instance.init(
secretKey: "sk_test_...",
publishKey: "pk_test_...",
);
β οΈ Use this only in development β Never expose your secretKey in production apps.
π§ͺ Quick Start #
1. Initialize Stripe #
await EasyStripePayment.instance.initStripe(
publishKey: "pk_test_...Just4prog.nl...",
baseUrl: "https://Just4prog.nl/",
merchantName: "Just4prog.nl",
);
2. Start Payment Flow #
final result = await EasyStripePayment.instance.makePayment(
paymentIntentEndpoint: "create-payment-intent/",
amount: 99.99,
currency: "eur",
name: "Ahmed",
email: "Ahmed@Just4prog.nl",
city: "Amsterdam",
country: "NL",
postalCode: "1234AB",
);
3. Verify Payment #
final verification = await EasyStripePayment.instance.verifyPayment(
statusEndpoint: "verify-payment/",
paymentIntentId: result.getOrElse(() => ""),
);
4. Get Charge Details #
final chargeDetails = await EasyStripePayment.instance.getChargeDetails(
chargeDetailsEndpoint: "charge-details/",
chargeId: "ch_1XYZ...",
);
5. Refunds (Full / Partial) #
// Full refund
await EasyStripePayment.instance.refundPayment(
refundEndpoint: "process-refund/",
chargeId: "ch_1XYZ...",
);
// Partial refund
await EasyStripePayment.instance.partialRefund(
partialRefundEndpoint: "partial-refund/",
amount: 50.00,
chargeId: "ch_1XYZ...",
);
π§ Architecture Overview #
EasyStripePaymentis a singleton for global access.- Integrates with your backend to handle all sensitive operations.
- Uses
Diofor HTTP requests. - Uses
Either<Error, Result>from Dartz to make error handling easy and expressive.
π¦ Backend Required Endpoints #
| Endpoint | Description |
|---|---|
/create-payment-intent |
Create a payment intent |
/verify-payment/:id |
Verify payment status via intent ID |
/charge-details/:id |
Retrieve charge details |
/process-refund/ |
Refund full payment |
/partial-refund/ |
Refund partial amount |
πΈ UI Example (in Flutter) #
ElevatedButton(
onPressed: () async {
final result = await EasyStripePayment.instance.makePayment(
paymentIntentEndpoint: "create-payment-intent",
amount: 49.99,
currency: "eur",
name: "Ahmed",
email: "Ahmed@just4prog.nl",
);
result.fold(
(error) => print("β Payment failed: $error"),
(intentId) => print("β
Success! Intent ID: $intentId"),
);
},
child: const Text("Pay β¬49.99"),
);
β¨ Author #
Developed with β€οΈ by Ahmed @ Just4Prog
Need a custom payment integration? Hit me up!
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.