GithubHelp home page GithubHelp logo

ayyshim / esewa_pnp Goto Github PK

View Code? Open in Web Editor NEW
41.0 1.0 23.0 11.61 MB

Unofficial esewa plugin for flutter application.

License: MIT License

Java 14.66% Swift 5.26% Objective-C 52.85% Dart 22.55% Ruby 4.68%
esewa payment-process esewa-pnp transaction nepal dart plugin flutter

esewa_pnp's Introduction

esewa_pnp

All Contributors

I regret to inform you that I have made the difficult decision to discontinue support for the eSewa_PnP plugin. As an individual developer, I am facing time constraints that prevent me from dedicating the necessary attention and maintenance that the plugin deserves. I understand the importance of providing reliable support, and I have found it increasingly challenging to balance my commitments.

I apologize for any inconvenience this may cause to your workflow. It is important to me that you have an alternative solution, which is why I want to recommend the Flutter plugin provided by eSewa. You can find more information about it at the following link: eSewa Flutter Plugin.

The eSewa Flutter plugin offers similar functionality to the eSewa_PnP plugin and is actively maintained by a dedicated team at eSewa. It has received positive feedback from the community and is well-suited to address your needs effectively. I encourage you to explore this alternative and evaluate its compatibility with your projects.

I would like to express my heartfelt gratitude to all of our contributors who have selflessly dedicated their valuable time and effort to maintain and support this plugin. Your contributions have been truly invaluable, and I am immensely grateful for your commitment and hard work. Your expertise and dedication have played a pivotal role in making this plugin a valuable resource for our community. I want to personally thank each and every one of you for your outstanding contributions and for being an integral part of this incredible journey. Your efforts have made a significant impact, and I am deeply appreciative of your support.

Status

esewa_pnp is flutter plugin that let's developer to integrate native eSewa payment method into their flutter application with just few lines of code.

How to install

  • Depend on it

    dependencies:
    	esewa_pnp: ^2.0.1
  • [Android] Add following attribute inside your AndroidMainfest.xml

     <application
        ...
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        ...>
    ...
    </application>
    
  • [iOS] esewa_pnp (version ^1.0.0) iOS can not be tested on simulator. For that you will need to depend on plugin from plugin's GitHub repository "dev" branch.

    dependencies:
    	# esewa_pnp: ^2.0.1 # Use it on production app or while testing esewa_pnp on real physical iOS device.
    	esewa_pnp:
    		git:
    			url: git://github.com/ayyshim/esewa_pnp.git
    			ref: dev

Usage

  1. Create a ESewaConfiguration object. Start with test environment. When application is ready, you can switch it to live (ENVIRONMENT_LIVE)
...

ESewaConfiguration _configuration = ESewaConfiguration(
    clientID: "<Client-ID>",
    secretKey: "<Secret-Key>",
    environment: ESewaConfiguration.ENVIRONMENT_TEST //ENVIRONMENT_LIVE
);
...

clientID and secretKey values are provided by eSewa to its merchant/client and is unique for each. For development phase, you can use the following credentials:

clientID: "JB0BBQ4aD0UqIThFJwAKBgAXEUkEGQUBBAwdOgABHD4DChwUAB0R"

secretKey: "BhwIWQQADhIYSxILExMcAgFXFhcOBwAKBgAXEQ=="

  1. Create ESewaPnp object and pass configuration.
...
ESewaPnp _eSewaPnp = ESewaPnp(configuration: _configuration);
  1. Finally create the payment object
...
ESewaPayment _payment = ESewaPayment(
    amount: <ANY_DOUBLE_VALUE>,
    productName: "<Product-Name>",
    productID: "<Unique-Product-ID>",
    callBackURL: "<Call-Back-URL>"
);
...
  1. Now call initPayment method.
...
final _res = await _eSewaPnp.initPayment(payment: _payment);
...
  1. Determine application behavior according to the response. Wrap the .initPayment method inside try-catch block.
...
try {
	final _res = await _eSewaPnp.initPayment(payment: _payment);
	// Handle success
} on ESewaPaymentException catch(e) {
	// Handle error
}
...

ESewaPaymentException

ESewaPaymentException class is thrown when payment process fails.

  • .message [String] : returns the error message

ESewaResult

ESewaResult is returned when payment process successful.

  • .message [String] : returns readable success message
  • .productId [String] : returns product id of the product customer paid for
  • .productName [String] : returns product name of the product customer paid for
  • .totalAmount [String] : returns total amount customer paid
  • .date [String] : returns the date of transaction
  • .status [String] : returns the transaction status
  • .referenceId [String] : returns the transaction reference id

ESewaPaymentButton

ESewaPaymentButton is a customizable button widget. It takes ESewaPnp, 6 required named parameters and 8 optional parameters.

To use this button you must download assets and paste it inside your assets folder of your project. Add following line inside your pubspec.yaml file too.

  ...
  flutter:
    assets:
      - assets/esewa/
  ...

Example #1 (Default):

  ...
  ESewaPaymentButton(
    _esewaPnp,
    amount: 800.0,
    callBackURL: "https://example.com",
    productId: "abc123",
    productName: "ESewa Pnp Example",
    onSuccess: (ESewaResult result) {
      // Do something with Result
    },
    onFailure: (ESewaPaymentException e) {
      // Do something with Error
    },
  ),
  ...

Example #2 (White background):

Changing button color will also result to dyanmically change in label color and esewa logo varient (dark/light).

  ...
  ESewaPaymentButton(
    _esewaPnp,
    amount: 800.0,
    callBackURL: "https://example.com",
    productId: "abc123",
    productName: "ESewa Pnp Example",
    onSuccess: (ESewaResult result) {
      // Do something with Result
    },
    onFailure: (ESewaPaymentException e) {
      // Do something with Error
    },
    color: Color(0xFFFFFFF), // White background
  ),
  ..

Example #3 (with labelBuilder):

  ...
  ESewaPaymentButton(
    _esewaPnp,
    amount: 800.0,
    callBackURL: "https://example.com",
    productId: "abc123",
    productName: "ESewa Pnp Example",
    onSuccess: (ESewaResult result) {
      // Do something with Result
    },
    onFailure: (ESewaPaymentException e) {
      // Do something with Error
    },
    color: Color(0xFF60BB47), // Green background
    labelBuilder: (int amount, Widget esewaLogo) {
      return Text("Pay Rs.$amount");
    }
  ),
  ..

Output: Screenshot

Platform Support

Platform Status
Android โœ…
iOS โœ…

๐Ÿ‘จโ€๐Ÿฆฑ Author

Ashim Upadhaya

Checkout example implementation : EsewaPnp Example

๐ŸŒŸ Starware

esewa_pnp is Starware.
This means you're free to use the project, as long as you star its GitHub repository.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Aawaz Gyawali

๐Ÿ’ป

Bibek Timsina

๐Ÿ’ป

Pratibimba Khadka

๐Ÿ’ป

Aarjan Baskota

๐Ÿ’ป

Bikram Aryal

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

esewa_pnp's People

Contributors

735l4 avatar aarjan avatar allcontributors[bot] avatar aryalg avatar ayyshim avatar bimsina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

esewa_pnp's Issues

Support for iOS

Great work, if I found the android version usefull. Ill send a PR to add iOS support soon. Kudos brother.

Success Response data don't match with response we send

After printing whole response all data is kinda like encrypted or replace. All transation is complete actual cost is deducted from your esewa account but response like encrypted data. It actually happening in live not in test need help.

