Skip to content

Commit

Permalink
Merge pull request #33 from MohamedF2001/master
Browse files Browse the repository at this point in the history
Add callback for widget PAYMENT_INIT event
  • Loading branch information
Shek863 committed Nov 12, 2023
2 parents 3dec731 + ad36891 commit c751e36
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 19 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ in your application or website.
Before using this SDK, make sure you have a right Merchant Account on [Kkiapay](https://kkiapay.me), otherwise [go](https://kkiapay.me)
and create your account is free and without pain :sunglasses:.

<p align="center">
<a href="https://pub.dev/packages/kkiapay_flutter_sdk"><img src="https://img.shields.io/pub/v/kkiapay_flutter_sdk.svg" alt="version"></a>
<a href="https://pub.dev/packages/kkiapay_flutter_sdk/score"><img src="https://img.shields.io/pub/popularity/kkiapay_flutter_sdk?logo=dart" alt="likes"></a>
<a href="https://pub.dev/packages/kkiapay_flutter_sdk/score"><img src="https://img.shields.io/pub/likes/kkiapay_flutter_sdk?logo=dart" alt="popularity"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg" alt="License: MIT"></a>
<a><img src="https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square" alt="all contributors"></a>
</p>

## Installation

To use this package :
Expand Down
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":"/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"}
{"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"}
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=/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"
Expand Down
14 changes: 13 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -23,6 +34,7 @@ void successCallback(response, context) {
),
),
);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(PAYMENT_SUCCESS),));
break;

case PAYMENT_FAILED: print(PAYMENT_FAILED);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions lib/src/widget_builder_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ class _KKiaPayState extends State<KKiaPay> {
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( {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum CallbackStatus {
PAYMENT_CANCELLED,
PAYMENT_FAILED,
PAYMENT_SUCCESS,
PAYMENT_INIT,
}

/// widget javascript events
Expand Down
24 changes: 12 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit c751e36

Please sign in to comment.