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.
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.
-
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
- 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
andsecretKey
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=="
- Create ESewaPnp object and pass configuration.
...
ESewaPnp _eSewaPnp = ESewaPnp(configuration: _configuration);
- Finally create the payment object
...
ESewaPayment _payment = ESewaPayment(
amount: <ANY_DOUBLE_VALUE>,
productName: "<Product-Name>",
productID: "<Unique-Product-ID>",
callBackURL: "<Call-Back-URL>"
);
...
- Now call
initPayment
method.
...
final _res = await _eSewaPnp.initPayment(payment: _payment);
...
- 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 class is thrown when payment process fails.
.message
[String] : returns the error message
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 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");
}
),
..
Platform | Status |
---|---|
Android | ✅ |
iOS | ✅ |
Checkout example implementation : EsewaPnp Example
esewa_pnp is Starware.
This means you're free to use the project, as long as you star its GitHub repository.
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!