uni_pay 1.1.5 copy "uni_pay: ^1.1.5" to clipboard
uni_pay: ^1.1.5 copied to clipboard

PlatformiOS

A library for making online payment by using Moyasar and Tamara payment gateway

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'UniPay Example',
      home: PaymentView(),
    );
  }
}

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

  @override
  State<PaymentView> createState() => _PaymentViewState();
}

class _PaymentViewState extends State<PaymentView> {
  @override
  Widget build(BuildContext context) {
    return UniPay(
      context: context,
      uniPayData: UniPayData(
        appName: "UniPay",
        locale: UniPayLocale.en,
        customerInfo: UniPayCustomerInfo(
          fullName: "Mohammad Saif",
          email: "example@mail.com",
          phoneNumber: "+966555666777",
          address: UniPayAddress(addressName: "Test Address", city: "Riyadh"),
        ),
        environment: UniPayEnvironment.development,
        credentials: UniPayCredentials(
          applePayMerchantIdentifier: "merchant.com.mystore.sa",
          paymentMethods: [
            UniPayPaymentMethods.card,
            UniPayPaymentMethods.applepay,
            UniPayPaymentMethods.tamara,
          ],
          moyasarCredential:
              MoyasarCredential(publishableKey: "pk_key", secretKey: "sk_key"),
          tamaraCredential: TamaraCredential(
            token: "Bearer TAMARA_TOKEN",
            merchantUrl:
                MerchantUrl(notification: "https://my-app.com/webhook"),
          ),
        ),
        orderInfo: UniPayOrder(
          transactionAmount: TransactionAmount(totalAmount: 150.55),
          orderId: DateTime.now().millisecondsSinceEpoch.toString(),
          description: "Test Order Description",
          items: [
            UniPayItem(
              id: "Product_ID",
              name: "Product name",
              quantity: 1,
              price: 50,
            )
          ],
        ),
        onPaymentSucess: (res) {
          debugPrint("Payment Success ----> ${res.toMap()}");
        },
        onPaymentFailed: (res) {
          debugPrint("Payment Failed ----> ${res.toMap()}");
        },
      ),
    );
  }
}
4
likes
140
pub points
56%
popularity

Publisher

verified publisherunicodesolutions.co

A library for making online payment by using Moyasar and Tamara payment gateway

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_inappwebview, flutter_localizations, http, lottie, moyasar

More

Packages that depend on uni_pay