Skip to content

fix: userCanPay without existing payment methods - #306

Open
josh-burton wants to merge 3 commits into
google-pay:mainfrom
josh-burton:user-can-pay
Open

fix: userCanPay without existing payment methods#306
josh-burton wants to merge 3 commits into
google-pay:mainfrom
josh-burton:user-can-pay

Conversation

@josh-burton

Copy link
Copy Markdown

Fixes #305

Describe the changes proposed

Adds a new existingPaymentMethodRequired parameter to the userCanPay method, so the developer can determine if Apple/Google pay is available without requiring cards to be added

Screenshots / Videos

If useful, include any screeshots or screencasts to better explain the change.

Additional context

Add any other context about the change here.

@JlUgia

JlUgia commented Jul 29, 2025

Copy link
Copy Markdown
Member

Hi @josh-burton, thank you for your contributions.
My preference would be to default to false on this new prop, in line with how both enabled providers operate today.
Also, how about we use a more straightforward prop name on the Flutter API surface? Both Apple and Google Pay have slight variations on how the API works, so I feel that something like existingPaymentMethodAvailable or similar would be more accurate, since we are looking to extract whether there's at least one payment method available for the configuration provided.

Thank you again.

@josh-burton

Copy link
Copy Markdown
Author

Hi @josh-burton, thank you for your contributions. My preference would be to default to false on this new prop, in line with how both enabled providers operate today. Also, how about we use a more straightforward prop name on the Flutter API surface? Both Apple and Google Pay have slight variations on how the API works, so I feel that something like existingPaymentMethodAvailable or similar would be more accurate, since we are looking to extract whether there's at least one payment method available for the configuration provided.

Thank you again.

Thank you for the review. I have made those changes

Comment thread pay_ios/ios/Classes/PaymentHandler.swift Outdated
Comment thread pay/lib/src/pay.dart Outdated
await throwIfProviderIsNotDefined(provider);
if (supportedProviders[defaultTargetPlatform]!.contains(provider)) {
return _payPlatform.userCanPay(_configurations[provider]!);
return _payPlatform.userCanPay(_configurations[provider]!, existingPaymentMethodAvailable: existingPaymentMethodAvailable);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this field is already part of the configuration, does it need to be also passed a method parameter here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We need this as a method parameter to allow some call sites only check whether Google Pay is supported, while others also need to check that the user has a card available (while using a single JSON config)

…out requiring cards to be added

Adds a new existingPaymentMethodRequired parameter to the userCanPay method, so the developer can determine if Apple/Google pay is available without requiring cards to be added
- align the availability flag with existingPaymentMethodRequired
- map the requirement when building Android payment profiles
- avoid parsing Apple Pay networks for device-support-only checks
- improve availability documentation and update channel tests
@josh-burton

Copy link
Copy Markdown
Author

@JlUgia thank you for the review. I have addressed your comments and would appreciate another review. Very keen to get this merged.

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.

Support userCanPay when no cards added

2 participants