Integrating Stripe Payment in Flutter

2020-08-01 02:59发布

问题:

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.

  • What went wrong: Execution failed for task ':stripe_payment:compileDebugKotlin'.

    Compilation error. See log for more details

  • 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 41s Finished with error: Gradle task assembleDebug failed with exit code 1

Can anyone please help me to integrate.

回答1:

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


回答2:

As stated in the documentation of this plugin for Android:

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



回答3:

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.