Skip to content

MiA is the Android SDK for developers building in-app mobile payment capabilities with Nets Easy.

Notifications You must be signed in to change notification settings

Nets-eCom/Nets-Easy-Android-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nets Easy - Android SDK v1.6.1


Logo

MiA Nets Easy Android SDK is a library which facilitates the Embedded DIBS Easy Checkout integration in your Android application

Detailed documentation can be found here.

  • Nets Easy technical documentation can be found here
  • Nets Easy API documentation can be found here
  • Nets Easy - iOS SDK can also be found here

Installation


In your build.gradle application level file, add:

implementation('eu.nets.mia:mia-sdk:1.6.1') { transitive = true;}

Note: the library is available through both jcenter() and mavenCentral() repositories.

Requirements


Minimum supported Android version is 5.1

Permissions


These permissions are handled inside the binary, and your integration won't require any additional changes.

MiA SDK will require the internet permissions to be fully operational.

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

Examples


We have provided a Sample Application to help you understand the use cases of the SDK functionalities. All you need to do is checkout the project and run it. Check our Overview Documentation for best-practices to keep in mind when you build your integration.

High level architecture of the Nets Easy SDK


The below picture illustrates the SDK and its interactions with the macro components of the integration's environment.

Usage


Assuming you have already created your backend integration towards Nets Easy Payment APIs, the SDK can be launched by simply calling:

/**
    *
    * @param paymentId the paymentId received in Create Payment API call
    * @param checkoutUrl the checkout page url used in Create Payment API call  
    * @param returnUrl the return page url used in Create Payment API call
*/
fun launchSDK(paymentId: String, checkoutUrl: String, returnUrl: String) {
    MiASDK.getInstance().startSDK(this, MiAPaymentInfo(paymentId, checkoutUrl, returnUrl))
}

The payment result will be delivered in your activity/fragment's onActivityResult():

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == MiASDK.EASY_SDK_REQUEST_CODE) {

            if (resultCode == Activity.RESULT_OK) {
                val result = data?.getParcelableExtra<MiAResult>(MiASDK.BUNDLE_COMPLETE_RESULT)

                when (result?.miaResultCode) {
                    //user completed the payment
                    MiAResultCode.RESULT_PAYMENT_COMPLETED -> {
                       //call getPayment()
                    }
                    //user has cancelled the payment
                    MiAResultCode.RESULT_PAYMENT_CANCELLED -> {
                       //call getPayment()
                    }
                    //user encountered and error and cannot proceed with the payment
                    MiAResultCode.RESULT_PAYMENT_FAILED -> {
                        //the SDK has an internal error and cannot proceed with the current payment
                    }
                }
            }

            return
        }
        super.onActivityResult(requestCode, resultCode, data)
    }

IMPORTANT: While making the API call for creating a payment or subscription, make sure you add "commercePlatformTag" : "AndroidSDK" in the request header. This is critical to identify the platform from which the payment is initiated.

private fun addHeader(request: Request): Request {
        val builder = request.newBuilder().method(request.method(), request.body())

        builder.addHeader("Content-Type", "application/json")
        builder.addHeader("Authorization", APIManager.secretKey)
        /**
         * @param commercePlatformTag This is critical to identify the platform from which the payment is initiated
         */
        builder.addHeader("commercePlatformTag", "AndroidSDK")
        return builder.build()
    }	

Contact


If you have any question or feedback, please contact us via email: [email protected]

License


Please check License file.