Giter Site home page Giter Site logo

momo.vn's Introduction

momo_vn

Getting Started

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);
  }

momo.vn's People

Contributors

lamdev99 avatar minhvn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

momo.vn's Issues

phần đối tác

Anh Minh ơi. Mấy cái mã đối tác đồ mình phải đăg ký hay là có tài khoản để test vậy anh. Néu có thì a có thể cho e xin được không ạ

Chạy trên android 11 SDK 30 bị lỗi

Hôm nay mình gặp lỗi không khởi động được app Momo trên android, luôn mở google store, mặc dù app đã được cài đặt và trên IOS thì mọi thứ vẫn mượt mà (bản demo example vẫn mở được mà app mình thì không).

Sau một hồi tìm kiếm thì mình biết lý do là android 11 mặc định sẽ ẩn các package được cài đặt, cần thêm 2 dòng này vào manifest thì sẽ thấy app cài đặt và mở được app momo. (https://developer.android.com/training/package-visibility)
Minh gửi lại đây nếu anh em nào bị gặp lỗi như mình thì áp dụng nhé.

<manifest>
        <queries>
                <package android:name="com.mservice.momotransfer"/>
                <package android:name="vn.momo.platform.test"/>
        </queries>
<manifest/>

Không có chỗ config IPN

Không biết bạn có bị thiếu phần IPN k nhỉ, mình k nhận đc notify từ Momo ping về. Thanks!

Upgrade to sound null safety

Hiện Flutter đã lên version 2.2, bắt buộc các package phải lên sound null safety, mình mong @minhvn sớm cập nhật package lên để mọi người đang sử dụng package này có thể dễ dàng upgrade flutter version kể từ bản 2.2.

Xin cảm ơn.

[Android, IOS] Thanh toán không thành công

Mình không thể thanh toán thành công với MOMO. Liên tục nhận được code 2400 khi check với server payment. Sau đó, mình folk vào sửa lại model MomoPaymentInfo thì mới thanh toán thành công. Mong bạn check lại giúp nha.

class MomoPaymentInfo {
  String partner;
  String appScheme;
  String merchantName;
  String merchantCode;
  String partnerCode;
  String merchantNameLabel;

  int amount;
  int fee;
  String? description;
  String? extra;
  String? username;
  String orderId;
  String orderLabel;

  bool isTestMode;

  MomoPaymentInfo({
    required this.appScheme,
    required this.merchantName,
    required this.merchantCode,
    required this.partnerCode,
    required this.amount,
    required this.orderId,
    required this.orderLabel,
    required this.partner,
    required this.merchantNameLabel,
    required this.fee,
    this.description,
    this.username,
    this.extra,
    this.isTestMode = false,
  });

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = {
      "merchantname": this.merchantName,
      "merchantcode": this.merchantCode,
      "partnercode": this.partnerCode,
      "amount": this.amount,
      "orderid": this.orderId,
      "orderlabel": this.orderLabel,
      "partner": this.partner,
      "fee": this.fee,
      "isTestMode": isTestMode,
      "merchantnamelabel": merchantNameLabel
    };
    if (Platform.isIOS) {
      json["appScheme"] = appScheme;
    }
    if (description != null) {
      json["description"] = description;
    }
    if (username != null) {
      json["username"] = username;
    }
    if (extra != null) {
      json["extra"] = extra;
    }
    return json;
  }
}

Open Momo APP Not payment

Mình chạy và thanh toán qua MOMO truyền những thông số cần thiết. Nhưng tới màn hình thanh toán trên app MOMO test cứ xoay xoay hoài. Không biết là lỗi code hay do app test MOMO đang lỗi. Ad có test được ko ạ? E cảm ơn ạ

[Android] Mở CHPlay thay vì MOMO App

Khi mình gọi open function thì ứng dụng mở CHPlay thay vì mở Momo App để thanh toán. Làm thế nào để giải quyến vấn đề này vậy ạ?

Lỗi khi build app trên flutter

Mình bị lỗi này ở phiên bản 1.0.3 , nhưng lên 1.0.4 vẫn bị đó là không thể build app trên flutter. Mong bạn fix ở các phiên bản tiếp theo
Lỗi này nằm ở file MomoVnPluginDelegate.kt và cách sửa là chỉ cần thêm toString() là được.
image

AndroidManifest.xml hình như bị đè chỗ nào ấy

C:\flutterprojects\mymomodemo\android\app\src\debug\AndroidManifest.xml:5:9-35 Error:
	Attribute application@label value=(mymomodemo) from AndroidManifest.xml:5:9-35
	is also present at [com.github.momo-wallet:mobile-sdk:1.0.6] AndroidManifest.xml:15:9-41 value=(@string/app_name).
	Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:4:4-41:19 to override.

Em có thử cái example bác làm mà có điều chèn vô mấy thông số doanh nghiệp của em, mà lúc connect thì nó báo như vậy, bác có hướng giải quyết chưa ạ :((((((

What to fill in the partner field ?

Screen Shot 2021-02-23 at 08 40 23
Em đang setup momo lên ứng dụng anh cho em hỏi là mình cần điền thông tin nào vào trường partner ạ ? ở trên em thấy có merchant name và merchant code rồi

Can't build app

Lúc build app nó hiện lỗiType mismatch: inferred type is String? but Any was expected ở cái file MomoVnPluginDelegate.kt. Mình chỉ mới add vào pubspec.yaml thôi. Chưa viết 1 dòng code nào cả.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.