Success Response::: {"productId":"DUJXRAU=","productName":"Nh4EBRVTIgsXCgUEAwgcBUUpEwdFOxUX","totalAmount":"VF1V","environment":"CRoTEg==","code":"VUM=","merchantName":"Nh4EBRVTIgsXCgUEAwgcBUUpEwdFOxUX","message":{"technicalSuccessMessage":"Your transaction has been completed.","successMessage":"Your transaction has been completed."},"transactionDetails":{"date":"NhIRVysGB0VIXVNUQFtBW19NV1MiOjVYW1BDUUZFRVFBWw==","referenceId":"VUckLioqUg==","status":"JjwoJy02PyA="}}

Build failed on android:

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Use Gradle version 4.1.3
  2. Use Flutter version 2.8
  3. Use esewa_pnp 1.1.0

Expected behavior
Build fails(both debug and release) with exception:

**Execution failed for task ':esewa_pnp:bundleReleaseAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: /Users/sagarshree/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/esewa_pnp-1.1.0/android/libs/eSewaSdk.aar**

  • esewa_pnp 1.0.1
  • Targeted OS: [e.g. iOS, Android]
  • Flutter Version 2.8
  • [only if targetd OS is iOS] Xcode Version and Swift Version

Bug: Module compile error

Describe the bug
Module compiled with Swift 5.5.1 cannot be imported by the Swift 5.5.2 compiler:

To Reproduce
Steps to reproduce the behavior:

  1. Build an app by latest Xcode & swift compiler

Screenshots
Screen Shot 2022-02-17 at 8 37 50 PM

Environment:

  • esewa_pnp 1.1.0
  • Flutter Version 2.10.1
  • Xcode 13.2.1 and Swift 5.5.2

Bug:

Describe the bug
Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: /Users/username/.pub-cache/hosted/pub.dartlang.org/esewa_pnp-1.0.4/android/libs/eSewaSdk.aar

To Reproduce
Steps to reproduce the behavior:
-Compilation of flutter debug

Expected behavior

Screenshots

Environment (please complete the following information):

  • esewa_pnp 1.0.4
  • Targeted OS: Android
  • Flutter 2.0.5

Additional context
Add any other context about the problem here.

Error while building in gradle plugin:4.1.0 and gradle version:6.5

The app is not building after upgrading Gradle.

Execution failed for task ':esewa_pnp:bundleDebugAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: ~/.pub-cache/hosted/pub.dartlang.org/esewa_pnp-1.0.0/android/libs/eSewaSdk.aar

Bug: Build Failed on Android Direct local .aar file dependencies are not supported when building an AAR.

Describe the bug
Build Failed on Android Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error).

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade Flutter Version to 2.10.0

Expected behavior
Build should succeed on android

Environment (please complete the following information):

  • esewa_pnp: 1.1.0
  • Targeted OS: ANDROID
  • Flutter Version: 2.10.0

Error: The method 'RaisedButton' isn't defined for the class 'ESewaPaymentButton'.

