Skip to content

fix(flutter): forward subscriptionProductReplacementParams on Android#97

Merged
hyochan merged 1 commit into
mainfrom
fix/flutter-subscription-product-replacement-params-channel
Apr 15, 2026
Merged

fix(flutter): forward subscriptionProductReplacementParams on Android#97
hyochan merged 1 commit into
mainfrom
fix/flutter-subscription-product-replacement-params-channel

Conversation

@hyochan

@hyochan hyochan commented Apr 15, 2026

Copy link
Copy Markdown
Member

Summary

  • RequestSubscriptionAndroidProps.subscriptionProductReplacementParams was declared in types.dart and parsed correctly by the Android plugin, but flutter_inapp_purchase.dart never copied the field onto the method-channel payload when translating the Dart props into the native call. Any value callers passed was silently dropped, so Google Play fell back to its default replacement mode (WITHOUT_PRORATION) regardless of what the Dart side requested.
  • Forwards the field through the channel payload and adds a channel test asserting that the serialized oldProductId / replacementMode reach the native call, so the wiring can't silently regress again.

Reported via #96 (comment). The legacy replacementMode int path was already wired correctly; this PR only fixes the newer per-product SubscriptionProductReplacementParams path (Billing Library 8.1.0+).

Test plan

  • flutter analyze — no issues
  • flutter test — 243 tests pass (new forwards subscriptionProductReplacementParams on Android subscription test included)
  • Format check: dart format --page-width 80 --set-exit-if-changed clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for Android subscription product replacement parameters during in-app purchase requests, enabling configuration when requesting subscriptions.
  • Tests

    • Added test coverage verifying proper handling of subscription product replacement parameters in Android purchase requests.

The field was declared on `RequestSubscriptionAndroidProps` and parsed
correctly on the native side, but `flutter_inapp_purchase.dart` was
dropping it when building the method-channel payload. Any value passed
in was silently discarded and Google Play fell back to its default
replacement mode (WITHOUT_PRORATION), regardless of what the caller
sent from Dart.

Forward the field through the channel and cover it with a channel test
so the wiring can't silently regress again.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hyochan hyochan added flutter_inapp_purchase flutter_inapp_purchase library 🐛 bug Something isn't working 🤖 android Related to android labels Apr 15, 2026
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5161b558-3a64-4ed2-9dcc-59db797541b6

📥 Commits

Reviewing files that changed from the base of the PR and between d54f868 and 040e22a.

📒 Files selected for processing (2)
  • libraries/flutter_inapp_purchase/lib/flutter_inapp_purchase.dart
  • libraries/flutter_inapp_purchase/test/flutter_inapp_purchase_channel_test.dart

📝 Walkthrough

Walkthrough

This pull request adds support for Android subscription product replacement parameters during purchase requests. A new nullable subscriptionProductReplacementParams variable is introduced in the Dart layer, extracted from subscription request properties, serialized to JSON, and forwarded to the native Android requestPurchase method. A corresponding test verifies correct parameter forwarding and serialization.

Changes

Cohort / File(s) Summary
Android Subscription Replacement Parameters
libraries/flutter_inapp_purchase/lib/flutter_inapp_purchase.dart
Introduces subscriptionProductReplacementParams variable initialization logic that extracts replacement parameters from subscription requests and appends serialized JSON to the native requestPurchase payload.
Subscription Replacement Parameters Testing
libraries/flutter_inapp_purchase/test/flutter_inapp_purchase_channel_test.dart
Adds comprehensive test case for Android subscription purchases that validates subscriptionProductReplacementParams forwarding, including verification of nested field serialization (oldProductId and replacementMode).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

🛠 bugfix

Poem

🐰 A parameter hops through the Android maze,
From Dart to native in a modern craze,
Subscriptions replaced with graceful care,
JSON serialized through the air! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: forwarding subscriptionProductReplacementParams on Android, which is the core fix implemented in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/flutter-subscription-product-replacement-params-channel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for subscriptionProductReplacementParams to the Android implementation of the Flutter In-App Purchase library, enabling item-level replacements as introduced in Billing Library 8.1.0. The changes include updating the purchase request logic to serialize these parameters into the platform channel payload and adding a corresponding test case to verify the integration. I have no feedback to provide.

@hyochan hyochan merged commit 7a12c12 into main Apr 15, 2026
8 checks passed
@hyochan hyochan deleted the fix/flutter-subscription-product-replacement-params-channel branch April 15, 2026 06:25
hyochan added a commit that referenced this pull request Apr 15, 2026
The two flutter_inapp_purchase entries shipped from the same
investigation thread (#96#97 channel fix → #98 debugMessage pipe)
so grouping them under a single header keeps the 2026-04-15 cut
readable instead of splitting the narrative across two cards.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Related to android 🐛 bug Something isn't working flutter_inapp_purchase flutter_inapp_purchase library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant