mpay_plugin 1.3.0
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 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.