pay_platform_interface 1.0.2 icon indicating copy to clipboard operation
pay_platform_interface: ^1.0.2 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: ^1.0.2

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.: apple_pay, google_pay).
  • data: a schemaless object with specific fields for the target payment provider. Take a look at the test assets folder to see examples 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
120
pub points
89%
popularity

Publisher

shield icon for verified publishersgoogle.dev

A common platform interface for payment plugins for Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter, yaml

More

Packages that depend on pay_platform_interface