transact_pay 0.0.2 copy "transact_pay: ^0.0.2" to clipboard
transact_pay: ^0.0.2 copied to clipboard

TransactPay provide innovative and flexible European BIN sponsorship and modular payment, debit, and prepaid services.

Transact Pay #

pub package License: MIT

TransactPay provide innovative and flexible European BIN sponsorship and modular payment, debit, and prepaid services.

🌟 Getting Started #

To start using this package, add transact_pay dependency to your pubspec.yaml

You also need to have Public key and Encryption key, which can be gotten from the transactpay marchant dashboard

dependencies:
  transact_pay: "<latest_release>"

📌 Simple Example (Thanks to @ChidiebereEdeh) #

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:transact_pay/transact_pay.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Transact Pay API Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  // Example API Key and Encryption Key
  String apiKey = "PGW-PUBLICKEY-TEST-5D9411AB210740019FF1374C896D86D0";
  String encryptionKey =
      "NDA5NiE8UlDg9PC9Nb2R1bHVzPjxFeHBvbmVudD5BUUFCPC9FeHBvbmVudD48L1JTQUtleVZhbHVlPg...==";

  late TransactPay transactPay;

  @override
  void initState() {
    super.initState();
    transactPay = TransactPay(apiKey: apiKey, encryptionKey: encryptionKey);
  }

  Future<String> fetchData(Function apiCall) async {
    try {
      http.Response response = await apiCall();
      return 'Status: ${response.statusCode}\nBody: ${response.body}';
    } catch (e) {
      return 'Error: $e';
    }
  }

  Future<String> createOrder() {
    Map<String, dynamic> payload = {
      "customer": {
        "firstname": "transact",
        "lastname": "pay",
        "mobile": "+2348134543421",
        "country": "NG",
        "email": "email@transactpay.ai"
      },
      "order": {
        "amount": 100,
        "reference": "12121212112",
        "description": "Pay",
        "currency": "NGN"
      },
      "payment": {"RedirectUrl": "https://www.hi.com"}
    };
    return fetchData(() => transactPay.createOrder(payload));
  }

  Future<String> payWithCard() {
    Map<String, dynamic> payload = {
      "reference": "1234asd",
      "paymentoption": "C",
      "country": "NG",
      "card": {
        "cardnumber": "5123450000784608",
        "expirymonth": "01",
        "expiryyear": "39",
        "cvv": "193"
      }
    };
    return fetchData(() => transactPay.payWithCard(payload));
  }

  // Add more methods for other endpoints following the same pattern...

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Transact Pay API Demo'),
      ),
      body: ListView(
        children: [
          buildApiResultTile('Create Order', createOrder),
          buildApiResultTile('Pay with Card', payWithCard),
          // Add more API result tiles for other endpoints...
        ],
      ),
    );
  }

  Widget buildApiResultTile(String title, Future<String> Function() apiCall) {
    return FutureBuilder<String>(
      future: apiCall(),
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return ListTile(
            title: Text(title),
            subtitle: Text('Loading...'),
            leading: CircularProgressIndicator(),
          );
        } else if (snapshot.hasError) {
          return ListTile(
            title: Text(title),
            subtitle: Text('Error: ${snapshot.error}'),
            leading: Icon(Icons.error, color: Colors.red),
          );
        } else {
          return ListTile(
            title: Text(title),
            subtitle: Text(snapshot.data ?? 'No data'),
            leading: Icon(Icons.check_circle, color: Colors.green),
          );
        }
      },
    );
  }
}

📝 Documentation #

📝 TransactPay Instantiation and encryption #

 // Example API Key and Encryption Key
