Payant Android can be used to access features on your Payant account dashboard.
For better understanding read the Payant API documentation before using this library.
Each of the major operations has a Manager Class in the PayantAndroid library, these managers are PayantClientManager, PayantInvoiceManager, PayantPaymentManager, PayantWalletmanager, PayantProductManager. These Manager Classes perform all needed operations that are performed on your dashboard, for instance the PayantClientManager Class can ADD, GET, EDIT, and DELETE a Client.
- Add JitPack to your build file.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the Library dependency
dependencies {
implementation 'com.github.LEMUBIT:PayantAndroid:1.1.0'
}
- Ensure that your app has internet permissions by making sure the
uses-permission
line below is present in the AndroidManifest.xml.
<uses-permission android:name="android.permission.INTERNET" />
- Initialize the SDK in
onCreate
.
The first argument is the Application Context
while the second argument is a boolean value which is set to true
when you are testing with a Live private key
and set to false
when you are using a Demo private key
.
Payant.init(getApplicationContext(),true);
- Set the private key.
Private key should be set after initializing the SDK.
Payant.setPrivateKey("XXXXXXXXXXXX");
- Use Manager Classes
Use the manager Class of the operation you want to perform. For instance perhaps you want to get the information of a Client with ID 166
, you would use the Client Manager's getPayantClient()
method.
PayantClientManager.getPayantClient(166, new PayantClientManager.OnGetPayantClientListener() {
@Override
public void onManagerResponse(PayantClientInfo payantClientInfo) {
Toast.makeText(MainActivity.this, payantClientInfo.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(MainActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
In the sample above, the object PayantClientInfo
contains the information of the Client whose info was requested.