Search packages, repositories and app categories

Package detailsv1.2.0

midtrans_sdk

A Flutter plugin for Midtrans Mobile SDK. Supports iOS and Android.

AndroidiOS
30-day downloads
102
Likes
26
Pub points
140

Install package

flutter pub add midtrans_sdk

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The midtrans_sdk is a Flutter plugin that integrates the Midtrans Mobile SDK into Android and iOS applications, enabling seamless in-app payment processing. It provides a straightforward interface for initiating payments, handling transaction callbacks, and managing payment flows securely. Designed for developers looking to add reliable payment functionality to their Flutter apps, it supports various payment methods available through Midtrans, including credit cards, e-wallets, and bank transfers. The plugin ensures compatibility with both major mobile platforms and simplifies integration with Midtrans' backend services.

Use cases

  • In-app purchases
  • E-commerce checkout
  • Mobile wallet integration
  • Subscription billing
  • Digital service payments

Key features

  • Supports Android and iOS
  • Secure payment processing
  • Transaction callback handling
  • Easy integration with Midtrans
  • Real-time payment status updates

Suitable for

  • Flutter developers building e-commerce apps
  • Apps requiring multiple payment methods
  • Developers using Midtrans as a payment gateway
  • Startups needing fast payment integration
  • Mobile apps targeting Southeast Asian markets

Considerations

  • Requires a Midtrans account
  • Needs proper API key configuration
  • Depends on native SDKs for full functionality
  • May require additional setup for sandbox testing
  • Limited to Midtrans-supported regions

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

midtrans_sdk

A Flutter plugin for Midtrans Mobile SDK. Visit https://midtrans.com.

pub package


Supported Platforms

  • [x] Android
  • [x] iOS
  • [ ] Web

Usage

To use this plugin, add midtrans_sdk as a dependency in your pubspec.yaml file.

Getting started

See the example directory for a sample about start payment by using snap token which using midtrans_sdk.

Android
  • If you are using FlutterActivity directly, change it to FlutterFragmentActivity in your AndroidManifest.xml.
  • If you are using a custom activity, update your MainActivity.java:
import io.flutter.embedding.android.FlutterFragmentActivity;

public class MainActivity extends FlutterFragmentActivity {
    // ...
}

or MainActivity.kt:

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() {
    // ...
}

MidtransConfig

To start using Midtrans you first need to create an instance of MidtransSDK before using any other of our sdk functionalities.
MidtransSDK receives a MidtransConfig object. This is how you can configure our MidtransSDK instance and connect it to your Midtrans account.

Example:

import 'package:midtrans_sdk/midtrans_sdk.dart';

var config = MidtransConfig(
  clientKey: "",
  merchantBaseUrl: "",
  colorTheme: ColorTheme(
    colorPrimary: Theme.of(context).colorScheme.primary,
    colorPrimaryDark: Theme.of(context).colorScheme.primary,
    colorSecondary: Theme.of(context).colorScheme.secondary,
  ),
);

Initializing the SDK

The next step is to call init which have the required MidtransConfig object parameter config. After we call init we can use all of Midtrans SDK features. Initialize the SDK to enable Midtrans to start payment.

MidtransSDK.init(
    config: config,
);

Starting payment

Start payment method screen

Default mode for midtrans_sdk is showing payment method screen. This screen will show all of your available payment methods. You can enable/disable payment methods via Snap Preferences in MAP.

Start payment by using snap token

We provide SDK method to allow you to make payment by using snap token without initialize transaction request first. You just need to pass snap token as argument of startPaymentUiFlow method.

_midtrans?.startPaymentUiFlow(
    token: "snap-token",
);

Categories

Source repository

Projects using this package

No data available yet.