paypal_webview 0.0.6 copy "paypal_webview: ^0.0.6" to clipboard
paypal_webview: ^0.0.6 copied to clipboard

Optimize your Flutter app's payment journey using the PayPal Flutter Package v2. Effortlessly incorporate the latest PayPal APIs for secure transactions, with the added flexibility to test using sandb [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:paypal_webview/Models/md_paypal.dart';
import 'package:paypal_webview/Models/md_purchase_items.dart';
import 'package:paypal_webview/paypal_webview.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  /// Create list using MDPurchaseItems Model for generating order against your products
  List<MDPurchaseItems> purchaseItems = [
    MDPurchaseItems(
        name: 'T-Shirt',
        description: 'Green XL',
        quantity: '1',
        unitAmount: UnitAmount(currencyCode: 'CAD', value: '10')),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0xFFFFFF),
        elevation: 3,
        title: Text('PayPal Demo Screen'),
        centerTitle: true,
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            Navigator.of(context)
                .push(
              MaterialPageRoute(
                builder: (context) => PayPalWebView(
                  /// you will find the client Id after login to paypal developer account .
                  clientId: 'ATBV7KdKvDd9sGHYL4*******************************',

                  /// you will find the secret key after login to paypal developer account .
                  secretKey:
                      'EEitYKcFpiUCXplgxm*******************************',
                  currencyCode: 'CAD',
                  totalAmount: '10',
                  purchaseItems: purchaseItems,

                  /// sandboxMode true for testing purposes
                  sandboxMode: true,
                ),
              ),
            )
                .then((value) async {
              if (value != null) {
                /// After Successful Transaction you will receive MDPayPal Model type Data from which paymentId is use to verify payments
                MDPayPal paypal = value;
                print("The paypal Token is:" + paypal.token.toString());
                print("the paypal payer id is:" + paypal.payerID.toString());
                print("The paypal id is: " + paypal.paymentId.toString());
              }
            });
          },
          style: ElevatedButton.styleFrom(
            backgroundColor: Color(0xff252C39), // Background color
            elevation: 2,
          ),
          child: Text(
            'PayPal',
            style: TextStyle(
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
110
pub points
51%
popularity

Publisher

unverified uploader

Optimize your Flutter app's payment journey using the PayPal Flutter Package v2. Effortlessly incorporate the latest PayPal APIs for secure transactions, with the added flexibility to test using sandbox accounts and seamlessly transition to live credentials for production environments.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, lottie, webview_flutter, webview_flutter_android, webview_flutter_wkwebview

More

Packages that depend on paypal_webview