mpay_plugin 1.4.0 copy "mpay_plugin: ^1.4.0" to clipboard
mpay_plugin: ^1.4.0 copied to clipboard

Flutter plugin integrating Macau Pass (MPay), Alipay, WeChat Pay, HK Wallet, and scan-to-pay QR codes with a unified adapter architecture.

1.4.0 #

  • HarmonyOS (OpenHarmony) support (Flutter-OH).

    • New ohos/ platform implementation (ArkTS) following the same method-channel protocol: Alipay direct payment via @cashier_alipay/cashiersdk 15.8.43, WeChat Pay via @tencent/wechat_open_sdk 1.0.20, and scan-to-pay QR generation via the system Scan Kit generateBarcode API.
    • WeChat payment callbacks flow through the host's onNewWantMpayPlugin.handleWechatWant(want); see README.OpenHarmony.
    • MPay unified channel and Hong Kong WeChat Wallet return a clear unsupported result on HarmonyOS (no Macau Pass HarmonyOS SDK; WeChat HK business view not available).
  • pub.dev score fixes:

    • Shortened the pubspec description to the recommended 60-180 characters.
    • Declared web / Windows / macOS / Linux platforms via Dart stub implementations (MpayPluginWeb / MpayPluginWindows / MpayPluginMacos / MpayPluginLinux). The vendor payment SDKs only exist on Android and iOS; payment methods raise UnimplementedError on unsupported platforms.

1.3.0 #

  • Refactor: Adapter pattern for native layers

    • Android: Extracted per-channel adapters (MPayAdapter, AliPayAdapter, WeChatPayAdapter, HongKongWalletAdapter) behind a common PayChannelAdapter interface; MpayPlugin is now a thin dispatcher that routes method-channel calls through PayChannelAdapterRegistry.
    • Android: Shared WeChat IWXAPI state moved into WeChatSession; payment result text mapping centralized in PayResultMapper.
    • iOS: Same adapter split (MPayAdapter, AliPayAdapter, WeChatPayAdapter, HongKongWalletAdapter) with a one-shot PendingResult delivery guard; WeChat registration state (isRunning / cachedOpenUrlRequest) is now owned by WeChatPayAdapter.
    • Removed dead code: lib/response/wechat_response.dart, lib/response/cancelable.dart, and the unused Android PermissionHandler.
    • The Dart public API and the method-channel protocol are unchanged.
  • New: Native QR-code generation for scan-to-pay.

    • New generateQrCode method-channel API (code + optional size) returning PNG bytes; rendered natively — ZXing core on Android, CoreImage CIQRCodeGenerator on iOS. No new Dart or plugin dependencies.
    • New QrPayView widget renders the QR from server-issued qr_code / code_url strings (Alipay precreate / WeChat Native).
    • Black-on-white, ErrorCorrectionLevel M, size clamped to 64..1024.
    • Payment-result confirmation (server polling / async notify) remains the merchant server's responsibility.

1.2.1 #

  • Bug fixes:

    • Android: Fixed NullPointerException caused by mActivity!! force-unwrap when the plugin is invoked before an Activity attaches.
    • Android: Fixed all four ActivityAware lifecycle callbacks (onDetachedFromActivity, onDetachedFromActivityForConfigChanges, onReattachedToActivityForConfigChanges). Previously empty, they now properly update and null-out the Activity reference, preventing stale references and memory leaks across screen rotations.
    • Android: registerApp now uses Application Context instead of Activity Context to avoid a WeChat IWXAPI memory leak.
    • Android: Added a resultSent guard in MPayHandler to prevent MethodChannel.Result from being called more than once when multiple SDK callbacks fire.
    • Android: payWithHongKongWallet now returns a Map consistent with all other payment methods (was incorrectly returning a raw Boolean, crashing ResultModel.fromJson).
    • Android: Fixed the errCode.toString() isEmpty check in WXAPIEventHandler that was always true (dead else-branch removed).
    • Android: Fixed timestamp argument parsing in WeChat Pay to handle both Int and Long from the Flutter method channel codec.
    • Android: PermissionHandler updated from the deprecated android.app.Fragment API to AndroidX ActivityCompat, and now skips the no-op WRITE_EXTERNAL_STORAGE request on Android 13+.
    • iOS: Replaced all Objective-C implementation files with Swift. Fixed a critical bug where _result was declared as a file-scoped global variable in MPayHandler.m, causing concurrent payment callbacks to corrupt each other's result pointers.
    • iOS: Added a resultSent guard in MPayHandler (mirrors Android fix).
    • iOS: onGetResult now safely handles nil fields from the Alipay SDK instead of crashing with NSInvalidArgumentException: attempt to insert nil object.
    • iOS: WeChat payment pendingResult is cleared immediately after use to prevent double-delivery.
    • Dart: invokeMethod return values are now null-safe ((response as Map?) ?? {}), preventing a crash in ResultModel.fromJson when the platform returns null.
    • Dart: Fixed ResultModel.toString() which was missing colons after result, memo, and type labels.
    • Dart: Removed stale print() debug statement from aliPay.
  • iOS rewrite (Objective-C → Swift 5):

    • MpayPlugin, MPayHandler, WXAPIEventHandler, WeChatPayDelegateHeader converted to Swift. The three WeChatSDK bridge headers (WXApi.h, WXApiObject.h, WechatAuthSDK.h) are retained as ObjC headers for the static library interface.
    • Podspec updated: swift_version = '5.0', minimum iOS raised to 12.0.

1.2.0 #

  • Added Hong Kong WeChat Wallet payment via HongKongWallet(prepayId: token).
  • PayType is now a sealed class; use Payment(...) for standard WeChat Pay or HongKongWallet(...) for the HK Wallet flow.

1.1.0 #

  • Added direct Alipay payment (aliPay) bypassing the MPay channel.
  • Added direct WeChat Pay (wechatPay) with registerApi pre-registration.
  • iOS Universal Link support for WeChat registration.

1.0.0 #

  • Initial release.
  • MPay unified channel supporting MPay, Alipay, and WeChat Pay.
  • init for configuring Alipay sandbox/online and MPay SIT/UAT/Production environments.
0
likes
140
points
56
downloads

Documentation

API reference

Publisher

verified publisherchihero.com

Weekly Downloads

Flutter plugin integrating Macau Pass (MPay), Alipay, WeChat Pay, HK Wallet, and scan-to-pay QR codes with a unified adapter architecture.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mpay_plugin

Packages that implement mpay_plugin