mdtrans 1.1.5 copy "mdtrans: ^1.1.5" to clipboard
mdtrans: ^1.1.5 copied to clipboard

Plugin for Midtrans payment gateway.

Midtrans Payment Gateway for Flutter #

Flutter Midtrans Payment Plugin

Please Read Midtrans Documentation before use this library and make sure you are already has Midtrans account for accessing the dashboard.

Android setup #

Only support AndroidX and compile targe minimum 28

Add style to your android/app/src/main/res/values/styles.xml :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
copied to clipboard

And full styles.xml will be like below :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
</resources>
copied to clipboard

And add the style to you Android Manifest in your application tag :

android:theme="@style/AppTheme"
copied to clipboard

IOS #

No specific setup required

Example usage #

Make sure you are already prepare these variables.

  • YOUR_CLIENT_ID: Midtrans CLIENT ID
  • YOUR_URL_BASE: Your backend URL base API to process payment
import 'package:mdtrans/mdtrans.dart';
...
final mdtrans = Mdtrans();

//Init the client ID you URL base
mdtrans.init("YOUR_CLIENT_ID", "YOUR_URL_BASE");

//Setup the callback when payment finished
mdtrans.setFinishCallback((finished) {
    //finished is TransactionFinished
});

//Make payment
mdtrans
.makePayment(
    MidtransTransaction(
        7500,
        MidtransCustomer(
            "Apin", "Prastya", "apin.klas@gmail.com", "08123456789"),
        [
        MidtransItem(
            "5c18ea1256f67560cb6a00cdde3c3c7a81026c29",
            7500,
            2,
            "USB FlashDisk",
        )
        ],
        skipCustomer: true,
        customField1: "ANYCUSTOMFIELD"),
)
.catchError((err) => print("ERROR $err"));
copied to clipboard
1
likes
130
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

2024.07.06 - 2025.01.18

Plugin for Midtrans payment gateway.

Homepage

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on mdtrans