String apiKey = "PGW-PUBLICKEY-TEST-5D9411AB210740019FF1374C896D86D0";
String encryptionKey =
    "NDA5NiE8UlNBS2V5VmFsdWU+PE1vZHVsdXM+cW5rdlhOWHT0xTNFBqYzZKcmN1eDg4bmJsd2Fyd0h4dnlrUy9STk92eFltU2ZPTlEzbW9vM1hhaWpXd2IwbnVVOTJ4anBmSzByb0FYaFo0emdHVUdlS081emY4enlncExTYzFqS05MMFNXZHZWYndMeTN3WHJiRTBrSjZJRWVvSThLRSs0anRndzY1R084Z3hJeGpibjhNemI5YVNreFdaSnVMRFRLNzJHcGcxYkwrNDBLYnVNc2tVWlJVTGxhNC84Y1dYSlpId2JINjRWNkNHQlVMMGVQUmQ4dnB3aEhySzhZSlZaRGxuYTdNbmxQVjdoeGg1Q0dabkVsNy91WEJjaGYvTExLOFNyckdnRWN1anFKWEZxMm9nUlEwNzBxN2RmOXBNZ0Q5YXpTK3dya2dBck9wNnVFcXBFQ1NnbXlvb1VMZFV2MTBhQk4xRUN5YTY2UnhuV3dEck5QZktSWjU4ZmFlNnJkelpMaExlajNId2VJRjZYcHpwL280VTlmVDVwOFNWTStHK1FZalFFV0RieldhYzMyMUIxRVhWc2xkMXFFTDJzZEk0UEFWNy9DWUcwS2hvR256NVdyZnNBQ1lRRUFkQm16MXM1NktYZnczV3dYVDJoUE1xWWtTZ2c4ejFiR1AxWTZJeDU3RHViUjdVcDlwc2taV0ptUzdNdkM1NnRHN1F6OUdiNzBjVTRiNXYvYkdBZnNMNUlRanBrc2QyRENsU2U0Vm5oNEcyWE0xeTEzS0gyZWVvNnViMUczdVBUMGtzZ2RxSXRtdjFKcmN3SThWaXJOWG9oeW1xL2xpbWg1VUhDTWhzMUhlUTQwMXIvNWt0S200bDJISFMvdXhNcmZlUmVEVTRWMXVBZTNQRU1jUDg9PC9Nb2R1bHVzPjxFeHBvbmVudD5BUUFCPC9FeHBvbmVudD48L1JTQUtleVZhbHVlPg==";

// Create an instance of TransactPay
TransactPay transactPay = TransactPay(
  apiKey: apiKey,
  encryptionKey: encryptionKey,
);

📝 Create Order #

 // Create an order example
//----------------------------------------------------------------------------

// Create an order payload
Map<String, dynamic> createOrderPayload = {
  "customer": {
    "firstname": "transact",
    "lastname": "pay",
    "mobile": "+2348134543421",
    "country": "NG",
    "email": "email@transactpay.ai"
  },
  "order": {
    "amount": 100,
    "reference": "12121212112",
    "description": "Pay",
    "currency": "NGN"
  },
  "payment": {"RedirectUrl": "https://www.hi.com"}
};

// Call the create order method
try {
http.Response createOrderResponse =
await transactPay.createOrder(createOrderPayload);
print('Create Order Response: ${createOrderResponse.statusCode}');
print('Response Body: ${createOrderResponse.body}');
} catch (e) {
print('Error creating order: $e');
}

📝 Pay Order #

 // Pay with Card example
//----------------------------------------------------------------------------

// Pay with card payload
Map<String, dynamic> payWithCardPayload = {
  "reference": "1234asd",
  "paymentoption": "C",
  "country": "NG",
  "card": {
    "cardnumber": "5123450000784608",
    "expirymonth": "01",
    "expiryyear": "39",
    "cvv": "193"
  }
};

// Call the paywithcard method
try {
http.Response payWithCardResponse =
await transactPay.payWithCard(payWithCardPayload);
print('Order Status Response: ${payWithCardResponse.statusCode}');
print('Response Body: ${payWithCardResponse.body}');
} catch (e) {
print('Error paying with card: $e');
}

📝 Order Status #

 // Order status example
//----------------------------------------------------------------------------

// Order status payload
Map<String, dynamic> orderStatusPayload = {"reference": "1234asd"};
// Call the order status method
try {
http.Response statusResponse =
await transactPay.orderStatus(orderStatusPayload);
print('Order Status Response: ${statusResponse.statusCode}');
print('Response Body: ${statusResponse.body}');
} catch (e) {
print('Error fetching order status: $e');
}

Other example can be found in the example tab #

Screens #

Example app Image

Example app Demo

Issues #

Please file any issues, bugs or feature request as an issue on our GitHub page.

Want to contribute #

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Credits #

Credits goes to ChidiebereEdeh as most of this package comes from his implementation.

transact_pay #

1
likes
0
points
43
downloads

Publisher

unverified uploader

Weekly Downloads

TransactPay provide innovative and flexible European BIN sponsorship and modular payment, debit, and prepaid services.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http, pointycastle

More

Packages that depend on transact_pay