flutter_stripe_payment 0.0.12
flutter_stripe_payment: ^0.0.12 copied to clipboard

Flutter Android iOS

Add Stripe to your Flutter Application to Accept Card Payments Using Payment Intents with Strong SCA 3DS Compliance

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_stripe_payment/flutter_stripe_payment.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _paymentMethodId;
  String _errorMessage = "";
  final _stripePayment = FlutterStripePayment();

  @override
  void initState() {
    super.initState();
    _stripePayment.setStripeSettings(
        "{STRIPE_PUBLISHABLE_KEY}", "{STRIPE_APPLE_PAY_MERCHANTID}");
    _stripePayment.onCancel = () {
      print("the payment form was cancelled");
    };
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Stripe App Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              _paymentMethodId != null
                  ? Text(
                      "Payment Method Returned is $_paymentMethodId",
                      textAlign: TextAlign.center,
                    )
                  : Container(
                      child: Text(_errorMessage),
                    ),
              RaisedButton(
                child: Text("Add Card"),
                onPressed: () async {
                  var paymentResponse = await _stripePayment.addPaymentMethod();
                  setState(() {
                    if (paymentResponse.status ==
                        PaymentResponseStatus.succeeded) {
                      _paymentMethodId = paymentResponse.paymentMethodId;
                    } else {
                      _errorMessage = paymentResponse.errorMessage;
                    }
                  });
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
16
likes
100
pub points
78%
popularity

Add Stripe to your Flutter Application to Accept Card Payments Using Payment Intents with Strong SCA 3DS Compliance

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

eopeter@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_stripe_payment