Android SDK
📱 Installation guide for our Android SDK
💡Supporting the latest versionsThe SDK supports Android 9 and above
Add the repository in your build.gradle
or build.gradle.kts
.
You can install the SDK by adding the following line to the build.gradle
file under dependencies:
Initialize the SDK in your application with the flow, environment and any parameters related to Buy, Sell, NFT or Swap. Additionally you can choose to render the widget either as an in-app browser or a webview.
💡How to choose?An in-app browser will allow you to use native features like Google Pay, social sign-in and popups.
A webview will allow you to use a communication layer between the widget and your app and therefore get your app to perform certain actions once some events occur in the widget.
See the parameters pages for Buy, Sell and Swap for details on which parameters can be passed for each flow.
Arguments:
config
: MoonPaySdkConfig,
Your config variant must match your query params variant.
Variants:
MoonPaySdkBuyConfig
MoonPaySdkSellConfig
MoonPaySdkSwapsCustomerSetupConfig
MoonPaySdkLegacyConfig
Arguments:
debug
: Booleanenvironment
: MoonPayWidgetEnvironmentparams
: MoonPayQueryParamshandlers
: MoonPayHandlers?
📘ConfigurationPossible values for
environment
: MoonPayWidgetEnvironment.sandbox, MoonPayWidgetEnvironment.production
Your query params variant must match your config variant.
Variants:
MoonPayBuyQueryParams
MoonPaySellQueryParams
MoonPaySwapsCustomerSetupParams
MoonPayLegacyParams
All of the following are optional. However, you must explicitly pass nil
for each handler you don't need to implement.
Arguments:
onSwapsCustomerSetupComplete
: () -> VoidonUnsupportedRegion
: () -> VoidonKmsWalletCreated
: () -> VoidonAuthToken
: (OnAuthTokenRequestPayload) -> VoidonLogin
: (OnLoginRequestPayload) -> VoidonInitiateDeposit
: (OnInitiateDepositRequestPayload) -> OnInitiateDepositResponsePayload
Arguments:
token
: StringcsrfToken
: String
Arguments:
isRefresh
: Boolean
Arguments:
transactionId
: StringcryptoCurrencyAmount
: StringcryptoCurrencyAmountSmallestDenomination
: StringfiatCurrencyAmount
: String?depositWalletAddress
: StringcryptoCurrency
: CryptoCurrencyfiatCurrency
: FiatCurrency
Arguments:
depositId
: String
Arguments:
id
: Stringname
: Stringcode
: StringcontractAddress
: String?chainId
: String?coinType
: String?networkCode
: String?
Arguments:
id
: Stringname
: Stringcode
: String
If you're using the walletAddress
or walletAddresses
query param, you need to sign your widget URL before you can display the widget. Learn more about URL signing.
moonPaySdk.show
takes one argument, mode
, which takes a value of type MoonPayRenderingOptionAndroid. The mode variants are MoonPayRenderingOptionAndroid.WebViewOverlay and MoonPayRenderingOptionAndroid.InAppBrowser.
You need to sign your widget URL before you can display the widget. Learn more about URL signing.
Updated 3 months ago
Table of Contents
Install
Initialize
SDK Configuration
MoonPayAndroidSdk
MoonPaySdkConfig
MoonPayQueryParams
MoonPayHandlers
Handler Payload Types
OnAuthTokenRequestPayload
OnLoginRequestPayload
OnInitiateDepositRequestPayload
OnInitiateDepositResponsePayload
CryptoCurrency
FiatCurrency
Display