GithubHelp home page GithubHelp logo

ettaegbe / icemix-mobile-money-android-library Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 142 KB

This a mobile money library for collecting payment through mobile money payment with android particularly for Africa. The aim is that the merchant communicate directly with the main mobile money provider rather than a third party.

Java 92.69% Kotlin 7.31%

icemix-mobile-money-android-library's Introduction

Icemix-Mobile-Money-Android-Library

This a mobile money library for collecting payment through mobile money payment with android particularly for Africa. The aim is that the merchant communicate directly with the main mobile money provider rather than a third party. This version supports only MTN Uganda and other Countries Under same services of MTN Uganda

Getting Started

Prerequisites

Installing

Add it to your build.gradle with:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

and

dependencies {
    implementation 'com.github.ettaegbe:Icemix-Mobile-Money-Android-Library:1.0.0'
}

Add Internet Permissions to your Android Manifest file

<uses-permission android:name="android.permission.INTERNET"/>

Initialize the library for UGANDA and other countries using the same MTN Mobile Money service as Uganda

UGMomoPaymentRequest ugMomoPaymentRequest = new UGMomoPaymentRequest();

And that's it! You now have access to the library functions and can make mobile money payments programatically!

A Simple Example

Have a user receive the mobile money USSD prompt after clicking a button.

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final String subscription = "2cbd35b7e91tr981629ba5d3a97b6";
        final String api_user = "e6fdf72e-6781-11e5-a9g3-1681bejg63dfe";
        final String api_key = "c2d87feac94246c3649f116f62971a88";
        final EditText amount = findViewById(R.id.editTextAmount);
        final EditText phone = findViewById(R.id.editTextPhone);
        final TextView status = findViewById(R.id.textViewStatus);
        AppCompatButton btn = findViewById(R.id.btnPayNow);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                UGMomoPaymentRequest ugMomoPaymentRequest = new UGMomoPaymentRequest();
                ugMomoPaymentRequest.setSubscriptionKey(subscription);
                ugMomoPaymentRequest.setApiUser(api_user);
                ugMomoPaymentRequest.setApiKey(api_key);
                ugMomoPaymentRequest.setAmount(Integer.parseInt(amount.getText().toString()));
                ugMomoPaymentRequest.setPhone(phone.getText().toString());
                ugMomoPaymentRequest.setCurrency("EUR");
                ugMomoPaymentRequest.setEnvironment("sandbox");
                ugMomoPaymentRequest.setExternalId("11212121122");
                ugMomoPaymentRequest.setPayerMessage("Message to payer");
                ugMomoPaymentRequest.setPayeeNote("Message to payee");

                status.setText("Payment started");
                ugMomoPaymentRequest.sendPayment();
                ugMomoPaymentRequest.setOnRequestCallbackListener(new UGMomoPaymentRequest.OnRequestCallbackListener() {
                    @Override
                    public void onComplete(StatusResponse response) {
                        Toast.makeText(getApplicationContext(),response.getStatus(),Toast.LENGTH_LONG).show();
                        status.setText("Payment completed");
                    }

                    @Override
                    public void onFail(String errorMessage) {
                        status.setText("Payment fail");
                        Log.e("ICEMIX_MOBILE_MONEY",errorMessage);
                    }

                    @Override
                    public void onPaymentFail(StatusResponse response, String errorMessage) {
                        status.setText("Payment fail: "+response.getReason().getMessage());
                    }

                    @Override
                    public void onStatusFail(Throwable throwable) {
                        status.setText("Payment fail");
                        Log.e("ICEMIX_MOBILE_MONEY",throwable.getMessage());
                    }

                    @Override
                    public void onAuthentificationSuccessful(String token) {
                        status.setText("Connected to payment server");

                    }

                    @Override
                    public void onAuthentificationFail(Throwable throwable) {
                        status.setText("Unable to connect to payment server");
                    }
                });
            }
        });
    }

That's it! You should now be ready to use the API

Authors

License

This project is licensed under the MIT License - see the MIT LICENSE file for details

Acknowledgments

  • GUY NONO
  • MTN MOBILE MONEY UGANDA

icemix-mobile-money-android-library's People

Contributors

ettaegbe avatar

Stargazers

 avatar

Watchers

 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.