Description
When a user cancels the subscription purchase flow, _iap.requestPurchase(builder.build()) throws
PurchaseError(
code: gentype.ErrorCode.ServiceError,
message: 'Failed to request purchase: ${error.toString()}',
)
when it catches PlatformException(user-cancelled, User cancelled the purchase flow, wo_pledge_v1_monthly, null). I think, in this case, it would be great to map PlatformException to PurchaseError with the right error code, as it provides a code: 'user-cancelled' that could be mapped to ErrorCode.UserCancelled, and a String message.
Expected Behavior
When a user cancels the subscription purchase flow _iap.requestPurchase(...) should return PurchaseError(code: ErrorCode.UserCancelled) instead of a PurchaseError(code: ErrorCode.ServiceError, ...).
Screenshots
Environment
- flutter_inapp_purchase: 8.2.7
- Flutter: 3.38.8
- Dart: 3.10.7
- Platforms: iOS 15.8 real device
- iOS deployment target: 15.0
- Xcode version: 26.2 (17C52)
Latest Version Check
To Reproduce
Steps to reproduce the behavior:
- Wrap
_iap.requestPurchase(...) call in a try-catch
- Call
_iap.requestPurchase(...)
- Cancel the subscription flow / close the native bottom sheet without purchasing the item
- Catch the
PurchaseError(code: ErrorCode.ServiceError, ...)
Description
When a user cancels the subscription purchase flow,
_iap.requestPurchase(builder.build())throwswhen it catches
PlatformException(user-cancelled, User cancelled the purchase flow, wo_pledge_v1_monthly, null). I think, in this case, it would be great to map PlatformException to PurchaseError with the right error code, as it provides acode: 'user-cancelled' that could be mapped to ErrorCode.UserCancelled, and a Stringmessage.Expected Behavior
When a user cancels the subscription purchase flow
_iap.requestPurchase(...)should returnPurchaseError(code: ErrorCode.UserCancelled)instead of aPurchaseError(code: ErrorCode.ServiceError, ...).Screenshots
Environment
Latest Version Check
To Reproduce
Steps to reproduce the behavior:
_iap.requestPurchase(...)call in a try-catch_iap.requestPurchase(...)PurchaseError(code: ErrorCode.ServiceError, ...)