### Install SDK Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Run this command in your terminal after updating pubspec.yaml to fetch the SDK. ```bash flutter pub get ``` -------------------------------- ### Fix iOS Pod Install Fails Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Run this command in the `ios` directory to resolve pod installation issues. ```bash cd ios && pod deintegrate && pod install --repo-update ``` -------------------------------- ### Add SDK to pubspec.yaml Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Add the Paymob Accept Flutter SDK dependency to your project's pubspec.yaml file. After adding, run `flutter pub get` to install the package. ```yaml dependencies: flutter_paymob_sdk: git: url: https://github.com/PaymobAccept/flutter_sdk.git ``` -------------------------------- ### Fetch Payment Credentials from Backend Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Obtain the public key and client secret from your backend API. Never embed your secret key directly in the Flutter app. This example shows a POST request to a backend endpoint. ```dart final response = await http.post( Uri.parse('https://your-backend.com/api/create-payment-intention'), headers: {'Content-Type': 'application/json'}, body: jsonEncode({ 'amount': 100, 'currency': 'EGP', 'billingData': { 'first_name': 'John', 'last_name': 'Doe', 'email': 'customer@example.com', 'phone_number': '+201000000000', 'apartment': 'NA', 'floor': 'NA', 'street': 'NA', 'building': 'NA', 'shipping_method': 'NA', 'postal_code': 'NA', 'city': 'Cairo', 'country': 'EG', 'state': 'NA', }, }), ); final backendCreds = jsonDecode(response.body); final publicKey = backendCreds['publicKey'] as String; final clientSecret = backendCreds['clientSecret'] as String; ``` -------------------------------- ### Import and Initialize PaymobService Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Import the SDK and create an instance of the PaymobService to interact with the payment gateway. ```dart import 'package:flutter_paymob_sdk/flutter_paymob_sdk.dart'; final paymobService = PaymobService(); ``` -------------------------------- ### Launch Paymob Payment SDK Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Initiate the payment process using the obtained public and client secrets. Customize the payment UI elements like app name, button colors, and save card options. ```dart final result = await paymobService.payWithPaymob( publicKey: publicKey, clientSecret: clientSecret, customization: PaymobCustomization( appName: 'My Store', buttonBackgroundColor: Colors.blue, buttonTextColor: Colors.white, showSaveCard: true, saveCardDefault: false, ), ); if (result.isSuccessful) { // Payment succeeded } else if (result.isFailure) { // Payment failed } else if (result.isPending) { // Payment is pending } ``` -------------------------------- ### payWithPaymob() Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Initiates a payment transaction using the Paymob SDK. It requires your public key and client secret, and optionally accepts a customization object to modify the UI. ```APIDOC ## `payWithPaymob()` ### Description Initiates a payment transaction using the Paymob SDK. It requires your public key and client secret, and optionally accepts a customization object to modify the UI. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * `publicKey` (String) - Required - Your Paymob public key * `clientSecret` (String) - Required - Client secret from your backend * `customization` (PaymobCustomization?) - Optional - Optional UI customization ### Returns `Future` ``` -------------------------------- ### Configure Android Gradle Repositories Source: https://github.com/paymobaccept/flutter_sdk/blob/main/README.md Configure Gradle repositories in android/settings.gradle.kts to include necessary Paymob SDK dependencies. This ensures proper dependency resolution for Android builds. ```kotlin dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories { google() mavenCentral() maven { url = uri("https://storage.googleapis.com/download.flutter.io") } maven { url = uri("https://jitpack.io") } val flutterPluginsDeps = file("../.flutter-plugins-dependencies") if (flutterPluginsDeps.exists()) { @Suppress("UNCHECKED_CAST") val json = groovy.json.JsonSlurper().parse(flutterPluginsDeps) as Map @Suppress("UNCHECKED_CAST") val androidPlugins = ((json["plugins"] as? Map)?.get("android") as? List>?) ?: emptyList() androidPlugins.find { it["name"] == "flutter_paymob_sdk" } ?.get("path") ?.let { maven { url = uri("${it}android/libs") } } } } } ``` -------------------------------- ### Add Jitpack Maven Repository for Android Source: https://github.com/paymobaccept/flutter_sdk/blob/main/README.md Configure your Android project to use the Jitpack Maven repository. This is required for resolving Paymob SDK dependencies. ```kotlin maven { url = uri("https://jitpack.io") } val flutterPluginsDeps = file("../.flutter-plugins-dependencies") if (flutterPluginsDeps.exists()) { @Suppress("UNCHECKED_CAST") val json = groovy.json.JsonSlurper().parse(flutterPluginsDeps) as Map @Suppress("UNCHECKED_CAST") val androidPlugins = ((json["plugins"] as? Map)?.get("android") as? List>?) ?: emptyList() androidPlugins.find { it["name"] == "flutter_paymob_sdk" } ?.get("path") ?.let { maven { url = uri("${it}android/libs") } } } ``` -------------------------------- ### PaymobCustomization Configuration Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Configure various UI elements and behaviors for the Paymob SDK, including branding, button appearance, card saving options, transaction result display, and keyboard handling for iOS. ```dart PaymobCustomization( // Branding appName: 'My Store', androidAppLogo: 'ic_launcher', // Android: drawable/mipmap resource name iosAppLogo: 'assets/logo.png', // iOS: Flutter asset path // Button buttonBackgroundColor: Colors.blue, buttonTextColor: Colors.white, // Card saving showSaveCard: true, saveCardDefault: false, // Screens showTransactionResult: true, // Show/hide the built-in result screen after payment // iOS only isKeyboardHandlingEnabled: true, // SDK keyboard avoidance behavior ) ``` -------------------------------- ### PaymobCustomization Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Defines the customization options for the Paymob SDK's UI elements and behavior. ```APIDOC ## `PaymobCustomization` ### Description Defines the customization options for the Paymob SDK's UI elements and behavior. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * `appName` (String?) - Both - Branding label shown inside the SDK UI * `androidAppLogo` (String?) - Android - Drawable/mipmap resource name e.g. `'ic_launcher'` * `iosAppLogo` (String?) - iOS - Flutter asset path e.g. `'assets/logo.png'` * `buttonBackgroundColor` (Color?) - Both - Payment button background color * `buttonTextColor` (Color?) - Both - Payment button text color * `showSaveCard` (bool?) - Both - Show/hide the save card checkbox * `saveCardDefault` (bool?) - Both - Pre-check the save card checkbox * `showTransactionResult` (bool?) - Both - Show/hide the built-in result screen after payment * `isKeyboardHandlingEnabled` (bool?) - iOS - SDK keyboard avoidance behavior ``` -------------------------------- ### Enable Data Binding in Android Source: https://github.com/paymobaccept/flutter_sdk/blob/main/README.md Enable Data Binding in your Android application's build.gradle.kts file. This is required for certain UI functionalities within the SDK. ```kotlin android { buildFeatures { dataBinding = true } } ``` -------------------------------- ### iOS App Logo Configuration Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Set the iOS app logo using a Flutter asset path. Ensure the image is declared in your `pubspec.yaml` file. ```dart iosAppLogo: 'assets/logo.png' ``` -------------------------------- ### Android App Logo Configuration Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Specify the Android app logo by providing the resource name from your Android project's drawable or mipmap directories. Defaults to 'ic_launcher'. ```dart androidAppLogo: 'ic_launcher' // uses the app launcher icon androidAppLogo: 'my_logo' // uses res/drawable/my_logo.png or res/mipmap/my_logo.png ``` -------------------------------- ### PaymobPaymentResult Source: https://github.com/paymobaccept/flutter_sdk/blob/main/example.md Represents the result of a payment transaction, including its status and details. ```APIDOC ## `PaymobPaymentResult` ### Description Represents the result of a payment transaction, including its status and details. ### Properties * `status` (PaymentStatus) - `successful`, `failure`, `pending` * `isSuccessful` (bool) - `true` if payment succeeded * `isFailure` (bool) - `true` if payment failed * `isPending` (bool) - `true` if payment is pending * `transactionDetails` (Map?) - Transaction data (successful payments only) * `errorMessage` (String?) - Error description if status is `failure` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.