Mobile SDK

The mobile SDKSDK - Software Development Kit allows you to integrate directly into your mobile app, our payments collection functionality. We allow your customers enjoy the same payment options and experiences that they do on our web channel.

We have developed SDKSDK - Software Development Kits for all the popular mobile development technologies. We have SDKSDK - Software Development Kits for the following platforms:

  • Android
  • iOS
  • React Native
  • Flutter

Process Flow

There are three steps you would have to complete to set up the SDKSDK - Software Development Kit and perform transaction.

  1. Install the SDKSDK - Software Development Kit as a dependency
  2. Configure the SDKSDK - Software Development Kit with Merchant Information
  3. Initiate payment with customer details
  4. Read the response

Installation

📘

iOS Releases

https://github.com/techquest/isw-mobile-sdk-ios/releases

//To install the project, add the following to your root project's build.gradle   
allprojects {
        repositories {
            google()
            jcenter()
            mavenCentral()
        }
    }
//Then add the following to the your app project's build.gradle
    dependencies {
        def versionName = 'latest-version'
        implementation "com.interswitchng:isw-mobile-payment-sdk:$versionName"
    }
//now build the project.
1. Click on the Releases link above, click on assets of the latest version and download the zip of IswMobileSdk.xcframework
2. Unzip to find the IswMobileSdk.xcframework, and move it to your project folder
3. Open your project in Xcode, and navigate to the General settings of your project
4. Choose your app in TARGETS, then in General settings, under Framework, Libraries and Embeded Content, click the + sign to add library
5. In the popup window, click Add Other -> Add Files, and navigate to the foler where you have the IswMobileSdk.xcframework folder and choose it

Now build the project
npm install react-native-isw-mobile-sdk --save
dependencies:
  #.... others

  # add the dependency for sdk
  isw_mobile_sdk: '<latest-version>'

Configuration
You would also need to configure the project with your merchant credentials.

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // configure sdk
        configureSDK();
    }

    public void configureSDK() {
        // use provided configuration for your merchant account
        String merchantId = "<your merchantId>"; 
        String merchantCode = "<your merchantCode>";
        String merchantKey = "<your merchantKey>";

        // create sdk configuration
        IswSdkConfig config = new IswSdkConfig(merchantId, 
                        merchantKey, merchantCode, "566");

        // uncomment to set environment, default is Environment.TEST
        // config.setEnv(Environment.PRODUCTION);

        // initialize sdk at boot of application
        IswMobileSdk.initialize(this, config);
    }
}
let merchantCode = "<your merchantCode>"
    let clientSecret = "<your clientSecret>"
    let clientId = "<your clientId>"
    let currencyCode = "566"
    let env: Environment = .sandbox

    // create merchant configuration
    let config = IswSdkConfig(
        clientId: clientId, 
        clientSecret: clientSecret,
        currencyCode: currencyCode, 
        merchantCode: merchantCode
    )
    // initialize sdk
    IswMobileSdk.intialize(config: config, env: env)
import IswMobileSdk, { IswPaymentInfo, Environment, IswSdkConfig } from 'react-native-isw-mobile-sdk';
// get your credentials
 const merchantId = "your-merchant-id",
 merchantCode = "your-merchant-code",
 merchantSecret = "your-merchant-seceret",
 currencyCode = "currency-code"; // e.g. 566

// create configuration for payment
// using the credentials
const config = new IswSdkConfig(
    merchantId, 
    merchantSecret,
    merchantCode,
    currencyCode
)
/**
 *  callback function for initialized sdk
 *  @param isSuccessful boolean flag indicating the result of initializing sdk
 */
const onSdkInitialized = (isSuccessful) => {
    // handle result
}

// initialize the sdk at the start of application
// you can point to a specific environment -> TEST || PRODUCTION
const env = Environment.TEST;
IswMobileSdk.initialize(config, env, onSdkInitialized);
import 'dart:async';
import 'package:isw_mobile_sdk/isw_mobile_sdk.dart';


class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    initSdk();
  }

    // messages to SDK are asynchronous, so we initialize in an async method.
  Future<void> initSdk() async {

    // messages may fail, so we use a try/catch PlatformException.
    try {
        String  merchantId = "your-merchant-id",
        merchantCode = "your-merchant-code",
        merchantSecret = "your-merchant-secret",
        currencyCode = "currency-code"; // e.g  566 for NGN

        var config = new IswSdkConfig (
            merchantId, 
            merchantKey, 
            merchantCode, 
            currencyCode
        );

        // initialize the sdk
        await IswMobileSdk.initialize(config);
        // intialize with environment, default is Environment.TEST
        // IswMobileSdk.initialize(config, Environment.SANDBOX);

    } on PlatformException {}
  }
}

Once the SDK has been initialized, you can then perform transactions.

Performing Transactions
You can perform a transaction, once the SDK is configured, by providing the payment info and a payment callback, like so:

public class PurchaseActivity extends AppCompatActivity implements IswMobileSdk.IswPaymentCallback  {

        @Override
        protected void onCreate() {
            //.. Trigger payment on button click
            payButton.setOnclickListener((v) -> {
                initiatePayment();
            });
        }
      
        @Override
        public void onUserCancel() {
            // called when the user cancels
        }

        @Override
        public void onPaymentCompleted(IswPaymentResult result) {
            // called when the transaction was completed (success/failure)
        }

