ezet / stripe-sdk

A simple and flexible Stripe library for Flutter with complete support for SCA and PSD2.
https://pub.dev/packages/stripe_sdk
Other
137 stars 137 forks source link

Project not compile after adding package #134

Closed vytautas-pranskunas- closed 2 years ago

vytautas-pranskunas- commented 3 years ago

I got this error

/D:/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_sdk-4.0.2/lib/src/models/card.dart:55:38: Error: Too few positional arguments: 2 required, 1 given.
      return _ccValidator.validateCVV(cvc, cardType: cardType).isValid;
                                     ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_sdk-4.0.2/lib/src/models/card.dart:57:38: Error: Too few positional arguments: 2 required, 1 given.
      return _ccValidator.validateCVV(cvc).isValid;
                                     ^

/D:/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_sdk-4.0.2/lib/src/ui/screens/payment_methods_screen.dart:151:39: Error: The getter 'ScaffoldMessenger' isn't defined for the class 'PaymentMethodsList'.
 - 'PaymentMethodsList' is from 'package:stripe_sdk/src/ui/screens/payment_methods_screen.dart' ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_sdk-4.0.2/lib/src/ui/screens/payment_methods_screen.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'ScaffoldMessenger'.
                                      ScaffoldMessenger.of(rootContext).showSnackBar(SnackBar(
                                      ^^^^^^^^^^^^^^^^^
2

FAILURE: Build failed with an exception.

* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

Any help would be appreciate.

josxha commented 3 years ago

try using version 3.0.1 in your pubspec.yaml file. Make the following change to your dependencies:

dependencies:
   ...
   stripe_sdk: 3.0.1
vytautas-pranskunas- commented 3 years ago

Why is that so?

On Wed, Apr 21, 2021, 5:41 PM Joscha Eckert @.***> wrote:

try using version 3.0.1 in your pubspec.yaml file. Make the following change to your dependencies:

dependencies:

  • ...
  • stripe_sdk: 3.0.1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ezet/stripe-sdk/issues/134#issuecomment-824162825, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA54ZF3RSGC2DCU3VYIIVRLTJ3W3BANCNFSM43KAGI6A .

josxha commented 3 years ago

The versions after 3.0.1 only worked in the beta channel at the time of the respective releases. Now Flutter 2.0 has been released, in which it should work again. However, this requires migrating your application to null safety.

However, there is no stable null safety release on pub.dev yet. @ezet Maybe you could release another prerelease version to pub.dev when https://github.com/ezet/stripe-sdk/issues/132 is resolved?

PaulCaroline commented 3 years ago

I've been using Flutter 2.0, and had the same issue until I switched from stripe_sdk 4.0.2 to the null-safety pre-release.

dependencies:
  ...
 stripe_sdk: ^5.0.0-nullsafety.0

Everything seems to be compiling now. I hope that helps.

josxha commented 3 years ago

@PaulCaroline This works as long as you don't use confirmPaymentIntent(). There is a small bug that has been fixed in https://github.com/ezet/stripe-sdk/pull/130 but is still not available on pub.dev.

Gregortega commented 3 years ago

I was having the same issue, but I have other dependencies in my project and Im unable to update to null-safety for now. So I opted for downloading the repo, and adding it to the project locally and simply modifying the code causing the issue which is the card validator packaged, in the card.dart model. I know is not ideal, but it is a temporary solution until I can migrate. This solved it for me, hope it helps anyone else.

  bool validateCVC() {
    if (cvc == null) return false;
    if (number != null) {
      final cardType = _ccValidator.validateCCNum(number).ccType;
      return _ccValidator.validateCVV(cvc, cardType).isValid;
    } else {
      return false;
    }
  }
vinnytwice commented 2 years ago

@PaulCaroline This works as long as you don't use confirmPaymentIntent(). There is a small bug that has been fixed in #130 but is still not available on pub.dev.

@ezet so pulling the package from GitHub instead won't have the confirmPayment problem? Any particular branch or just the master would do? Many thanks

ezet commented 2 years ago

Fixed