The Android IPG SDK library enables you to integrate Interswitch payments to your mobile app
Adding it to a project
To get the library add the following dependency to your module gradle file(app.gradle):
implementation 'com.github.interswitch-kenya-limited:mobpay:0.5.0'
Ensure that the jitpack io repository is part of your project by adding it to the root build.gradle in the allprojects => repositories section
Configuring
Edit you app manifest file to add the following configuration metadata inside the application tag, the values given here are for test and you will need to change them once you are ready to go live.
Finally ensure data binding is enabled in the root gradle file of your projects by adding the following config in its android section
dataBinding {
enabled = true
}
Usage examples
Get an interswitch client Id and client secret for your interswitch merchant account then instantiate a mobpay object by doing the following:
final Merchant merchant = new Merchant(merchantId, domain);
final Payment payment = new Payment(amount, transactionRef, "MOBILE", terminalId, "CRD", currency, orderId);
payment.setPreauth(preauth);
final Customer customer = new Customer(customerId);
customer.setEmail(customerEmail);
MobPay.Config config = new MobPay.Config();// May be used for advanced configuration, can be null
config.setIconUrl('YOUR ICONS URL') can be used to change the logo
mobPay = MobPay.getInstance(MainActivity.this, clientId, clientSecret, config);// Instantiate the mobpay library object to make a payment and get the results in the callbacks
mobPay.pay(MainActivity.this,// The instance of an activity that will be active until the payment is completed
merchant,
payment,
customer,
new TransactionSuccessCallback() {
@Override
public void onSuccess(TransactionResponse transactionResponse) {
// Your code to proceed to after success
}
},
new TransactionFailureCallback() {
@Override
public void onError(Throwable error) {
// Code to handle failure
}
});
Source code
Visit https://github.com/interswitch-kenya-limited/mobpay/ to get the source code and releases of this project if you want to try a manual integration process that does not make use of gradle.