easymerchantsdk 0.0.2
easymerchantsdk: ^0.0.2 copied to clipboard
EasyMerchantSDK
Easy Merchant Sdk Implementation. #
To implement the sdk in your flutter project, you have to add the below path in your pubspec.yaml file inside dependencies section:
dependencies:
easymerchantsdk: ^0.0.2
Easy Merchant Sdk Implementation(Android Side). #
Follow the below steps to implement the easymerchant sdk in your flutter project
Change the minimum sdk version. #
In your android -> app -> build.gradle file, there is a defaultConfig section. Change the minSdk to 24 in the defaultConfig.
Add the dependencies. #
Add the below dependencies in your android -> app -> build.gradle file.
dependencies {
implementation 'com.app:paysdk:1.1.9'
implementation 'com.hbb20:ccp:2.7.3'
implementation 'com.github.androidmads:QRGenerator:1.0.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
}
Add the gradle urls. #
To add the gradle urls, open your android -> build.gradle file and add the below lines in it.
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url = uri(your_github_url)
credentials {
username = username
password = password
}
}
}
configurations.all {
resolutionStrategy {
force 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22' // Replace with your desired version
}
}
}
Changes in settings.gradle file. #
Now open your android -> settings.gradle and add the below code inside repositories block.
repositories {
...
maven { url 'https://jitpack.io' }
maven {
url = uri(your_github_url)
credentials {
username = username
password = password
}
}
}
Changes in MainActivity file #
Inside your andorid/app/src/main/kotlin/your_package_name There is MainActivity.kt file, replace all code except first line with below:
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import com.example.easymerchantsdk.EasymerchantsdkPlugin
class MainActivity: FlutterActivity(){
private val CHANNEL = "easymerchantsdk"
private var easymerchantsdkPlugin: EasymerchantsdkPlugin? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
easymerchantsdkPlugin = EasymerchantsdkPlugin()
easymerchantsdkPlugin?.setActivity(this)
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
easymerchantsdkPlugin?.let {
EasymerchantsdkPlugin().setActivity(this)
}
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "billing") {
val amount = call.argument<String>("amount") ?: ""
val billinginfo = call.argument<String?>("billinginfo") ?: ""
easymerchantsdkPlugin?.onMethodCall(call, result)
} else if(call.method == "getPlatformVersion"){
result.success("Android ${android.os.Build.VERSION.RELEASE}")
} else {
result.notImplemented()
}
}
}
}
Easy Merchant Sdk Implementation(IOS Side). #
Initialize view controller for ios
Future<void> initializeViewController() async {
try {
await easymerchant.setViewController();
print('ViewController initialized successfully');
} catch (e) {
print('Failed to initialize ViewController: $e');
showSnackbar('Failed to initialize ViewController: $e');
}
}
You can use the below json parameters to send the billing data if available otherwise you can send null object when calling the function
Map<String, dynamic> additionalInfoRequest = {
"name": "Test User",
"email": "test@gmail.com",
"phone_number": "9465351125",
"country_code": "91",
"description": "Test"
};
Map<String, dynamic> billingInfo = {
"address": "Mohali, Punjab",
"country": "India",
"state": "Punjab",
"city": "Anandpur Sahib",
"postal_code": "140118",
"additional_info": additionalInfoRequest,
};
String jsonString = json.encode(billingInfo);
For call the ios side below ios the function
final result = await easymerchant.billing(
textEditingController.text.toString(),
jsonString or null, // you can send null if billingInfo not available
"staging",
"mobilesdk1980IUuCzwWl",
"mobilesdk1980LVHnN0Oh"
);
For android side call the below function same as ios function
final result = await easymerchant.makePayment(
textEditingController.text,
jsonRequestt or null, // you can send null if billingInfo not available
"staging",
"mobilesdk1980IUuCzwWl",
"mobilesdk1980LVHnN0Oh"
);
For more info, you can go with the refer the EXAMPLE.