Configuration
#
Initialize the SDKnote
These methods must be executed first before any other methods from BharatX's SDK is executed.
To identify who you are, share your partner ID and your API key using the following methods (simply use the ID and key given in the code for testing):
- Java
- Kotlin
- React Native
- Flutter
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { // ... BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey"); // if you want the SDK to use a custom 'primary color' for seamless UI BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey", Color.parseColor("#FF0000")); // or with a color resource BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey", ContextCompat.getColor(this, R.color.colorAccent)); // ... }}
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // ... BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey") // if you want the SDK to use a custom 'primary color' for seamless UI BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey", Color.parseColor("#FF0000")) // or with a color resource BharatXStartupTierManager.initialize(this, "testPartnerId", "testApiKey", ContextCompat.getColor(this, R.color.colorAccent)) // ... }}
import BharatXStartupManager from '@bharatx/bharatx-reactnative-startup';
// You cannot set the theme color here directly.// Open the next section to see how to set the theme color.BharatXStartupManager.initialize("testPartnerId", "testApiKey");
import 'package:bharatx_flutter_startup/bharatx_flutter_startup.dart';
await BharatXStartupTierManager.initialize("testPartnerId", "testApiKey");// if you want the SDK to use a custom 'primary color' for seamless UIawait BharatXStartupTierManager.initialize("testPartnerId", "testApiKey", Colors.deepOrange);// or with a hex intawait BharatXStartupTierManager.initialize("testPartnerId", "testApiKey", 0xFF5722);// or with a hex string (the '#' is optional)await BharatXStartupTierManager.initialize("testPartnerId", "testApiKey", "#FF5722");
#
Configure fields separatelyYou can configure the Partner ID, Partner API Key or Theme Color of the SDK separately, you can use the following helper methods:
Click to open
warning
You've to execute any one of the initialize()
methods in the previous section before using these methods. It is not optional.
- Java
- Kotlin
- React Native
- Flutter
// for Partner IDSecurityStorageManager.storePartnerId(this, "bharatx");
// for Partner API KeySecurityStorageManager.storePartnerApiKey(this, "testKey");
// for Theme ColorSecurityStorageManager.storeThemeColorPreference(this, Color.parseColor("#FF0000"));// or with a color resourceSecurityStorageManager.storeThemeColorPreference(this, ContextCompat.getColor(this, R.color.colorAccent));
// for Partner IDSecurityStorageManager.storePartnerId(this, "bharatx")
// for Partner API KeySecurityStorageManager.storePartnerApiKey(this, "testKey")
// for Theme ColorSecurityStorageManager.storeThemeColorPreference(this, Color.parseColor("#FF0000"))// or with a color resourceSecurityStorageManager.storeThemeColorPreference(this, ContextCompat.getColor(this, R.color.colorAccent))
import BharatXSecurityHelpers from '@bharatx/bharatx-reactnative-securityhelpers';
// ...
// for Partner IDBharatXSecurityHelpers.storePartnerId('testPartnerId');
// for Partner API KeyBharatXSecurityHelpers.storePartnerApiKey('testApiKey');
// for Theme Color// in hexBharatXSecurityHelpers.storeThemeColorPreferenceInHex("#FFFFFF");// in rgbaBharatXSecurityHelpers.storeThemeColorPreferenceInRGBA("rgba(255, 255, 255, 1)");
import 'package:bharatx_flutter_securityhelpers/bharatx_flutter_securityhelpers.dart';
// ...
// for Partner IDawait BharatXSecurityHelpers.storePartnerId("testPartnerId");
// for Partner API Keyawait BharatXSecurityHelpers.storePartnerApiKey("testApiKey");
// for Theme Color// in Color classawait BharatXSecurityHelpers.storeThemeColorPreference(Colors.deepOrange);// or with a hex intawait BharatXSecurityHelpers.storeThemeColorPreference(0xFF5722);// or with a hex string (the '#' is optional)await BharatXSecurityHelpers.storeThemeColorPreference("#FF5722");
#
Theming (optional)note
These methods must be executed before using the privacy policy or progress dialog section if you want the theme to be applied.
#
Custom Primary ColorView the Initialize the SDK or Configure fields separately section to know how to change the theme color of the SDK so that it appears seamless in your app.
#
Custom Progress DialogTo set a custom layout for the progress dialog that is displayed:
- Java
- Kotlin
- React Native
- Flutter
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { // ... BharatXCommonUtilManager.setProgressLayout(R.layout.my_awesome_layout); // ... }}
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // ... BharatXCommonUtilManager.progressLayout = R.layout.my_awesome_layout // ... }}
This is not available in our React Native SDK yet.
This is not available in our Flutter SDK yet.
#
Credit Notificationswarning
This is crucial for the BharatX ecosystem, and must be omitted in no way.
We need to send users notifications for specific purposes like repaying their credit. To enable that, place this in your login/dashboard activity:
- Java
- Kotlin
- React Native
- Flutter
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { // ... CreditAccessManager.register(this); // ... }}
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // ... CreditAccessManager.register(this) // ... }}
import BharatXCommonUtilManager from '@bharatx/bharatx-reactnative-common';
// ...
BharatXCommonUtilManager.registerCreditAccess();
import 'package:bharatx_flutter_common/bharatx_flutter_common.dart';
// ...
BharatXCommonUtilManager.registerCreditAccess();
#
Registering your user identificationwarning
This method should be called as early as possible, even before the user clicks on the BharatX button. It should be called only after the "Configure the SDK" step.
Why do it?
Say your servers identify a person as ABC, and BharatX's servers identify the same person as PQR. When you communicate with us about ABC, we don't know which person you're talking about. This method is to solve that exact problem.
To register your user ID with us, use the following method:
- Java
- Kotlin
- React Native
- Flutter
String userId = // the ID you use to identify the user in your serversBharatXCommonUtilManager.registerUserId(this, userId);
val userId: String = // the ID you use to identify the user in your serversBharatXCommonUtilManager.registerUserId(this, userId)
import BharatXCommonUtilManager from '@bharatx/bharatx-reactnative-common';
const userId = // type String; the ID you use to identify the user in your serversBharatXCommonUtilManager.registerUserId(userId);
import 'package:bharatx_flutter_common/bharatx_flutter_common.dart';
dynamic userId = // type String; the ID you use to identify the user in your serversBharatXCommonUtilManager.registerUserId(userId);
#
User Banking Information (optional)warning
Call this API before starting the "Confirm Transaction" from the app.
If the user's banking details are provided via the API, it will appear pre-filled when the user tries to set up e-Mandate with us, improving the UX of the user journey. This is an option that is often leveraged by our partners who have such data available (mainly Social Commerce, Financial Apps etc).
POST https://sdk.bharatx.tech/merchant/user/info
Headers:X-Signature: base64-encoded sha256(requestBody + privateApiKey)X-Partnerid: partnerId
Body:{ "userId": string, // user identifier in perspective of you "userName": string, "userAccountNumber": string, "userIfscCode": string}
Headers:-
Body:{ "message": string}
Status = 200; message = "ok"Status = 400; message = "INVALID_INPUT"Status = 401; message = "AUTHORIZATION_FAILED"Status = 500; message = "INTERNAL_SERVER_ERROR"