flutter_paypal_payment_checkout_v2 2.0.1 copy "flutter_paypal_payment_checkout_v2: ^2.0.1" to clipboard
flutter_paypal_payment_checkout_v2: ^2.0.1 copied to clipboard

retracted

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

Flutter PayPal Payment #

A powerful, easy-to-use Flutter package that enables seamless PayPal checkout flows using:

  • PayPal Payments / Orders API V2 (recommended)
  • Legacy Payments API V1 (deprecated by PayPal, but still supported)

This package supports:

  • Secure backend-driven order creation
  • Client-side sandbox testing
  • In-app WebView checkout experience
  • Custom transaction models
  • Full capture flow for PayPal V2

✨ Features #

  • πŸ”’ Production-ready PayPal V2 flow (backend creates + captures order)
  • πŸ§ͺ Sandbox testing mode
  • βš™οΈ Full PayPal Orders API V2 request/response models
  • πŸ’³ Line items, shipping, taxes, preferences & more
  • 🌐 Custom return & cancel URL schemes (e.g., paypal-sdk://success)
  • 🎯 Callbacks for success, error, cancellation
  • πŸš€ Supports PayPal API V1 for backward compatibility

πŸ“¦ Installation #

Add to pubspec.yaml:

dependencies:
  flutter_paypal_payment_checkout_v2: ^2.0.1

Install:

flutter pub get

πŸš€ Usage #

You can choose between:


βœ… Using PayPal API V2 (Recommended) #

V2 supports modern PayPal features, is more secure, and is PayPal’s officially recommended API.

Secure Backend Flow #

πŸ” In production, you MUST create and capture orders on your backend. Your backend returns only the approval URL.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => PaypalCheckoutViewV2(
      sandboxMode: true,

      /// Recommended: backend returns approval URL
      approvalUrl: () async {
        // Your backend should return a full checkout URL
        return await myBackend.createPaypalOrder();
      },

      /// Called when user finishes checkout and redirects back to app
      onSuccess: (result) {
        print("Payment success: $result");
        Navigator.pop(context);
      },

      onError: (error) {
        print("Error: $error");
        Navigator.pop(context);
      },

      onCancel: () {
        print("Payment cancelled");
        Navigator.pop(context);
      },
    ),
  ),
);

Client-Side Flow (Sandbox Only) #

⚠️ Never use this in production. It exposes your PayPal clientId + secretKey.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => PaypalCheckoutViewV2(
      sandboxMode: true,
      clientId: "SANDBOX_CLIENT_ID",
      secretKey: "SANDBOX_SECRET_KEY",
      overrideInsecureClientCredentials: true, // allow local tokens

      getAccessToken: () async => null,

      transactions: PayPalOrderRequestV2(
        intent: PayPalOrderIntent.capture,
        // amount, items, shipping, etc...
      ),

      onSuccess: (PayPalCaptureOrderResponse res) {
        print("Captured: ${res.status}");
      },

      onError: (error) => print(error),
      onCancel: () => print("Cancelled"),
    ),
  ),
);

🟑 Legacy PayPal V1 Checkout (Optional) #

PayPal V1 is older and deprecated, but supported for compatibility.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => PaypalCheckoutViewV1(
      sandboxMode: true,
      clientId: "ONLY FOR SANDBOX",
      secretKey: "ONLY FOR SANDBOX",
      getAccessToken: null,   // MUST be handled by your backend in live mode

      transactions: PaypalTransactionV1(
        amount: PaypalTransactionV1Amount(
          subTotal: 100.0,
          tax: 0.0,
          shipping: 0.0,
          handlingFee: 0.0,
          shippingDiscount: 0.0,
          insurance: 0.0,
          total: 100.0,
          currency: 'USD',
        ),
        description: "Order description",
        items: [
          PaypalTransactionV1Item(
            name: "Apple",
            quantity: 4,
            price: 10.0,
            tax: 0.0,
            currency: "USD",
            sku: "SKU_APPLE",
            description: "Fresh apples",
          ),
        ],
      ),

      onSuccess: (params) {
        print("Success: $params");
      },
      onError: (error) => print("Error: $error"),
      onCancel: () => print("Cancelled"),
    ),
  ),
);

πŸ” Security Notes (Important) #

DO NOT PUT YOUR PAYPAL SECRET KEY IN A MOBILE APP FOR PRODUCTION. #

Flutter code can be extracted even from release builds.

βœ” Use backend mode (approvalUrl) for all real payments βœ” Limit local credentials to sandbox only βœ” Set overrideInsecureClientCredentials only for testing


❀️ Donate #

If you would like to support this package:

PayPal: https://paypal.me/mazenelgayar

Thank you for your support!

3
likes
0
points
46
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)
View/report issues

License

unknown (license)

Dependencies

dartz, dio, flutter, flutter_inappwebview

More

Packages that depend on flutter_paypal_payment_checkout_v2