khipu_pay_plugin 1.1.0 copy "khipu_pay_plugin: ^1.1.0" to clipboard
khipu_pay_plugin: ^1.1.0 copied to clipboard

Plugin to create payment identifiers, process payments and verify the status of a payment through the Khipu Platform.

example/lib/main.dart

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

import 'package:khipu_pay_plugin/khipu_pay.dart';
import 'package:khipu_pay_plugin/khipu_payment_status.dart';
import 'package:khipu_pay_plugin/khipu_payment.dart';

void main() {
  runApp(MyApp());
  KhipuPay.initialize(hexaColor: "#7F7094");
}

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

class _MyAppState extends State<MyApp> {
  String paymentId = "";
  String paymentStatus = "-";

  String id = "";
  String secret = "";

  @override
  void initState() {
    super.initState();

    if (kReleaseMode) {
      // Production Credentials
      id = "";
      secret = "";
    } else {
      // Development Credentials
      id = "";
      secret = "";
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text('KhipuPay Plugin'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              MaterialButton(
                color: Colors.blueAccent,
                child: Text(
                  'Get payment ID',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () async {
                  String idPayment = await KhipuPayment().getPaymentId(
                    id: id, //Information delivered by khipu
                    secret: secret, //Information delivered by khipu
                    subject: "Subject of payment",
                    amount: "1000",
                    currency: "CLP",
                  );

                  print('The payment ID is: $idPayment');

                  setState(() {
                    paymentId = idPayment;
                  });
                },
              ),
              MaterialButton(
                color: Colors.blueAccent,
                child: Text(
                  'Make payment for ID: $paymentId',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () async {
                  String statusProcess =
                      await KhipuPay.paymentProcess(paymentId: paymentId);

                  print("Payment status is $statusProcess");
                },
              ),
              MaterialButton(
                color: Colors.green,
                child: Text(
                  'See Payment Status: $paymentId',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () async {
                  paymentStatus = await KhipuPaymentStatus().status(
                    transactionCode: paymentId,
                    id: id, //Information delivered by khipu
                    secret: secret, //Information delivered by khipu
                  );

                  setState(() {});

                  print('Payment status is: $paymentStatus');
                },
              ),
              SizedBox(height: 30.0),
              Text("Payment status is: $paymentStatus"),
            ],
          ),
        ),
      ),
    );
  }
}
7
likes
100
pub points
0%
popularity

Publisher

unverified uploader

Plugin to create payment identifiers, process payments and verify the status of a payment through the Khipu Platform.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

crypto, cryptoutils, diacritic, flutter, http

More

Packages that depend on khipu_pay_plugin