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

Flutter plugin integrating the Macau Pass (MPay) payment platform into Android and iOS apps. Provides the MPay unified channel, direct Alipay, direct WeChat Pay (mainland), Hong Kong WeChat Wallet, an [...]

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
130
points
56
downloads

Documentation

API reference

Publisher

verified publisherchihero.com

Weekly Downloads

Flutter plugin integrating the Macau Pass (MPay) payment platform into Android and iOS apps. Provides the MPay unified channel, direct Alipay, direct WeChat Pay (mainland), Hong Kong WeChat Wallet, and scan-to-pay QR code rendering, with multi-environment switching and consistent result callbacks. Native layers are structured as per-channel adapters behind a common PayChannelAdapter interface.

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