Skip to content

Commit

Permalink
Merge remote-tracking branch 'nemesis/chores/update-score-on-pub.dev'…
Browse files Browse the repository at this point in the history
… into NemesisX1-chores/update-score-on-pub.dev

# Conflicts:
#	.flutter-plugins-dependencies
#	example/.flutter-plugins-dependencies
  • Loading branch information
Shegun Montcho committed Apr 30, 2024
2 parents 9bef7c2 + ee91064 commit 8a2807f
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 58 deletions.
21 changes: 21 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Open SI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.

export "FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.16.9/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/segun/StudioProjects/opensi/kkiapay-flutter-sdk/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
Expand Down
6 changes: 2 additions & 4 deletions lib/src/view.part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class LoadingView extends ViewModelWidget<WidgetBuilderViewModel> {
value: viewModel.progression,
backgroundColor: Colors.grey.withOpacity(0.3),
color: Colors.grey.withOpacity(0.6),
)
),

)),
Container(
height: 42,
child: Center(
Expand All @@ -39,4 +37,4 @@ class LoadingView extends ViewModelWidget<WidgetBuilderViewModel> {
)
);
}
}
}
120 changes: 66 additions & 54 deletions lib/src/widget_builder_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ class _KKiaPayState extends State<KKiaPay> {
theme: widget.theme,
callbackUrl: widget.callbackUrl,
name: widget.name,
email: widget.email ) )
));
email: widget.email))));

// #docregion platform_features
if (controller.platform is AndroidWebViewController) {
Expand All @@ -150,13 +149,12 @@ class _KKiaPayState extends State<KKiaPay> {
Widget build(BuildContext context) {
return ViewModelBuilder<WidgetBuilderViewModel>.reactive(
onViewModelReady: (viewModel) {

_controller
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
debugPrint('WebView is loading (progress : $progress%)');
viewModel.setProgression(progress/100);
viewModel.setProgression(progress / 100);
},
onPageStarted: (String url) {
debugPrint('Page started loading: $url');
Expand All @@ -176,59 +174,72 @@ class _KKiaPayState extends State<KKiaPay> {
''');
},
onUrlChange: (UrlChange change) {
viewModel.onUrlChange( change, context);
viewModel.onUrlChange(change, context);
},
),
)
..addJavaScriptChannel('SDK_CHANNEL', onMessageReceived: (message) {
print( JsonDecoder().convert(message.message));

switch (JsonDecoder().convert(message.message)["name"]) {

case CLOSE_WIDGET:
if (viewModel.lastEvent != PAYMENT_SUCCESS)
widget.callback( {
'requestData': viewModel.data,
'transactionId': null,
'status': CallbackStatus.PAYMENT_CANCELLED.name
}, context);
break;

case WIDGET_SUCCESSFULLY_INIT:
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( {
'requestData': viewModel.data,
'transactionId': JsonDecoder().convert(message.message)["data"]["transactionId"],
'status': CallbackStatus.PAYMENT_SUCCESS.name
}, context);
break;

case WAVE_LINK:
Utils.launchWave(
JsonDecoder().convert(message.message)["data"],);
break;

default:
break;
}
});

print(JsonDecoder().convert(message.message));

switch (JsonDecoder().convert(message.message)["name"]) {
case CLOSE_WIDGET:
if (viewModel.lastEvent != PAYMENT_SUCCESS) {
widget.callback({
'requestData': viewModel.data,
'transactionId': null,
'status': CallbackStatus.PAYMENT_CANCELLED.name
}, context);
}
break;

case WIDGET_SUCCESSFULLY_INIT:
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({
'requestData': viewModel.data,
'transactionId': JsonDecoder()
.convert(message.message)["data"]["transactionId"],
'status': CallbackStatus.PAYMENT_SUCCESS.name
}, context);
break;

case PAYMENT_FAILED:
widget.callback({
'requestData': null,
'transactionId': JsonDecoder()
.convert(message.message)["data"]["transactionId"],
'status': CallbackStatus.PAYMENT_FAILED.name
}, context);
break;

case WAVE_LINK:
Utils.launchWave(
JsonDecoder().convert(message.message)["data"],
);
break;

default:
break;
}
});


/// Change status bar if ios devise
if (!Platform.isIOS) {
Expand All @@ -254,7 +265,8 @@ class _KKiaPayState extends State<KKiaPay> {
});
},
builder: (context, viewModel, child) => Scaffold(
backgroundColor: Color(Utils.getColorFromHex(widget.theme ?? defaultTheme)),
backgroundColor:
Color(Utils.getColorFromHex(widget.theme ?? defaultTheme)),
body: Stack(
children: [
Container(
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: kkiapay_flutter_sdk
description: KKiaPay allows businesses to safely receive payments by mobile money, credit card and bank account.
version: 1.3.0-dev.4
homepage: "https://kkiapay.me/"
platforms:
android:
ios:

environment:
sdk: '>=3.0.3 <4.0.0'
Expand Down

0 comments on commit 8a2807f

Please sign in to comment.