Skip to content

[2.1.0] Migrate Google Pay button to the pay package (RawGooglePayButton)#11

Draft
flitt-sdk-developers wants to merge 3 commits into
flittpayments:mainfrom
flitt-sdk-developers:fix/gpay-button-pay-migration-2.2.0
Draft

[2.1.0] Migrate Google Pay button to the pay package (RawGooglePayButton)#11
flitt-sdk-developers wants to merge 3 commits into
flittpayments:mainfrom
flitt-sdk-developers:fix/gpay-button-pay-migration-2.2.0

Conversation

@flitt-sdk-developers

@flitt-sdk-developers flitt-sdk-developers commented Jul 9, 2026

Copy link
Copy Markdown

Draft / strategic follow-up. Stacked on #10 (the 2.0.1 hotfix) — rebase onto main after #10 merges. Not yet compile-/device-verified (no Flutter SDK in author env).

Summary

Replaces our own native Google Pay button with the official pay package's RawGooglePayButton (native, Hybrid Composition, Google-brand-compliant). This removes the entire custom-platform-view bug class — the unregistered view factory, the create-before-config race, Virtual-Display glitches, and the empty dispose() — instead of hardening our own implementation.

Why keep our own GooglePayButton widget at all? It stays as a thin wrapper so the public API and the Flitt tokenization + 3DS flow are preserved; only the button rendering is delegated to pay.

Changes

  • lib/src/google_pay_button.dart: render RawGooglePayButton; build its PaymentConfiguration from the internal Google Pay config (config['data'], already returned by the SDK) via PaymentConfiguration.fromJsonString. Map ButtonType/ButtonThemes to pay's enums; borderRadiuscornerRadius; width/height via SizedBox. Adds a cloudipspBuilder test seam.
  • Delete GooglePayButtonPlugin and its registration in FlittMobilePlugin.
  • pubspec.yaml: add pay: ^3; raise Dart SDK floor to 3.1; version: 2.1.0.
  • android/build.gradle: minSdkVersion 23 (required by pay); play-services-wallet/base as implementation for the native loadPaymentData path.
  • README/CHANGELOG updates.

Backward compatibility

  • Public Dart API unchanged — same GooglePayButton constructor, enums, callbacks. Drop-in for merchants.
  • Imperative Cloudipsp.googlePay/googlePayToken unchanged — native loadPaymentData kept.
  • New requirements: pay dependency, minSdkVersion 23, Dart 3.1+.
  • No working behavior lost by deleting the custom platform view (it never rendered in the stock SDK).

Follow-up (not in this PR)

Optionally delegate tokenization to pay's Pay.showPaymentSelector and drop the native loadPaymentData entirely.

Verification (todo on a machine with Flutter)

flutter pub get + flutter analyze clean; on real Android devices (API 23/29/34) the button renders and completes token-based payment through 3DS to onSuccess; confirm the imperative API path still works. Update the example app to use the widget for coverage.

🤖 Generated with Claude Code

flitt-sdk-developers and others added 2 commits July 9, 2026 19:18
The native Google Pay AndroidView was gated on the fast native support
check only, so when it resolved before the slower payment-config fetch,
the platform view was created with allowedPaymentMethods == null. The
subsequent config load then reset _viewKey to a new UniqueKey(),
destroying and recreating the legacy Virtual-Display AndroidView and
leaving the button blank.

Gate the view on `supportsGPay && config != null` and drop the _viewKey
reset in _initializeCloudipsp(), so the platform view is created exactly
once with valid config, independent of async completion order.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The platform view factory for "google_pay_button_view" was registered
only inside GooglePayButtonPlugin, which is never added to the Flutter
engine: pubspec declares FlittMobilePlugin as the sole pluginClass, so
GeneratedPluginRegistrant only loads FlittMobilePlugin. As a result the
view type was never registered and any GooglePayButton widget failed to
create its native view — without this the race fix alone still cannot
render the button.

Register the factory from FlittMobilePlugin.onAttachedToEngine (the plugin
that is actually loaded) and expose GooglePayButtonFactory for it. Also
move the example MainActivity to the directory matching its declared
package (com.flitt.mobile_example).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@flitt-sdk-developers
flitt-sdk-developers force-pushed the fix/gpay-button-pay-migration-2.2.0 branch from 9300d9e to 8eb59ef Compare July 9, 2026 16:20
Replace the custom `google_pay_button_view` PlatformView with the official
`pay` package's `RawGooglePayButton` (native, Hybrid Composition,
policy-compliant), eliminating the custom-platform-view issues
(unregistered factory, create-before-config race, Virtual-Display
glitches, empty dispose).

- lib/src/google_pay_button.dart: render RawGooglePayButton; build its
  PaymentConfiguration from the internal Google Pay config (config['data'])
  via PaymentConfiguration.fromJsonString. Map ButtonType/ButtonThemes to
  pay's enums; borderRadius -> cornerRadius; width/height via SizedBox.
  Add a cloudipspBuilder test seam. Public API unchanged.
- Keep the Flitt tokenization + 3DS flow: _onPress still calls
  cloudipsp.googlePayToken/googlePay; FlittMobilePlugin's native
  loadPaymentData/supportsGooglePay/setCookie are unchanged, so the
  imperative Cloudipsp API stays backward compatible.
- Delete GooglePayButtonPlugin and its registration in FlittMobilePlugin.
- pubspec: add pay ^3; raise Dart SDK floor to 3.1; version 2.1.0.
- android/build.gradle: minSdkVersion 23 (required by pay); wallet/base as
  implementation for the native loadPaymentData path.
- README/CHANGELOG: document minSdk 23, pay-provided wallet, unchanged API.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@flitt-sdk-developers
flitt-sdk-developers force-pushed the fix/gpay-button-pay-migration-2.2.0 branch from 8eb59ef to 7b19b04 Compare July 9, 2026 16:30
@flitt-sdk-developers flitt-sdk-developers changed the title [Strategic/2.2.0] Migrate Google Pay button to the pay package (RawGooglePayButton) [2.1.0] Migrate Google Pay button to the pay package (RawGooglePayButton) Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant