Flutter SDK
The MoneyHash Flutter SDK allows developers to integrate MoneyHash payment processing into their mobile applications. With this SDK, you can easily accept customer payments, manage subscriptions, and send payouts in your Flutter apps.
Prerequisites
Before integrating MoneyHash with the Flutter SDK, ensure you have completed the following steps:
- Get Started with MoneyHash to access your own Organization.
- Create an Account within your Organization.
- Connect providers to your new Account.
- Set up your Payment Defaults.
- Obtain your API keys from the dashboard to make API calls.
Installing
To install MoneyHash's Flutter SDK, Run the following in your terminal:
flutter pub add moneyhash_payment
This will add a line like this to your package's pubspec.yaml with the package including the latest version:
dependencies:
moneyhash_payment: ^{{latest_version}}
Additional Requirements for Android
To use the MoneyHash SDK on Android, you must include the following activities in your AndroidManifest.xml
file:
<activity android:name="com.moneyhash.sdk.android.payment.PaymentActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
<activity android:name="com.moneyhash.sdk.android.payout.PayoutActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
To ensure these activities are displayed in full-screen mode, you can define a custom style in your styles.xml
file, as shown below:
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Integration
After installing the MoneyHash Flutter SDK, you can start integrating it into your Flutter application. The integration involves several key steps:
Step 1: Create an Intent
Before initiating any payment or payout process, you need to get the intent id that created by you server. An Intent represents a payment or payout operation that you plan to perform.
Ensure you receive and store the intentId
from the your server response, as you will need it in subsequent steps.
Step 2: Create a MoneyHash Instance
Import the MoneyHash SDK in your Dart code and create an instance of MoneyHashSDK
.
import 'package:moneyhash/moneyhash.dart';
final MoneyHashSDK moneyHashSDK = MoneyHashSDK();
Step 3: Set the Public API Key
Set your public API key to authenticate your SDK instance. Obtain your public API key from the MoneyHash Dashboard under your Account settings. For more information on obtaining your public API key, see the MoneyHash Authentication Documentation.
moneyHashSDK.setPublicKey("your_public_api_key");
Step 4: Get Intent Details
Retrieve the details of the intent that was created earlier by your server. This will provide you with the current state of the intent and other relevant information.
try {
final intentDetails = await moneyHashSDK.getIntentDetails(
"<intent_id>",
IntentType.payment, // or IntentType.payout
);
print(intentDetails);
} catch (e) {
print("Error retrieving intent details: $e");
}
Refer to the IntentDetails
model for a complete list of available properties.
Basic Concepts
- Basic Concepts: Understand how the MoneyHash Flutter SDK works and the key elements to know before starting the integration.
- Retrieve Available Methods: Learn how to retrieve available payment or payout methods for an account or a specific intent.
- Collect Card Information: Discover how to collect card data securely for processing payments.
- Pay with Card Information: Learn how to process payments using card data collected through the MoneyHash SDK.
- Save Card Information: Explore how to save a customer's card information for future payments.
- Apple Pay & Native Payment Methods: Learn how to integrate native payment methods like Apple Pay or Google Pay for a streamlined payment experience.
Overview of MoneyHash APIs
For a detailed guide to all available APIs in the MoneyHash SDK for Flutter, including parameters, return types, and usage examples, refer to the following documentation:
This includes methods for handling payments, retrieving intent details, submitting forms, and more.
Overview of MoneyHash Models
The MoneyHash SDK for Flutter features various models to represent data structures like intents, payment methods, transactions, and card information. For comprehensive details on these models, including their properties and usage within the SDK, see the Models Documentation.
Migrating from Previous Versions
If you are currently using MoneyHash SDK version 2.0 and wish to upgrade to version 2.1, please refer to our Migration Guide. The guide provides detailed instructions on updating your codebase to be compatible with the latest SDK version.
Questions and Issues
Please provide any feedback or report issues via a GitHub Issue.
Updated 2 months ago