Android SDK
The MoneyHash Android 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 Android apps.
Prerequisites
Before integrating MoneyHash with the Android 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 integrate MoneyHash's Android SDK into your application, follow these steps:
Step 1: Add the MoneyHash SDK Dependency
-
Open Your Project's
build.gradle
FileNavigate to your project's
build.gradle
file (usually the one at the project root) and ensure that themavenCentral()
repository is included:allprojects { repositories { google() mavenCentral() } }
-
Add the Dependency to Your Module's
build.gradle
FileOpen your app module's
build.gradle
file and add the MoneyHash SDK dependency:dependencies { // Other dependencies implementation 'io.moneyhash:android:{{latest_version}}' // Replace with the latest version }
-
Sync Your Project
After adding the dependency, sync your project to download the SDK.
Integration
After installing the MoneyHash Android SDK, you can start integrating it into your Android application. The integration involves several key steps:
Step 1: Create an Intent
Before initiating any payment or payout process, you need to create an Intent on your server. An Intent represents a payment or payout operation that you plan to perform.
Ensure you receive and store the intentId
from your server's response, as you will need it in subsequent steps.
Step 2: Initialize the MoneyHash SDK
Import the MoneyHash SDK in your Java or Kotlin code and create an instance of MoneyHashSDK
.
For Kotlin:
// Initialize the SDK using the builder
val moneyHashSDK = MoneyHashSDKBuilder()
.setPublicKey("your_public_api_key")
.build()
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.
(Note: The public API key is set during the initialization in the previous step.)
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.
For Kotlin:
// Retrieve intent details
try {
val intentDetails = moneyHashSDK.getIntentDetails(
intentId = "<intent_id>",
intentType = IntentType.Payment // or IntentType.Payout
)
println("Intent Details: $intentDetails")
} catch (throwable: Throwable) {
println("Error retrieving intent details: ${throwable.message}")
}
Refer to the IntentDetails
model for a complete list of available properties.
Basic Concepts
- Basic Concepts: Understand how the MoneyHash Android 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.
- Native Pay Documentation: Explore how to complete the payment using native pay methods (google pay).
Overview of MoneyHash APIs
For a detailed guide to all available APIs in the MoneyHash SDK for Android, 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 Android 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.
Questions and Issues
Please provide any feedback or report issues via a GitHub Issue.
This documentation provides Android developers with the necessary guidance to install and integrate the MoneyHash SDK into their applications, following the same structure and sections as the Flutter documentation provided.
Updated 25 days ago