        private void initiatePayment() {
            // set customer info
            String customerId = "<customer-id>",
                    customerName = "<customer-name>",
                    customerEmail = "<[email protected]>",
                    customerMobile = "<customer-phone>",
                    // generate a unique random
                    // reference for each transaction
                    reference = "<your-unique-ref>";

            // amount in kobo e.g. "N500.00" -> 50000
            long amount = providedAmount; // e.g. 50000

            // create payment info
            IswPaymentInfo iswPaymentInfo = new IswPaymentInfo(customerId,
                    customerName, customerEmail, customerMobile,
                    currencyCode, reference, amount);

            // trigger payment with info and payment-callback
            IswMobileSdk.getInstance().pay(iswPaymentInfo, this);
        }

    }
@IBAction func onPayTapped(_ sender: Any) {
    
        let customerId = "<customer-id>",
            customerName = "<customer-name>",
            customerEmail = "<[email protected]>",
            customerMobile = "<customer-phone>",
            // generate a unique random
            // reference for each transaction
            reference = "<your-unique-ref>";
                        
        // amount in kobo e.g. "N500.00" -> 50000
        let amount = providedAmount; // e.g. 50000

        // create payment info
        let info = IswPaymentInfo(
            customerId: customerId,
            customerName: customerName,
            customerEmail: customerEmail, 
            customerMobile: customerMobile,
            reference: reference, 
            amount: amount
        )
        
        // Note: If you have split settlement accounts,
        // you can create payment info with the variant
        // constructor that takes split settlement accounts
        // list of accounts 'IswSettlementAccount' 
        let settlementAccounts = [
            IswSettlementAccount(alias: "pacct", amount: 0, percentage: 63.79, description: "primary account", isPrimary: true),
            IswSettlementAccount(alias: "sacct", amount: 0, percentage: 36.21, description: "secondary account", isPrimary: false)
        ]
        
        let info = IswPaymentInfo(
            customerId: customerId,
            customerName: customerName,
            customerEmail: customerEmail, 
            customerMobile: customerMobile,
            reference: reference, 
            amount: amount,
            settlementAccounts: settlementAccounts)
        )
    
        // Note: If access tokens are generated from your server,
        // set access token in the payment info
        info.with(accessToken: sampleAccessToken)
        
        // trigger payment
        // parameters
        // -- on: the UIViewController triggering payment
        // -- with: the payment information to be processed
        // -- call: the IswPaymentDelegate that receives the result
        IswMobileSdk.pay(on: self, with: info, call: self)
    }
let triggerPayment = (amount) => {
    // amount expressed in lowest
    // denomination (e.g. kobo): "N500.00" -> 50000
    amount = amount * 100


    const customerId = "<customer-id>",
        customerName = "<customer-name>",
        customerEmail = "<[email protected]>",
        customerMobile = "<customer-phone>",
        // generate a unique random
        // reference for each transaction
        reference = "<your-unique-ref>";;


    // create payment information object
    const paymentInfo = new IswPaymentInfo(
        customerId,
        customerName,
        customerEmail,
        customerMobile,
        reference,
        amount,
    )

    // trigger payment with the payment information
    IswMobileSdk.pay(paymentInfo, userDidComplete, userDidCancel);
}
Future<void> pay(int amount) async {

    var customerId = "<customer-id>",
        customerName = "<customer-name>",
        customerEmail = "<[email protected]>",
        customerMobile = "<customer-phone>",
        // generate a unique random
        // reference for each transaction
        reference = "<your-unique-ref>";
    // initialize amount
    // amount expressed in lowest
    // denomination (e.g. kobo): "N500.00" -> 50000
    int amountInKobo = amount * 100
    // create payment info
    var iswPaymentInfo = new IswPaymentInfo(
        customerId, 
        customerName,
        customerEmail, 
        customerMobile, 
        reference, 
        amountInKobo
    );
    // trigger payment
    var result = await IswMobileSdk.pay(iswPaymentInfo);
    // process result
    handleResult(result)
  }

Handling Result
All you need to do is handle the result in the callback methods: whenever the user cancels, IswPaymentCallback.onUserCancel is called, and when the transaction is complete, IswPaymentCallback.onPaymentCompleted is called with the result: an instance of IswPaymentResult.

HANDLING RESULT

FieldTypeMeaning
responseCodeStringTransaction response code
responseDescriptionStringTransaction response code description
isSuccessfulbooleanFlag that indicates if transaction is successful
transactionReferenceStringreference for transaction
amountNumberTransaction amount
channelStringChannel used to make payment: one of CARD, WALLET, QR, USSD
public class PurchaseActivity extends AppCompatActivity implements IswMobileSdk.IswPaymentCallback  {
    // ... other stuff

    @Override
    public void onUserCancel() {
        toast("You cancelled payment, please try again.");
    }
    @Override
    public void onPaymentCompleted(IswPaymentResult result) {
        if (result.isSuccessful)
            toast("your payment was successful, using: " + result.channel.name());
        else toast("unable to complete payment at the moment, try again later");
    }
    private void toast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
    }
}
extension ViewController: IswPaymentDelegate {
    // user cancelled payment without completion
    func onUserDidCancel() {
        // handle cancellation
    }
    
    // user completed the payment
    func onUserDidCompletePayment(result: IswPaymentResult) {
        // handle payment result
    }
}
let userDidComplete = (result) => {
    // process result
}

let userDidCancel = () => {
    // handle cancellation
}
void handleResult(Optional<IswPaymentResult> result) {

    if (result.hasValue) {
        // process result
        showPaymentSuccess(result.value);
    } else { 
        showPaymentError()
    }   
}

And that is it. You can start processing payments in your android app.

Sample Codes

Android: https://github.com/techquest/isw-payment-sdk-android

iOS: https://github.com/techquest/isw-mobile-sdk-ios

React Native:https://github.com/techquest/react-native-isw-mobile-sdk

Flutter: https://github.com/techquest/isw_mobile_sdk_flutter

📘

TEST CARDS

Click here to get test cards to test your transactions.


Did this page help you?