搜索分类、插件与代码仓

插件详情v3.3.0

pay

一个用于在 Flutter 应用程序中添加支付支持的插件。

AndroidiOS
近 30 天下载
11.6万
喜欢数
1110
Pub 分数
150

安装插件

flutter pub add pay

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

支付包是一个Flutter插件,可在移动应用程序中实现支付功能,支持Android和iOS的Google Pay集成。它使开发者能够安全地处理支付、管理支付方式并处理应用内的交易。该插件由Google设计,通过标准化API简化了支付流程的实现。该插件支持两大主流平台,并确保符合安全最佳实践。适用于电子商务、订阅服务以及任何需要应用内支付处理的应用。

适合场景

  • 应用内购买
  • 订阅计费
  • 电子商务结账
  • 数字商品购买
  • 移动钱包集成

主要特点

  • Google Pay 集成
  • 跨平台支持(Android 和 iOS)
  • 安全的支付处理
  • 支付请求的简单 API
  • 支持多种支付方式

适合对象

  • 电子商务应用
  • 订阅服务
  • 移动钱包
  • 支持支付的市场
  • 需要安全交易的应用程序

使用建议

  • 需要在设备上设置 Google Pay
  • 需要为生产环境进行正确配置
  • 依赖于平台特定的支付网关
  • 仅限Google Pay生态系统
  • 可能需要额外的后端验证

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

A plugin to add payments to your Flutter application.

pay pay_android pay_ios pay_platform_interface
pub package pub package pub package pub package

Platform Support

Android iOS
Google Pay Apple Pay

Getting started

Before you start, create an account with the payment providers you are planning to support and follow the setup instructions:

Apple Pay:
  1. Take a look at the integration requirements.
  2. Create a merchant identifier for your business.
  3. Create a payment processing certificate to encrypt payment information.
Google Pay:
  1. Take a look at the integration requirements.
  2. Sign up to the business console and create an account.

Installation

This adds the pay package to the list of dependencies in your pubspec.yaml file with the following command:

flutter pub add pay

Usage

Define the configuration for your payment provider(s). Take a look at the parameters available in the documentation for Apple Pay and Google Pay, and explore the sample configurations in this package.

Example

This snippet assumes the existence of a payment configuration for Apple Pay (defaultApplePayConfig) and another one for Google Pay (defaultGooglePayConfig):

import 'package:pay/pay.dart';
import 'payment_configurations.dart' as payment_configurations;

const _paymentItems = [
  PaymentItem(
    label: 'Total',
    amount: '99.99',
    status: PaymentItemStatus.final_price,
  )
];

ApplePayButton(
  paymentConfiguration: payment_configurations.defaultApplePayConfig,
  paymentItems: _paymentItems,
  style: ApplePayButtonStyle.black,
  type: ApplePayButtonType.buy,
  margin: const EdgeInsets.only(top: 15.0),
  onPaymentResult: onApplePayResult,
  loadingIndicator: const Center(
    child: CircularProgressIndicator(),
  ),
),

GooglePayButton(
  paymentConfiguration: payment_configurations.defaultGooglePayConfig,
  paymentItems: _paymentItems,
  type: GooglePayButtonType.buy,
  margin: const EdgeInsets.only(top: 15.0),
  onPaymentResult: onGooglePayResult,
  loadingIndicator: const Center(
    child: CircularProgressIndicator(),
  ),
),

void onApplePayResult(paymentResult) {
  // Send the resulting Apple Pay token to your server / PSP
}

void onGooglePayResult(paymentResult) {
  // Send the resulting Google Pay token to your server / PSP
}

To learn more about the pay plugin and alternative integration paths, check out the readme in the pay folder.

Other packages in this plugin

The packages in this repository follow the federated plugin architecture. Each package has a specific responsibility and can be used independently to fulfil less conventional integration needs:

Package Description When to use
pay An app-facing package with support for all the platforms supported by this plugin. This package offers an agnostic integration for the platforms supported in this plugin and features the easiest path to add payments to your Flutter application.
pay_android The endorsed implementation of this plugin for Android. This package contains the necessary business logic to support the Android platform. You can integrate this package separately or use it to build your own app-facing package.
pay_ios The endorsed implementation of this plugin for iOS. This package contains the necessary business logic to support the iOS platform. You can integrate this package separately or use it to build your own app-facing package.
pay_platform_interface A common API contract for platform-specific implementations. Folow the contract in this package to add new platforms to the plugin or create your own Android or iOS implementations. Take a look at the guide about plugin development to learn more.

Additional resources

Check out the following resources to manage your payment accounts and learn more about the APIs for the supported providers:

Google Pay Apple Pay
Platforms Android iOS
Documentation Overview Overview
Console Google Pay Business Console Developer portal
Reference API reference Apple Pay API
Style guidelines Brand guidelines Buttons and Marks

Note: This is not an officially supported Google product.

所属分类

依赖

依赖清单 4 项

  • meta^1.10.0
  • pay_android^3.2.0
  • pay_ios^1.1.0
  • pay_platform_interface^2.0.0

源码仓库

使用此插件的项目