diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 26ae27b..abd8fc8 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.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.2/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_android-6.2.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.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.0/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/shegunmontcho/.pub-cache/hosted/pub.dev/url_launcher_web-2.2.0/","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-11-05 22:46:51.693674","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/fulberto/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.4/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_android-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/webview_flutter_android-3.12.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_macos-3.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.0/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_web-2.2.0/","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-11-13 17:12:52.915398","version":"3.13.9"} \ No newline at end of file diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 59ae4a1..c7bc88a 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":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/home/farid/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.2/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_android-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/home/farid/.pub-cache/hosted/pub.dev/webview_flutter_android-3.12.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_macos-3.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.0/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/home/farid/.pub-cache/hosted/pub.dev/url_launcher_web-2.2.0/","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-11-10 16:06:06.464171","version":"3.13.0"} \ 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/fulberto/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.9.2/","native_build":true,"dependencies":[]}],"android":[{"name":"url_launcher_android","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_android-6.2.0/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/webview_flutter_android-3.12.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_macos-3.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.0/","native_build":true,"dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/fulberto/.pub-cache/hosted/pub.dev/url_launcher_web-2.2.0/","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-11-13 17:31:36.544214","version":"3.13.9"} \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index d4fd85e..dd76087 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/home/farid/snap/flutter/common/flutter" -export "FLUTTER_APPLICATION_PATH=/home/farid/opensi_project/kkiapay-flutter-sdk/example" +export "FLUTTER_ROOT=/Users/fulberto/Library/Android/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/fulberto/Desktop/kkiapay-flutter-sdk/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" diff --git a/example/lib/main.dart b/example/lib/main.dart index f7d74a7..47e0183 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,27 +1,32 @@ import 'package:flutter/material.dart'; -import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart'; -import 'package:kkiapay_flutter_sdk/utils/config.dart'; -import './successScreen.dart'; +import 'package:kkiapay_flutter_sdk/kkiapay_flutter_sdk.dart'; +import 'success_screen.dart'; -void main() => runApp(App()); +void main() => runApp(const App()); void successCallback(response, context) { + switch (response['status']) { + case PAYMENT_CANCELLED: + debugPrint(PAYMENT_CANCELLED); + Navigator.pop(context); + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text(PAYMENT_CANCELLED), + )); + break; + case PENDING_PAYMENT: + debugPrint(PENDING_PAYMENT); + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text(PENDING_PAYMENT), + )); + break; - switch ( response['status'] ) { - - case PAYMENT_CANCELLED: print(PAYMENT_CANCELLED); - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PAYMENT_CANCELLED),)); - break; - - case PENDING_PAYMENT : print(PENDING_PAYMENT); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PENDING_PAYMENT),)); - break; - - case PAYMENT_INIT : print(PAYMENT_INIT); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PAYMENT_INIT),)); - break; + case PAYMENT_INIT: + debugPrint(PAYMENT_INIT); + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text(PAYMENT_INIT), + )); + break; case PAYMENT_SUCCESS: Navigator.pop(context); @@ -34,11 +39,14 @@ void successCallback(response, context) { ), ), ); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PAYMENT_SUCCESS),)); + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text(PAYMENT_SUCCESS), + )); break; - case PAYMENT_FAILED: print(PAYMENT_FAILED); - break; + case PAYMENT_FAILED: + debugPrint(PAYMENT_FAILED); + break; default: break; @@ -58,10 +66,11 @@ const kkiapay = KKiaPay( callback: successCallback, theme: defaultTheme, partnerId: 'AxXxXXxId', - paymentMethods: ["momo","card"] -); + paymentMethods: ["momo", "card"]); class App extends StatelessWidget { + const App({super.key}); + @override Widget build(BuildContext context) { return MaterialApp( @@ -87,31 +96,31 @@ class KkiapaySample extends StatelessWidget { Widget build(BuildContext context) { return Center( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ButtonTheme( - minWidth: 500.0, - height: 100.0, - child: TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Color(0xff222F5A)), - foregroundColor: MaterialStateProperty.all(Colors.white), - ), - child: const Text( - 'Pay Now', - style: TextStyle(color: Colors.white), - ), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => kkiapay), - ); - }, - ), - ) - ], + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ButtonTheme( + minWidth: 500.0, + height: 100.0, + child: TextButton( + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(const Color(0xff222F5A)), + foregroundColor: MaterialStateProperty.all(Colors.white), + ), + child: const Text( + 'Pay Now', + style: TextStyle(color: Colors.white), + ), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => kkiapay), + ); + }, + ), ) - ); + ], + )); } } diff --git a/example/lib/successScreen.dart b/example/lib/success_screen.dart similarity index 76% rename from example/lib/successScreen.dart rename to example/lib/success_screen.dart index aa6a44e..1a5d9e5 100644 --- a/example/lib/successScreen.dart +++ b/example/lib/success_screen.dart @@ -2,15 +2,15 @@ import 'package:flutter/material.dart'; class SuccessScreen extends StatelessWidget { final int? amount; - final transactionId; + final String? transactionId; - const SuccessScreen({this.amount, this.transactionId}); + const SuccessScreen({super.key, this.amount, this.transactionId}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( - title: Text('PAYMENT SUCCESSFUL'), + title: const Text('PAYMENT SUCCESSFUL'), ), body: Center( child: Text( diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index fadbf36..71293b2 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -10,12 +10,12 @@ import 'package:flutter_test/flutter_test.dart'; //import 'package:example/main.dart'; -import '../lib/main.dart'; +import 'package:example/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(App()); + await tester.pumpWidget(const App()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); diff --git a/lib/kkiapay_flutter_sdk.dart b/lib/kkiapay_flutter_sdk.dart new file mode 100644 index 0000000..2c79140 --- /dev/null +++ b/lib/kkiapay_flutter_sdk.dart @@ -0,0 +1,5 @@ +library kkiapay; + +export 'src/widget_builder_view.dart'; +export 'utils/utils.dart'; +export 'utils/config.dart'; diff --git a/lib/src/widget_builder_view_model.dart b/lib/src/widget_builder_view_model.dart index 8aa07e9..e74d830 100644 --- a/lib/src/widget_builder_view_model.dart +++ b/lib/src/widget_builder_view_model.dart @@ -1,16 +1,10 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.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'; -import 'package:webview_flutter_android/webview_flutter_android.dart'; -import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart'; - class WidgetBuilderViewModel extends BaseViewModel { - String _progression = "..."; String get progression => _progression; void setProgression(value) { @@ -20,11 +14,12 @@ class WidgetBuilderViewModel extends BaseViewModel { bool _onLoading = true; bool get onLoading => _onLoading; - void loadingStart () { + void loadingStart() { _onLoading = true; notifyListeners(); } - void loadingFinish () { + + void loadingFinish() { _onLoading = false; notifyListeners(); } @@ -36,25 +31,23 @@ class WidgetBuilderViewModel extends BaseViewModel { notifyListeners(); } - Map _data = {}; - Map get data => _data; - void setData (Map data) { + Map _data = {}; + Map get data => _data; + void setData(Map data) { _data = data; notifyListeners(); } - FutureOr onUrlChange (UrlChange urlChange, context) - async { - if (urlChange.url == null ) { + FutureOr onUrlChange(UrlChange urlChange, context) async { + if (urlChange.url == null) { return NavigationDecision.prevent; - }else{ - if (urlChange.url!.startsWith(WaveRedirectURI) - || urlChange.url!.startsWith(PlayStoreRedirectURI)) { + } else { + if (urlChange.url!.startsWith(WaveRedirectURI) || + urlChange.url!.startsWith(PlayStoreRedirectURI)) { Utils.launchWave(urlChange.url!); return NavigationDecision.prevent; } return NavigationDecision.navigate; } } - }