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

插件详情v2.0.2

momo_vn

集成开放的 MoMo.VN 应用程序进行支付。完成后,系统将记录成功或失败的数据,并据此处理下一步。

AndroidiOS
近 30 天下载
27
喜欢数
30
Pub 分数
120

安装插件

flutter pub add momo_vn

插件介绍

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

momo_vn 包使 Android 和 iOS 上的 MoMo.VN 移动支付应用集成成为可能,允许用户通过开放的 MoMo 应用完成交易。支付处理完成后,该包会记录成功或失败状态,从而便于自动处理后续步骤,如订单确认或错误恢复。它通过利用 MoMo 已建立的支付基础设施,简化了安全的内应用支付。

适合场景

  • 应用内购买
  • 电子商务结账
  • 数字服务订阅
  • 支付跟踪和日志记录
  • 移动钱包集成

主要特点

  • 无缝启动MoMo应用
  • 事务状态记录
  • 成功/失败事件处理
  • 跨平台支持(Android 和 iOS)
  • 通过 Flutter pub 简单集成

适合对象

  • 需要MoMo支付的Flutter应用
  • 面向越南市场的开发者
  • 具有实时支付验证的应用程序
  • 使用MoMo作为主要支付方式的企业
  • 需要最少设置的移动支付项目

使用建议

  • 需要在用户设备上安装MoMo应用
  • 仅限MoMo.VN生态系统
  • 依赖外部应用程序的行为
  • 不支持离线交易
  • 用户必须在MoMo应用中确认付款

原始 README

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

momo_vn

Getting Started

  • Need register your application at momo business home page : https://business.momo.vn, detail: https://developers.momo.vn/#/home?id=t%c3%a0i-kho%e1%ba%a3n-doanh-nghi%e1%bb%87p
  • Download testapp, test account at: https://developers.momo.vn/#/docs/testing_information
1. Android set up:
  • Step 1: Request Internet permission at AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
2. iOS set up:
  • Step 1: Update Info.plist file as below:
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLName</key>
    <string></string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>partnerSchemeId</string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>momo</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
  • Step 2: Define call back url for momo at AppDelegate.swift file:
import momo_vn
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        MoMoPayment.handleOpenUrl(url: url, sourceApp: sourceApplication!)
        return true
    }

override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        MoMoPayment.handleOpenUrl(url: url, sourceApp: "")
        return true
    }
See more setup at: https://developers.momo.vn/#/

Usage

  • Import
import 'package:momo_vn/momo_vn.dart';
  • Init
 void initState() {
    super.initState();
    _momoPay = MomoVn();
    _momoPay.on(MomoVn.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
    _momoPay.on(MomoVn.EVENT_PAYMENT_ERROR, _handlePaymentError);
    initPlatformState();
  }
  • Create data Object
MomoPaymentInfo options = MomoPaymentInfo(
    merchantname: "Tên đối tác",
    merchantcode: 'Mã đối tác',
    appScheme: "1221212",
    amount: 6000000000,
    orderId: '12321312',
    orderLabel: 'Label để hiển thị Mã giao dịch',
    merchantnamelabel: "Tiêu đề tên cửa hàng",
    fee: 0,
    description: 'Mô tả chi tiết',
    username: 'Định danh user (id/email/...)',
    partner: 'merchant',
    extra: "{\"key1\":\"value1\",\"key2\":\"value2\"}",
    isTestMode: true
);
  • Open MoMo application
try {
    _momoPay.open(options);
  } catch (e) {
    debugPrint(e);
  }
  • Get result
void _setState() {
    _payment_status = 'Đã chuyển thanh toán';
    if (_momoPaymentResult.isSuccess) {
      _payment_status += "\nTình trạng: Thành công.";
      _payment_status += "\nSố điện thoại: " + _momoPaymentResult.phonenumber;
      _payment_status += "\nExtra: " + _momoPaymentResult.extra;
      _payment_status += "\nToken: " + _momoPaymentResult.token;
    }
    else {
      _payment_status += "\nTình trạng: Thất bại.";
      _payment_status += "\nExtra: " + _momoPaymentResult.extra;
      _payment_status += "\nMã lỗi: " + _momoPaymentResult.status.toString();
    }
  }
  void _handlePaymentSuccess(PaymentResponse response) {
    setState(() {
      _momoPaymentResult = response;
      _setState();
    });
    Fluttertoast.showToast(msg: "THÀNH CÔNG: " + response.phonenumber, timeInSecForIos: 4);
  }

  void _handlePaymentError(PaymentResponse response) {
    setState(() {
      _momoPaymentResult = response;
      _setState();
    });
    Fluttertoast.showToast(msg: "THẤT BẠI: " + response.message.toString(), timeInSecForIos: 4);
  }

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目