Coder Social home page Coder Social logo

wilburx9 / rave_flutter Goto Github PK

View Code? Open in Web Editor NEW
31.0 3.0 58.0 747 KB

A Flutter plugin for Flutterwaves's rave.

License: Apache License 2.0

Kotlin 0.61% Ruby 1.21% Swift 0.55% Objective-C 0.23% Dart 97.41%
rave ravepay flutterwave flutterwave-rave payment flutter flutter-plugin

rave_flutter's Introduction

Rave Flutter

build status Coverage Status pub package

A robust Flutter plugin for accepting payment on Rave with

  • Card
  • Nigerian Bank Account
  • ACH Payments
  • Mobile money Francophone Africa
  • Mpesa
  • Ghana Mobile Money
  • Uganda Mobile Money

Keys

Installation

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

Webview is required so enable PlatformView on iOS by adding:

<key>io.flutter.embedded_views_preview</key>
<true/

to Info.plist file

Making Payment

Instantiate RavePayInitializer and pass it to RavePayManager.prompt along with the BuildContext. The result of the transaction is the Future returned by RavePayManager.initialize

processTransaction() async {
    // Get a reference to RavePayInitializer
    var initializer = RavePayInitializer(
        amount: 500, publicKey: publicKey, encryptionKey: encryptionKey)
      ..country = "NG"
      ..currency = "NGN"
      ..email = "[email protected]"
      ..fName = "Ciroma"
      ..lName = "Adekunle"
      ..narration = narration ?? ''
      ..txRef = txRef
      ..subAccounts = subAccounts
      ..acceptMpesaPayments = acceptMpesaPayment
      ..acceptAccountPayments = acceptAccountPayment
      ..acceptCardPayments = acceptCardPayment
      ..acceptAchPayments = acceptAchPayments
      ..acceptGHMobileMoneyPayments = acceptGhMMPayments
      ..acceptUgMobileMoneyPayments = acceptUgMMPayments
      ..staging = true
      ..isPreAuth = preAuthCharge
      ..displayFee = shouldDisplayFee;

    // Initialize and get the transaction result
    RaveResult response = await RavePayManager()
        .prompt(context: context, initializer: initializer);
  }

Documentation

Documentation can be found here.

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.

rave_flutter's People

Contributors

emmarex avatar wilburx9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rave_flutter's Issues

Web support

I changed the Webviewer with Easywebviewer, the only issue now is that I have no URL callback

Dialog buttons in the payment flow

Hi,

I have been testing out the package but it seems that the confirm buttons when using the mpesa payment flow are not visible (screenshot). Could it be that I am using production keys or what am I missing?

The logs do not show any error at all.

Wrong public Key error

We am getting this error while using Francophone Mobile Money from Ivory coast

{"status":"error","message":"Invalid public key passed","data":{"code":"INV_PUBK","message":"Invalid public key passed"}}

I have checked the keys on Flutterwave dashboard and it's correct.
I have even tried to use the secret key instead but I keep getting this error.
I have also tried to generate a new public key, but still

as a side note i am getting this error on sandbox mode:

flutter: Response Text:
flutter: {"status":"success","message":"Charged fee","data":{"charge_amount":"200.00","fee":2.8,"merchantfee":"0","ravefee":"2.8","stampdutyfee":0,"currency":"XOF"}}
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method '[]=' was called on null.
Receiver: null
Tried calling: []=("orderRef", "531ce346-d40f-4313-ab36-ba368a3a07e4")
#0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)
#1      Payload.toJson 
package:rave_flutter/…/dto/payload.dart:142
#2      new ChargeRequestBody.fromPayload 
package:rave_flutter/…/dto/charge_request_body.dart:23
#3      MMFrancophoneTransactionManager.charge 
package:rave_flutter/…/manager/mm_francoophone_transaction_manager.dart:24
#4      BaseTransactionManager.displayFeeDialog.charge 
package:rave_flutter/…/manager/base_transaction_manager.dart:125
#5      GestureRecognizer.invokeCallback 
package:flutter/…/gestures/recognizer.dart:182
#6      TapGestureRecognizer.handleTapUp 
package:flutter/…/gestures/tap.dart:504
#7      BaseTapGestureRecognizer._checkUp 
package:flutter/…/gestures/tap.dart:282
#8      BaseTapGestureRecognizer.acceptGestu<…>

