esewa_client 0.1.1 copy "esewa_client: ^0.1.1" to clipboard
esewa_client: ^0.1.1 copied to clipboard

A flutter plugin to integrate ESEWA merchant services into your application.

example/lib/main.dart

import 'package:esewa_client/esewa_client.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: TextButton(
            child: Text('Pay with esewa'),
            onPressed: _payViaEsewa,
          ),
        ),
      ),
    );
  }

  _payViaEsewa() async {
    // change credentials during production
    EsewaClient _esewaClient = EsewaClient.configure(
      clientId: "JB0BBQ4aD0UqIThFJwAKBgAXEUkEGQUBBAwdOgABHD4DChwUAB0R",
      secretKey: "BhwIWQQADhIYSxILExMcAgFXFhcOBwAKBgAXEQ==",
      environment: EsewaEnvironment.TEST,
    );

    /*
    * Enter your own callback url to receive response callback from esewa to your client server
    * */
    EsewaPayment payment = EsewaPayment(
        productId: "test_id",
        amount: "10",
        name: "Test Product",
        callbackUrl:
        "http://example.com/");

    _esewaClient.startPayment(
        esewaPayment: payment,
        onSuccess: (data) {
          print("success");
        },
        onFailure: (data) {
          print("failure");
        },
        onCancelled: (data) {
          print("cancelled");
        });
  }
}
2
likes
120
pub points
51%
popularity

Publisher

verified publishersanzaaltech.com

A flutter plugin to integrate ESEWA merchant services into your application.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on esewa_client