pay_platform_interface 2.0.0 copy "pay_platform_interface: ^2.0.0" to clipboard
pay_platform_interface: ^2.0.0 copied to clipboard

A common platform interface for payment plugins for Flutter.

pub package

A common platform interface for the pay plugin.

The contract in this package allows platform-specific implementations of the pay plugin, to ensure a common interface across plugins.

Take a look at the guide about plugin development if you'd like to learn more about the process of creating federated plugins.

Usage #

To implement a new platform-specific implementation, add pay_platform_interface as a dependency in your pubspec.yaml file:

dependencies:
  pay_platform_interface: ^2.0.0

Start by extending PayPlatform with an implementation that performs the platform-specific behavior.

The methods in the interface are:

  • Future<bool> userCanPay(PaymentConfiguration paymentConfiguration)
    This method helps users of the plugin learn about whether a user can pay with a selected provider. The logic in this call is in charge of communicating directly with the payment provider specified in the payment configuration to return a result.
  • Future<Map<String, dynamic>> showPaymentSelector(PaymentConfiguration paymentConfiguration, List<PaymentItem> paymentItems)
    This method takes provider-specific payment configuration and a list of payment items (eg.: articles, taxes, subtotal, etc) and starts the payment process by showing the payment selector to users.

Payment configuration #

The configuration to setup a payment provider is based on a open-ended schema (with provider-specific classes coming soon) with two required properties:

  • provider: with the target payment provider (eg.: PayProvider.apple_pay, PayProvider.google_pay).
  • data: a schemaless object with specific fields for the target payment provider. Take a look at the test assets folder to see sample configurations.

Note on breaking changes #

Strongly prefer non-breaking changes (such as adding a method to the interface) over breaking changes for this package.

Take a look at this discussion on why a less-clean interface is preferable to a breaking change.


Note: This is not an officially supported Google product.
1
likes
150
points
53.5k
downloads

Publisher

verified publishergoogle.dev

Weekly Downloads

A common platform interface for payment plugins for Flutter.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, yaml

More

Packages that depend on pay_platform_interface