SDK Methods
Related sections
- Definitions are found under Definitions
- Success and error callbacks are found under Success and Error types
- The data flow connected to the different methods are found under Sequence Diagrams
- What the consumer sees during the different flows are found under Execution flow screenshots
Sessions
A valid session id and key are almost always required as arguments in order to call the SDK methods. To create a session, the Mobile App Backend needs to create a session and return it to the Mobile App, either via API or push messages. See the API Reference and Create Wallet Session.
Generic methods
Current available methods used regardless of selected flow are outlined below.
Signature | Description |
|---|---|
getSDKVersion⚠️ | Get the current Wallets SDK version NB! Deprecated. Will be removed in the future. Use getSDKInfo instead. |
deleteWallet | Delete the wallet and secure ID of the consumer. The consumer must go through the onboarding again if they later want to use the wallet. |
getSDKInfo | Returns relevant Wallets- and Secure ID SDK information |
getDynamicSDKId🆕 | Returns a dynamic and unique Secure ID SDK ID. |
getSDKVersion ⚠️
Returns SDK version as a String. NB! Will soon be removed. Use getSDKInfo instead.
Example
val sdkVersion = walletsSDK.getSDKVersion()
deleteWallet
Deletes both Wallet and Secure ID of the consumer. Will call delete on keys in secure hardware and delete other data used by the SDK. Requires consumer authentication
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Example
walletsSDK.deleteWallet(sessionId, sessionKey, callback)
getSDKInfo
Returns SDK information, including Secure ID information.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| callback | WalletCallback | See WalletCallbacksection |
Returns
Parameter name | Parameter type | Note |
|---|---|---|
data | SDKInfo | See |
Example
val sdkVersion = walletsSDK.getSDKInfo(callback)
getDynamicSDKId 🆕
Returns a dynamic and unique Secure ID SDK ID.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| callback | WalletCallback | See WalletCallbacksection |
Returns
Parameter name | Parameter type | Note |
|---|---|---|
data | String | UUID The dynamic ID |
Example
val dynamicSDKId = walletsSDK.getDynamicSDKId(callback)
Methods: Standard flow
Current available methods are outlined below.
Signature | Description |
|---|---|
openWallet | Onboards/authenticates the consumer and opens the Wallets Dashboard for managing payment instruments. |
initPayment | Will retrieve payment information and display it in a payment UI above the Mobile App UI. On consumer clicking the pay button, a SCA will be performed to sign the transaction. |
openWallet
Wallets SDK will handle most of the lifecycle for the merchant. The SDK will check device compatibility, if the consumer has been onboarded before, and select the correct onboarding or signing options for SCA before opening the Wallets Frontend in a WebView.
Consumers must authenticate, either by onboarding with pre-defined Identity Providers, or if already onboarded, signing in with app pin (and biometrics when used).
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Example
walletsSDK.openWallet(sessionId, sessionKey, callback)
initPayment
Will retrieve payment information and display it in a payment UI over the Mobile App UI. On consumer clicking the pay button, a SCA will be performed to sign the transaction.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Example
walletsSDK.initPayment(sessionId, sessionKey, callback)
Methods: Partial flow
| Signature | Description |
|---|---|
| getOpenWalletURL | Onboards/authenticates the consumer and returns a URL to the Wallets Dashboard for managing payment instruments. Mobile App is responsible for opening the dashboard. |
| getPaymentInfo | Retrieves payment information and returns the information to the Mobile App. Mobile App is responsible for displaying the payment information to be signed in a payment UI. |
| signPayment | Signs the payment with SCA. Mobile App is responsible for displaying success/error. |
| cancelPayment | Informs backend systems of consumer cancelling a payment from Mobile App payment UI |
getOpenWalletURL
Wallets SDK will handle most of the lifecycle for the merchant. The SDK will check device compatibility, if the consumer has been onboarded before, and select the correct onboarding or signing options for SCA before returning a Wallets Frontend URL to the Mobile App. Consumers must authenticate, either by onboarding with pre-defined Identity Providers, or if already onboarded, signing in with app pin (and biometrics when used).
The Mobile App is responsible for displaying the Wallets Frontend in a WebView using the provided URL. The URL must be opened before session expiration.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Returns
Parameter name | Parameter type | Note |
|---|---|---|
data | AuthenticateData | See |
Example
walletsSDK.getOpenWalletUrl(sessionId, sessionKey, callback)
IWebAppInterface
When partial open wallet flow is selected with getOpenWalletURL, the Mobile App is responsible for opening the Wallets Frontend in a WebView. The Wallets SDK IWebAppInterface should be implemented to allow for correct handling of session expiration and navigation, allowing for communication between Mobile App and the Wallets dashboard inside the WebView.
The following methods from Wallets SDK IWebAppInterface should be overridden
- handleSessionExpiration – Implement logic on how to handle session expiration. E.g. show UI to user.
- notifyCanGoback – Implement logic to avoid WebView being closed when user natively goes back while inside the WebView, unless user is on the Wallets dashboard front page.
import com.aerahost.aerawalletssdk.external.webview.IWebAppInterface
class YourWebAppInterface(viewModel: YourViewModel): IWebAppInterface {
@JavaScriptInterface
Override fun handleSessionExpiration(){
// Implement your logic
}
@JavaScriptInterface
Override fun notifyCanGoBack(canGoBack: Boolean){
// Update viewModel or similar with canGoback
}
}
@Composable
class YourWebVievWapper {
// Handle back clicks, e.g.
BackHandler(enabled = true) {
val webview = webviewRef.value
if (canGoBack) {
// user is not on wallets dashboard/front page and should navigate back inside the webview
webview?.evaluateJavascript(“(typeof window.goBackInWebapp === ‘function’)”
) { isDefined ->
/* only navigate back in dashboard if in Aera wallet.
If user wants to navigate back while in external URL without navigation implementation
(e.g. during pps onboarding) inside webview, close wallet. */
if (isDefined == "true") {
webView.evaluateJavascript("window.goBackInWebApp()", null)
} else {
// navigate back in your app
}
}
} else {
// navigate back in your app
}
}
// ...implement your WebView logic and display the wallets dashboard
// Allow Wallets dashboard to call the “Android” methods implemented in YourWebAppInterface
addJavaScriptInterface(YourWebAppInterface(viewModel), “Android”)
}
getPaymentInfo
Wallets SDK will handle retrieval of payment information.
The Mobile App is responsible for opening a payment UI using their own UI and signing the payment with the payment instrument ID selected by the consumer.
Returns payment information to be displayed and used for payment.
The method should first be called when the Mobile App backend has triggered the Mobile App to do so after the Merchant Store (POS) has initiated a sale. See “Data flows” section.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Returns
Parameter name | Parameter type | Note |
|---|---|---|
data | PaymentData | See |
Example
walletsSDK.getPaymentInfo(sessionId, sessionKey, callback)
signPayment
The method should be called whenever a consumer wants to sign the payment, e.g. clicking a pay button inside the Mobile App Payment UI.
Wallets SDK will handle SCA for signing the payment.
Mobile App is responsible for displaying confirmation/error feedback to the consumer.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| data | SignPaymentData | See Definitionssection |
| callback | WalletCallback | See WalletCallbacksection |
Example
walletsSDK.signPayment(sessionId, sessionKey, signPaymentData, callback)
cancelPayment
The method should be called whenever a consumer wants to cancel a payment via the Mobile App Payment UI before a transaction is finished.
After the Mobile App Payment UI is opened, the Mobile App must notify other systems of any payment cancellation initiated by the consumer, e.g. consumer clicking cancel/close buttons or swiping away a dialog. The method should not be called when cancellation occurs after the transaction has been conducted with success or error result.
Arguments
| Parameter name | Parameter type | Note |
|---|---|---|
| sessionKey | String | UUID |
| sessionId | String | UUID |
| callback | WalletCallback | See WalletCallbacksection |
Example
walletsSDK.cancelPayment(sessionId, sessionKey, callback)Updated about 1 month ago
