easy_pay 0.0.2 copy "easy_pay: ^0.0.2" to clipboard
easy_pay: ^0.0.2 copied to clipboard

EasyPay SDK.

easy_pay android implementation #

This guide provides step-by-step instructions to configure your Flutter project with the necessary Android dependencies and settings.

Step 1: Add SoftPos-v1.3.66.7-Debug_Test.aar to Your Project #

  1. Navigate to the android folder in your Flutter project.
  2. Create a new folder named libs inside the android folder.
  3. Paste the SoftPos-v1.3.66.7-Debug_Test.aar file into the libs folder.

Step 2: Update build.gradle File #

  1. Open the android/app/build.gradle file.

  2. In the dependencies section, add the following lines of code:

    implementation 'com.sdk:easypay:1.1.1'
    implementation 'com.denovo:topliteapp:1.7.5.0'
    compileOnly files('libs/SoftPos-v1.3.66.7-Debug_Test.aar')
    

Step 3: Configure Repositories #

  1. Open the android/settings.gradle file.
  2. In the dependencyResolutionManagement section, under repositories, add the following code:

Step 3: Extend FlutterActivity in MainActivity #

  1. Navigate to android/app/src/main/kotlin/your/package/name/.

  2. Create or update the MainActivity.kt file with the following code:

    import android.os.Bundle
    import io.flutter.embedding.android.FlutterActivity
    import io.flutter.embedding.engine.FlutterEngine
    import io.flutter.plugin.common.MethodChannel
    import io.flutter.plugins.GeneratedPluginRegistrant
    
    class MainActivity : FlutterActivity() {
    
        private val CHANNEL = "easy_pay"
        private var easyPayPlugin: EasyPayPlugin? = null
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            // Initialize the EasyPay plugin
            easyPayPlugin = EasyPayPlugin()
            easyPayPlugin?.setActivity(this)
        }
    
        override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
            super.configureFlutterEngine(flutterEngine)
            GeneratedPluginRegistrant.registerWith(flutterEngine)
            easyPayPlugin?.let {
                flutterEngine.plugins.add(it)
            }
    
            MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
                when (call.method) {
                    "startPayment" -> {
                        val amount = call.argument<String>("amount") ?: ""
                        val secretKey = call.argument<String>("secretKey") ?: ""
                        val jsonRequest = call.argument<String>("jsonRequest") ?: ""
                        easyPayPlugin?.onMethodCall(call, result)
                    }
                    "registerDevice" -> {
                        val tpn = call.argument<String>("tpn") ?: ""
                        val merchantKey = call.argument<String>("merchantKey") ?: ""
                        easyPayPlugin?.onMethodCall(call, result)
                    }
                    else -> {
                        result.notImplemented()
                    }
                }
            }
        }
    }
    

By following these steps, you will successfully configure your Flutter project with the necessary Android dependencies and settings. If you encounter any issues, please refer to the respective documentation for additional assistance.