Giter VIP home page Giter VIP logo

nravepay's Introduction

nravepay

Nravepay is a package that makes accepting card payments in a flutter project easier using Flutterwave. This work is motivated and influenced by rave_flutter

Features

  • Custom Flutter native UI
  • Save card and pay with token
  • Card payments only
  • Split payments

Initialize at Startup

   void main(){
      NRavePayRepository.setup(Setup(
      publicKey: PaymentKeys.publicKey,
      encryptionKey: PaymentKeys.encryptionKey,
      secKey: PaymentKeys.secretKey,
      staging: true,
      version: Version.v3,
      allowSaveCard: true,
      logging: true))
        ...//other codes
   }

Usage

     var initializer = PayInitializer(
        amount: 450,
        email: '[email protected]',
        txRef: 'TXREF-${DateTime.now().microsecondsSinceEpoch}',
        narration: 'New payment',
        country: 'NG',
        currency: 'NGN',
        firstname: 'Nelson',
        lastname: 'Eze',
        phoneNumber: '09092343432',
        metadata: {'paymentType': 'card', 'platform': 'android'},
        onComplete: (result) {
          if (result.status == HttpStatus.success) {
            if (result.card != null) {
              print(result.card);
              //  saveCard(card);
            }
          }
          print(result.message);
        });
    return PayManager().prompt(context: context, initializer: initializer);
  }
  

Customization

You can customize all the texts in this package. This is particulary useful when your app supports more than one language.

To customize texts include override using the setup function

NRavePayRepository.setup(Setup(
      // other params
      payText: 'Pay Now',
      chooseCardHeaderText: 'Payment Cards',
      addCardHeaderText: 'Add Card',
      addNewCardText: 'Add New Card',   
      strings: Strings().copyWith()))

To customize the pay button you can include a custom buttonBuilder in the payment Initializer

var initializer = PayInitializer(
  //..other params,
  buttonBuilder: (amout, onPress) {
          return TextButton(
            child: Text(amout.toString()),
            onPressed: onPress,
          );
        }),

Services

This package also exposes some useful methods incase you want to call them somewhere else.

You can access any method in the TransactionService, HttpService and BankService

For example, to perform a charge request using a Payload object;

var payload = Payload(...)
ChargeResponse response = await TransactionService.instance.charge(payload)

For example if you wanted to get the list of banks supported

 var banks = await BankService.instance.fetchBanks

In the case that you want to perform a custom method operation you can make use of the HttpService.

Here is an example that verifies if an account number is correct

 Future<dynamic> verifyAccount(String acctNo, String bankCode) async {
    var data = {
      'recipientaccount': acctNo,
      'destbankcode': bankCode,
      'PBFPubKey': Setup.instance.publicKey
    };
    try {
      final res = await HttpService()
          .dio
          .post('/flwv3-pug/getpaidx/api/resolve_account', data: data);
      if (res.statusCode == 200) {
        print(res.data);
      }
    } catch (e) {
      print(e);
    }
  }

Screenshots

Bugs/Requests

If you encounter any problems feel free to open an issue feature suggestions and Pull requests are also welcome.

nravepay's People

Contributors

nelsonweze avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

nisone

nravepay's Issues

Split Payment Functionality

Hey , great package , just one doubt , so i want that users pay directly to vendor from my flutter app , and i got commison out of it , so by using this split functionality , can i achieve this , and will payment settledown to bank accounts of vendors and mine , instantly ??

Payment fails with tripledes runtime error

From looking at the error's stack trace, I noticed this was coming from the tripledes package used with the plugin, since you authored both packages and I only added directly referenced this, I figured I should open the issue here.

The exact error: 'Null' is not a subtype of type int in type cast.
Current flutter version: 2.5.2

Steps to reproduce:

  1. Setup plugin
  2. Setup Initializer and call Paymanger().prompt()
  3. Fill in card details and hit pay.

PS: Run with sound nullsafety

Not working on Production

Package not working when app built with flutter build apk --split-per-abi

It doesn't move forward after card details are entered.

It works on debug app but not when in Production. Please need help with this ASAP, thanks

Merchant does not support Rave v3

Screenshot 2021-05-31 at 08 32 38

For some reason, Merchant does not support Rave v3 still affects the library. Is there any way to bypass this so I can use v2? Thanks

