Skip to content

Commit

Permalink
Merge pull request #34 from FulbertoDev/master
Browse files Browse the repository at this point in the history
Imports issues solved
  • Loading branch information
Shek863 authored Nov 17, 2023
2 parents f407129 + f84c389 commit dce4d4b
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
4 changes: 2 additions & 2 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
105 changes: 57 additions & 48 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
Expand All @@ -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(
Expand All @@ -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),
);
},
),
)
);
],
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions lib/kkiapay_flutter_sdk.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library kkiapay;

export 'src/widget_builder_view.dart';
export 'utils/utils.dart';
export 'utils/config.dart';
29 changes: 11 additions & 18 deletions lib/src/widget_builder_view_model.dart
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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();
}
Expand All @@ -36,25 +31,23 @@ class WidgetBuilderViewModel extends BaseViewModel {
notifyListeners();
}

Map<String,dynamic> _data = {};
Map<String,dynamic> get data => _data;
void setData (Map<String,dynamic> data) {
Map<String, dynamic> _data = {};
Map<String, dynamic> get data => _data;
void setData(Map<String, dynamic> data) {
_data = data;
notifyListeners();
}

FutureOr<NavigationDecision> onUrlChange (UrlChange urlChange, context)
async {
if (urlChange.url == null ) {
FutureOr<NavigationDecision> 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;
}
}

}

0 comments on commit dce4d4b

Please sign in to comment.