mctpaymentapiflutter 1.0.4
mctpaymentapiflutter: ^1.0.4 copied to clipboard
MCTPaymentApi flutter plugin.
Flutter Plugin Setup Guide #
Getting Started #
Feature #
- Payment Support KHQR Personal Account
- Allow integrate with flutter app
Ensure your Flutter application initializes properly by using the following main.dart configuration:
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
runApp(const MyApp());
}
Installation #
Add Dependencies #
Add the following dependency to your pubspec.yaml file:
- required dartz: ^0.10.0
- mctpaymentapiflutter: ^1.0.4
dependencies:
dartz: ^0.10.0
mctpaymentapiflutter: ^1.0.4
Using #
import 'package:mctpaymentapiflutter/mctpaymentapiflutter.dart';
import 'package:mctpaymentapiflutter/model/payment_request.dart'
Android Setup #
Modify project/build.gradle #
- Ensure your build.gradle file includes the necessary repositories:
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("https://gitlab.com/api/v4/projects/67854824/packages/maven")
}
}
}
Modify project/settings.gradle #
- Android Studio | 2024.3.1 latest Update the plugin version in project/build.gradle:
plugins {
id("com.android.application") version "8.9.0" apply false
id("org.jetbrains.kotlin.android") version "2.1.10" apply false
}
- Android Studio | 2024.2.2 Update the plugin version in project/build.gradle:
plugins {
id("com.android.application") version "8.8.2" apply false
id("org.jetbrains.kotlin.android") version "2.1.10" apply false
}
Configure app/build.gradle #
- Set up the Android application ID for your Flutter project: Your id the same configuration on your account register morecambodia.com before you can use Api.
defaultConfig {
// TODO: Specify your own unique Application ID.
applicationId = "com.example.flutterandroidapp"
}
Modify app/src/main/AndroidManifest.xml #
- To show QRCodeActivity
<application>
<activity
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:name="com.morecambodia.mctpaymentapi.QRCodeActivity"/>
</application
Android Result #
iOS Setup #
- The SDK Build for >= iOS 12.0, so you neet to set the platform version in the Podfile to iOS 12 or above.
platform :ios, '12.0'
- For iOS, simply no install the required: /ios
pod install
IOS Result #
Parameters Breakdown #
- appId (String)
- Description: This is the unique identifier for your application that is provided by the payment service provider (MCTPayment). Purpose: It is used to authenticate and associate the payment requests to your specific application.
- Example: "e12174f95029b0ae387e9dd7a67e2a02ebcaea03fd97f505b4ae7db925d11ece"
- Node appId has production and development. When you development please use development.
- secretKey (String)
- Description: The secret key is provided by the payment service provider and is used to securely authenticate your application and process payments. Purpose: It ensures that only authorized applications can initiate payment requests.
- Example: "70a1ea4ed46f38294d51a10602744926629d6f0964e711658f57978b7488ac67"
- Node secretKey has production and development. When you development please use development.
- appContext (AndroidAppContext)
- Description: The context of your Android application is used to initialize the payment API and interact with the Android system. Purpose: Provides necessary app-specific information and resources to the payment API. In this case, it is initialized using the current activity context (this).
- Example: AndroidAppContext(this) (where this refers to the context of the current activity).
- buildMode (Boolean)
- Description: This flag determines whether the application is running in a debug mode or release mode. Purpose: It helps in deciding which environment to use for the payment process (debug or production). This is typically set based on whether the application is in development or production.
- Example: isDebuggable which checks the application’s debug flag using applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE.
ProcessPayment Method Parameters #
- amount (Double)
- Description: The amount of money to be processed in the payment. Purpose: This is the value that will be charged for the transaction.
- Example: 1000.0 (This would represent an amount of 1000 Cambodian Riels).
- currency (String)
- Description: The currency code in which the amount is specified. Purpose: Ensures that the payment is processed in the correct currency.
- Example: "khr" (Cambodian Riel).
- orderId (Int)
- Description: A unique identifier for the order that is being processed. Purpose: This helps to track the payment against the order in the system, making it easy to identify the transaction later.
- Example: 2 (Order ID for the current transaction).
- qrCodeView (AndroidQRCodeView)
- Description: The AndroidQRCodeView is a view component that is used to display the QR code for the payment. Purpose: It allows the user to scan the QR code with a compatible app to complete the payment.
- Example: AndroidQRCodeView(this) (initialized with the context of the current activity).
Callback Parameters #
- data: This contains the result data from the payment process. It can include information about the success of the payment.
- error: This contains any error message or exception if something goes wrong during the payment process.
Notes
- Ensure that you have the correct API credentials (appId and secretKey) provided by MCTPayment.
- Make sure the amount is specified correctly and that the currency is valid.
- Always verify whether the application is in debug or production mode by using the isDebuggable flag.
- The orderId should be unique for every payment request to ensure that each transaction can be properly tracked.
- The QR code view should be placed appropriately in your layout to provide a seamless user experience.
How to Get Your appId and secretKey #
To get your appId and secretKey, you need to follow the registration process on our website:
1. Sign up and Register:
- Visit the MCTPayment website: www.morecambodia.com. Click the link below to register your application with us: Register for MCTPayment API.
2.Fill Out the Registration Form:
- On the registration page, you’ll need to provide details about your application, including your app name, description, and contact information.
- After registering, you'll receive a confirmation email with your appId and secretKey.
3. Access Your Credentials:
- After registration, you will be able to log in to your account on the dashboard and view or manage your appId and secretKey at any time.
How to Get: To obtain your Android App ID, follow these steps: #
- Visit the MCTPayment website: www.morecambodia.com.
- After registration, you will receive an appId that uniquely identifies your app.
Run #
flutter clean
flutter pub get
flutter run