paytm_allinonesdk 1.1.3-beta copy "paytm_allinonesdk: ^1.1.3-beta" to clipboard
paytm_allinonesdk: ^1.1.3-beta copied to clipboard

outdated

Paytm All-in-One SDK provides a swift, secure, and seamless payment experience to your users by invoking the Paytm app (if installed on your user’s smartphone) to complete payment for your order. It e [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:paytm_allinonesdk/callback_result_listener.dart';
import 'package:paytm_allinonesdk/paytm_allinonesdk.dart';
import './edit_text.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.dark),
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter App'),
        ),
        body: HomeScreen(),
      ),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _HomeScreenState();
  }
}

class _HomeScreenState extends State<HomeScreen>
    implements CallbackResultListener {
  String mid = "", orderId = "", amount = "", txnToken = "";
  String response = "";
  bool isStaging = false;
  bool isApiCallInprogress = false;
  String callbackUrl = "";
  bool restrictAppInvoke = false;
  bool enableAssist = true;
  @override
  void initState() {
    print("initState");
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Card(
      child: SingleChildScrollView(
        child: Container(
          margin: EdgeInsets.all(8),
          child: Column(
            children: <Widget>[
              EditText('Merchant ID', mid, onChange: (val) => mid = val),
              EditText('Order ID', orderId, onChange: (val) => orderId = val),
              EditText('Amount', amount, onChange: (val) => amount = val),
              EditText('Transaction Token', txnToken,
                  onChange: (val) => txnToken = val),
              Row(
                children: <Widget>[
                  Checkbox(
                      activeColor: Theme.of(context).buttonColor,
                      value: isStaging,
                      onChanged: (bool? val) {
                        setState(() {
                          isStaging = val!;
                        });
                      }),
                  Text("Staging")
                ],
              ),
              Row(
                children: <Widget>[
                  Checkbox(
                      activeColor: Theme.of(context).buttonColor,
                      value: restrictAppInvoke,
                      onChanged: (bool? val) {
                        setState(() {
                          restrictAppInvoke = val!;
                        });
                      }),
                  Text("Restrict AppInvoke")
                ],
              ),
              Container(
                margin: EdgeInsets.all(16),
                child: ElevatedButton(
                  onPressed: isApiCallInprogress
                      ? null
                      : () {
                          _startTransaction();
                        },
                  child: Text('Start Transcation'),
                ),
              ),
              Container(
                alignment: Alignment.bottomLeft,
                child: Text("Message : "),
              ),
              Container(
                child: Text(response),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> _startTransaction() async {
    if (txnToken.isEmpty) {
      return;
    }
    var sendMap = <String, dynamic>{
      "mid": mid,
      "orderId": orderId,
      "amount": amount,
      "txnToken": txnToken,
      "callbackUrl": callbackUrl,
      "isStaging": isStaging,
      "restrictAppInvoke": restrictAppInvoke,
      "enableAssist": enableAssist
    };
    print(sendMap);
    try {
      //enableAssist is optional parameter
      AllInOneSdk().startTransaction(mid, orderId, amount, txnToken, "",
          isStaging, restrictAppInvoke, this, enableAssist);
    } catch (err) {
      response = err.toString();
    }
  }

  @override
  void onError(String message, Map? result) {
    print(message + " \n  " + result.toString());
    setState(() {
      response = message + " \n  " + result.toString();
    });
  }

  @override
  void onSuccess(Map? result) {
    print(result);
    setState(() {
      response = result.toString();
    });
  }
}
49
likes
0
pub points
98%
popularity

Publisher

unverified uploader

Paytm All-in-One SDK provides a swift, secure, and seamless payment experience to your users by invoking the Paytm app (if installed on your user’s smartphone) to complete payment for your order. It enables you to accept payment via Paytm Wallet, Paytm Payments Bank, Saved Debit/Credit Cards, Net Banking, BHIM UPI, or EMI as available in your customer’s Paytm account. If the Paytm app is not installed on a customer's device, the transaction will be processed via web view within the All-in-One SDK.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on paytm_allinonesdk