Bank Account
This document provides comprehensive guidance on implementing and using the MoneyHash Bank Account feature in React Native applications.
1. Android Configuration
Add the following activity declaration to your android/app/src/main/AndroidManifest.xml
:
<activity
android:name="com.moneyhash.sdk.android.bank.BankAccountActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
This activity is required for the bank account tokenization flow on Android.
Models and Types
BankAccountTokenizationStatus
Represents the result of bank account tokenization operations:
enum BankAccountTokenizationStatus {
SUCCESSFUL = 'SUCCESSFUL',
PENDING_APPROVAL = 'PENDING_APPROVAL',
FAILED = 'FAILED'
}
BankAccountStatus
Represents the status of a saved bank account:
enum BankAccountStatus {
PENDING = 'PENDING',
ACTIVE = 'ACTIVE',
INACTIVE = 'INACTIVE'
}
MethodType
The SDK now includes support for saved bank accounts:
enum MethodType {
// ... other types
SavedBankAccount = 'savedBankAccount'
}
Using Saved Bank Accounts for Payment
Step 1: Retrieve Payment Methods
First, get the available payment methods to find saved bank accounts:
const methods = await moneyHashSDK.getMethods({
amount: 100,
currency: 'AED',
customer: 'customer-id',
});
console.log('Saved bank accounts:', methods.savedBankAccounts);
Step 2: Proceed with Saved Bank Account
Use a saved bank account for payment:
const savedBankAccounts = methods.savedBankAccounts;
if (savedBankAccounts && savedBankAccounts.length > 0) {
const selectedBankAccount = savedBankAccounts[0];
const proceedResult = await moneyHashSDK.proceedWithMethod(
'intent-id',
IntentType.Payment,
selectedBankAccount.id || '',
MethodType.SavedBankAccount,
undefined, // methodMetaData
undefined, // useWalletBalance
undefined // installmentPlanData
);
console.log('Proceed result:', proceedResult);
}
Step 3: Handle URL Rendering (if needed)
If the payment requires additional authentication, handle URL rendering:
const state = proceedResult.details?.intentState;
if (state && typeof state === 'object' && 'type' in state) {
if (state.type === 'url_to_render') {
const urlToRender = state as any;
const urlToShow = urlToRender.url;
console.log('URL to render:', urlToShow);
const urlResult = await moneyHashSDK.renderURL({
url: urlToShow,
intentId: 'intent-id',
intentType: IntentType.Payment,
});
console.log('URL render result:', urlResult);
}
}
Creating New Bank Account Tokens
Basic Bank Account Tokenization
To create a new bank account token:
try {
const result = await moneyHashSDK.renderCreateBankAccountTokenEmbed({
intentId: 'your-intent-id'
});
console.log('Tokenization result:', result);
// Handle different statuses
switch (result) {
case BankAccountTokenizationStatus.SUCCESSFUL:
console.log('Bank account successfully tokenized!');
break;
case BankAccountTokenizationStatus.PENDING_APPROVAL:
console.log('Bank account tokenization pending approval');
break;
case BankAccountTokenizationStatus.FAILED:
console.log('Bank account tokenization failed');
break;
}
} catch (error) {
console.error('Bank account tokenization error:', error);
}
Updated about 15 hours ago