From ad368913c2643b8fe455af758583c3369b66e751 Mon Sep 17 00:00:00 2001 From: MohamedFarid Date: Fri, 10 Nov 2023 16:39:40 +0100 Subject: [PATCH] callback for PAYMENT_INIT --- example/.flutter-plugins-dependencies | 2 +- .../ios/Flutter/flutter_export_environment.sh | 4 ++-- example/lib/main.dart | 14 ++++++++++- example/pubspec.lock | 2 +- example/pubspec.yaml | 2 +- example/test/widget_test.dart | 4 +++- lib/src/widget_builder_view.dart | 13 ++++++++++ lib/utils/config.dart | 1 + pubspec.lock | 24 +++++++++---------- 9 files changed, 47 insertions(+), 19 deletions(-) diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index ebe8876..59ae4a1 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.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.792491","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":"/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 diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index da5062a..d4fd85e 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=/opt/homebrew/Caskroom/flutter/3.10.2/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/shegunmontcho/StudioProjects/opensi/kkiapay-flutter-sdk/example" +export "FLUTTER_ROOT=/home/farid/snap/flutter/common/flutter" +export "FLUTTER_APPLICATION_PATH=/home/farid/opensi_project/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 7d8ed2d..f7d74a7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,14 +6,25 @@ import './successScreen.dart'; void main() => runApp(App()); void successCallback(response, context) { - Navigator.pop(context); + 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_SUCCESS: + Navigator.pop(context); Navigator.push( context, MaterialPageRoute( @@ -23,6 +34,7 @@ void successCallback(response, context) { ), ), ); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PAYMENT_SUCCESS),)); break; case PAYMENT_FAILED: print(PAYMENT_FAILED); diff --git a/example/pubspec.lock b/example/pubspec.lock index 8a9f29a..738a723 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -397,5 +397,5 @@ packages: source: hosted version: "3.9.2" sdks: - dart: ">=3.1.3 <4.0.0" + dart: ">=3.1.0 <4.0.0" flutter: ">=3.13.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 67b9af8..34859f9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.1.3 <4.0.0' + sdk: '>=3.1.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index e9c786f..fadbf36 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:example/main.dart'; +//import 'package:example/main.dart'; + +import '../lib/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { diff --git a/lib/src/widget_builder_view.dart b/lib/src/widget_builder_view.dart index e7b4d51..fb558dc 100644 --- a/lib/src/widget_builder_view.dart +++ b/lib/src/widget_builder_view.dart @@ -194,6 +194,19 @@ class _KKiaPayState extends State { viewModel.loadingFinish(); break; + case PAYMENT_INIT: + if (viewModel.lastEvent != PAYMENT_SUCCESS) + widget.callback({ + 'requestData': viewModel.data, + 'transactionId': null, + 'status': CallbackStatus.PAYMENT_INIT.name + },context); + break; + + case PENDING_PAYMENT: + viewModel.isBusy; + break; + case PAYMENT_SUCCESS: viewModel.setLastEvent(PAYMENT_SUCCESS); widget.callback( { diff --git a/lib/utils/config.dart b/lib/utils/config.dart index 6b4176a..308be2d 100644 --- a/lib/utils/config.dart +++ b/lib/utils/config.dart @@ -33,6 +33,7 @@ enum CallbackStatus { PAYMENT_CANCELLED, PAYMENT_FAILED, PAYMENT_SUCCESS, + PAYMENT_INIT, } /// widget javascript events diff --git a/pubspec.lock b/pubspec.lock index 92e0acd..5e8d834 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: build_daemon - sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.1" build_resolvers: dependency: transitive description: @@ -210,10 +210,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: ad76540d21c066228ee3f9d1dad64a9f7e46530e8bb7c85011a88bc1fd874bc5 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -420,10 +420,10 @@ packages: dependency: transitive description: name: provider - sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + sha256: "659adaefa8196fa2799d7ac3dca3c2e831e549dc40b082d07a599fe9150d75fc" url: "https://pub.dev" source: hosted - version: "6.0.5" + version: "6.1.0" pub_semver: dependency: transitive description: @@ -689,18 +689,18 @@ packages: dependency: "direct main" description: name: webview_flutter - sha256: c1ab9b81090705c6069197d9fdc1625e587b52b8d70cdde2339d177ad0dbb98e + sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" url: "https://pub.dev" source: hosted - version: "4.4.1" + version: "4.4.2" webview_flutter_android: dependency: "direct main" description: name: webview_flutter_android - sha256: b0cd33dd7d3dd8e5f664e11a19e17ba12c352647269921a3b568406b001f1dff + sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf" url: "https://pub.dev" source: hosted - version: "3.12.0" + version: "3.12.1" webview_flutter_platform_interface: dependency: transitive description: @@ -713,10 +713,10 @@ packages: dependency: "direct main" description: name: webview_flutter_wkwebview - sha256: b4b42295b3aa91ed22ba6d3dd7de56efbb8f3ab3d6e41d8b1615d13537c7801d + sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76 url: "https://pub.dev" source: hosted - version: "3.9.2" + version: "3.9.4" yaml: dependency: transitive description: