open_payment 2.0.0 copy "open_payment: ^2.0.0" to clipboard
open_payment: ^2.0.0 copied to clipboard

Flutter plugin which lets you seamlessly integrate OPEN Payment Gateway with your Flutter app and start collecting payments from your customers.

example/lib/main.dart

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

import 'package:open_payment/open_payment.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String accessToken = "your-access-token";
  String paymentToken = "payment-token";
  PaymentEnvironment environment = PaymentEnvironment.live;
  String? result;

  Future<void> onPaymentClick() async {
    OpenPaymentPayload openPaymentPayload = OpenPaymentPayload(
        accessToken: accessToken,
        paymentToken: paymentToken,
        environment: environment,
        logoUrl: "your-logo-url",
        mainColor: "#83025c",
        errorColor: "#ff0000");

    await OpenPayment.initiatePayment(
        openPaymentPayload: openPaymentPayload,
        onTransactionComplete: (TransactionDetails transactionDetails) {
          setState(() {
            result = transactionDetails.status;
          });
        },
        onError: (String error) {
          setState(() {
            result = error;
          });
        });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Open Payment Demo'),
        ),
        body: Text(result.toString()),
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.add),
          onPressed: onPaymentClick,
        ),
      ),
    );
  }
}
7
likes
130
pub points
74%
popularity

Publisher

unverified uploader

Flutter plugin which lets you seamlessly integrate OPEN Payment Gateway with your Flutter app and start collecting payments from your customers.

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, json_annotation

More

Packages that depend on open_payment