In Flutter 3.3.2, I am getting such error:

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/esewa_pnp-2.0.1/lib/esewa_pnp.dart:215:14: Error: The method 'RaisedButton' isn't defined for the class 'ESewaPaymentButton'.

  • 'ESewaPaymentButton' is from 'package:esewa_pnp/esewa_pnp.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/esewa_pnp-2.0.1/lib/esewa_pnp.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'RaisedButton'.
    child: RaisedButton(
    ^^^^^^^^^^^^

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

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

Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • 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.

BUILD FAILED in 3m 19s

Bug: Execution failed for task ':esewa_pnp:bundleDebugAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error:

i cannot run my app after installing esewa pnp 1.0.7

Execution failed for task ':esewa_pnp:bundleDebugAar'. > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\esewa_pnp-1.0.7\android\libs\eSewaSdk.aar

Double value not supported by amount

Double value is not supported by amount parameter and converting all payment amount to int is not really an option because it leads to inconsistent payment data.

Web support

Hey, thank you for this great package.
Any plan on adding web support for it?

Thanks ๐Ÿ™‚

Bug: module compiled with Swift 5.3.1 cannot be imported by the Swift 5.4 compiler

I had tried to test eSewa SDK in the simulator and got the error while building the project

SwiftEsewaPnpPlugin.swift:3:8: error: module compiled with Swift 5.3.1 cannot be imported by the Swift 5.4 compiler: /Volumes/Storage/Flutter/insurance_flutter_app/ios/.symlinks/plugins/esewa_pnp/ios/EsewaSDK.framework/Modules/EsewaSDK.swiftmodule/x86_64-apple-ios-simulator.swiftmodule
import EsewaSDK
^

Screen Shot 2021-06-21 at 11 29 22

xcode build fail

Xcode's output:
โ†ณ
:1:1: warning: umbrella header for module 'Flutter' does
not include header 'FlutterNavigationController.h'
#import "Headers/Flutter.h"
^
SwiftEsewaPnpPlugin.swift:3:8: error: could not find module 'EsewaSDK' for
target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios,
arm64-apple-ios, arm, armv7
import EsewaSDK
^
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone 11.

Unable to login to esewa through the app. it says "Incorrect username or password"

Hey again,
I dont know why but every time i try to log in to esewa through my app, it says "Incorrect username or password" although the credentials are correct.
i can log in directly to esewa app with those credential but not through my app.
Have you ever faced this error and what causes this.
i have implemented the plugin as directed by you in example tab and your video.
please help me

Bug: App doesnot build with error "Direct local .aar file dependencies are not supported when building an AAR."

After installing the package i get this error while trying to build the app.

Execution failed for task ':esewa_pnp:bundleDebugAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\esewa_pnp-1.0.4\android\libs\eSewaSdk.aar

Am i missing something while installing?

Bug: Execution failed for task ':esewa_pnp:bundleDebugAar'.

Describe the bug

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :esewa_pnp project caused this error: C:\flutter.pub-cache\hosted\pub.dartlang.org\esewa_pnp-1.0.4\android\libs\eSewaSdk.aar

To Reproduce
Steps to reproduce the behavior:

  1. Using distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip
    classpath 'com.android.tools.build:gradle:4.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Environment (please complete the following information):

  • esewa_pnp Version ^1.0.4
  • Targeted OS: [e.g. iOS, Android]
  • Flutter Version 1.22.6
  • [only if targetd OS is iOS] Xcode Version and Swift Version

Couldn't build project after adding eSewa Pub

Attribute application@allowBackup value=(false) from AndroidManifest.xml:
is also present at [eSewaSdk.aar] AndroidManifest.xml:14:18-44 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:26:5-115:19 to override.

Bug: Couldn't Login in Live Environment

Describe the bug
I tried logining in Live Environment using the Client Id and Secret Key provided by eSewa. But I couldnot login and prompted with the following dialog. Afterwards I received an OTP from eSewa

To Reproduce
Steps to reproduce the behavior:

  1. Go to Login
  2. Enter username and password
  3. Presented with the error in the terminal:

Success Response::: {"identifier":"SEFUQlZAXldUJiJXTgJKP1QbADUHOyAxKgQTNjwANFA4XwY6V0AHIjEqOyQ=","environment":"CRoTEg==","merchantName":"JwYPFhRTOAAOBFM1ARVdSykNAQ==","userName":"XEtRRFNGU1RKUg==","balance":"VEddQ09AXw==","productName":"JwYPFhRTOAAOBFM1ARVdSykNAQ==","totalAmount":"U0ZLRw==","message":{"technicalErrorMessage":"Service unavailable","errorMessage":"Sorry your request failed. Contact your service provider."},"charge":null,"cashBack":null,"Cookie":"JSESSIONID=25348C543CFC99282F16FFDF1D02D78B; Path=\/; HttpOnly"}

  1. I get an OTP from eSewa after the error is shown. The OTP code says use this to login in online payment.

Expected behavior
Should have login.

Screenshots

If applicable, add screenshots to help explain your problem.

  • Esewa Environment : LIVE
  • Esewa_pnp Version : 1.0.7
  • Targeted OS: Android
  • Flutter Version

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.