testpackage_fraudsdk 1.0.4 copy "testpackage_fraudsdk: ^1.0.4" to clipboard
testpackage_fraudsdk: ^1.0.4 copied to clipboard

PlatformAndroid

The SDK detects device risks like rooting, VPNs, and remote access, providing insights to enhance fraud protection.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:testpackage_fraudsdk/testpackage_fraudsdk.dart';
import 'package:testpackage_fraudsdk/model/options.dart';
import 'package:testpackage_fraudsdk/model/update_options.dart';
import 'package:testpackage_fraudsdk_example/utils/log.dart';

import 'json_viewer.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  const MyApp();

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

class _MyAppState extends State<MyApp> {
  String initValue = "";
  String stop = "";
  String sessionID = "";
  var jsonData = Map<String, dynamic>();

  @override
  void initState() {
    super.initState();
    initSign3Sdk();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Sign3 SDK Flutter'),
        ),
        body: SingleChildScrollView(
          physics: BouncingScrollPhysics(),
          scrollDirection: Axis.vertical,
          child: Container(
            child: Column(
              children: [
                Text("INIT: $initValue"),
                Text("STOP: $stop"),
                Text("SESSION ID: $sessionID"),

                SingleChildScrollView(
                  scrollDirection: Axis.horizontal,
                  child: Row(
                    children: [
                      ElevatedButton(
                          onPressed: () async {
                            await initSign3Sdk();
                          },
                          child: const Text("Init Sdk")
                      ),
                      ElevatedButton(
                          onPressed: () async {
                            await getIntelligence();
                          },
                          child: const Text("Get Intelligence")
                      ),
                      ElevatedButton(
                          onPressed: () async {
                            showCustomDialog(context);
                          },
                          child: const Text("Update Options")
                      ),
                    ],
                  ),
                ),
                Container(
                  height: jsonData.keys.length * JsonViewer.textSize * 40 ,
                  child: Padding (
                    padding: const EdgeInsets.all(8.0),
                    child: JsonViewer(jsonData: jsonData),
                  ),
                ),
                SizedBox(
                  width: 1,
                  height: 50,
                  child: Container(),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  void showCustomDialog(BuildContext context) {
    TextEditingController phoneController = TextEditingController();
    TextEditingController idController = TextEditingController();

    showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: const Text('Update Options'),
          content: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              TextField(
                controller: phoneController,
                decoration: const InputDecoration(
                  labelText: 'Set Phone Number',
                ),
                keyboardType: TextInputType.number, // Set to number input type
              ),
              const SizedBox(height: 10),
              TextField(
                controller: idController,
                decoration: const InputDecoration(
                  labelText: 'Set ID',
                ),
                keyboardType: TextInputType.number, // Set to number input type
              ),
            ],
          ),
          actions: [
            ElevatedButton(
              onPressed: () async {
                if (phoneController.text.isEmpty || idController.text.isEmpty) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(
                      content: Text('Both fields must be filled out.'),
                    ),
                  );
                  return;
                }
                await updateOptions(getUpdatedOptions(phoneController.text, idController.text));
                await getIntelligence();
                Navigator.of(context).pop();
              },
              child: const Text('Update Options'),
            ),
          ],
        );
      },
    );
  }

  UpdateOptions getUpdatedOptions(String phone, String id) {
    Map<String, String> additionalAttributes = {
      "TRANSACTION_ID": "76381256165476154713",
      "DEPOSIT": "5000",
      "WITHDRAWAL": "2000",
      "METHOD": "UPI",
      "STATUS": "SUCCESS",
      "CURRENCY": "INR",
      "TIMESTAMP": DateTime.now().millisecondsSinceEpoch.toString(),
    };

    UpdateOptions updateOptions = UpdateOptionsBuilder()
        .setPhoneNumber(phone)
        .setUserId(id)
        .setPhoneInputType(PhoneInputType.GOOGLE_HINT)
        .setOtpInputType(OtpInputType.AUTO_FILLED)
        .setUserEventType(UserEventType.TRANSACTION)
        .setMerchantId("1234567890")
        .setAdditionalAttributes(additionalAttributes)
        .build();
    return updateOptions;
  }

  Future<void> initSign3Sdk() async {
    var init = await Sign3Intelligence.isSdkInitialized();
    var stopResult = await Sign3Intelligence.stop();
    var id = await Sign3Intelligence.getSessionId();
    setState(() {
      initValue = init.toString();
      stop = stopResult.toString();
      sessionID = id;
    });
  }

  Future<void> getIntelligence() async {
    try {
      var intelligence = await Sign3Intelligence.getIntelligence();
      var id = await Sign3Intelligence.getSessionId();
      setState(() {
        jsonData = intelligence.toJson();
        sessionID = id;
        initValue = "true";
      });
      Log.i("TAG_GET_INTELLIGENCE", intelligence.toJson().toString());
    } catch (e) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text(e.toString()),
        ),
      );
      Log.i("TAG_GET_INTELLIGENCE_ERROR", e.toString());
    }
  }

  Future<void> updateOptions(UpdateOptions options) async {
    await Sign3Intelligence.updateOptions(options);
  }
}
0
likes
120
points
222
downloads

Publisher

unverified uploader

Weekly Downloads

The SDK detects device risks like rooting, VPNs, and remote access, providing insights to enhance fraud protection.

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

flutter

More

Packages that depend on testpackage_fraudsdk