nexi_payment 0.0.1-dev.2 copy "nexi_payment: ^0.0.1-dev.2" to clipboard
nexi_payment: ^0.0.1-dev.2 copied to clipboard

outdated

Flutter plugin for Nexi Payment integration (XPay). Supports Web View payment

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:nexi_payment/nexi_payment.dart';
import 'package:nexi_payment/models/currency_utils_qp.dart';
import 'package:nexi_payment/models/environment_utils.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: TestPage(),
    );
  }
}

class TestPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => TestPageState();
}

class TestPageState extends State<TestPage> {
  NexiPayment _nexiPayment;

  @override
  void initState() {
    super.initState();
    _nexiPayment = new NexiPayment(secretKey:"8A6PBH0TO7F0B9ON2QQH7808VE3QZZLK", environment: EnvironmentUtils.TEST);
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body:Center(
          child: Column(
              mainAxisAlignment:  MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                RaisedButton(child: Text("PAY"), onPressed:  () => _paga("insert_cod_trans") ),
              ]
          )
      ) ,
    );
  }

  void _paga(String codTrans) async {
    var res = await _nexiPayment.xPayFrontOfficePaga("ALIAS_WEB_00026202", codTrans, CurrencyUtilsQP.EUR, 2500);
    openEndPaymentDialog(res);
  }


  openEndPaymentDialog(String response) async {

    await showDialog(
      barrierDismissible: false,
      context: context,
      builder: (BuildContext c2) {
        return AlertDialog(
          title:
          Container(
              margin: EdgeInsets.only(bottom: 10),
              child: Stack(children: <Widget>[

                Positioned(
                  bottom: -12,
                  left: -15,
                  child: IconButton(
                      icon: Icon(Icons.arrow_back),
                      color: Colors.blueAccent,
                      onPressed: () => Navigator.of(context).pop()),
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(right: 5),
                      child: Icon(Icons.euro_symbol, color: Colors.black38, size: 25,),
                    ) ,
                    Text("Response", style: TextStyle(fontSize: 22, color: Colors.black38, fontWeight: FontWeight.bold),),
                  ],
                )

              ],)),
          content:
          Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Text(response, style: TextStyle(color: response == "OK" ? Colors.green : Colors.red))
            ],
          )
          ,
        );

      },
    );

  }

}
2
likes
0
pub points
42%
popularity

Publisher

unverified uploader

Flutter plugin for Nexi Payment integration (XPay). Supports Web View payment

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on nexi_payment