mpay_plugin 1.4.0
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/cashiersdk15.8.43, WeChat Pay via@tencent/wechat_open_sdk1.0.20, and scan-to-pay QR generation via the system Scan KitgenerateBarcodeAPI. - WeChat payment callbacks flow through the host's
onNewWant→MpayPlugin.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).
- New
-
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 raiseUnimplementedErroron unsupported platforms.
1.3.0 #
-
Refactor: Adapter pattern for native layers
- Android: Extracted per-channel adapters (
MPayAdapter,AliPayAdapter,WeChatPayAdapter,HongKongWalletAdapter) behind a commonPayChannelAdapterinterface;MpayPluginis now a thin dispatcher that routes method-channel calls throughPayChannelAdapterRegistry. - Android: Shared WeChat
IWXAPIstate moved intoWeChatSession; payment result text mapping centralized inPayResultMapper. - iOS: Same adapter split (
MPayAdapter,AliPayAdapter,WeChatPayAdapter,HongKongWalletAdapter) with a one-shotPendingResultdelivery guard; WeChat registration state (isRunning/cachedOpenUrlRequest) is now owned byWeChatPayAdapter. - Removed dead code:
lib/response/wechat_response.dart,lib/response/cancelable.dart, and the unused AndroidPermissionHandler. - The Dart public API and the method-channel protocol are unchanged.
- Android: Extracted per-channel adapters (
-
New: Native QR-code generation for scan-to-pay.
- New
generateQrCodemethod-channel API (code + optional size) returning PNG bytes; rendered natively — ZXing core on Android, CoreImageCIQRCodeGeneratoron iOS. No new Dart or plugin dependencies. - New
QrPayViewwidget renders the QR from server-issuedqr_code/code_urlstrings (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.
- New
1.2.1 #
-
Bug fixes:
- Android: Fixed
NullPointerExceptioncaused bymActivity!!force-unwrap when the plugin is invoked before an Activity attaches. - Android: Fixed all four
ActivityAwarelifecycle 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:
registerAppnow uses Application Context instead of Activity Context to avoid a WeChat IWXAPI memory leak. - Android: Added a
resultSentguard inMPayHandlerto preventMethodChannel.Resultfrom being called more than once when multiple SDK callbacks fire. - Android:
payWithHongKongWalletnow returns aMapconsistent with all other payment methods (was incorrectly returning a rawBoolean, crashingResultModel.fromJson). - Android: Fixed the
errCode.toString()isEmpty check inWXAPIEventHandlerthat was alwaystrue(dead else-branch removed). - Android: Fixed timestamp argument parsing in WeChat Pay to handle both
IntandLongfrom the Flutter method channel codec. - Android:
PermissionHandlerupdated from the deprecatedandroid.app.FragmentAPI toAndroidX ActivityCompat, and now skips the no-opWRITE_EXTERNAL_STORAGErequest on Android 13+. - iOS: Replaced all Objective-C implementation files with Swift. Fixed a critical bug where
_resultwas declared as a file-scoped global variable inMPayHandler.m, causing concurrent payment callbacks to corrupt each other's result pointers. - iOS: Added a
resultSentguard inMPayHandler(mirrors Android fix). - iOS:
onGetResultnow safely handlesnilfields from the Alipay SDK instead of crashing withNSInvalidArgumentException: attempt to insert nil object. - iOS: WeChat payment
pendingResultis cleared immediately after use to prevent double-delivery. - Dart:
invokeMethodreturn values are now null-safe ((response as Map?) ?? {}), preventing a crash inResultModel.fromJsonwhen the platform returnsnull. - Dart: Fixed
ResultModel.toString()which was missing colons afterresult,memo, andtypelabels. - Dart: Removed stale
print()debug statement fromaliPay.
- Android: Fixed
-
iOS rewrite (Objective-C → Swift 5):
MpayPlugin,MPayHandler,WXAPIEventHandler,WeChatPayDelegateHeaderconverted 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). PayTypeis now a sealed class; usePayment(...)for standard WeChat Pay orHongKongWallet(...)for the HK Wallet flow.
1.1.0 #
- Added direct Alipay payment (
aliPay) bypassing the MPay channel. - Added direct WeChat Pay (
wechatPay) withregisterApipre-registration. - iOS Universal Link support for WeChat registration.
1.0.0 #
- Initial release.
- MPay unified channel supporting MPay, Alipay, and WeChat Pay.
initfor configuring Alipay sandbox/online and MPay SIT/UAT/Production environments.