Coder Social home page Coder Social logo

android_pos_sdk's Introduction

SmartPOS SDK Technical Documentation

The SDK is divided into three(3) modules namely -

  • smart-pos-core
  • smart-pos-emv-pax
  • smart-pos-usb

To start using the SDK, follow the steps below:

  • add module smart-pos-core and module smart-pos-emv-pax to your project. If you want to make use of USB communication between the SDK and a PC, add the third module smart-pos-usb
  • Configure the SDK in your android Application class or your main Activity like below
// create POSDevice Implementation instance for pax device
POSDeviceImpl device  = POSDeviceImpl.create(getApplicationContext());

String clientId = "your-client-id";
String clientSecret = "your-client-secret";
String alias = "your-alias";
String merchantCode = "your-merchant-code";

// initialize POSConfig 
POSConfig config = new POSConfig(alias, clientId, clientSecret, merchantCode);

// setup terminal
IswPos.setupTerminal(getApplication(), device, config);

Configure Terminal

In order to communicate effectively with the terminal, some initialization and configuration needs to be done, in your main activity, you can add a menu to achieve this:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.terminal_config) {
            IswPos.showSettingsScreen(); // show settings for terminal configuration
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

Initiating Payment

You can trigger SDK payment flow using the code below

int KOBO = 100;
int amount = 1000 * KOBO; // convert to kobo

// to start the payment flow, pass the following parameters to IswPos#initiatePayment()
// activity - the calling activity instance
// amount - the amount you want to accept in KOBO
// paymentType - the specific payment type you want to trigger
// there are four(4) payment types that you can use
// and they are (CARD, USSD, QR and PAYCODE), if paymentType is null
// A default screen will be displayed for you to choose the type of payment
    try {
        // trigger payment
        IswPos.getInstance().initiatePayment(this, currentAmount, null);
    } catch (NotConfiguredException e) {
        Toast.makeText(this, "Pos has not been configured", Toast.LENGTH_LONG).show();
    }

The SDK will take over from here. You can override your Activity's onActivityResult method to handle the result of the initiated payment

    @Override
    protected void onActivityResult(int requestCode,
    int resultCode, @Nullable Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            // handle success
            PurchaseResult result = IswPos.getResult(data);
            // process result here
            // you can access the following properties in PurchaseResult
            // class PurchaseResult {
            //     String responseCode = "";
            //     String responseMessage = "";
            //     String transactionReference = "";
            // }
        } else {
            // else handle error
        }
    }
Note on USB communication

For USB communication between the SDK and a PC to work, the below steps need to be followed

  • ADB must be installed and added to Path enviroment variable on the PC
  • USB Debugging must be enabled in the Android terminal

android_pos_sdk's People

Contributors

dayorolands avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.