パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリtomykho/midtrans_sdk

midtrans_sdk

Flutter用MidtransモバイルSDK。

midtrans_sdk のプロジェクト画像
スター
25
フォーク
35
最終プッシュ(UTC)
2025/11/13
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

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",
);
Tomy Kho GitHub avatar
GitHub 作者

Tomy Kho ↗

@esseplore Batam, Indonesia
言語DartKotlinObjective-CRubyHTMLJava

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 2 件

  • flutter{"sdk":"flutter"}
  • flutter_test開発用{"sdk":"flutter"}

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