From def31738da23025cb70acc2019b390753d4f696c Mon Sep 17 00:00:00 2001 From: Montcho Shegun Date: Sun, 22 Oct 2023 18:57:20 +0100 Subject: [PATCH] dependencies update - 100 % documentation - 40% --- .flutter-plugins-dependencies | 2 +- README.md | 8 +- example/.flutter-plugins-dependencies | 2 +- example/lib/main.dart | 6 +- example/pubspec.lock | 28 +-- example/pubspec.yaml | 2 +- lib/{kkiapay => }/app/app.dart | 2 +- lib/{kkiapay => }/app/app.locator.dart | 2 +- lib/{kkiapay => }/app/app.router.dart | 163 +++++++++--------- lib/kkiapay/view/view.part.dart | 118 ------------- lib/src/view.part.dart | 129 ++++++++++++++ .../view => src}/widget_builder_view.dart | 71 +++++--- .../widget_builder_view_model.dart | 22 ++- .../{kkiapayConf.sample.dart => config.dart} | 43 ++--- lib/utils/utils.dart | 2 +- pubspec.lock | 24 +-- pubspec.yaml | 16 +- 17 files changed, 327 insertions(+), 313 deletions(-) rename lib/{kkiapay => }/app/app.dart (84%) rename lib/{kkiapay => }/app/app.locator.dart (94%) rename lib/{kkiapay => }/app/app.router.dart (85%) delete mode 100644 lib/kkiapay/view/view.part.dart create mode 100644 lib/src/view.part.dart rename lib/{kkiapay/view => src}/widget_builder_view.dart (72%) rename lib/{kkiapay/view => src}/widget_builder_view_model.dart (68%) rename lib/utils/{kkiapayConf.sample.dart => config.dart} (73%) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 094d652..b33de66 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher_ios","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.5/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_android-6.1.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_android-2.10.4/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.6/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.20/","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-10-14 22:37:57.478435","version":"3.13.7"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher_ios","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.5/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.1/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_android-6.1.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_android-3.12.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.6/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.20/","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-10-22 06:15:01.639544","version":"3.13.7"} \ No newline at end of file diff --git a/README.md b/README.md index 91c93e9..f3dfc50 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ dependencies: ## Usage ```dart - import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart'; + import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart'; ``` ##### Initialise the Kkiapay Instance @@ -55,9 +55,9 @@ final Widget kkiapayWebview = KkiapayWebview(kkiapay) ```dart import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart'; +import 'package:kkiapay_flutter_sdk/kkiapay/src/widget_builder_view.dart'; import 'package:kkiapay_flutter_sdk/kkiapayWeb/web_widget_builder.dart'; -import 'package:kkiapay_flutter_sdk/utils/kkiapayConf.sample.dart'; +import 'package:kkiapay_flutter_sdk/utils/config.dart'; void main() => runApp(App()); @@ -171,9 +171,7 @@ the successCallback function takes two parameters in the following order 'phone': String, 'reason': String, 'data': String, - 'paymentMethods': List, 'partnerId': String, - 'countries': List, 'sandbox': bool, 'name': String, 'email': String diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 3bc4e89..d2134db 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher_ios","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.5/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-2.9.5/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_android-6.1.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_android-2.10.4/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.6/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.19/","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-10-14 22:38:33.269193","version":"3.13.7"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher_ios","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.5/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.1/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_android-6.1.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_android-3.12.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.7/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.6/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.20/","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-10-22 06:15:01.683116","version":"3.13.7"} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 2a18915..ce3d1de 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart'; -import 'package:kkiapay_flutter_sdk/utils/kkiapayConf.sample.dart'; +import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart'; +import 'package:kkiapay_flutter_sdk/utils/config.dart'; import './successScreen.dart'; void main() => runApp(App()); @@ -42,7 +42,7 @@ final kkiapay = KKiaPay( reason: 'transaction reason',// data: 'Fake data',// sandbox: true,// - apikey: '4afb8d60021211edadbe55ee0346ea8f',// + apikey: public_api_key,// callback: successCallback,// theme: defaultTheme, // Ex : "#222F5A", partnerId: 'AxXxXXxId',// diff --git a/example/pubspec.lock b/example/pubspec.lock index c50680f..5640378 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -84,10 +84,10 @@ packages: dependency: transitive description: name: get - sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a" + sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e url: "https://pub.dev" source: hosted - version: "4.6.5" + version: "4.6.6" get_it: dependency: transitive description: @@ -320,10 +320,10 @@ packages: dependency: transitive description: name: url_launcher_web - sha256: ba140138558fcc3eead51a1c42e92a9fb074a1b1149ed3c73e66035b2ccd94f2 + sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5" url: "https://pub.dev" source: hosted - version: "2.0.19" + version: "2.0.20" url_launcher_windows: dependency: transitive description: @@ -352,34 +352,34 @@ packages: dependency: transitive description: name: webview_flutter - sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88" + sha256: c1ab9b81090705c6069197d9fdc1625e587b52b8d70cdde2339d177ad0dbb98e url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.4.1" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd" + sha256: b0cd33dd7d3dd8e5f664e11a19e17ba12c352647269921a3b568406b001f1dff url: "https://pub.dev" source: hosted - version: "2.10.4" + version: "3.12.0" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf" + sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f" url: "https://pub.dev" source: hosted - version: "1.9.5" + version: "2.6.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0 + sha256: "30b9af6bdd457b44c08748b9190d23208b5165357cc2eb57914fee1366c42974" url: "https://pub.dev" source: hosted - version: "2.9.5" + version: "3.9.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.10.0" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3851294..a92c7b0 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=3.0.3 <4.0.0' dependencies: flutter: diff --git a/lib/kkiapay/app/app.dart b/lib/app/app.dart similarity index 84% rename from lib/kkiapay/app/app.dart rename to lib/app/app.dart index c0b0cde..d8a0cbd 100644 --- a/lib/kkiapay/app/app.dart +++ b/lib/app/app.dart @@ -1,6 +1,6 @@ import 'package:stacked/stacked_annotations.dart'; import 'package:stacked_services/stacked_services.dart'; -import '../view/widget_builder_view.dart'; +import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart'; @StackedApp( routes: [ diff --git a/lib/kkiapay/app/app.locator.dart b/lib/app/app.locator.dart similarity index 94% rename from lib/kkiapay/app/app.locator.dart rename to lib/app/app.locator.dart index 81b2cde..d845284 100644 --- a/lib/kkiapay/app/app.locator.dart +++ b/lib/app/app.locator.dart @@ -6,9 +6,9 @@ // ignore_for_file: public_member_api_docs, implementation_imports, depend_on_referenced_packages -import 'package:stacked/stacked_annotations.dart'; import 'package:stacked_services/src/navigation/navigation_service.dart'; import 'package:stacked_services/src/snackbar/snackbar_service.dart'; +import 'package:stacked_shared/stacked_shared.dart'; final locator = StackedLocator.instance; diff --git a/lib/kkiapay/app/app.router.dart b/lib/app/app.router.dart similarity index 85% rename from lib/kkiapay/app/app.router.dart rename to lib/app/app.router.dart index cebc7a5..0c2e248 100644 --- a/lib/kkiapay/app/app.router.dart +++ b/lib/app/app.router.dart @@ -7,8 +7,7 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:flutter/material.dart' as _i3; import 'package:flutter/material.dart'; -import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart' - as _i2; +import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart' as _i2; import 'package:stacked/stacked.dart' as _i1; import 'package:stacked_services/stacked_services.dart' as _i4; @@ -33,18 +32,18 @@ class StackedRouter extends _i1.RouterBase { builder: (context) => _i2.KKiaPay( key: args.key, amount: args.amount, - apikey: args.apikey, - callback: args.callback, - phone: args.phone, - partnerId: args.partnerId, - countries: args.countries, reason: args.reason, + phone: args.phone, + name: args.name, + email: args.email, data: args.data, - paymentMethods: args.paymentMethods, + partnerId: args.partnerId, + callback: args.callback, + apikey: args.apikey, sandbox: args.sandbox, theme: args.theme, - name: args.name, - email: args.email), + countries: args.countries, + paymentMethods: args.paymentMethods), settings: data, ); } @@ -61,54 +60,54 @@ class KKiaPayArguments { const KKiaPayArguments({ this.key, required this.amount, - required this.apikey, - required this.callback, + required this.reason, this.phone, - this.partnerId, - this.countries, - this.reason, + this.name, + this.email, this.data, - this.paymentMethods, + this.partnerId, + required this.callback, + required this.apikey, required this.sandbox, this.theme, - this.name, - this.email, + this.countries, + this.paymentMethods, }); final _i3.Key? key; final int amount; - final String? apikey; - - final dynamic Function( - Map, - _i3.BuildContext, - ) callback; + final String reason; final String? phone; - final String? partnerId; - - final List? countries; + final String? name; - final String? reason; + final String? email; final String? data; - final List? paymentMethods; + final String? partnerId; + + final dynamic Function( + Map, + _i3.BuildContext, + ) callback; + + final String apikey; final bool? sandbox; final String? theme; - final String? name; + final List? countries; - final String? email; + final List? paymentMethods; @override String toString() { - return '{"key": "$key", "amount": "$amount", "apikey": "$apikey", "callback": "$callback", "phone": "$phone", "partnerId": "$partnerId", "countries": "$countries", "reason": "$reason", "data": "$data", "paymentMethods": "$paymentMethods", "sandbox": "$sandbox", "theme": "$theme", "name": "$name", "email": "$email"}'; + return '{"key": "$key", "amount": "$amount", "reason": "$reason", "phone": "$phone", "name": "$name", "email": "$email", "data": "$data", "partnerId": "$partnerId", "callback": "$callback", "apikey": "$apikey", "sandbox": "$sandbox", "theme": "$theme", "countries": "$countries", "paymentMethods": "$paymentMethods"}'; } @override @@ -116,36 +115,36 @@ class KKiaPayArguments { if (identical(this, other)) return true; return other.key == key && other.amount == amount && - other.apikey == apikey && - other.callback == callback && - other.phone == phone && - other.partnerId == partnerId && - other.countries == countries && other.reason == reason && + other.phone == phone && + other.name == name && + other.email == email && other.data == data && - other.paymentMethods == paymentMethods && + other.partnerId == partnerId && + other.callback == callback && + other.apikey == apikey && other.sandbox == sandbox && other.theme == theme && - other.name == name && - other.email == email; + other.countries == countries && + other.paymentMethods == paymentMethods; } @override int get hashCode { return key.hashCode ^ amount.hashCode ^ - apikey.hashCode ^ - callback.hashCode ^ - phone.hashCode ^ - partnerId.hashCode ^ - countries.hashCode ^ reason.hashCode ^ + phone.hashCode ^ + name.hashCode ^ + email.hashCode ^ data.hashCode ^ - paymentMethods.hashCode ^ + partnerId.hashCode ^ + callback.hashCode ^ + apikey.hashCode ^ sandbox.hashCode ^ theme.hashCode ^ - name.hashCode ^ - email.hashCode; + countries.hashCode ^ + paymentMethods.hashCode; } } @@ -153,21 +152,21 @@ extension NavigatorStateExtension on _i4.NavigationService { Future navigateToKKiaPay({ _i3.Key? key, required int amount, - required String? apikey, + required String reason, + String? phone, + String? name, + String? email, + String? data, + String? partnerId, required dynamic Function( Map, _i3.BuildContext, ) callback, - String? phone, - String? partnerId, - List? countries, - String? reason, - String? data, - List? paymentMethods, + required String apikey, required bool? sandbox, String? theme, - String? name, - String? email, + List? countries, + List? paymentMethods, int? routerId, bool preventDuplicates = true, Map? parameters, @@ -178,18 +177,18 @@ extension NavigatorStateExtension on _i4.NavigationService { arguments: KKiaPayArguments( key: key, amount: amount, - apikey: apikey, - callback: callback, - phone: phone, - partnerId: partnerId, - countries: countries, reason: reason, + phone: phone, + name: name, + email: email, data: data, - paymentMethods: paymentMethods, + partnerId: partnerId, + callback: callback, + apikey: apikey, sandbox: sandbox, theme: theme, - name: name, - email: email), + countries: countries, + paymentMethods: paymentMethods), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -199,21 +198,21 @@ extension NavigatorStateExtension on _i4.NavigationService { Future replaceWithKKiaPay({ _i3.Key? key, required int amount, - required String? apikey, + required String reason, + String? phone, + String? name, + String? email, + String? data, + String? partnerId, required dynamic Function( Map, _i3.BuildContext, ) callback, - String? phone, - String? partnerId, - List? countries, - String? reason, - String? data, - List? paymentMethods, + required String apikey, required bool? sandbox, String? theme, - String? name, - String? email, + List? countries, + List? paymentMethods, int? routerId, bool preventDuplicates = true, Map? parameters, @@ -224,18 +223,18 @@ extension NavigatorStateExtension on _i4.NavigationService { arguments: KKiaPayArguments( key: key, amount: amount, - apikey: apikey, - callback: callback, - phone: phone, - partnerId: partnerId, - countries: countries, reason: reason, + phone: phone, + name: name, + email: email, data: data, - paymentMethods: paymentMethods, + partnerId: partnerId, + callback: callback, + apikey: apikey, sandbox: sandbox, theme: theme, - name: name, - email: email), + countries: countries, + paymentMethods: paymentMethods), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, diff --git a/lib/kkiapay/view/view.part.dart b/lib/kkiapay/view/view.part.dart deleted file mode 100644 index b8af4f1..0000000 --- a/lib/kkiapay/view/view.part.dart +++ /dev/null @@ -1,118 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:kkiapay_flutter_sdk/utils/utils.dart'; -import 'package:stacked/stacked.dart'; -import 'package:webview_flutter/webview_flutter.dart'; -import '../../utils/kkiapayConf.sample.dart'; -import 'widget_builder_view_model.dart'; - -class LoadingView extends ViewModelWidget { - LoadingView({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context, WidgetBuilderViewModel viewModel) { - return Container( - color: Colors.white, - child: Align( - alignment: Alignment.center, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - height: 52, - child: Center( - child: imageFromBase64String(), - )), - RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 18.0, - ), - children: [ - new TextSpan( - text: 'Chargement', - style: new TextStyle( - fontWeight: FontWeight.bold, color: Colors.black)), - new TextSpan( - text: '...', - style: new TextStyle( - fontWeight: FontWeight.bold, color: Colors.black54)), - ], - ) - ), - ], - ), - )); - } -} - -class WidgetBuild extends ViewModelWidget { - final Function(Map, BuildContext) callback; - final String url; - - const WidgetBuild({Key? key, required this.url, required this.callback}) - : super(key: key); - - @override - Widget build(BuildContext context, WidgetBuilderViewModel viewModel) { - return WebView( - initialUrl: url, - zoomEnabled: false, - javascriptMode: JavascriptMode.unrestricted, - javascriptChannels: Set.from([ - JavascriptChannel( - name: 'SDK_CHANNEL', - onMessageReceived: (JavascriptMessage message) { - print( JsonDecoder().convert(message.message)); - - switch (JsonDecoder().convert(message.message)["name"]) { - - case CLOSE_WIDGET: if (viewModel.lastEvent != PAYMENT_SUCCESS) callback( { - 'requestData': viewModel.data, - 'transactionId': null, - 'status': CallbackStatus.PAYMENT_CANCELLED.name - }, context); - break; - - case WIDGET_SUCCESSFULLY_INIT: viewModel.loadingFinish(); - break; - - case PAYMENT_SUCCESS: - viewModel.setLastEvent(PAYMENT_SUCCESS); - callback( { - 'requestData': viewModel.data, - 'transactionId': JsonDecoder().convert(message.message)["data"]["transactionId"], - 'status': CallbackStatus.PAYMENT_SUCCESS.name - }, context); - break; - - case PAYMENT_FAILED: callback( { - 'requestData': null, - 'transactionId': JsonDecoder().convert(message.message)["data"]["transactionId"], - 'status': CallbackStatus.PAYMENT_FAILED.name - }, context); - break; - - default: - break; - } - }) - ]), - onWebViewCreated: (WebViewController webViewController) { - webViewController.clearCache(); - }, - onWebResourceError: (error) { - viewModel.loadingStart(); - }, - //onPageStarted: (url) => viewModel.loadingStart(), - navigationDelegate: (NavigationRequest request) { - return viewModel.onUrlChange( request, (object, context) async { - callback(object, context); - }, context); - }, - ); - } -} diff --git a/lib/src/view.part.dart b/lib/src/view.part.dart new file mode 100644 index 0000000..d9de69a --- /dev/null +++ b/lib/src/view.part.dart @@ -0,0 +1,129 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:kkiapay_flutter_sdk/utils/utils.dart'; +import 'package:stacked/stacked.dart'; +import 'package:webview_flutter/webview_flutter.dart'; +import '../../utils/config.dart'; +import 'widget_builder_view_model.dart'; + +class LoadingView extends ViewModelWidget { + LoadingView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context, WidgetBuilderViewModel viewModel) { + return Container( + color: Colors.white, + child: Align( + alignment: Alignment.center, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + height: 52, + child: Center( + child: imageFromBase64String(), + )), + RichText( + text: new TextSpan( + style: new TextStyle( + fontSize: 18.0, + ), + children: [ + new TextSpan( + text: 'Chargement', + style: new TextStyle( + fontWeight: FontWeight.bold, color: Colors.black)), + new TextSpan( + text: '...', + style: new TextStyle( + fontWeight: FontWeight.bold, color: Colors.black54)), + ], + ) + ), + ], + ), + )); + } +} + +class WidgetBuild extends ViewModelWidget { + final Function(Map, BuildContext) callback; + final String url; + + const WidgetBuild({Key? key, required this.url, required this.callback}) + : super(key: key); + + @override + Widget build(BuildContext context, WidgetBuilderViewModel viewModel) { + WebViewController controller = WebViewController() + ..enableZoom(false) + ..setJavaScriptMode(JavaScriptMode.unrestricted) + /// listen widget logs event from JavaScriptChannel + ..addJavaScriptChannel('SDK_CHANNEL', onMessageReceived: (message) { + print( JsonDecoder().convert(message.message)); + + switch (JsonDecoder().convert(message.message)["name"]) { + + case CLOSE_WIDGET: if (viewModel.lastEvent != PAYMENT_SUCCESS) callback( { + 'requestData': viewModel.data, + 'transactionId': null, + 'status': CallbackStatus.PAYMENT_CANCELLED.name + }, context); + break; + + case WIDGET_SUCCESSFULLY_INIT: viewModel.loadingFinish(); + break; + + case PAYMENT_SUCCESS: + viewModel.setLastEvent(PAYMENT_SUCCESS); + callback( { + 'requestData': viewModel.data, + 'transactionId': JsonDecoder().convert(message.message)["data"]["transactionId"], + 'status': CallbackStatus.PAYMENT_SUCCESS.name + }, context); + break; + + case PAYMENT_FAILED: callback( { + 'requestData': null, + 'transactionId': JsonDecoder().convert(message.message)["data"]["transactionId"], + 'status': CallbackStatus.PAYMENT_FAILED.name + }, context); + break; + + default: + break; + } + }) + ..setNavigationDelegate( + NavigationDelegate( + onPageStarted: (url) => viewModel.loadingStart(), + onProgress: (int progress) { + // Update loading bar. + }, + onPageFinished: (String url) { + // controller.clearCache(); + }, + onUrlChange: (url){ + viewModel.onUrlChange( url, (object, context) async { + Navigator.pop(context); + callback(object, context); + }, context); + }, + onWebResourceError: (WebResourceError error) { + viewModel.loadingStart(); + }, + onNavigationRequest: (NavigationRequest request) { + if (request.url.startsWith('https://www.youtube.com/')) { + return NavigationDecision.prevent; + } + return NavigationDecision.navigate; + }, + ), + ) + ..loadRequest(Uri.parse(url)); + + return WebViewWidget(controller: controller); + } +} diff --git a/lib/kkiapay/view/widget_builder_view.dart b/lib/src/widget_builder_view.dart similarity index 72% rename from lib/kkiapay/view/widget_builder_view.dart rename to lib/src/widget_builder_view.dart index 5b45081..dfea826 100644 --- a/lib/kkiapay/view/widget_builder_view.dart +++ b/lib/src/widget_builder_view.dart @@ -1,42 +1,63 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:kkiapay_flutter_sdk/kkiapay/view/view.part.dart'; +import 'package:kkiapay_flutter_sdk/src/view.part.dart'; import 'package:stacked/stacked.dart'; -import '../../utils/kkiapayConf.sample.dart'; +import '../../utils/config.dart'; import '../../utils/utils.dart'; import 'widget_builder_view_model.dart'; import 'dart:io'; class KKiaPay extends StackedView { + + /* Payment info */ + /// @Params: Payment amount final int amount; - final String? reason; + /// @Params : Payment reason + final String reason; + /// @Params : Payment phoneNumber final String? phone; + /// @Params : Payment owner + final String? name; + /// @Params email : Payment owner address mail + final String? email; + /// @Params : Payment data send by webhook final String? data; - final String? apikey; - final bool? sandbox; + /// @Params partnerId : Your application payment reference + final String? partnerId; + /// @Params : Payment callback final Function(Map, BuildContext) callback; + + + /* Widget ui config */ + /// @Params : Your public api key according to [sandbox] value + final String apikey; + /// @Params : Payment environment according to [apikey] value + final bool? sandbox; + /// @Params : Widget authorized countries final String? theme; - final String? name; - final String? email; + /// @Params : Widget authorized countries final List? countries; - final String? partnerId; + /// @Params : Widget authorized payment paymentMethods final List? paymentMethods; + const KKiaPay({ Key? key, + /* Payment info */ required this.amount, - required this.apikey, - required this.callback, + required this.reason, this.phone, - this.partnerId, - this.countries, - this.reason, + this.name, + this.email, this.data, - this.paymentMethods, + this.partnerId, + required this.callback, + /* Widget ui config */ + required this.apikey, required this.sandbox, this.theme, - this.name, - this.email, + this.countries, + this.paymentMethods, }) : super(key: key); @override @@ -49,8 +70,7 @@ class KKiaPay extends StackedView { Container( margin: EdgeInsets.only( top: MediaQuery.of(context).viewPadding.top), - child: viewModel.hide - ? null + child: viewModel.onLoading ? null : WidgetBuild( url: Utils.getUrl(SdkData( reason: reason, @@ -75,24 +95,28 @@ class KKiaPay extends StackedView { @override void onViewModelReady(WidgetBuilderViewModel viewModel) { super.onViewModelReady(viewModel); + + /// Change status bar if ios devise if (!Platform.isIOS) { SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( statusBarColor: Colors.black, statusBarBrightness: Brightness.light, statusBarIconBrightness: Brightness.light)); } + + /// Initialise javascript event history viewModel.setLastEvent(""); + + /// Save payment data for callback viewModel.setData({ - 'countries': countries, - 'partnerId': partnerId, 'amount': amount, 'reason': reason, 'phone': phone, + 'name': name, + 'email': email, + 'partnerId': partnerId, 'data': data, - 'paymentMethods': paymentMethods, 'sandbox': sandbox, - 'name': name, - 'email': email }); } @@ -100,4 +124,5 @@ class KKiaPay extends StackedView { WidgetBuilderViewModel viewModelBuilder(BuildContext context) { return WidgetBuilderViewModel(); } + } diff --git a/lib/kkiapay/view/widget_builder_view_model.dart b/lib/src/widget_builder_view_model.dart similarity index 68% rename from lib/kkiapay/view/widget_builder_view_model.dart rename to lib/src/widget_builder_view_model.dart index f8f52ca..c62cd3b 100644 --- a/lib/kkiapay/view/widget_builder_view_model.dart +++ b/lib/src/widget_builder_view_model.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; -import 'package:kkiapay_flutter_sdk/utils/kkiapayConf.sample.dart'; +import 'package:kkiapay_flutter_sdk/utils/config.dart'; import 'package:kkiapay_flutter_sdk/utils/utils.dart'; import 'package:stacked/stacked.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -8,12 +8,6 @@ import 'package:webview_flutter/webview_flutter.dart'; class WidgetBuilderViewModel extends BaseViewModel { - bool _hide = false; - bool get hide => _hide; - void hideWebView () { - _hide = true; - notifyListeners(); - } bool _onLoading = true; bool get onLoading => _onLoading; @@ -40,15 +34,19 @@ class WidgetBuilderViewModel extends BaseViewModel { notifyListeners(); } - FutureOr onUrlChange (request, + FutureOr onUrlChange (UrlChange request, Function(Map, BuildContext)? callback, context) async { - if (request.url.startsWith(WaveRedirectURI) - || request.url.startsWith(PlayStoreRedirectURI)) { - Utils.launchWave(request.url); + if (request.url == null ) { return NavigationDecision.prevent; + }else{ + if (request.url!.startsWith(WaveRedirectURI) + || request.url!.startsWith(PlayStoreRedirectURI)) { + Utils.launchWave(request.url!); + return NavigationDecision.prevent; + } + return NavigationDecision.navigate; } - return NavigationDecision.navigate; } } diff --git a/lib/utils/kkiapayConf.sample.dart b/lib/utils/config.dart similarity index 73% rename from lib/utils/kkiapayConf.sample.dart rename to lib/utils/config.dart index d1c38ab..6b4176a 100644 --- a/lib/utils/kkiapayConf.sample.dart +++ b/lib/utils/config.dart @@ -1,31 +1,25 @@ import 'dart:convert'; - import 'dart:ui'; +/// developer account api key +const public_api_key = '4afb8d60021211edadbe55ee0346ea8f'; +/// widget default theme +const defaultTheme = "#4E6BFC"; + +/// KKiaPay widget base url const KKiaPayURL = "https://widget-v3.kkiapay.me"; -const KKiaPayRedirectURL = "http://redirect.kkiapay.me"; + +/// const for wave payment const WaveRedirectURI = "wave:"; const PlayStoreRedirectURI = "https://play.google.com"; const WaveStoreRedirectURI = "market://details?id=com.wave.personal"; -const key = "xxxxxxxxxxxxxxxxxxxxxx"; -/// API Key */ +/// static additional data +const nColorPrimary = Color(0xffF11C33); const callback = 'http://redirect.kkiapay.me'; - -/// Webhook */ const sdk = "flutter"; -const defaultTheme = "#4E6BFC"; -const nColorPrimary = Color(0xffF11C33); -const nColorSecondary = Color(0xff222F5A); -const nColorYellow = Color(0xffE8C145); -const nColorGray1 = Color(0xffF9F9F9); -const nColorGray2 = Color(0xeaeaea); - -/// Widget hex color */ const url = ""; - -/// Widget header image url */ -const host = ""; /** package name **/ +const host = ""; /// Widget payment Mode enum PaymentMethod { @@ -41,7 +35,7 @@ enum CallbackStatus { PAYMENT_SUCCESS, } - +/// widget javascript events const NETWORK_STATE_CHANGED = 'NETWORK_STATE_CHANGED'; const INIT_WIDGET = 'INIT_WIDGET'; const WIDGET_SUCCESSFULLY_INIT = 'WIDGET_SUCCESSFULLY_INIT'; @@ -60,16 +54,7 @@ const RETRY_PAYMENT = 'RETRY_PAYMENT'; - - - class SdkData { - /// @Params amount : Payment amount - /// @Params reason : Payment reason - /// @Params name : Payment owner - /// @Params phone : Payment phoneNumber - /// @Params data : Payment data send by webhook - /// @Params sandbox : Payment request made in sandbox SdkData({ this.amount, this.paymentMethod, @@ -115,6 +100,4 @@ class SdkData { var bytes = utf8.encode(json); return base64.encode(bytes); } -} - -// var json = jsonEncode({"amount":100,"sandbox":false,"serviceId":"INTEGRATION","position":"left","theme":"primary","key":"LprYUAyMpfAjq4z2yTHPiY0b6XktIQ","paymentMethods":["momo","card","direct_debit"]}); \ No newline at end of file +} \ No newline at end of file diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index f73dfaa..e42fdc0 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'kkiapayConf.sample.dart'; +import 'config.dart'; class Utils { diff --git a/pubspec.lock b/pubspec.lock index ddac3ed..0412a84 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -210,10 +210,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: ad76540d21c066228ee3f9d1dad64a9f7e46530e8bb7c85011a88bc1fd874bc5 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -324,10 +324,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" logger: dependency: transitive description: @@ -689,34 +689,34 @@ packages: dependency: "direct main" description: name: webview_flutter - sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88" + sha256: c1ab9b81090705c6069197d9fdc1625e587b52b8d70cdde2339d177ad0dbb98e url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.4.1" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd" + sha256: b0cd33dd7d3dd8e5f664e11a19e17ba12c352647269921a3b568406b001f1dff url: "https://pub.dev" source: hosted - version: "2.10.4" + version: "3.12.0" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf" + sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f" url: "https://pub.dev" source: hosted - version: "1.9.5" + version: "2.6.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0 + sha256: "30b9af6bdd457b44c08748b9190d23208b5165357cc2eb57914fee1366c42974" url: "https://pub.dev" source: hosted - version: "2.9.5" + version: "3.9.1" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4fb348d..8f8d302 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,21 +1,21 @@ name: kkiapay_flutter_sdk -description: KkiaPay allows businesses to safely receive payments by mobile money, credit card and bank account. +description: KKiaPay allows businesses to safely receive payments by mobile money, credit card and bank account. version: 1.2.6 support: kkiapay homepage: "https://github.com/kkiapay/kkiapay-flutter-sdk" environment: - sdk: ">=2.17.0 <4.0.0" + sdk: '>=3.0.3 <4.0.0' dependencies: flutter: sdk: flutter - stacked: ^3.4.1+1 - stacked_services: ^1.3.0 - url_launcher: ^6.1.14 - http: ^1.1.0 - webview_flutter: ^3.0.4 - cupertino_icons: ^1.0.6 + stacked: + stacked_services: + url_launcher: + http: + webview_flutter: + cupertino_icons: dev_dependencies: flutter_test: