Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter_stripe Initialization error #1944

Open
joabeliot opened this issue Sep 30, 2024 · 5 comments
Open

flutter_stripe Initialization error #1944

joabeliot opened this issue Sep 30, 2024 · 5 comments
Labels
needs triage Needs triage

Comments

@joabeliot
Copy link

Am having issues with initializing the flutter project with Stripe Package
So, I been trying to use flutter_stripe to confirm a payment intent created from my server which send the Payment Intent and Payment Method to the flutter app which will confirm the payment intent and make the payment, But I couldn't even get the cardField working properly

To Reproduce
Steps to reproduce the behavior:

  1. I guess just Install flutter and import futter_stripe

What have I don't so far

  1. Reinstalled Android Studio to get the recent kotlin preferences and gradle preferences
  2. Checked if the version are according to the version specified in pub.dev
  3. Deleted .gradle/caches file and repopulated it, which partially fixed the code which finally build the app which didn't happen before now it's not working as intended

Versions I Use

  1. android/settings.gradle
pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.0" apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
  1. android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
  1. android/app/build.gradle
plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.example.stablish_stripe"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.stablish_stripe"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}
  1. android/build.gradle
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

Expected behavior
Expected behaviour is to get the Payment Intent client secret id and the payment method id and make the payment

Repo
https://github.com/joabeliot/Stripe-Flutter-Test

@joabeliot joabeliot added the needs triage Needs triage label Sep 30, 2024
@PogudoTanya
Copy link

PogudoTanya commented Oct 4, 2024

I probably have the same error (Android)

Unhandled Exception: PlatformException(error, lateinit property stripeSdk has not been initialized, null, kotlin.UninitializedPropertyAccessException: lateinit property stripeSdk has not been initialized

flutter_stripe: ^11.1.0

@jonasbark
Copy link
Member

jonasbark commented Oct 6, 2024

@joabeliot

But I couldn't even get the cardField working properly

How so? What happened?
Your repository cannot be accessed.

@joabeliot
Copy link
Author

Hey Jonas, My bad i forgot i had it in private mode, I've changed it so you can take a look. I am trying to pass the Payment Intent and Payment Method generated in my Django server and I want the flutter frontend to handle the payment confirmation steps... I couldn'e even get the cardform running properly, Throws errors with the cross platform is not working, not initialized and stuff

@jonasbark
Copy link
Member

You'll have to provide more information on the issues you're facing.

@PogudoTanya
Copy link

PogudoTanya commented Oct 6, 2024

About my error, I had the error fixed ✅ when I added the correct theme to ALL files values-night-v31, values-v31, values-night, values, not just the values and values-night files

android/app/src/main/res/values-night-v31/styles.xml
android/app/src/main/res/values-v31/styles.xml
android/app/src/main/res/values-night/styles.xml
android/app/src/main/res/values/styles.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Needs triage
Projects
None yet
Development

No branches or pull requests

3 participants