payu_ppi_flutter 1.0.0 copy "payu_ppi_flutter: ^1.0.0" to clipboard
payu_ppi_flutter: ^1.0.0 copied to clipboard

The PPI for Flutter provides a complete Mobile solution for the Flutter App and allows you to integrate Virtual CARD DISPLAY POWERED BY PayU for iOS and Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:payu_ppi_flutter_example/HashService.dart';
import 'package:payu_ppi_flutter/payu_ppi_flutter.dart';
import 'package:payu_ppi_flutter/PayUConstantKeys.dart';


void main() {
  runApp(MaterialApp(home: MyApp()));
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> implements PayUPPIProtocol {
  
  late PayUPPIFlutter _ppi;

  @override
  void initState() {
    super.initState();
      _ppi = PayUPPIFlutter(this);
  }

   @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('PayU PPI SDK'),
        ),
        body: Center(
          child: ElevatedButton(
            child: const Text("Show Cards"),
            onPressed: () async {
              _ppi.showCards(
                payUPPIParams: PayUParams.createPayUPPIParams()
              );
            },
          ),
        ),
      ),
    );
  }

  showAlertDialog(BuildContext context, String title, String content) {
    Widget okButton = TextButton(
      child: const Text("OK"),
      onPressed: () {
        Navigator.pop(context);
      },
    );

    showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text(title),
            content: SingleChildScrollView(
              scrollDirection: Axis.vertical,

              child: new Text(content),
            ),
            actions: [okButton],
          );
        });
  }

  @override
  generateHash(Map response) {
    // Pass response param to your backend server
    // Backend will generate the hash and will callback to
    Map hashResponse = HashService.generateHash(response);
    _ppi.hashGenerated(hash: hashResponse);
  }

  @override
  onCancel() {
    showAlertDialog(context, "onCancel", "Cancel By user");
  }

  @override
  onError(Map? response) {
    showAlertDialog(context, "onError", response.toString());
  }
}

class PayUTestCredentials { 
  static const merchantKey = "smsplus";//TODO: Add Merchant Key
  //Use your success and fail URL's.
}

//Pass these values from your app to SDK, this data is only for test purpose
class PayUParams {
  static Map createPayUPPIParams() {
    var payUParams = {
      PayUPPIParamKey.merchantKey: PayUTestCredentials.merchantKey,
      PayUPPIParamKey.referenceId: "payu${DateTime.now().millisecondsSinceEpoch}", // inCase of skudDetails pass amount equal to total skuAmount
      PayUPPIParamKey.walletUrn: "1003097",
      PayUPPIParamKey.environment: "0",
      PayUPPIParamKey.walletIdentifier: "OLW",
      PayUPPIParamKey.mobileNumber: "9528340384"
    };

    return payUParams;
  }
}
2
likes
0
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

The PPI for Flutter provides a complete Mobile solution for the Flutter App and allows you to integrate Virtual CARD DISPLAY POWERED BY PayU for iOS and Android.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on payu_ppi_flutter

Packages that implement payu_ppi_flutter