juicyway_flutter 1.2.0 copy "juicyway_flutter: ^1.2.0" to clipboard
juicyway_flutter: ^1.2.0 copied to clipboard

Official Juicyway Flutter SDK

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:juicyway_flutter/juicyway_flutter.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Juicyway Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Juicyway Flutter SDK'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, this.title});

  final String? title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: Text(
          widget.title ?? '',
          style: const TextStyle(
            color: Colors.black,
            fontSize: 18,
          ),
        ),
        backgroundColor: Colors.white,
      ),
      backgroundColor: Colors.white,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const SizedBox(height: 60),
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  height: 60,
                  margin: const EdgeInsets.symmetric(horizontal: 30),
                  child: CupertinoButton(
                    color: Colors.green,
                    onPressed: openJuicywayCheckout,
                    child: const Center(
                      child: Text(
                        'Launch Checkout',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 13,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
                const SizedBox(height: 60),
              ],
            ),
          ],
        ),
      ),
    );
  }

  void openJuicywayCheckout() async {
    const options = JuicyWayChekoutOptions(
      amount: 6000,
      currency: JuicyWayCurrency.USD,
      accountId: 'YOUR_ACCOUNT_ID',
      key: '',
      customer: JuicywayCustomer(
        billingAddress: JuicywayBillingAddress(
          city: 'Ikeja',
          countryCode: 'NG',
          line1: 'Sample Address here...',
          state: 'Lagos',
          zipCode: '101251',
        ),
        email: 'test@example.com',
        firstName: 'John',
        lastName: 'Doe',
        phoneNumber: '+234...........',
      ),
      paymentMethod: PaymentMethod.card,
    );

    await JuicywayCheckoutView(
      options: options,
      showLogs: true,
      onClosed: () {
        log('closed');
        Navigator.pop(context);
      },
      onSuccess: (data) {
        log(data.toString());
        Navigator.pop(context);
      },
      onError: print,
    ).show(context);
  }
}
0
likes
150
points
87
downloads

Publisher

unverified uploader

Weekly Downloads

Official Juicyway Flutter SDK

Homepage
Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

connectivity_plus, equatable, flutter, url_launcher, uuid, webview_flutter

More

Packages that depend on juicyway_flutter