Code Monkey home page Code Monkey logo

flutter_khalti's Introduction

flutter_khalti

Khalti SDK for flutter apps. Khalti Merchant can use this library to integrate the payment system in their system.

Setup

Android

No change is required, works out of the box.

IOS

You have to add URL scheme to the project and send it as a parameter to the FlutterKhalti class as shown in the example code below.

Khalti scheme setup overview

How to use

FlutterKhalti _flutterKhalti = FlutterKhalti.configure(
  publicKey: "test_public_key_eacadfb91994475d8bebfa577b0bca68",
  urlSchemeIOS: "KhaltiPayFlutterExampleScheme",
);

KhaltiProduct product = KhaltiProduct(
  id: "test",
  amount: 1000,
  name: "Hello Product",
);

_flutterKhalti.startPayment(
  product: product,
  onSuccess: (data) {
    print("Success message here");
  },
  onFaliure: (error) {
    print("Error message here");
  },
);

flutter_khalti's People

Contributors

awazgyawali avatar pc-brainants avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_khalti's Issues

Execution failed for task ':app:compileDebugJavaWithJavac'.

Launching lib/main.dart on some_emulator in debug mode...
Running Gradle task 'assembleDebug'...
/home/something/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:18: error: package com.example.flutterkhalti does not exist
com.example.flutterkhalti.FlutterKhaltiPlugin.registerWith(shimPluginRegistry.registrarFor("com.example.flutterkhalti.FlutterKhaltiPlugin"));
^
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 27s
Exception: Gradle task assembleDebug failed with exit code 1

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 2.2.0-10.3.pre, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] VS Code (version 1.56.2)
[✓] Connected device (2 available)

• No issues found!

Cannot detect back press

After the UI has been presented to the user, if user decides to go back either by clicking back button on Android or by pressing close on IOS, we currently can't detect that action.

it would be great if we got a string like - "Canceled by user" on the onFailure callback for this senario.

Getting a unexpected error!

Hey mate,
its me again...
can you please say me that why am i getting this error;

D:\pro\foodgrap\android\app\src\debug\AndroidManifest.xml:11:9-30 Error:
	Attribute application@label value=(app_name) from AndroidManifest.xml:11:9-30
	is also present at [com.khalti:khalti-android:2.00.01] AndroidManifest.xml:17:9-41 value=(@string/app_name).
	Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:8:5-51:19 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@label value=(app_name) from AndroidManifest.xml:11:9-30
  	is also present at [com.khalti:khalti-android:2.00.01] AndroidManifest.xml:17:9-41 value=(@string/app_name).
  	Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:8:5-51:19 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 41s
Picked up _JAVA_OPTIONS: -Xms256m -Xmx2048m
Exception: Gradle task assembleDebug failed with exit code 1

Note: i didn't do anything you said to do for ios cause i don't have a mac now.

thanks.

Unhandled Exception when function called.

This error occurs whenever the "paywithkhalti" button is clicked. I cloned the example repo but the issue persists. Please help fix it.

