搜尋分類、套件與程式碼儲存庫

套件詳情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

原始碼儲存庫

使用此套件的專案