I don't know if it is wanted or not but it cause the loader to keep rolling until i manually close the box so I can't continue on the next API implementation my app.

rave payment issue

Hi,

Whenever i use the plugin for USD card payment, it stays on this display for a long time, is that a problem with flutterwave payment or the plugin. Please check it out.

var initializer = RavePayInitializer(
        amount: 20.0,
        publicKey: ConfigUtils.ravePublickey(),
        encryptionKey: ConfigUtils.raveEnckey())
      ..country = 'NG'
      ..currency = 'USD'
      ..email = 'your email'
      ..fName = 'john'
      ..lName = 'doe'
      ..narration = 'Transfer'
      ..txRef = 'FL-${DateTime.now().millisecondsSinceEpoch}'
      ..acceptCardPayments = true
      ..staging = true
      ..displayFee = false
      ..acceptAccountPayments = false
      ..displayAmount = false
      ..displayEmail = false
      ..companyLogo = Image.asset(
        'assets/images/logo.png',
        fit: BoxFit.contain,
      )
      ..companyName = 'My Company';

I used Test MasterCard 3DSecure authentication
5438 8980 1456 0229
cvv 564
Expiry: 10/20
Pin 3310
otp 12345

Simulator Screen Shot - iPhone 6s - 2019-11-24 at 11 58 48

Error after switching to live key

