All Projects → wilburt → flutter_paystack

wilburt / flutter_paystack

Licence: Apache-2.0 License
💳 A robust Flutter plugin for making payments via Paystack Payment Gateway. Completely supports Android and iOS

Programming Languages

dart
5743 projects
objective c
16641 projects - #2 most used programming language
kotlin
9241 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to flutter paystack

angular4-paystack
💵 An angular2+ module for paystack transactions
Stars: ✭ 51 (-65.07%)
Mutual labels:  money, payment, paystack
cashier-paystack
Cashier provides an expressive, fluent interface to Paystack's subscription billing services.
Stars: ✭ 44 (-69.86%)
Mutual labels:  payment, paystack
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-89.73%)
Mutual labels:  money, payment
awesome-payment
A curated list of payment services
Stars: ✭ 22 (-84.93%)
Mutual labels:  payment, payment-gateway
PaymentCardView
Custom Credit/Debit card view
Stars: ✭ 62 (-57.53%)
Mutual labels:  payment, payment-gateway
sep-pay
Pay.ir Payment Package for Laravel 5.3+
Stars: ✭ 17 (-88.36%)
Mutual labels:  payment, payment-gateway
paymentgateway
Dokumentace ČSOB platební brány a jejího eAPI pro platby platebními kartami, Apple Pay, mallpay a platebními tlačítky ČSOB.
Stars: ✭ 104 (-28.77%)
Mutual labels:  payment, payment-gateway
laravel-pix
Uma solucão simples para integrar sua aplicação Laravel a API PIX do Banco Central do Brasil
Stars: ✭ 73 (-50%)
Mutual labels:  payment, payment-gateway
cashier
Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP
Stars: ✭ 43 (-70.55%)
Mutual labels:  payment, payment-gateway
adyen-salesforce-commerce-cloud
Salesforce Commerce Cloud (formerly Demandware)
Stars: ✭ 63 (-56.85%)
Mutual labels:  payment, payment-gateway
youzan-pay
基于有赞云和有赞微小店实现个人收款解决方案。
Stars: ✭ 69 (-52.74%)
Mutual labels:  payment, payment-gateway
PayPalPlugin
Official integration with PayPal Commerce Platform
Stars: ✭ 21 (-85.62%)
Mutual labels:  payment, payment-gateway
python-daraja
Python Wrapper for interacting with the MPESA Daraja API. More Features to be implemented
Stars: ✭ 20 (-86.3%)
Mutual labels:  payment, payment-gateway
Paynow-NodeJS-SDK
NodeJS SDK for Zimbabwe's leading payments gateway, Paynow
Stars: ✭ 23 (-84.25%)
Mutual labels:  payment, payment-gateway
omnipay-2checkout
2Checkout driver for the Omnipay PHP payment processing library
Stars: ✭ 25 (-82.88%)
Mutual labels:  payment, payment-gateway
adyen-python-api-library
Adyen API Library for Python
Stars: ✭ 41 (-71.92%)
Mutual labels:  payment, payment-gateway
react-native-payumoney
React Native Payumoney (Android/IOS)
Stars: ✭ 18 (-87.67%)
Mutual labels:  payment, payment-gateway
cybersource-sdk-java
Java SDK for CyberSource Simple Order API
Stars: ✭ 44 (-69.86%)
Mutual labels:  payment, payment-gateway
nagadApi
This is Bangladeshi nagad payment gateway api development library. This library can be used in any php application.
Stars: ✭ 20 (-86.3%)
Mutual labels:  payment, payment-gateway
midtrans-python-client
Official Midtrans Payment API Client for Python | https://midtrans.com
Stars: ✭ 24 (-83.56%)
Mutual labels:  payment, payment-gateway

💳 Paystack Plugin for Flutter

build status Coverage Status pub package

A Flutter plugin for making payments via Paystack Payment Gateway. Fully supports Android and iOS.

🚀 Installation

To use this plugin, add flutter_paystack as a dependency in your pubspec.yaml file.

Then initialize the plugin preferably in the initState of your widget.

import 'package:flutter_paystack/flutter_paystack.dart';

class _PaymentPageState extends State<PaymentPage> {
  var publicKey = '[YOUR_PAYSTACK_PUBLIC_KEY]';
  final plugin = PaystackPlugin();