E/MethodChannel#flutter_khalti(20261): Failed to handle method call E/MethodChannel#flutter_khalti(20261): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? E/MethodChannel#flutter_khalti(20261): at android.app.ContextImpl.startActivity(ContextImpl.java:794) E/MethodChannel#flutter_khalti(20261): at android.app.ContextImpl.startActivity(ContextImpl.java:768) E/MethodChannel#flutter_khalti(20261): at android.content.ContextWrapper.startActivity(ContextWrapper.java:356) E/MethodChannel#flutter_khalti(20261): at khalti.utils.ActivityUtil.openActivity(Unknown Source) E/MethodChannel#flutter_khalti(20261): at khalti.checkOut.helper.KhaltiCheckOut.show(Unknown Source) E/MethodChannel#flutter_khalti(20261): at com.example.flutterkhalti.FlutterKhaltiPlugin.initKhaltiPayment(FlutterKhaltiPlugin.kt:52) E/MethodChannel#flutter_khalti(20261): at com.example.flutterkhalti.FlutterKhaltiPlugin.onMethodCall(FlutterKhaltiPlugin.kt:31) E/MethodChannel#flutter_khalti(20261): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201) E/MethodChannel#flutter_khalti(20261): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88) E/MethodChannel#flutter_khalti(20261): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:219) E/MethodChannel#flutter_khalti(20261): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter_khalti(20261): at android.os.MessageQueue.next(MessageQueue.java:324) E/MethodChannel#flutter_khalti(20261): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#flutter_khalti(20261): at android.app.ActivityThread.main(ActivityThread.java:6244) E/MethodChannel#flutter_khalti(20261): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter_khalti(20261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891) E/MethodChannel#flutter_khalti(20261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781) E/flutter (20261): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?, null) E/flutter (20261): #0 StandardMethodCodec.decodeEnvelope E/flutter (20261): #1 MethodChannel.invokeMethod E/flutter (20261): <asynchronous suspension> E/flutter (20261): #2 FlutterKhalti.initPayment E/flutter (20261): #3 _CartScreenState._payViaKhalti E/flutter (20261): #4 _CartScreenState.build.<anonymous closure> E/flutter (20261): #5 _InkResponseState._handleTap E/flutter (20261): #6 _InkResponseState.build.<anonymous closure> E/flutter (20261): #7 GestureRecognizer.invokeCallback E/flutter (20261): #8 TapGestureRecognizer._checkUp E/flutter (20261): #9 TapGestureRecognizer.handlePrimaryPointer E/flutter (20261): #10 PrimaryPointerGestureRecognizer.handleEvent E/flutter (20261): #11 PointerRouter._dispatch E/flutter (20261): #12 PointerRouter.route E/flutter (20261): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent E/flutter (20261): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent E/flutter (20261): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent E/flutter (20261): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue E/flutter (20261): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket E/flutter (20261): #18 _rootRunUnary (dart:async/zone.dart:1136:13) E/flutter (20261): #19 _CustomZone.runUnary (dart:async/zone.dart:1029:19) E/flutter (20261): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7) E/flutter (20261): #21 _invoke1 (dart:ui/hooks.dart:233:10) E/flutter (20261): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)

Unable to build app after package installation

***********During the first installation I got this error

/Volumes/Storage/Flutter/khaltitesttest/android/app/src/debug/AndroidManifest.xml:5:9-39 Error:
Attribute application@label value=(khaltitesttest) from AndroidManifest.xml:5:9-39
is also present at [com.khalti:khalti-android:2.00.01] AndroidManifest.xml:17:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:4:4-42:19 to override.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugMainManifest'.

Manifest merger failed : Attribute application@label value=(khaltitesttest) from AndroidManifest.xml:5:9-39
is also present at [com.khalti:khalti-android:2.00.01] AndroidManifest.xml:17:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:4:4-42:19 to override.

********** So I added this line in manifest file tools:replace="label"
********* after that I am getting following error which I am unable to solve

/Volumes/Storage/Flutter/khaltitesttest/android/app/src/main/AndroidManifest.xml:7:9-36:20 Error:
tools:replace specified at line:7 for attribute tools:label, but no new value specified
/Volumes/Storage/Flutter/khaltitesttest/android/app/src/main/AndroidManifest.xml Error:
Validation failed, exiting

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugMainManifest'.

Manifest merger failed with multiple errors, see logs

Android Configuration

Do we need to any configuration for Android? I have to add this code to run the app successfully.

In AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.exampleapp" 
    xmlns:tools="http://schemas.android.com/tools"> <!-- this line -->
<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="exampleapp"
        tools:replace="android:label" <!--this line -->
        android:icon="@mipmap/ic_launcher">

Can you check?

Run time error on Android

Error Log: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, Unable to find explicit activity class {com.package/com.khalti.checkout.CheckOutActivity}; have you declared this activity in your AndroidManifest.xml?, null, android.content.ActivityNotFoundException: Unable to find explicit activity class {com.package/com.khalti.checkout.CheckOutActivity}; have you declared this activity in your AndroidManifest.xml?

Description:
App build smoothly in android but when calling Package api it crashed with above log

Android Version: 10
plugin ver: ^1.1.0+1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.