# @capgo/capacitor-pay 中文文档

规范地址：https://npmcn.com/package/%40capgo/capacitor-pay/

版本：8\.2\.1
npm 元数据更新时间：2026-10-15T05:32:50.502Z
中文译文更新时间：2026-11-09T04:26:43.884Z
软件包许可：MPL-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40capgo/capacitor-pay
原文对照：https://npmcn.com/package/%40capgo/capacitor-pay/?lang=original
项目主页：https://capgo.app/docs/plugins/pay/
源码仓库：https://github.com/Cap-go/capacitor-pay

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：348 kB，29 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：@capacitor/core \>=8\.0\.0
- 首次发布：2025-10-09T00:15:36.878Z
- 最新版本发布：2026-10-15T05:32:50.200Z
- 近 30 天下载量：25543（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：53（近 12 个月 42 个）

## 中文简介

启动本地支付iOS( APPLAY) 和 Android( Google Pay) 的电容插件

## 安装

```sh
npm install @capgo/capacitor-pay
```

也可以使用：`pnpm add @capgo/capacitor-pay`、`yarn add @capgo/capacitor-pay`、`bun add @capgo/capacitor-pay`

## README

# @ capgo/ 电容器- pay

在您的 Capacitor app 中接受 Apple Pay 和 Google Pay , 使用本地支付表使用 JavaScript API .

