Skip to content

Cokitchen/thepeer-flutter-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Thepeer

This package makes it easy to use the Thepeer in a flutter project.

📸 Screen Shots

🚀 How to Use plugin

Adding MaterialSupport

Add the dependency on Android’s Material in /android/app/build.gradle:

dependencies {
    // ...
    implementation 'com.google.android.material:material:<version>'
    // ...
}

ThePeer Send

  • Launch ThepeerSendView in a bottom_sheet
import 'package:thepeer_flutter/thepeer_flutter.dart';

  void launch() async {
      await ThepeerSendView(
               data: ThePeerData(
                  amount: 400000,
                  publicKey: "pspk_one_more_thing",
                  userReference: "stay-foolish-stay-hungry-forever",
                  currency: 'NGN',
                  meta: {
                    "city": "San Fransisco",
                    "state": "california"
                  }
               ),
               showLogs: true,
               onClosed: () {
                  print('closed');
                  Navigator.pop(context);
               },
               onSuccess: (data) {
                  print(data); // ThepeerSuccessModel
                  Navigator.pop(context);
               },
               onError: print,
      ).show(context);
  }
  • Use ThepeerSendView widget
import 'package:thepeer_flutter/thepeer_flutter.dart';

     ...

     ThepeerSendView(
         data: ThePeerData(
            amount: 10000,
            publicKey: "pspk_one_more_thing",
            userReference: "stay-foolish-stay-hungry-forever",
            currency: 'NGN',
            meta: {
               "city": "San Fransisco",
               "state": "california"
            }
         ),
         onClosed: () {
            Navigator.pop(context);
            print('Widget closed')
         },
         onSuccess: (data) {
            print(data); // ThepeerSuccessModel
            Navigator.pop(context);
         },
         onError: print,
        error: Text('Error'),
      )

      ...

ThePeer DirectCharge

  • Launch ThepeerDirectChargeView in a bottom_sheet
import 'package:thepeer_flutter/thepeer_flutter.dart';

  void launch() async {
    await ThepeerDirectChargeView(
            data: ThePeerData(
              amount: 10000,
              publicKey: "pspk_one_more_thing",
              userReference: "stay-foolish-stay-hungry-forever",
              currency: 'NGN',
              meta: {
                  "city": "San Fransisco",
                  "state": "california"
               }
            ),
            showLogs: true,
             onClosed: () {
               Navigator.pop(context);
               print('Widget closed');
            },
            onSuccess: () {
               print(data);
               Navigator.pop(context);
            },
            onError: print,
      ).show(context);
  }
  • Use ThepeerDirectChargeView widget
import 'package:thepeer_flutter/thepeer_flutter.dart';

     ...

      await ThepeerDirectChargeView(
            data: ThePeerData(
              amount: 10000,
              publicKey: "pspk_one_more_thing",
              userReference: "stay-foolish-stay-hungry-forever",
              currency: 'NGN'
              meta: {
                  "city": "San Fransisco",
                  "state": "california"
               }
            ),
            showLogs: true,
            onClosed: () {
            Navigator.pop(context);
            print('Widget closed')
         },
         onSuccess: (data) {
            print(data); // ThepeerSuccessModel
            Navigator.pop(context);
         },
         onError: print,
      )

      ...

ThePeer Checkout

  • Launch ThepeerCheckoutView in a bottom_sheet
import 'package:thepeer_flutter/thepeer_flutter.dart';

  void launch() async {
    await ThepeerCheckoutView(
            data: ThePeerData(
              amount: 10000,
              publicKey: "pspk_one_more_thing",
              userReference: "stay-foolish-stay-hungry-forever",
              currency: 'NGN',
              meta: {
                  "city": "San Fransisco",
                  "state": "california"
               }
            ),
            showLogs: true,
            onClosed: () {
               Navigator.pop(context);
               print('Widget closed')
            },
            onSuccess: () {
               print(data); // ThepeerSuccessModel
               Navigator.pop(context);
            },
            onError: print,
      ).show(context);
  }
  • Use ThepeerCheckoutView widget
import 'package:thepeer_flutter/thepeer_flutter.dart';

     ...

      await ThepeerCheckoutView(
            data: ThePeerData(
              amount: 10000,
              publicKey: "pspk_one_more_thing",
              userReference: "stay-foolish-stay-hungry-forever",
              currency: 'NGN'
              meta: {
                  "city": "San Fransisco",
                  "state": "california"
               }
            ),
            showLogs: true,
            onClosed: () {
               Navigator.pop(context);
               print('Widget closed')
            },
            onSuccess: (data) {
               print(data); // ThepeerSuccessModel
               Navigator.pop(context);
            },
            onError: print,
      )

      ...

Configuration Options

publicKey

String: required

Your public key can be found on your dashboard settings.

userReference

String: required

The user reference returned by Thepeer API when a user has been indexed

amount

String: required

The amount you intend to send in kobo

currency

String: required

The currency of the amount to be paid

onSuccess

(ThepeerSuccessModel) =>: optional

returns ThepeerSuccessModel

This is called when a transaction is successfully. It returns a response with event type and transaction details.

See the event details below.

onError

VoidCallback: optional

returns dynamic

This is called when a transaction fails. It returns a response with event type

See the event details below.

onClose

VoidCallback: optional

This is called when a user clicks on the close button.

meta

Map<String, Object>: optional This object should contain additional/optional attributes you would like to have on your transaction response

transaction: ThepeerSuccessModel

The transaction ThepeerSuccessModel object returned from the success events.

✨ Contribution

Lots of PR's would be needed to improve this plugin. So lots of suggestions and PRs are welcome.

About

Official plugin for using Thepeer SDK with flutter https://thepeer.co

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 93.9%
  • Ruby 2.1%
  • HTML 1.7%
  • Swift 1.2%
  • Shell 0.8%
  • Kotlin 0.2%
  • Objective-C 0.1%