xpresspayments_gateway 0.0.9 copy "xpresspayments_gateway: ^0.0.9" to clipboard
xpresspayments_gateway: ^0.0.9 copied to clipboard

This is a plugin for easy integration of Xpresspayments payment gateway with your flutter application.

example/lib/main.dart

import 'dart:math';

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

void main() {
  runApp(const PaymentGateWayApp());
}

class PaymentGateWayApp extends StatelessWidget {
  const PaymentGateWayApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Xpay',
      theme: ThemeData(
       // primarySwatch: Colors.blue,
        primaryColor: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  int get date => DateTime.now().microsecondsSinceEpoch;

  int get transactionId => Random().nextInt(1000000).floor().toInt();

 String get publicKey => "XPPUBK-e634d14d9ded04eaf05d5b63a0a06d2f-X";
  //String get publicKey => "Bearer XPPUBK-e634d14d9ded04eaf05d5b63a0a06d2f-X";

  InitialisePayment get initialisePayment => InitialisePayment(
      transactionId: (date + transactionId).toString(),
      amount: 100.0,
      email: "adegbitefemisamson@gmail.com",
      productId: "12",
      productDescription: "some description");

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Colors.white,
        child: Center(
          child: TextButton(
            style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all<Color>(Colors.green),
            ),
            onPressed: () {
              pay(context);
            },
            child: const Text(
              "Pay",
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),
      ),
    );
  }

  void pay(BuildContext context) {


    Xpay xpay = Xpay(context, publicKey, isLive: false);

    xpay.transact(initialisePayment, (transaction) {
      debugPrint("result: ${transaction.toString()}");
    }, (exception, transaction) {
      debugPrint("error: " + exception.message);
    });
  }
}

//https://docs.flutter.dev/cookbook/navigation/navigate-with-arguments
//https://docs.flutter.dev/cookbook/navigation/passing-data
//Create dialog
0
likes
120
points
187
downloads

Publisher

verified publisherxpresspayments.com

Weekly Downloads

This is a plugin for easy integration of Xpresspayments payment gateway with your flutter application.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

dartz, device_info_plus, dio, flutter, flutter_svg, get, intl, pinput, pretty_dio_logger, signalr_netcore, webview_flutter, win32

More

Packages that depend on xpresspayments_gateway