flutter_paypal_payment_plus 1.0.1 copy "flutter_paypal_payment_plus: ^1.0.1" to clipboard
flutter_paypal_payment_plus: ^1.0.1 copied to clipboard

This package simplifies integrating PayPal payments into your mobile app. Key features include seamless in-app PayPal integration

Flutter PayPal Payment Plus Package #

The Flutter PayPal Payment Plus Package offers a seamless and straightforward integration of PayPal Checkout into your Flutter mobile applications. Whether you're developing for sandbox testing or live production, this package enables a smooth and customizable checkout experience.


๐Ÿ“ฆ Features #

  • โœ… Seamless PayPal Integration: Simplified integration for PayPal payments within Flutter apps.
  • ๐Ÿงช Sandbox Mode Support: Easily toggle between sandbox and production environments.
  • ๐Ÿ’ณ Customizable Transactions: Define full transaction details including items, amounts, and descriptions.
  • ๐Ÿ”„ Payment Callbacks: Respond to success, error, or cancellation using intuitive callback handlers.

๐Ÿš€ Installation #

To get started, follow these steps:

1. Add the dependency: #

In your pubspec.yaml file:

dependencies:
  flutter_paypal_payment_plus: ^1.0.1

2. Fetch the package: #

flutter pub get

๐Ÿ› ๏ธ Usage #

1. Import the package #

import 'package:flutter_paypal_payment_plus/flutter_paypal_payment_plus.dart';

2. Use PaypalCheckoutView to initiate a payment: #

Below is a complete example:

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_paypal_payment_plus/flutter_paypal_payment_plus.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PaypalPaymentDemo',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: TextButton(
            child: const Text('Pay with PayPal'),
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (BuildContext context) => PaypalCheckoutView(
                    sandboxMode: true,
                    clientId: "YOUR_CLIENT_ID",
                    secretKey: "YOUR_SECRET_KEY",
                    returnURL: "YOUR_RETURN_URL",
                    cancelURL: "YOUR_CANCEL_URL",
                    transactions: const TransactionOption(
                      payPalAmount: PayPalAmount(
                        total: "100",
                        currency: "USD",
                        details: PaymentDetails(
                          subtotal: '100',
                          shipping: "0",
                          shippingDiscount: 0,
                        ),
                      ),
                      description: "The payment transaction description.",
                      itemList: ItemList(
                        items: [
                          Item(
                            name: "Apple",
                            quantity: 1,
                            price: "50",
                            currency: "USD",
                          ),
                          Item(
                            name: "Pineapple",
                            quantity: 5,
                            price: "10",
                            currency: "USD",
                          ),
                        ],
                      ),
                    ),
                    note: "Contact us for any questions on your order.",
                    onSuccess: (PaymentSuccessModel model) async {
                      log("onSuccess: ${model.toJson()}");
                      Navigator.pop(context);
                    },
                    onError: (error) {
                      log("onError: $error");
                      Navigator.pop(context);
                    },
                    onCancel: () {
                      print('Cancelled');
                      Navigator.pop(context);
                    },
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}

๐Ÿ“˜ Notes #

  • To obtain clientId and secretKey, register your app at PayPal Developer Dashboard.
  • This package is built on top of the WebView-based implementation of PayPal's Smart Payment Buttons.

๐Ÿ“„ License #

This package is open-source and available under the MIT License.


๐Ÿค Contributions #

Contributions, suggestions, and pull requests are welcome!
Feel free to open an issue if you find bugs or want new features.


2
likes
150
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

This package simplifies integrating PayPal payments into your mobile app. Key features include seamless in-app PayPal integration

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

dio, equatable, flutter, flutter_inappwebview

More

Packages that depend on flutter_paypal_payment_plus