twocheckout_flutter 0.0.1-dev.2 twocheckout_flutter: ^0.0.1-dev.2 copied to clipboard
A wrapper flutter plugin for implementation of 2checkout-android-sdk
2Checkout Flutter #
The 2Checkout Flutter SDK wrapper for 2checkout-android-sdk allows you to build delightful payment experiences in your native Android (for iOS work is in progress). We provide powerful and customizable UI screens, widget, and method channels for native functions access that can be used out-of-the-box to collect your users' payment details.
Features #
- Simplified Security: We make it simple for you to collect sensitive data such as credit card numbers and remain PCI compliant. This means the sensitive data is sent directly to 2Checkout (Now Verifone) instead of passing through your server. For more information, see our Integration Security Guide.
- Payment methods: Accepting more payment methods helps your business expand its global reach and improve checkout conversion.
- SCA-Ready: The SDK automatically performs native 3D Secure authentication if needed to comply with Strong Customer Authentication.
- Native UI: We provide native screens and elements to securely collect payment details on Android and iOS.
- Pre-built payments UI: Learn how to integrate Payment Sheet, the new pre-built payments UI for mobile apps. This pre-built UI lets you accept cards and Paypal out of the box.
Recommended usage #
If you're selling digital products or services within your app, (e.g. subscriptions, in-game currencies, game levels, access to premium content, or unlocking a full version), you must use the app store's in-app purchase APIs. See Apple's and Google's guidelines for more information. For all other scenarios you can use this SDK to process payments via 2checkout.
Installation #
To install the 2Checkout Flutter plugin, use the following Dart package command:
dart pub add twocheckout_flutter
Requirements #
Android Requirements #
To ensure proper functionality on Android devices, please make sure to follow these steps:
- Use Android 4.0 (API level 19) and above.
- Utilize Kotlin version 1.7.0 and above.
- Ensure you are using an up-to-date Android Gradle build tools version.
- Use an up-to-date Gradle version accordingly.
- Remember to rebuild the app after making the above changes, as these changes may not take effect with hot reload.
If you encounter difficulties while setting up the package on Android, join the discussion for support.
Usage #
Card Payments #
You can handle card payments using two methods: PayPal integration and Card Form.
Financial Connections #
The latest SDK also supports financial connections. Refer to the documentation to learn more about setting it up.
Dart API #
The library offers several methods for handling 2Checkout-related actions:
Callback to show a dialogue with title and detail.
void onShowDialogue(String title, String detail);
Callback to dismiss a displayed dialogue.
void onDismissDialogue();
Callback to show a loading spinner or progress bar.
void onShowProgressBar();
Callback to hide a loading spinner or progress bar (optional).
void onHideProgressBar();
Callback to show a payment confirmation screen.
void onShowPaymentDoneScreen();
Response Return from Api call
void onApiCallResponse();
Initialization of 2Checkout SDK #
_twoCheckoutFlutterPlugin.setTwoCheckoutCredentials(
"secretKey", "merchant_key");
Customization of native code on the Flutter side makes it easier for Flutter developers to perform actions such as displaying alert dialogues, dismissing/loading spinners, and navigating to customized pages. you just need to implement TwoCheckoutFlutterEvents class to override your required methods
@override
void onHideProgressBar() {
dismissProgressBar();
}
@override
void onShowDialogue(String title, String detail) {
showMyDialog(title,detail);
}
@override
void onShowPaymentDoneScreen() {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => const PaymentFlowDoneScreen(
label: 'Customer label',
amount: '10 USD',
ref: 'ref',
),
),
);
}
@override
void onShowProgressBar() {
progressDialogue(context);
}
@override
void onDismissDialogue() {
// TODO: implement onDismissDialogue
}
Running the Example App #
To run the example app, follow these steps:
- Navigate to the example folder:
cd example
. - Install the dependencies:
flutter pub get
. - Set up environment variables for the Flutter app and a local backend.
- Obtain your secret and Merchant key from the 2Checkout dashboard.
- Set the keys in the function called
_twoCheckoutFlutterPlugin.setTwoCheckoutCredentials("secretKey", "merchant_key")
.
Here is the list of test cards on the official 2Checkout platform.
- Run Flutter:
flutter run
.
Contributing #
You can help us make this project better by contributing. Feel free to open a new issue or submit a pull request.