midpay 0.0.1-dev.1 midpay: ^0.0.1-dev.1 copied to clipboard
An unofficial midtrans payment plugin for flutter.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:midpay/midpay.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
final midpay = Midpay();
@override
void initState() {
super.initState();
midpay.init("SB-Mid-client-9Uuc57SxiDzsZstV", "https://market.dorun.id/public/",environment: Environment.sanbox);
midpay.setFinishCallback(_callback);
}
_makePayment() {
midpay
.makePayment(
MidtransTransaction(
100000,
MidtransCustomer(
"Zaki", "Mubarok", "kakzakis@gmail.com", "085704703691"),
[
MidtransItem(
"IDXXX",
50000,
2,
"Charger",
)
],
skipCustomer: true,
customField1: "ANYCUSTOMFIELD"),
)
.catchError((err) => print("ERROR $err"));
}
Future<void> _callback(TransactionFinished finished) async {
return Future.value(null);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Midpay Plugin example app'),
),
body: new Center(
child: RaisedButton(
child: Text("Payment"),
onPressed: () => _makePayment(),
),
),
),
);
}
}