maswend_payment 0.0.2 copy "maswend_payment: ^0.0.2" to clipboard
maswend_payment: ^0.0.2 copied to clipboard

Midtrans Plugin

example/lib/main.dart

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

void main() => runApp(new MyApp());

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

class _MyAppState extends State<MyApp> {
  bool isMakePayment = false;
  @override
  void initState() {
    super.initState();
    MaswendPayment.instance.init(
        "SB-Mid-client-nxIV6qUGgjz-1ACh", "https://edenvidiapi.herokuapp.com");
    MaswendPayment.instance.setTransactionFinishedCallback(_callback);
  }

  _makePayment() {
    setState(() {
      isMakePayment = true;
    });
    MaswendPayment.instance
        .makePayment(MidtransTransaction(
          transaction_id: new DateTime.now().toString(),
          user_id: '42fd18bd-76c0-4f71-875f-2f8b4c3b76ba',
          total: 14000,
          customer: new MidtransCustomer(
              "abc", "def", "abcdef@abcdef.com", "08235847489"),
          items: [new MidtransItem("abc", 7000, 2, "Ale-ale")],
          skip_customer_details_page: true,
          show_email_in_cc_form: false,
          auto_read_sms: false,
          save_card_checked: false,
          show_payment_status: true,
        ))
        .catchError((err) => print("ERROR $err"));
  }

  Future<void> _callback(TransactionFinished finished) async {
    setState(() {
      isMakePayment = false;
    });
    return Future.value(null);
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: isMakePayment
              ? CircularProgressIndicator()
              : ElevatedButton(
                  child: Text("Make Payment"),
                  onPressed: () => _makePayment(),
                ),
        ),
      ),
    );
  }
}
1
likes
105
points
18
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Midtrans Plugin

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on maswend_payment