Rahul Arora
Rahul Arora

Reputation: 21

Integrating Stripe Payment in Flutter

I am trying to integrate Stripe Payment Gateway in Flutter app and i am following below link

https://pub.dartlang.org/packages/stripe_payment

But unfortunately i am getting error. I am using dependencies: stripe_payment: ^0.1.0. But i am getting below error

FAILURE: Build failed with an exception.

BUILD FAILED in 41s Finished with error: Gradle task assembleDebug failed with exit code 1

Can anyone please help me to integrate.

Upvotes: 2

Views: 5379

Answers (4)

Andy
Andy

Reputation: 81

I had this issue after switching to a different branch.

flutter clean
flutter pub get
flutter run

Fixed it for me.

Upvotes: -1

Apurv Thakkar
Apurv Thakkar

Reputation: 10248

Please go through below link, in this demo stripe and PayPal payment gateway are integrated.

https://github.com/android-inheritx/Flutter_Payment_Stipe_Paypal

In stripe, payment can be done in two ways. First with payment intent and second with charges API.

In the above-mentioned link, stripe payment is achieved by charges API.

Upvotes: 1

SAndriy
SAndriy

Reputation: 808

In your \android\app\src\main\java\com\example\yourProjectName\MainActivity.java file you should have code similar to the code below:

package com.example.yourProjectName;

import android.os.Bundle;
//import io.flutter.app.FlutterActivity;
import io.flutter.app.FlutterFragmentActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

//public class MainActivity extends FlutterActivity {
public class MainActivity extends FlutterFragmentActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

In order it works for version ^0.1.0, include this into your project's android/gradle.properties file

android.useAndroidX=true
android.enableJetifier=true

Upvotes: 2

Toma
Toma

Reputation: 2945

As stated in the documentation of this plugin for Android:

Please be aware that your main activity must extend from FlutterFragmentActivity.

Upvotes: 1

Related Questions