搜索插件、代码仓与 APP 分类

插件详情v1.2.0

midtrans_sdk

Midtrans 移动 SDK 的 Flutter 插件。支持 iOS 和 Android。

AndroidiOS
近 30 天下载
102
喜欢数
26
Pub 分数
140

安装插件

flutter pub add midtrans_sdk

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

midtrans_sdk 是一个 Flutter 插件,可将 Midtrans 移动 SDK 集成到 Android 和 iOS 应用程序中,实现无缝的内应用支付处理。它提供了一个简单的接口,用于启动支付、处理交易回调以及安全地管理支付流程。专为希望为其 Flutter 应用添加可靠支付功能的开发者设计,支持 Midtrans 提供的各种支付方式,包括信用卡、电子钱包和银行转账。该插件确保与两大主要移动平台兼容,并简化了与 Midtrans 后端服务的集成。

适合场景

  • 应用内购买
  • 电子商务结账
  • 移动钱包集成
  • 订阅计费
  • 数字服务付款

主要特点

  • 支持 Android 和 iOS
  • 安全支付处理
  • 事务回调处理
  • 与 Midtrans 的轻松集成
  • 实时支付状态更新

适合对象

  • Flutter 开发人员构建电子商务应用
  • 需要多种支付方式的应用程序
  • 使用 Midtrans 作为支付网关的开发者
  • 需要快速支付集成的初创企业
  • 面向东南亚市场的移动应用

使用建议

  • 需要一个 Midtrans 账户
  • 需要正确的 API 密钥配置
  • 依赖原生 SDK 以实现完整功能
  • 沙盒测试可能需要额外的设置
  • 仅限支持的Midtrans地区

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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",
);

所属分类

源码仓库

使用此插件的项目

暂无相关数据。