checkout_plugin 0.0.4 copy "checkout_plugin: ^0.0.4" to clipboard
checkout_plugin: ^0.0.4 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:checkout_plugin/checkout_plugin.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  late CheckoutPlugin _obj;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Checkout Plugin Sample App'),
        ),
        body: Center(
            child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
              RaisedButton(onPressed: openCheckout, child: Text('Pay'))
            ])),
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    _obj = CheckoutPlugin();
  }

  void openCheckout() async {
    var options = {
      'secureKey': 'yourSecureKey',
      'requestParameters': {
        'memberId': '1234567',
        'paymentMode': 'CC',
        'terminalId': '',
        'merchantTransactionId': 'uniqueOrderId',
        'amount': '1.00',
        'currency': 'USD',
        'toType': 'docspartner',
        'paymentBrand': 'VISA',
        'merchantRedirectUrl': 'https://www.merchantredirecturl.com',
        'tmplAmount': '1.00',
        'tmplCurrency': 'USD',
        'orderDescription': 'Test Transaction',
        'country': 'UK',
        'state': 'NA',
        'street': '19 Scrimshire Lane',
        'city': 'Aston',
        'email': 'abc@domain.com',
        'postCode': 'CH5 3LJ',
        'telnocc': '+44',
        'phone': '07730432996',
        'hostUrl': 'https://www.hostURL.com/',
        'device': 'ios' // depending on device ios/android
      }
    };

    try {
      _obj.clear();
      var event_success = CheckoutPlugin.EVENT_SUCCESS;
      var event_failed = CheckoutPlugin.EVENT_FAILED;

      _obj.on(event_success, _handlePaymentSuccess);
      _obj.on(event_failed, _handlePaymentFail);
      _obj.payment(options);
    } catch (e) {
      debugPrint('Error: e');
    }
  }

  @override
  void dispose() {
    super.dispose();
    _obj.clear();
  }

  void _handlePaymentSuccess(PaymentSuccessResponse response) {
    print('In Success Main' + response.response.toString());
    _obj.clear();
  }

  void _handlePaymentFail(PaymentFailureResponse response) {
    print('In Fail Main' + response.response.toString());
    _obj.clear();
  }
}
3
likes
130
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A new flutter plugin project.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

eventify, flutter, flutter_plugin_android_lifecycle

More

Packages that depend on checkout_plugin