[![Capgo - Build Capacitor apps with AI, ship updates instantly](https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-pay)](https://capgo.app/?ref=plugin_pay)

**队长**:在几分钟内将修正推给您的 Capacitor 用户,在没有Mac的情况下构建已签名的iOS和Android apps,并在一击中回滚.

## [\*免费开始\*](https://capgo.app/register/?ref=plugin_pay)

14天无限自由审判. 不需要信用卡

> 🤖 **建筑与AI编码代理?** 安装 [Capgo 技能](https://capgo.app/skills/?ref=plugin_pay) 所以克劳德代码,代码,光标,副驾驶,或双子座CLI知道如何安装和使用 `@capgo/capacitor-pay` 在您的电容应用程序中: `npx skills add Cap-go/capgo-skills`。然后问你的经纪人: _添加@capgo/capacor-pay to my Capacitor app 并连接起来。"_ [代理设置指南](https://capgo.app/agents/?ref=plugin_pay) • 妇女 [主机磁共振](https://capgo.app/docs/ai/mcp/?ref=plugin_pay)

![@capgo/capacitor-pay for Capacitor apps](https://raw.githubusercontent.com/Cap-go/capacitor-pay/main/assets/github-social-preview.png)

## 主要特点

-   **可用性**数字 : `isPayAvailable()` 检查设备能否用您的网络支付.
-   **原生表单**数字 : `requestPayment()` 显示 Apple Pay 或 Google Pay, 并返回带有支付数据的结构化结果.
-   **苹果支付选项**:商号标识,所支持的网络,能力和联系字段.
-   **谷歌付费选项**:测试或生产环境,卡片网络,和网关或直接标注.
-   **平台**: iOS和Android. 互联网档案馆的存檔,存档日期2013-12-22. iOS使用PassKit,Android通过Play服务使用Google Pay. 在网上不可用.

## 文档

这里有最完整的医生: [https://capgo.app/docs/plugins/pay/ (中文(简体) )](https://capgo.app/docs/plugins/pay/)

## 兼容性

| 插件版本 | 电容兼容性 | 维护 |
| --- | --- | --- |
| 联合国 | 联合国 | ✅ |
| 页:1 | 页:1 | 应要求 |
| 页:1 | 页:1 | ❌ |
| 页:1 | 页:1 | ❌ |

> **说明:** 此插件的主要版本沿用了Capacitor的主要版本. 使用匹配您的 Capacitor 安装的版本( 如 Capacitor 8 的插件 v8) 。 只有最新的主要版本得到积极维护.

## 安装

您可以使用我们的 AI 辅助设置安装插件 。 使用以下命令将 Capgo 技能添加到您的 AI 工具 :

```bash
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
```

然后使用下列提示:

```text
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-pay` plugin in my project.
```

如果您更喜欢手动设置,请通过运行以下命令来安装插件,并遵循下面的平台特定指令:

```bash
# Install (choose one)
npm install @capgo/capacitor-pay
pnpm add @capgo/capacitor-pay
yarn add @capgo/capacitor-pay
bun add @capgo/capacitor-pay

# Then sync Capacitor (choose one)
npx cap sync
pnpm exec cap sync
yarn cap sync
bunx cap sync
```

## 平台设置

在引用插件之前, 填写此寄存器中记录的本地配置 :

-   **苹果支付( iOS) :** 见 [`docs/apple-pay-setup.md`](https://npmcn.com/package/%40capgo/capacitor-pay/docs/apple-pay-setup.md) 用于商家ID创建,证书,Xcode权限,以及设备测试.
-   **谷歌付费( Android) :** 跟着 [`docs/google-pay-setup.md`](https://npmcn.com/package/%40capgo/capacitor-pay/docs/google-pay-setup.md) 配置商务简介、标识设置和运行时间 JSON 有效载荷.

完成每个应用程序的两条指南,以便在设备上解锁本地付款单.

Google 付费请求和响应类型与此插件捆绑在一起, 因此不需要安装 `@types/googlepay` 除非你在应用程序的其他地方也使用Google的网络JavaScript客户端.

## 使用量

```ts
import { Pay } from '@capgo/capacitor-pay';

// Check availability on the current platform.
const availability = await Pay.isPayAvailable({
  apple: {
    supportedNetworks: ['visa', 'masterCard', 'amex'],
  },
  google: {
    // Optional: falls back to a basic CARD request if omitted.
    isReadyToPayRequest: {
      apiVersion: 2,
      apiVersionMinor: 0,
      allowedPaymentMethods: [
        {
          type: 'CARD',
          parameters: {
            allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
            allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'],
          },
        },
      ],
    },
  },
});

if (!availability.available) {
  // Surface a friendly message or provide an alternative checkout.
  return;
}

if (availability.platform === 'ios') {
  const result = await Pay.requestPayment({
    apple: {
      merchantIdentifier: 'merchant.com.example.app',
      countryCode: 'US',
      currencyCode: 'USD',
      supportedNetworks: ['visa', 'masterCard'],
      paymentSummaryItems: [
        { label: 'Example Product', amount: '19.99' },
        { label: 'Tax', amount: '1.60' },
        { label: 'Example Store', amount: '21.59' },
      ],
      requiredShippingContactFields: ['postalAddress', 'name', 'emailAddress'],
    },
  });
  console.log(result.apple?.paymentData);
} else if (availability.platform === 'android') {
  const result = await Pay.requestPayment({
    google: {
      environment: 'test',
      paymentDataRequest: {
        apiVersion: 2,
        apiVersionMinor: 0,
        allowedPaymentMethods: [
          {
            type: 'CARD',
            parameters: {
              allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
              allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'],
              billingAddressRequired: true,
              billingAddressParameters: {
                format: 'FULL',
              },
            },
            tokenizationSpecification: {
              type: 'PAYMENT_GATEWAY',
              parameters: {
                gateway: 'example',
                gatewayMerchantId: 'exampleGatewayMerchantId',
              },
            },
          },
        ],
        merchantInfo: {
          merchantId: '01234567890123456789',
          merchantName: 'Example Merchant',
        },
        transactionInfo: {
          totalPriceStatus: 'FINAL',
          totalPrice: '21.59',
          currencyCode: 'USD',
          countryCode: 'US',
        },
      },
    },
  });

  console.log(result.google.paymentData);
  // Process the payment token on your backend server here.
}
```

## 经常性付款

Apple Pay 通过 `recurringPaymentRequest` (iOS 16+):

```ts
import { Pay } from '@capgo/capacitor-pay';

await Pay.requestPayment({
  apple: {
    merchantIdentifier: 'merchant.com.example.app',
    countryCode: 'US',
    currencyCode: 'USD',
    supportedNetworks: ['visa', 'masterCard'],
    paymentSummaryItems: [
      { label: 'Pro Plan', amount: '9.99' },
      { label: 'Example Store', amount: '9.99' },
    ],
    recurringPaymentRequest: {
      paymentDescription: 'Pro Plan Subscription',
      managementURL: 'https://example.com/account/subscription',
      regularBilling: {
        label: 'Pro Plan',
        amount: '9.99',
        intervalUnit: 'month',
        intervalCount: 1,
        startDate: Date.now(),
      },
    },
  },
});
```

Google Pay 在其中没有专门的“ 经常性请求” 对象 `PaymentDataRequest`。对于订阅,您通常:

1.  和普通人一起收集一个符号 `paymentDataRequest`。 。 。 .
2.  将其存储在服务器侧并用您的 PSP/出入口(Stripe/Adyen/Braintree/etc) 创建经常性收费.

```ts
import { Pay, type GooglePayPaymentDataRequest } from '@capgo/capacitor-pay';

const paymentDataRequest: GooglePayPaymentDataRequest = {
  apiVersion: 2,
  apiVersionMinor: 0,
  allowedPaymentMethods: [
    {
      type: 'CARD',
      parameters: {
        allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
        allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'],
      },
      tokenizationSpecification: {
        type: 'PAYMENT_GATEWAY',
        parameters: {
          gateway: 'example',
          gatewayMerchantId: 'exampleGatewayMerchantId',
        },
      },
    },
  ],
  merchantInfo: {
    merchantId: '01234567890123456789',
    merchantName: 'Example Merchant',
  },
  transactionInfo: {
    totalPriceStatus: 'FINAL',
    totalPrice: '9.99',
    currencyCode: 'USD',
    countryCode: 'US',
  },
};

const result = await Pay.requestPayment({
  google: {
    environment: 'test',
    paymentDataRequest,
  },
});

// Send `result.google.paymentData` to your backend and use your PSP to start the subscription.
```

`requestPayment()` 是两个平台上的完成路径.

## 航运方法(付薪)

过 `shippingMethods` 让用户选择订单的交付方式,例如家用快递或商店取货。 第一个方法是默认选择的。 当用户更改地址或方法时,工作表会等待到您用 `updateApplePayShipping()`,通过 `selectionId` 活动安排。 回答每个事件, 也是当您自己的搜索失败时; 工作表在 20 秒内没有更新, 报告选择失败 。 当方法有不同的金额 `applePayShippingMethodSelected` 需要听众:

```ts
import { Pay } from '@capgo/capacitor-pay';

const deliveryMethods = [
  { identifier: 'home', label: 'Home delivery', amount: '4.95', startDate: '2026-10-16', endDate: '2026-10-17' },
  { identifier: 'store', label: 'Pick up in store', amount: '0.00', detail: 'Ready tomorrow' },
];

await Pay.addListener('applePayShippingContactSelected', async (contact) => {
  // Apple only shares city, postal code and country until the payment is authorized
  // An empty `shippingMethods` array marks the address as unserviceable
  const shippingMethods = await getShippingMethodsFor(contact.postalAddress?.isoCountryCode);
  await Pay.updateApplePayShipping({
    selectionId: contact.selectionId,
    paymentSummaryItems: getSummaryItems(shippingMethods[0]),
    shippingMethods,
  });
});

await Pay.addListener('applePayShippingMethodSelected', async (shippingMethod) => {
  await Pay.updateApplePayShipping({
    selectionId: shippingMethod.selectionId,
    paymentSummaryItems: getSummaryItems(shippingMethod),
  });
});

const result = await Pay.requestPayment({
  apple: {
    merchantIdentifier: 'merchant.com.example.app',
    countryCode: 'NL',
    currencyCode: 'EUR',
    supportedNetworks: ['visa', 'masterCard'],
    requiredShippingContactFields: ['postalAddress', 'name', 'emailAddress'],
    shippingMethods: deliveryMethods,
    paymentSummaryItems: getSummaryItems(deliveryMethods[0]),
  },
});

// `result.apple.shippingMethod` is the method the user selected
```

## API 密码

-   [`isPayAvailable(...)`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-ispayavailable)
-   [`requestPayment(...)`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-requestpayment)
-   [`updateApplePayShipping(...)`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-updateapplepayshipping)
-   [`addListener('applePayShippingContactSelected', ...)`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-addlistenerapplepayshippingcontactselected-)
-   [`addListener('applePayShippingMethodSelected', ...)`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-addlistenerapplepayshippingmethodselected-)
-   [`removeAllListeners()`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-removealllisteners)
-   [`getPluginVersion()`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-getpluginversion)
-   [接口](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-interfaces)
-   [类型异名](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-type-aliases)

### 是PayAvailable (...) (中文(简体) )

```typescript
isPayAvailable(options?: PayAvailabilityOptions | undefined) => Promise<PayAvailabilityResult>
```

检查当前平台是否有本地薪酬. 在iOS上,这个评价Apple Pay,在Android上,它评价Google Pay.

| 参数 | 类型 |
| --- | --- |
| **`options`** | `[PayAvailabilityOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-payavailabilityoptions)` |

**回返情况:** `Promise<[PayAvailabilityResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-payavailabilityresult)>`

* * *

### 请求支付(...)

```typescript
requestPayment(options: PayPaymentOptions) => Promise<PayPaymentResult>
```

呈现当前平台的本地薪资表. 在iOS上提供苹果付费配置,在Android上提供谷歌付费配置.

这个承诺是两个平台上的完成路径.

| 参数 | 类型 |
| --- | --- |
| **`options`** | `[PayPaymentOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-paypaymentoptions)` |

**回返情况:** `Promise<[PayPaymentResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-paypaymentresult)>`

* * *

### 更新 ApplePayShipping (...)

```typescript
updateApplePayShipping(options: ApplePayShippingUpdate) => Promise<void>
```

答复最新数据 `applePayShippingContactSelected` 或者说 `applePayShippingMethodSelected` 事件 有新的总数,新的地址有新的运输方法。 仅iOS.

苹果支付表等待这个电话, 所以打电话给它一次 每一次你听 您的搜索失败 。 未在20秒内更新,工作表报告选择失败.

| 参数 | 类型 |
| --- | --- |
| **`options`** | `[ApplePayShippingUpdate](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayshippingupdate)` |

* * *

### 添加倾听器( “ applePayShippingContact Select” ,...)

```typescript
addListener(eventName: 'applePayShippingContactSelected', listenerFunc: (contact: ApplePayShippingContactSelectedEvent) => void) => Promise<PluginListenerHandle>
```

当用户选择或更改Apple Pay表中的运货地址时调用. 仅iOS.

在授权支付之前,苹果公司只共享一个被编辑的地址(城市,州,邮政编码和国家). 床单等你打来 `updateApplePayShipping()`没有收听者,工作表将保留当前总数.

| 参数 | 类型 |
| --- | --- |
| **`eventName`** | `'applePayShippingContactSelected'` |
| **`listenerFunc`** | `(contact: [ApplePayShippingContactSelectedEvent](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayshippingcontactselectedevent)) => void` |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-pluginlistenerhandle)>`

* * *

### 添加聆听器( “ applePayShipping Method Select” ,...)

```typescript
addListener(eventName: 'applePayShippingMethodSelected', listenerFunc: (shippingMethod: ApplePayShippingMethodSelectedEvent) => void) => Promise<PluginListenerHandle>
```

当用户在Apple Pay平单中选择了另一种传输方法时调用. 仅iOS.

床单等你打来 `updateApplePayShipping()`没有收听者,工作表保持其当前总数, 因此,当运输方法有不同的金额时,需要这个收听器.

| 参数 | 类型 |
| --- | --- |
| **`eventName`** | `'applePayShippingMethodSelected'` |
| **`listenerFunc`** | `(shippingMethod: [ApplePayShippingMethodSelectedEvent](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayshippingmethodselectedevent)) => void` |

**回返情况:** `Promise<[PluginListenerHandle](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-pluginlistenerhandle)>`

* * *

### 删除所有收听器( )

```typescript
removeAllListeners() => Promise<void>
```

删除此插件的所有听众 .

* * *

### 获取 PluginVersion ()

```typescript
getPluginVersion() => Promise<{ version: string; }>
```

获取本地 Capacitor 插件版本

**回返情况:** `Promise<{ version: string; }>`

* * *

### 接口

#### 薪资可偿还性

| Prop | 类型 |
| --- | --- |
| **`available`** | `boolean` |
| **`platform`** | `[PayPlatform](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-payplatform)` |
| **`apple`** | `[ApplePayAvailabilityResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayavailabilityresult)` |
| **`google`** | `[GooglePayAvailabilityResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayavailabilityresult)` |

#### ApplePayAvail可操作性

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`canMakePayments`** | `boolean` | 表示该设备能否普遍支付苹果支付. |
| **`canMakePaymentsUsingNetworks`** | `boolean` | 说明该设备能否与所提供网络进行苹果支付. |

#### GooglePay-Avail可操作性

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`isReady`** | `boolean` | 用户是否能够通过谷歌支付表提供支付信息. |
| **`paymentMethodPresent`** | `boolean` | 当前用户使用其中指定的一种或多种支付方法支付的能力 `IsReadyToPayRequest.allowedPaymentMethods`。只有在 `IsReadyToPayRequest.existingPaymentMethodRequired` 设定为 `true`。属性价值将永远是 `true` 如果为测试环境配置了请求. |

#### 可选择性

| Prop | 类型 |
| --- | --- |
| **`apple`** | `[ApplePayAvailabilityOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayavailabilityoptions)` |
| **`google`** | `[GooglePayAvailabilityOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayavailabilityoptions)` |

#### ApplePay 可用性选项

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`supportedNetworks`** | `ApplePayNetwork[]` | 您打算使用的支付网络的可选列表 。 传递网络决定返回值 `canMakePaymentsUsingNetworks`。 。 。 . |

#### GooglePay 可用性选项

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`environment`** | `[GooglePayEnvironment](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayenvironment)` | 用于构建谷歌支付客户端的环境. 默认为 `'test'`。 。 。 . |
| **`isReadyToPayRequest`** | `[GooglePayIsReadyToPayRequest](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayisreadytopayrequest)` | 原始内容 `IsReadyToPayRequest` JSON由谷歌付费API定义. 提供您打算在运行时支持的卡片网络和认证方法 . |

#### GooglePay is ReadyToPay 请求

基于官方请求对象和绝对Typed定义的自成一体的Google Pay请求类型.

该插件将提供的JSON转发给Android上的本地Google Pay SDK,同时将类型表面保留在本地 所以消费者不需要安装 `@types/googlepay`。 。 。 .

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`apiVersion`** | `number` | Google Pay API主要版本. 使用 `2` 用于当前整合. |
| **`apiVersionMinor`** | `number` | 谷歌付费API小版本. 使用 `0` 用于当前整合. |
| **`allowedPaymentMethods`** | `GooglePayAllowedPaymentMethod[]` | 您想要测试的支付方法 . |
| **`existingPaymentMethodRequired`** | `boolean` | 何时 `true`, Google Pay 也表示是否存在现有的匹配支付方法. 在那个 `test` 环境总是决定 `true`。 。 。 . |

#### GooglePay Allowed Payment Method 页面存档备份,存于互联网档案馆 页面存档备份,存于互联网档案馆

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `[GooglePayPaymentMethodType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentmethodtype)` | 支持的支付方法类型 . `CARD` 是Google Pay 请求对象目前接受的唯一值. |
| **`parameters`** | `[GooglePayCardPaymentMethodParameters](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaycardpaymentmethodparameters)` | 用于控制哪些卡可以显示以及收集哪些额外数据的参数. |
| **`tokenizationSpecification`** | `[GooglePayTokenizationSpecification](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaytokenizationspecification)` | 选定支付方法的切入设置 。 在Google Pay中,这需要用于 `PaymentDataRequest` 支付卡的方法, 但被忽略 `IsReadyToPayRequest`。 。 。 . |

#### GooglePayCardPayment 方法软件

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`allowedAuthMethods`** | `GooglePayAuthMethod[]` | 认证方法 您的网关或处理器接受 . |
| **`allowedCardNetworks`** | `GooglePayCardNetwork[]` | 您的网关或处理器接受卡片网络 . |
| **`allowPrepaidCards`** | `boolean` | 是否允许预付卡 。 默认为 `true` 在谷歌付费. |
| **`allowCreditCards`** | `boolean` | 是否允许信用卡 。 默认为 `true` 在谷歌付费. |
| **`allowedIssuerCountryCodes`** | `string[]` | 限制用户在提供的ISO 3166-1 α-2国家发行的卡. |
| **`blockedIssuerCountryCodes`** | `string[]` | 在所提供的ISO 3166-1 alpha-2国家中发行的区块卡. 这是相互排斥的 `allowedIssuerCountryCodes`。 。 。 . |
| **`assuranceDetailsRequired`** | `boolean` | Google Pay是否应该包含关于所选卡的保证细节. |
| **`billingAddressRequired`** | `boolean` | 是否要求买方提供账单地址. |
| **`billingAddressParameters`** | `[GooglePayBillingAddressParameters](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaybillingaddressparameters)` | 使用额外的帐单地址控制 `billingAddressRequired` 实值 `true`。 。 。 . |
| **`cardNetworkParameters`** | `GooglePayCardNetworkParameters[]` | 支持网络的可选网络专用处理参数. |
| **`cvcRequired`** | `boolean` | 是否应当在支付符中返回卡验证代码 。 这需要谷歌启用您的账户 . |

#### GooglePayBilling Address 算法

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`format`** | `[GooglePayBillingAddressFormat](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaybillingaddressformat)` | 计费地址格式在 `billingAddressRequired` 实值 `true`启用 `FULL` 只当您真的需要额外的字段来完成命令时. |
| **`phoneNumberRequired`** | `boolean` | 是否还应退还帐号. |

#### GooglePayCard 网络参数

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`cardNetwork`** | `[GooglePayCardNetwork](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaycardnetwork)` | 卡片网络适用这些网络特定参数. |
| **`acquirerBin`** | `string` | 获取一些网络特定流量所使用的机构识别代码. |
| **`acquirerMerchantId`** | `string` | 获得指定商号标识,一些网络特定流量使用. |

#### GooglePayGateway 用户化规格

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `'PAYMENT_GATEWAY'` | 将一个支持的第三方网关的支付数据存储. |
| **`parameters`** | `[GooglePayPaymentGatewayTokenizationParameters](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentgatewaytokenizationparameters)` | 网关专用的标志化参数. |

#### GooglePayPayment Gateway 客户化

切换参数 `PAYMENT_GATEWAY` 符号化,它将支付数据发送给一个被支持的第三方网关进行符号化和处理.

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`gateway`** | `string` | 谷歌付费网关标识符. |
| **`gatewayMerchantId`** | `string` | 您的支付网关根据需要发布的 Merchant 标识 . |

#### GooglePayDirectTokenization 规格

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `'DIRECT'` | 将支付数据直接用于商边解密. |
| **`parameters`** | `[GooglePayDirectTokenizationParameters](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaydirecttokenizationparameters)` | 支付数据密码学的直接标志化参数. |

#### GooglePayDirect Tokenization Parameters (英语:GooglePayDirect Tokenization Paremeters) (英语)

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`protocolVersion`** | `string` | 支付数据加密协议版本. |
| **`publicKey`** | `string` | Base64-编码椭圆曲线公钥用于加密支付数据. |

#### GooglePayCusttom 客户化规格

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `[GooglePayTokenizationType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaytokenizationtype)` | 您的 Google Pay 集成所理解的切入式类型 . |
| **`parameters`** | `[Record](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-record)<string, string>` | 托肯化参数. Google Pay 期望字符串值. |

#### ApplePay 请求支付结果

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`platform`** | `'ios'` | 解决支付请求的平台. |
| **`apple`** | `[ApplePayPaymentResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaypaymentresult)` | 苹果支付有效载荷. |

#### ApplePayPayment 结果

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`paymentData`** | `string` | 原始支付符被编码为 Base64 字符串 . |
| **`paymentString`** | `string` | 原始支付符JSON字符串,用于调试. |
| **`transactionIdentifier`** | `string` | 支付交易识别符. |
| **`paymentMethod`** | `{ displayName?: string; network?: [ApplePayNetwork](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaynetwork); type: 'credit' | 'debit' | 'prepaid' | 'store'; }` |  |
| **`shippingContact`** | `[ApplePayContact](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaycontact)` |  |
| **`billingContact`** | `[ApplePayContact](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaycontact)` |  |
| **`shippingMethod`** | `[ApplePayShippingMethod](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayshippingmethod)` | 在工作表中选择的运输方法,何时 `shippingMethods` 已提供. |

#### ApplePay 联系人

| Prop | 类型 |
| --- | --- |
| **`name`** | `{ givenName?: string; familyName?: string; middleName?: string; namePrefix?: string; nameSuffix?: string; nickname?: string; }` |
| **`emailAddress`** | `string` |
| **`phoneNumber`** | `string` |
| **`postalAddress`** | `{ street?: string; city?: string; state?: string; postalCode?: string; country?: string; isoCountryCode?: string; subAdministrativeArea?: string; subLocality?: string; }` |

#### ApplePay 测试方法

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`identifier`** | `string` | 运输方法标识符,返回 `applePayShippingMethodSelected` 和支付结果. |
| **`label`** | `string` | 在苹果支付表上显示的名称. |
| **`amount`** | `string` | 作为十进制字符串的运输方法的成本(例如) `"4.95"`) (中文(简体) ). |
| **`detail`** | `string` | 标签下显示的额外行, 例如预期的交付 . |
| **`startDate`** | `string | number` | 首个预期交付日期,与 `endDate`。接受的格式与 [`ApplePayRecurringPaymentSummaryItem.startDate`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentsummaryitem)。每日在协调世界时阅读. |
| **`endDate`** | `string | number` | 最后一个预期交付日期,与 `startDate`。接受的格式与 [`ApplePayRecurringPaymentSummaryItem.endDate`](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentsummaryitem)。每日在协调世界时阅读. |

#### GooglePay 请求支付结果

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`platform`** | `'android'` | 解决支付请求的平台. |
| **`google`** | `[GooglePayPaymentResult](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentresult)` | 谷歌支付有效载荷. |

#### GooglePayPayment 付款结果

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`paymentData`** | `[GooglePayPaymentData](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentdata)` | Google Pay返回的支付数据. |

#### GooglePayPayment 数据

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`apiVersion`** | `number` | Google Pay API主要版本在回复中返回. |
| **`apiVersionMinor`** | `number` | Google Pay API小版本在回复中返回. |
| **`email`** | `string` | 购买者的电子邮件地址, 当 `emailRequired` 有人要求这样做. |
| **`shippingAddress`** | `[GooglePayAddress](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayaddress)` | 运输地址: `shippingAddressRequired` 有人要求这样做. |
| **`paymentMethodData`** | `[GooglePayPaymentMethodData](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentmethoddata)` | 选定付款方法细节和象征性有效载荷. |
| **`offerData`** | `[GooglePayOfferData](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayofferdata)` | 在适用报价时提供赎回数据. |
| **`shippingOptionData`** | `[GooglePaySelectionOptionData](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayselectionoptiondata)` | 使用航运选项时的选定航运选项数据. |

#### 谷歌付费地址

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`name`** | `string` | 收件人或持卡人姓名. |
| **`address1`** | `string` | 第一条地址线. |
| **`address2`** | `string` | 第二通地址线. |
| **`address3`** | `string` | 第三个地址线. |
| **`locality`** | `string` | 城市或地区. |
| **`administrativeArea`** | `string` | 州,行省,或者其他行政区域. |
| **`countryCode`** | `string` | 双字母ISO 3166-1α-2国家代码. |
| **`postalCode`** | `string` | 邮政或ZIP代码. |
| **`sortingCode`** | `string` | 一些国家使用的排序代码. |
| **`phoneNumber`** | `string` | 电话被请求时还原了. |
| **`iso3166AdministrativeArea`** | `string` | ISO 3166-2 行政区域代码 `FULL-ISO3166` 采用了格式. |

#### GooglePayPayment 方法数据

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `[GooglePayPaymentMethodType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentmethodtype)` | Google Pay返回的支付方法类型. |
| **`info`** | `[GooglePayCardInfo](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaycardinfo)` | 关于所选卡的额外信息 . |
| **`description`** | `string` | 对选定供资来源的用户介绍. |
| **`tokenizationData`** | `[GooglePayPaymentMethodTokenizationData](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentmethodtokenizationdata)` | 您发送到您的后端或处理器的肯化支付数据 . |

#### 谷歌PayCardInfo 页面存档备份,存于互联网档案馆

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`assuranceDetails`** | `[GooglePayAssuranceDetails](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayassurancedetails)` | 可选的保证细节在 `assuranceDetailsRequired` 有人要求这样做. |
| **`cardNetwork`** | `[GooglePayCardNetwork](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaycardnetwork)` | 选定支付方法的卡片网络 . |
| **`cardDetails`** | `string` | 卡片细节,一般为后四位数字. |
| **`billingAddress`** | `[GooglePayAddress](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayaddress)` | 当账单地址返回时 `billingAddressRequired` 有人要求这样做. |
| **`cardFundingSource`** | `[GooglePayCardFundingSource](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaycardfundingsource)` | 所选卡的资金来源. |

#### GooglePayAssurance 详情

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`accountVerified`** | `boolean` | Google 是否对所选卡的账户持有进行校验 . |
| **`cardHolderAuthenticated`** | `boolean` | 是否为所选卡完成卡持有者认证或ID&V. |

#### GooglePayPayment MethodTokenization 数据

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`type`** | `[GooglePayTokenizationType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaytokenizationtype)` | 用于选定支付方法的切换类型 . |
| **`token`** | `string` | 串行支付符或网关有效载荷. |

#### GooglePayOfferData (英语)

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`redemptionCodes`** | `string[]` | 买方适用的赎回法. |

#### GooglePay 选择选项数据

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`id`** | `string` | 选定选项的标识符. |

#### 支付选项

| Prop | 类型 |
| --- | --- |
| **`apple`** | `[ApplePayPaymentOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaypaymentoptions)` |
| **`google`** | `[GooglePayPaymentOptions](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentoptions)` |

#### ApplePayPayment 选项

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`merchantIdentifier`** | `string` | Merchant标识符创建于苹果开发者门户网站. |
| **`countryCode`** | `string` | 双字母ISO 3166国家代码. |
| **`currencyCode`** | `string` | 三字母ISO 4217货币代码. |
| **`paymentSummaryItems`** | `ApplePaySummaryItem[]` | 支付汇总项目显示于苹果支付表. |
| **`supportedNetworks`** | `ApplePayNetwork[]` | 需要支持的卡片网络. |
| **`merchantCapabilities`** | `ApplePayMerchantCapability[]` | 商业支付能力。 省略时默认为 \['3DS'\] . |
| **`requiredShippingContactFields`** | `ApplePayContactField[]` | 运输必须提供的联系地. |
| **`requiredBillingContactFields`** | `ApplePayContactField[]` | 开具账单必须提供的联系字段. |
| **`shippingType`** | `[ApplePayShippingType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayshippingtype)` | 控制提交用户的货运流量. |
| **`shippingMethods`** | `ApplePayShippingMethod[]` | 用户可以在工作表中选择的运输方法。 第一个是默认选择的。 包含选定方法的成本 `paymentSummaryItems` 自己,听着 `applePayShippingMethodSelected` 编号 : `applePayShippingContactSelected` 以更新总数。 当方法有不同的金额时,a `applePayShippingMethodSelected` 需要听众. |
| **`supportedCountries`** | `string[]` | 可选的ISO 3166 商家支持的国家代码. |
| **`applicationData`** | `string` | 可选的不透明应用程序数据在支付符中传回. |
| **`recurringPaymentRequest`** | `[ApplePayRecurringPaymentRequest](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentrequest)` | 经常性支付配置(iOS 16+). |

#### ApplePay 概要项目

| Prop | 类型 |
| --- | --- |
| **`label`** | `string` |
| **`amount`** | `string` |
| **`type`** | `[ApplePaySummaryItemType](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepaysummaryitemtype)` |

#### ApplePay 重复支付请求

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`paymentDescription`** | `string` | 关于Apple Pay表上显示的经常性支付的说明. |
| **`regularBilling`** | `[ApplePayRecurringPaymentSummaryItem](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentsummaryitem)` | 经常性的计费项目(例如您的订阅) . |
| **`managementURL`** | `string` | URL,用户可以管理经常性支付(取消,更新等). |
| **`billingAgreement`** | `string` | 向用户显示备选计费协议文本. |
| **`tokenNotificationURL`** | `string` | 可选的 URL 苹果可以发送令牌更新通知. |
| **`trialBilling`** | `[ApplePayRecurringPaymentSummaryItem](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentsummaryitem)` | 任择审判收费项目(例如免费审判期). |

#### ApplePay 经常支付项目

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`intervalUnit`** | `[ApplePayRecurringPaymentIntervalUnit](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-applepayrecurringpaymentintervalunit)` | 经常性付款之间的时间单位. |
| **`intervalCount`** | `number` | 数目 `intervalUnit` 经常付款之间的单位(例如) `1` 一个月, `2` 页:1. |
| **`startDate`** | `string | number` | 周期的起算日期。 在所支持的平台上,这可以是: `number` 代表自 Unix 时代起的毫秒,或 -- a `string` 以本地执行所接受的日期格式(例如ISO 8601日期时间字符串或 `yyyy-MM-dd` 日期字符串). |
| **`endDate`** | `string | number` | 周期结束日期。 在所支持的平台上,这可以是: `number` 代表自 Unix 时代起的毫秒,或 -- a `string` 以本地执行所接受的日期格式(例如ISO 8601日期时间字符串或 `yyyy-MM-dd` 日期字符串). |

#### 谷歌付费选项

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`environment`** | `[GooglePayEnvironment](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepayenvironment)` | 用于构建谷歌支付客户端的环境. 默认为 `'test'`。 。 。 . |
| **`paymentDataRequest`** | `[GooglePayPaymentDataRequest](https://npmcn.com/package/%40capgo/capacitor-pay/#readme-googlepaypaymentdatarequest)` | 原始内容 `PaymentDataRequest` JSON由谷歌付费API定义. 提供交易细节、商号信息和标识参数. |

#### 谷歌 PayPayment 数据请求

基于官方请求对象和绝对Typed定义的自成一体的Google付费请求类型.

该插件将提供的JSON转发给Android上的本地Google Pay SDK,同时将类型表面保留在本地 所以消费者不需要安装 `@types/googlepay`。 。 。 .

| Prop | 类型 | 说明 |
| --- | --- | --- |
| **`apiVersion`** | `number` | Google Pay API主要版本. 使用 `2` 用于当前整合. |
| **`apiVersionMinor`** | `number` | 谷歌付费API小版本. 使用 `0` 用于当前整合. |

## 常见问题

### @capgo/capacitor-pay 是什么？

启动本地支付iOS\( APPLAY\) 和 Android\( Google Pay\) 的电容插件

### 如何安装 @capgo/capacitor-pay？

在项目目录运行 npm install @capgo/capacitor-pay，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@capacitor/core（\>=8\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @capgo/capacitor-pay 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @capgo/capacitor-pay 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @capgo/capacitor-pay 可以商用吗？

@capgo/capacitor-pay 使用 MPL-2\.0 许可。弱 Copyleft：可以商用，也可以和闭源代码一起使用；但如果分发时修改了 MPL 授权的文件，这些文件的修改需以 MPL 开源。以上为概括，不构成法律意见，请以许可原文为准。

### @capgo/capacitor-pay 的下载量有多少？

根据 npm 官方下载统计，@capgo/capacitor-pay 在 2026/10/09 – 2026/11/07 这 30 天内被下载 25,543 次，日均约 851 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @capgo/capacitor-pay 还在维护吗？

最新版本 8\.2\.1 发布于 2026/10/15（25 天前）；至今共发布 53 个版本，其中过去 12 个月发布了 42 个；首次发布于 2025/10/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

