Flutter
EdfaPay Payment Gateway Flutter SDK
EdfaPay is a white-label payment software provider. Thanks to our 15+ years of experience in the
payment industry, we’ve developed a state-of-the-art white-label payment system that ensures smooth
and uninterrupted payment flow for merchants across industries.
EdfaPay Flutter SDK was developed and designed with one purpose: to help the Flutter developers
easily integrate the EdfaPay API Payment Platform for a specific merchant.
Installation
[!IMPORTANT]
Configure RepositoryThis Flutter plugin is a wrapper of Android and iOS native libraries.
Setup Android
Setup Android**
Latest Version: 2.0.11+2
You must add the
jitpackrepository support to the Gradle to access and download the native dependency.Add below to the
./android/build.gradleof your projectallprojects { repositories { ... // Add below at the same location maven { url 'https://jitpack.io' } } }
Or add below to the
./android/settings.gradleof your projectdependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { ... // Add below at the same location maven { url "https://jitpack.io" } } }Setup iOS
iOS does not require any setup just install Flutter plugin.
If you need to enableApple Payin your app it can be enabled by following the instructions at Link[!IMPORTANT]
Installing Flutter PluginIn the
dependencies:section of yourpubspec.yaml, add the following lines:dependencies: intl: ^0.17.0 edfapg_sdk: any # ⚠️ IMPORTANT: # The "edfapay_properties" key must start at the beginning of the line (no indentation). # - If edfapay_properties not defined in the pubspec.yaml it take the latest version as defined fallback in plugin. edfapay_properties: pg_android: "2.1.9" pg_ios: "2.1.5"[!IMPORTANT]
Important Note
To ensure the Flutter SDK uses the correct native Android and iOS versions, always refer to the official changelog: https://pub.dev/packages/edfapg_sdk/changelog#20101
After updating or defining the versions in
pubspec.yaml, run the following command in your project directory:
dart run edfapg_sdk:configureThis step is required to apply and sync the native SDK versions. Skipping it may cause version mismatch or runtime issues.
Kindly note that these versions are compatible with the latest stable Flutter release (3.41.6).
Configuring the Proguard RuleAndroid
If your project is obfuscated with proguard, please add the rule below to your android project proguard-rules.pro
-keep class com.edfapg.sdk.** { public protected private *; }
Usage
[!IMPORTANT]
Initialize SDKEdfaPgSdk.instance.config( key: MERCHANT_CLIENT_KEY, // Your Secret Merchant Key password: MERCHANT_CLIENT_PASSWORD, // Your Secret Merchant Password enableDebug: true );[!TIP]
Get Ready for PaymentCreate
EdfaPgSaleOrderModelfinal order = EdfaPgSaleOrder( id: EdfaPgSdk.instance.HELPER.generateUUID(), description: "Test Order", currency: "SAR", amount: 1.00//Random().nextInt(9)/10, // will not exceed 0.9 );Create
EdfaPgPayerModelfinal payer = EdfaPgPayer( firstName: "First Name", lastName: "Last Name", address: "EdfaPay Payment Gateway", country: "SA", city: "Riyadh", zip: "123768", email: "[email protected]", phone: "+966500409598", ip: "66.249.64.248", options: EdfaPgPayerOption( // Options middleName: "Middle Name", birthdate: DateTime.parse("1987-03-30"), address2: "Usman Bin Affan", state: "Al Izdihar" ) );Payment with Card
EdfaCardPay() .setOrder(order) .setPayer(payer) .setRecurring(true) // Set 'true' for enable recurring else don't call the setRecurring .setLanguage(EdfaPayLanguage.ar) .setDesignType(EdfaPayDesignType.one) // EdfaPayDesignType.two, EdfaPayDesignType.three .onTransactionSuccess((response){ print("onTransactionSuccess.response ===> ${response.toString()}"); }).onTransactionFailure((response){ print("onTransactionFailure.response ===> ${response.toString()}"); }).onError((error){ print("onError.error ===> ${error.toString()}"); }).initialize(context);Pay With ApplePay - iOS Only
EdfaApplePay() .setOrder(order) .setPayer(payer) .setApplePayMerchantID(APPLEPAY_MERCHANT_ID) .onAuthentication((response){ print("onAuthentication.response ===> ${response.toString()}"); }).onTransactionSuccess((response){ print("onTransactionSuccess.response ===> ${response.toString()}"); }).onTransactionFailure((response){ print("onTransactionFailure.response ===> ${response.toString()}"); }).onError((error){ print("onError.response ===> ${error.toString()}"); }).initialize(context);
Addon'sCreate
EdfaPgSaleOrder&EdfaPgPayerModel Like ThisCreate
EdfaPgSaleOptionModelfinal saleOption = EdfaPgSaleOption( channelId: "channel-id-here", // channel-id if its enable for merchant recurringInit: true // Make sure recurring is enabled for merchant and [true=if want to do recurring, false=if don't want do recurring] );Create
EdfaPgCardModelfinal card = EdfaPgCard( number: "1234567890987654", expireMonth: 01, expireYear: 2028, cvv: 123 );Sale Transaction - Make sure to pass null to
saleOption:and false toisAuth:EdfaPgSdk.instance.ADAPTER.SALE.execute( order: order, card: card, payer: payer, saleOption: null, isAuth: false, onResponse: SaleResponseCallback( success: (EdfaPgSaleSuccess result) { debugPrint(result.toJson().toString()); }, decline: (EdfaPgSaleDecline result) { debugPrint(result.toJson().toString()); }, recurring: (EdfaPgSaleRecurring result) { debugPrint(result.toJson().toString()); }, redirect: (EdfaPgSaleRedirect result) { debugPrint(result.toJson().toString()); }, secure3d: (EdfaPgSale3DS result) { debugPrint(result.toJson().toString()); }, error: (EdfaPgError result) { debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );Recurring Transaction
- Make sure to pass false to
isAuth:- Card Number should be passed the same used for the first
SalewithEdfaPgSaleOption.recurringInit==trueEdfaPgRecurringOptions.firstTransactionId:shouldtransactionIdfrom first successSalewithEdfaPgSaleOption.recurringInit==trueEdfaPgRecurringOptions.token:Should be recurringToken from first successSalewithEdfaPgSaleOption.recurringInit==trueEdfaPgSdk.instance.ADAPTER.RECURRING_SALE.execute( cardNumber: "1234567890123456", isAuth: false, order: order, payerEmail: "[email protected]", recurringOptions: EdfaPgRecurringOptions( firstTransactionId: "c9f9b51b-72f4-4e2d-8a49-3b26c97b2f50", token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" ), onResponse: RecurringSaleResponseCallback( success: (EdfaPgSaleSuccess result) { debugPrint(result.toJson().toString()); }, decline: (EdfaPgSaleDecline result) { debugPrint(result.toJson().toString()); }, recurring: (EdfaPgSaleRecurring result) { debugPrint(result.toJson().toString()); }, redirect: (EdfaPgSaleRedirect result) { debugPrint(result.toJson().toString()); }, secure3d: (EdfaPgSale3DS result) { debugPrint(result.toJson().toString()); }, error: (EdfaPgError result) { debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );Capture Transaction
transactionId:shouldtransactionIdfrom successSalewithisAuth:true- Card Number should be passed the same used for the
SalewithisAuth:truecardNumber:should authorized bySalewithisAuth:trueamount:should be the same asSalewithisAuth:trueEdfaPgSdk.instance.ADAPTER.CAPTURE.execute( amount: 1.0, transactionId: "c9f9b51b-72f4-4e2d-8a49-3b26c97b2f50", cardNumber: "1234567890123456", payerEmail: "[email protected]", onResponse: CaptureResponseCallback( success: (EdfaPgCaptureSuccess result){ debugPrint(result.toJson().toString()); }, decline: (EdfaPgCaptureDecline result){ debugPrint(result.toJson().toString()); }, error: (EdfaPgError result){ debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );Credit Void Transaction
transactionId:shouldtransactionIdfrom successSalewithisAuth:true- Card Number should be passed the same used for the
SalewithisAuth:truecardNumber:should authorized bySalewithisAuth:trueamount:should be the same asSalewithisAuth:trueEdfaPgSdk.instance.ADAPTER.CREDIT_VOID.execute( amount: 1.0, transactionId: "c9f9b51b-72f4-4e2d-8a49-3b26c97b2f50", cardNumber: "1234567890123456", payerEmail: "[email protected]", onResponse: CreditVoidResponseCallback( success: (EdfaPgCreditVoidSuccess result){ debugPrint(result.toJson().toString()); }, error: (EdfaPgError result){ debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );Transaction Detail
transactionId:should be from the last transaction,cardNumber:should be passed the same used for the last transactionEdfaPgSdk.instance.ADAPTER.TRANSACTION_DETAILS.execute( transactionId: "c9f9b51b-72f4-4e2d-8a49-3b26c97b2f50", cardNumber: "1234567890123456", payerEmail: "[email protected]", onResponse: TransactionDetailsResponseCallback( success: (EdfaPgTransactionDetailsSuccess result){ debugPrint(result.toJson().toString()); }, error: (EdfaPgError result){ debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );Transaction Status
transactionId:should be from the last transaction,cardNumber:should be passed the same used for the last transactionEdfaPgSdk.instance.ADAPTER.TRANSACTION_STATUS.execute( transactionId: "c9f9b51b-72f4-4e2d-8a49-3b26c97b2f50", cardNumber: "1234567890123456", payerEmail: "[email protected]", onResponse: TransactionStatusResponseCallback( success: (EdfaPgTransactionStatusSuccess result){ debugPrint(result.toJson().toString()); }, error: (EdfaPgError result){ debugPrint(result.toJson().toString()); } ), onResponseJSON: (data){ debugPrint(data); }, onFailure: (result) { debugPrint(result.toJson().toString()); } );
Getting help
To report a specific issue or feature request, open
a new issue.
Or write a direct letter to the [email protected] .
License
MIT License. See
the LICENSE file for
more details.
Contacts
Website: https://edfapay.com/home/
Phone: +966920031242
Email: [email protected]
7637 Othman Bin Affan St., 2123 Al Ezdihar Dist., 12487 Riyadh, Riyadh, Saudi Arabia
© 2022 - 2023 EdfaPay. All rights reserved.
Important Note
The official package page https://pub.dev/packages/edfapg_sdk#intalling-flutter-plugin
contains the latest SDK version, change log, and example code. Always refer to it before upgrading or integrating.
Updated 5 days ago