NavBar and Pay Button Text Customisation

I love the way this package is heading, I was about to create an issue for removing the 'Save Card' feature but that has been handled. Thank You
This is a customization issue, I need to customize the navbar text to read 'Add Card' not 'Card payment', also for the 'Pay' button if it could read something else like 'Add card' too. I will explain to the user beforehand that I will need to make a tiny charge in order for their card to be saved. Also, the Pay text and the currency on the right seem a bit off, maybe reduce the spacing between the two texts, this is in the pay button.
In summary,

  1. Ability to customize the text on NavBar
  2. Ability to customize the text on the button
  3. Ability to remove the amount to be charged from that button when say, I have 'Add Card' text on the button. I don't want it to read 'Add Card Ksh 100'

Animated Size widget creating build issues

Running Gradle task 'assembleRelease'...                        
../programs/flutter/.pub-cache/hosted/pub.dartlang.org/nravepay-1.0.6/lib/src/pages/add.card.page.dart:45:26: Error: Required named parameter 'vsync' must be provided.

      child: AnimatedSize(

                         ^

../programs/flutter/packages/flutter/lib/src/widgets/animated_size.dart:56:9: Context: Found this candidate, but the arguments don't match.

  const AnimatedSize({

        ^^^^^^^^^^^^

../programs/flutter/.pub-cache/hosted/pub.dartlang.org/nravepay-1.0.6/lib/src/pages/add.card.page.dart:98:36: Error: Required named parameter 'vsync' must be provided.

                child: AnimatedSize(

                                   ^

../programs/flutter/packages/flutter/lib/src/widgets/animated_size.dart:56:9: Context: Found this candidate, but the arguments don't match.

  const AnimatedSize({

        ^^^^^^^^^^^^

../programs/flutter/.pub-cache/hosted/pub.dartlang.org/nravepay-1.0.6/lib/src/pages/choose_card.payment.dart:108:36: Error: Required named parameter 'vsync' must be provided.

                child: AnimatedSize(

                                   ^

../programs/flutter/packages/flutter/lib/src/widgets/animated_size.dart:56:9: Context: Found this candidate, but the arguments don't match.

  const AnimatedSize({

        ^^^^^^^^^^^^





FAILURE: Build failed with an exception.



* Where:

Script '/Users/builder/programs/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035



* What went wrong:

Execution failed for task ':app:compileFlutterBuildRelease'.

> Process 'command '/Users/builder/programs/flutter/bin/flutter'' finished with non-zero exit value 1



* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.



* Get more help at https://help.gradle.org

I get this error when building the app. I do not know where the animated widget is in the package but it is throwing the error. This is after upgrading to v1.0.6. I am also on flutter 2.5

Not working for 2.12

I've tried so many things. After debugging for hours I found that there's a problem with trippledes package. It is unable to generate the base64 key and throwing

List<int> is not subtype of Null error.

Please help me solve the issue.

 var initializer = PayInitializer(
        amount: 450,
        email: '[email protected]',
        txRef: 'TXREF-${DateTime.now().microsecondsSinceEpoch}',
        narration: 'New payment',
        country: 'NG',
        currency: 'NGN',
        firstname: 'Nelson',
        lastname: 'Eze',
        phoneNumber: '09092343432',
        onComplete: (result) {
          if (result.status == HttpStatus.success) {
            if (result.card != null) {
              print(result.card);
              //  saveCard(card);
            }
          }
          print(result.message);
        });
    return PayManager().prompt(context: context, initializer: initializer);
  }

This is the code I'm using, V3 though.

"Add Credit Card" text is misleading.

I was reading through the docs and found this image .

Debit cards are primarily/largely used in NG and that "add Credit Card" text is misleading. It might look ignorable, but from a UX POV it could use some tuning. Something generic like "add card", "new card" would suffice even for countries with large credit card support.

Good job on the plugin btw.

Payment failing with tripledes error at runtime

Error from debug console below:

RangeError (end): Invalid value: Only valid value is 0: 2 [log] #0 RangeError.checkValidRange (dart:core/errors.dart:356:9) #1 List.sublist (dart:core-patch/growable_array.dart:84:38)

Steps to reproduce:
Setup plugin
Setup Initializer and call Paymanger().prompt()
Fill in card details and hit pay.

PS: Run with sound nullsafety

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.