RaveResult{status: RaveStatus.error, rawResponse: null, message: ER_CANT_AGGREGATE_2COLLATIONS: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='}

how can I solve this?

Help on implementing Mpesa

Hi @Wilburt I see from latest commit, that this library works with Mpesa, however when I try to use Mpesa, the rave modal shows error This payment mode is currently under development. Please help.

image

Subaccount not being sent

Hi, I noticed that my subaccounts are not being sent in the payload, please what could i be doing wrong?

Pub libraries

Hi,

May you please update packages.

They seem to be way old.

Having issues implenting this

var response = await RavePayManager().prompt(context: context, initializer: initializer);

I got error from the line above, stating that "The method prompt is not defined for the class RavePayManager".

Please, how do I solve this?

Cannot not pass paymentPlan in initializer

The payment plan is not going through on payment for recurring billing . All other data is present on the dashboard. I suspect the key in the initializer is supposed to be payment_plan and not paymentPlan.

flutter_svg-0.18.1 problem in flutter 2.0.0

I have just updated my flutter SDK version to 2.0.0 and I run my project I got this error please Fix this issue asap

Error

../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
        context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                          ^^^^^^        
../../../Development/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
  static Locale localeOf(BuildContext context) {                        
                ^^^^^^^^                                                
FAILURE: Build failed with an exception.                                
* Where:                                                                
Script '/Users/helpmac/Development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildDebug'.              
> Process 'command '/Users/helpmac/Development/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                              
BUILD FAILED in 50s                                                     
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        50.9s
Exception: Gradle task assembleDebug failed with exit code 1

Flutter doctor

[✓] Flutter (Channel stable, 2.0.0, on Mac OS X 10.15 19A583 darwin-x64, locale en-GB)
    • Flutter version 2.0.0 at /Users/helpmac/Development/flutter
    • Framework revision 60bd88df91 (9 days ago), 2021-03-03 09:13:17 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/helpmac/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/helpmac/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.
[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.0, Build version 11A420a
    ! Xcode 11.0.0 out of date (12.0.1 is recommended).
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.1
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.54.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0
[✓] Connected device (3 available)
    • IN Note1 (mobile) • BS7746M4KN1120012228                 • android-arm64  • Android 10 (API 29)
    • iPhone X (mobile) • 3EF95060-4336-4017-9BE0-73CB5C3CE227 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
    • Chrome (web)      • chrome                               • web-javascript • Google Chrome 89.0.4389.82
! Doctor found issues in 1 category.

Exception in GHmobileMoney (Dev mode)

The following assertion was thrown building GhMobileMoneyPaymentWidget(dirty, dependencies: [_EffectiveTickerMode], state: _GhMobileMoneyPaymentWidgetState#c43f9(tickers: tracking 2 tickers)):

A non-null String must be provided to a Text widget.
'package:flutter/src/widgets/text.dart':
Failed assertion: line 298 pos 10: 'data != null'

Please update packages to latest version

Package not working with my project, causing build errors because of an outdated package

../../../../.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {

Subaccounts flat rate split payments

Looking a the Subaccount class constructor it takes an id and transactionSplitRatio. This is convenient for percentage based sharing.
However I want to work with the flat_subaccount transaction_charge_type and simply pass a static amount which I need shared to that particular subaccount. Just static amount and not based on ratio or percentage. For instance if total amount is KES 1,500, I want the subaccount to get KES 1, 050 which I have determined from my own calculations.

Please, how can I achieve this?

Unable to build app with Flutter 2.0. Update flutter_svg

When I run my app with the new flutter version , I get this error
./../../../.pub-cache/hosted/pub.dartlang.org/rave_flutter-0.0.9-alpha+2/lib/src/ui/payment/rave_pay_widget.dart:2:8: Error: Error when reading '../../../../.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/flutter_svg.dart': No such file or directory
This is because I updated my flutter svg package to the new one which is flutter_svg: ^0.19.3
The previous version of flutter svg is not compatible with Flutter 2.0
Fix is to upgrade flutter svg in your pubspec

Unhandled Exception: NoSuchMethodError:

ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method '[]=' was called on null.
Receiver: null
Tried calling: []=("orderRef", "1591159969334")
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 Payload.toJson (package:rave_flutter/src/dto/payload.dart:142:11)
#2 new ChargeRequestBody.fromPayload (package:rave_flutter/src/dto/charge_request_body.dart:23:60)
#3 CardTransactionManager.charge (package:rave_flutter/src/manager/card_transaction_manager.dart:24:50)
#4 BaseTransactionManager.displayFeeDialog.charge (package:rave_flutter/src/manager/base_transaction_manager.dart:125:12)

Meta object not being sent

please help!!!, am i doing it wrong, or is the "meta" field not being sent cause I cannot find it in my webhook, same for "narration"

Uganda Mobile Money Support

Hey awesome package, any sort of time scale as to when we could expect support for the 2 remaining unsupported mobile money variants; Uganda and Ghana?
It is a great package but hinders a few of us trying to produce apps that have a market not in the other countries you already support.

You can only charge US Accounts in Dollars

Now i'm trying to payment getting this error.

{"status":"error","message":"You can only charge US Accounts in Dollars","data":{"code":"ERR","message":"You can only charge US Accounts in Dollars"}}

rave_flutter 0.0.9-alpha+1 returns This payment mode is currently under development

I installed rave_flutter plugin , copied production keys from my flutterwave account but I get This payment mode is currently under development.

  1. Payement by card
  2. MPesa
  3. Mobile Money (Uganda)
    and other payment options all don't work.

Here's my code
`void payWithMobileMoney() async {
Navigator.pop(context);
var initializer = RavePayInitializer(
amount: 500, publicKey: 'FLWPUBK-fd13744184c7c4ec3fb622ababef95a5-X',
encryptionKey: 'fb7f8d35b0b249431a9db2b0')
..country = "UG"
..currency = "UGX"
..email = "$email"
..fName = "$fullName"
..narration = 'Subscribe for premium' ?? ''
..txRef = 'txRef'
..companyName = Text('UNRA')
..publicKey = 'FLWPUBK-fd13744184c7c4ec3fb622ababef95a5-X'
..encryptionKey = 'fb7f8d35b0b249431a9db2b0'
..acceptAccountPayments = true
..acceptCardPayments = false
..acceptUgMobileMoneyPayments = true
..staging = false
..isPreAuth = false
..displayFee = true;

// Initialize and get the transaction result
RaveResult response = await RavePayManager()
    .prompt(context: context, initializer: initializer);

print(response.status);
print(response.rawResponse);
print(response.message);
}`

Payment with MPESA does not initiate STK push

I put pay with MPESA as an option .
In the UI for the plugin . I entered my phone number after selecting MPESA.
From there I got the loader and then the prompt asking me to confirm that I will be charged.
After that I got the response that the. payment was successful and even got an email about the payment.
However I was not prompted to enter my MPESA PIN meaning that the transaction did not actually go through as my Balance has not changed and I have received no communication about the charge on my MPESA.

displayEmail cannot be null

Getting error displayEmail cannot be null, just copy pasted from Pub.dev
Help please,
Thanks,

var initializer = RavePayInitializer(
        displayEmail: true,
        displayAmount: true,
        displayFee: true,
        amount: amount,
        publicKey: 'FLWPUBK-XXxxxxxxxxxXXxxxxxx-X',
        encryptionKey: 'eded53xxxxxxxxxxxxxxx7d')
      ..country = "ZA"
      ..currency = "ZAR"
      ..email = "${user.email}"
      ..fName = "${user.firstName}"
      ..lName = "${user.lastName}"
      ..narration = ''
      ..txRef = user.userId + time.millisecondsSinceEpoch.toString()
      ..acceptAccountPayments = true
      ..acceptCardPayments = true
      ..acceptAchPayments = true
      ..acceptGHMobileMoneyPayments = true
      ..acceptUgMobileMoneyPayments = true
      ..staging = true
      ..isPreAuth = true
      ..displayFee = true;

    // Initialize and get the transaction result
    RaveResult response = await RavePayManager()
        .initialize(context: context, initializer: initializer);

payment links / payment pages

I don't think there is presently a way to make subscription payments with this sdk. I have a payment link, I want to subscribe clients to that link and charge them.

Secured By Flutterwave

Great Work! Well Done. Kindly add SECURED BY FLUTTERWAVE for pop up. (Needed for user trust.)

I keep getting this error when trying to user rave_flutter

Everything I try to install tripledes: ^2.1.0 I keep getting the error

Because no versions of tripledes match 2.1.0 and no versions of tripledes match >2.1.0 <3.0.0, tripledes ^2.1.0 is forbidden.
So, because **** depends on tripledes ^2.1.0, version solving failed.
pub get failed (1; So, because **** depends on tripledes ^2.1.0, version solving failed.)

It happens every single times and i dont know what caused it, cause am trying to use rave_flutter: ^0.0.9-alpha+2 which depends on tripledes and its not working because of this error.
What is the problem

This are my depencies:

dependencies:
google_sign_in: ^4.5.6
firebase_auth:
provider: ^4.3.2+3
flutter_switch: ^0.2.0
cached_network_image: ^2.5.0
shared_preferences: ^0.5.12+4
image_picker: ^0.6.7+17
flutter_image_compress: ^0.7.0
image_cropper: ^1.3.1
intl: ^0.16.1
http: ^0.12.2
transparent_image: ^1.0.0
country_state_city_picker: ^1.2.7
animations: ^1.1.2
smooth_star_rating: ^1.1.1
csc_picker: ^0.0.4
firebase_core: ^0.7.0
rave_flutter: ^0.0.9-alpha+2
async: ^2.4.2
dio: ^3.0.10
equatable: ^1.2.5
flutter_svg: ^0.19.2+1
get_it: ^5.0.2
meta: ^1.2.4
tripledes: ^2.1.0
webview_flutter: ^1.0.7
flutter:
sdk: flutter

Mobile money (Mpesa) error responses

Testing Mpesa payments, I realized that Mpesa error responses are not being caught, to display error response in the app.
An Mpesa error may arise from

  1. Wrong Mpesa account no
  2. Insufficient Mpesa account funds
  3. Mpesa pin prompt cancelled by user
  4. Wrong Mpesa PIN entered by user
  5. Timeout & other errors

I understand this plugin is not a solely Mpesa plugin, but if the errors would be well caught to give an alert of the error, and to dismiss the spinner and maybe the modal, it would be more user friendly.

card payment failed " An error occured while attempting to decrypt some parameters"

when i tried to do card payment or mpesa it is giving error
and console i m getting this
*** DioError ***:
I/flutter (26380): uri: https://ravesandboxapi.flutterwave.com/flwv3-pug/getpaidx/api/charge
I/flutter (26380): DioError [DioErrorType.RESPONSE]: Http status error [400]
I/flutter (26380): uri: https://ravesandboxapi.flutterwave.com/flwv3-pug/getpaidx/api/charge
I/flutter (26380): statusCode: 400
I/flutter (26380): headers:
I/flutter (26380): connection: keep-alive
I/flutter (26380): x-powered-by: Express
I/flutter (26380): access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, v3-xapp-id, flw-auth-token, mra-auth-token, alt_mode_auth, mid
I/flutter (26380): date: Mon, 01 Feb 2021 07:28:47 GMT
I/flutter (26380): x-moesif-transaction-id: 1b223e84-06c8-4a4c-ba13-feac39de9c40
I/flutter (26380): access-control-allow-origin: *
I/flutter (26380): access-control-allow-methods: PUT, POST, GET, DELETE, OPTIONS
I/flutter (26380): content-length: 103
I/flutter (26380): etag: W/"67-zshR+cq5UdFzzywHJM9Wlg"
I/flutter (26380): via: 1.1 vegur
I/flutter (26380): content-type: application/json; charset=utf-8
I/flutter (26380): server: Cowboy
I/flutter (26380): Response Text:
I/flutter (26380): {"status":"error","message":"An error occured while attempting to decrypt some parameters","data":null}
I/flutter (26380): RaveResult{status: RaveStatus.error, rawResponse: null, message: An error occured while attempting to decrypt some parameters}

issue with companyName

Hi,
I tried adding a company name in RavePayInitializer(companyName=''), but this doesnt work because your initializer is requiring a Widget.
I think you should change it from Widget companyName; to String companyName; because of your code here:

var rightStr =_initializer.companyName ?? _initializer.staging ? Strings.demo : '';
var rightText = Text(
    rightStr,
    maxLines: 1,
    style: TextStyle(color: Colors.grey[800], fontSize: 16),
);

As you can see _initializer.companyName is being added to the Text widget already so doesnt need to be cast as a widget.

Meanwhile var rightStr =_initializer.companyName ?? _initializer.staging ? Strings.demo : ''; should have brackets enclosed like this var rightStr =_initializer.companyName ?? (_initializer.staging ? Strings.demo : ''); because its introducing a bug.

displayAmount cannot be null

Hi,
I keep getting this error message saying displayAmount cannot be null. If you look at the validator_utills.dart file, you will notice the bug there.

It should be
if (init.displayAmount == null) return Strings.cannotBeNull("displayAmount");
instead of
if (init.displayAmount) return Strings.cannotBeNull("displayAmount"); because init.displayAmount will always be true or false and not null.

It'll be nice if you could try it out and update the plugin soon. Nice job you did though.

Failed assertion: boolean expression must not be null

Hi @Wilburt
After the latest changes, the pay modal is not showing, this is the error when I run the .prompt() method

════════ Exception caught by widgets ════════════════════════════════
The following assertion was thrown building IconTheme(color: Color(0xdd000000)):
Failed assertion: boolean expression must not be null


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

The relevant error-causing widget was: 
  MaterialApp

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.