  @override
  void initState() {
    plugin.initialize(publicKey: publicKey);
  }
}

No other configuration required—the plugin works out of the box.

💲 Making Payments

There are two ways of making payment with the plugin.

  1. Checkout: This is the easy way; as the plugin handles all the processes involved in making a payment (except transaction initialization and verification which should be done from your backend).
  2. Charge Card: This is a longer approach; you handle all callbacks and UI states.

1. 🌟 Checkout (Recommended)

You initialize a charge object with an amount, email & accessCode or reference. Pass an accessCode only when you have initialized the transaction from your backend. Otherwise, pass a reference.

Charge charge = Charge()
      ..amount = 10000
      ..reference = _getReference()
       // or ..accessCode = _getAccessCodeFrmInitialization()
      ..email = '[email protected]';
    CheckoutResponse response = await plugin.checkout(
      context context,
      method: CheckoutMethod.card, // Defaults to CheckoutMethod.selectable
      charge: charge,
    );

Please, note that an accessCode is required if the method is CheckoutMethod.bank or CheckoutMethod.selectable.

plugin.checkout() returns the state and details of the payment in an instance of CheckoutResponse .

It is recommended that when plugin.checkout() returns, the payment should be verified on your backend.

2. Charge Card

You can choose to initialize the payment locally or via your backend.

A. Initialize Via Your Backend (Recommended)

1.a. This starts by making a HTTP POST request to paystack on your backend.

1.b If everything goes well, the initialization request returns a response with an access_code. You can then create a Charge object with the access code and card details. The charge is in turn passed to the plugin.chargeCard() function for payment:

  PaymentCard _getCardFromUI() {
    // Using just the must-required parameters.
    return PaymentCard(
      number: cardNumber,
      cvc: cvv,
      expiryMonth: expiryMonth,
      expiryYear: expiryYear,
    );
  }

  _chargeCard(String accessCode) async {
    var charge = Charge()
      ..accessCode = accessCode
      ..card = _getCardFromUI();

    final response = await plugin.chargeCard(context, charge: charge);
    // Use the response
  }

The transaction is successful if response.status is true. Please, see the documentation of CheckoutResponse for more information.

2. Initialize Locally

Just send the payment details to plugin.chargeCard

      // Set transaction params directly in app (note that these params
      // are only used if an access_code is not set. In debug mode,
      // setting them after setting an access code would throw an error
      Charge charge = Charge();
      charge.card = _getCardFromUI();
      charge
        ..amount = 2000
        ..email = '[email protected]'
        ..reference = _getReference()
        ..putCustomField('Charged From', 'Flutter PLUGIN');
      _chargeCard();

🔧 🔩 Validating Card Details

You are expected but not required to build the UI for your users to enter their payment details. For easier validation, wrap the TextFormFields inside a Form widget. Please check this article on validating forms on Flutter if this is new to you.

NOTE: You don't have to pass a card object to Charge. The plugin will call-up a UI for the user to input their card.

You can validate the fields with these methods:

card.validNumber

This method helps to perform a check if the card number is valid.

card.validCVC

Method that checks if the card security code is valid.

card.validExpiryDate

Method checks if the expiry date (combination of year and month) is valid.

card.isValid

Method to check if the card is valid. Always do this check, before charging the card.

card.getType

This method returns an estimate of the string representation of the card type(issuer).

✔️ Verifying Transactions

This is quite easy. Just send a HTTP GET request to https://api.paystack.co/transaction/verify/$[TRANSACTION_REFERENCE]. Please, check the official documentaion on verifying transactions.

🚁 Testing your implementation

Paystack provides tons of payment cards for testing.

▶️ Running Example project

For help getting started with Flutter, view the online documentation.

An example project has been provided in this plugin. Clone this repo and navigate to the example folder. Open it with a supported IDE or execute flutter run from that folder in terminal.

📝 Contributing, 😞 Issues and 🐛 Bug Reports

The project is open to public contribution. Please feel very free to contribute. Experienced an issue or want to report a bug? Please, report it here. Remember to be as descriptive as possible.

🏆 Credits

Thanks to the authors of Paystack iOS and Android SDKS. I leveraged on their work to bring this plugin to fruition.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].