flutter_braintree 0.1.1
flutter_braintree: ^0.1.1 copied to clipboard

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> {
  String _text = "";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Braintree example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                onPressed: () async {
                  setState(() {
                    _text = 'Waiting for result...';
                  });
                  var request = BraintreeDropInRequest(
                    tokenizationKey: 'sandbox_8hxpnkht_kzdtzv2btm4p7s5j',
                    collectDeviceData: true,
                    googlePaymentRequest: BraintreeGooglePaymentRequest(
                      totalPrice: '4.20',
                      currencyCode: 'USD',
                      billingAddressRequired: false,
                    ),
                    paypalRequest: BraintreePayPalRequest(
                      amount: '4.20',
                      displayName: 'Example company',
                    ),
                  );
                  BraintreeDropInResult result =
                      await BraintreeDropIn.start(request);
                  setState(() {
                    if (result == null) {
                      _text = 'Selection canceled';
                    } else {
                      _text = 'Nonce: ${result.paymentMethodNonce.nonce}\n\n'
                          'Nonce label: ${result.paymentMethodNonce.typeLabel}\n\n'
                          'Nonce description: ${result.paymentMethodNonce.description}\n\n'
                          'Device data: ${result.deviceData}';
                    }
                  });
                },
                child: Text(
                  'SELECT PAYMENT METHOD',
                ),
              ),
              Padding(
                padding: EdgeInsets.all(16.0),
                child: Text(_text, textAlign: TextAlign.center),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
107
likes
100
pub points
92%
popularity

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_braintree