@capgo/capacitor-pay

中文文档
8.2.1发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2.6万

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

中文使用文档
文档目录18 节
  1. *免费开始*
  2. 主要特点
  3. 文档
  4. 兼容性
  5. 安装
  6. 平台设置
  7. 使用量
  8. 经常性付款
  9. 航运方法(付薪)
  10. API 密码
  11. 是PayAvailable (...) (中文(简体) )
  12. 请求支付(...)
  13. 更新 ApplePayShipping (...)
  14. 添加倾听器( “ applePayShippingContact Select” ,...)
  15. 添加聆听器( “ applePayShipping Method Select” ,...)
  16. 删除所有收听器( )
  17. 获取 PluginVersion ()
  18. 接口

@ capgo/ 电容器- pay

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

Capgo - Build Capacitor apps with AI, ship updates instantly

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

*免费开始*

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

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

@capgo/capacitor-pay for Capacitor apps

主要特点

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

文档

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

兼容性

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

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

安装

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

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

然后使用下列提示:

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

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

# 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 用于商家ID创建,证书,Xcode权限,以及设备测试.
  • 谷歌付费( Android) : 跟着 docs/google-pay-setup.md 配置商务简介、标识设置和运行时间 JSON 有效载荷.

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

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

使用量

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+):

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) 创建经常性收费.
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 需要听众:

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 密码

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

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

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

参数类型
optionsPayAvailabilityOptions

回返情况: Promise<PayAvailabilityResult>


请求支付(...)

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

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

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

参数类型
optionsPayPaymentOptions

回返情况: Promise<PayPaymentResult>


更新 ApplePayShipping (...)

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

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

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

参数类型
optionsApplePayShippingUpdate

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

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

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

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

参数类型
eventName'applePayShippingContactSelected'
listenerFunc(contact: ApplePayShippingContactSelectedEvent) => void

回返情况: Promise<PluginListenerHandle>


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

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

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

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

参数类型
eventName'applePayShippingMethodSelected'
listenerFunc(shippingMethod: ApplePayShippingMethodSelectedEvent) => void

回返情况: Promise<PluginListenerHandle>


删除所有收听器( )

removeAllListeners() => Promise<void>

删除此插件的所有听众 .


获取 PluginVersion ()

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

获取本地 Capacitor 插件版本

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


接口

薪资可偿还性

Prop类型
availableboolean
platformPayPlatform
appleApplePayAvailabilityResult
googleGooglePayAvailabilityResult

ApplePayAvail可操作性

Prop类型说明
canMakePaymentsboolean表示该设备能否普遍支付苹果支付.
canMakePaymentsUsingNetworksboolean说明该设备能否与所提供网络进行苹果支付.

GooglePay-Avail可操作性

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

可选择性

Prop类型
appleApplePayAvailabilityOptions
googleGooglePayAvailabilityOptions

ApplePay 可用性选项

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

GooglePay 可用性选项

Prop类型说明
environmentGooglePayEnvironment用于构建谷歌支付客户端的环境. 默认为 'test'。 。 。 .
isReadyToPayRequestGooglePayIsReadyToPayRequest原始内容 IsReadyToPayRequest JSON由谷歌付费API定义. 提供您打算在运行时支持的卡片网络和认证方法 .

GooglePay is ReadyToPay 请求

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

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

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

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

Prop类型说明
typeGooglePayPaymentMethodType支持的支付方法类型 . CARD 是Google Pay 请求对象目前接受的唯一值.
parametersGooglePayCardPaymentMethodParameters用于控制哪些卡可以显示以及收集哪些额外数据的参数.
tokenizationSpecificationGooglePayTokenizationSpecification选定支付方法的切入设置 。 在Google Pay中,这需要用于 PaymentDataRequest 支付卡的方法, 但被忽略 IsReadyToPayRequest。 。 。 .

GooglePayCardPayment 方法软件

Prop类型说明
allowedAuthMethodsGooglePayAuthMethod[]认证方法 您的网关或处理器接受 .
allowedCardNetworksGooglePayCardNetwork[]您的网关或处理器接受卡片网络 .
allowPrepaidCardsboolean是否允许预付卡 。 默认为 true 在谷歌付费.
allowCreditCardsboolean是否允许信用卡 。 默认为 true 在谷歌付费.
allowedIssuerCountryCodesstring[]限制用户在提供的ISO 3166-1 α-2国家发行的卡.
blockedIssuerCountryCodesstring[]在所提供的ISO 3166-1 alpha-2国家中发行的区块卡. 这是相互排斥的 allowedIssuerCountryCodes。 。 。 .
assuranceDetailsRequiredbooleanGoogle Pay是否应该包含关于所选卡的保证细节.
billingAddressRequiredboolean是否要求买方提供账单地址.
billingAddressParametersGooglePayBillingAddressParameters使用额外的帐单地址控制 billingAddressRequired 实值 true。 。 。 .
cardNetworkParametersGooglePayCardNetworkParameters[]支持网络的可选网络专用处理参数.
cvcRequiredboolean是否应当在支付符中返回卡验证代码 。 这需要谷歌启用您的账户 .

GooglePayBilling Address 算法

Prop类型说明
formatGooglePayBillingAddressFormat计费地址格式在 billingAddressRequired 实值 true启用 FULL 只当您真的需要额外的字段来完成命令时.
phoneNumberRequiredboolean是否还应退还帐号.

GooglePayCard 网络参数

Prop类型说明
cardNetworkGooglePayCardNetwork卡片网络适用这些网络特定参数.
acquirerBinstring获取一些网络特定流量所使用的机构识别代码.
acquirerMerchantIdstring获得指定商号标识,一些网络特定流量使用.

GooglePayGateway 用户化规格

Prop类型说明
type'PAYMENT_GATEWAY'将一个支持的第三方网关的支付数据存储.
parametersGooglePayPaymentGatewayTokenizationParameters网关专用的标志化参数.

GooglePayPayment Gateway 客户化

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

Prop类型说明
gatewaystring谷歌付费网关标识符.
gatewayMerchantIdstring您的支付网关根据需要发布的 Merchant 标识 .

GooglePayDirectTokenization 规格

Prop类型说明
type'DIRECT'将支付数据直接用于商边解密.
parametersGooglePayDirectTokenizationParameters支付数据密码学的直接标志化参数.

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

Prop类型说明
protocolVersionstring支付数据加密协议版本.
publicKeystringBase64-编码椭圆曲线公钥用于加密支付数据.

GooglePayCusttom 客户化规格

Prop类型说明
typeGooglePayTokenizationType您的 Google Pay 集成所理解的切入式类型 .
parametersRecord<string, string>托肯化参数. Google Pay 期望字符串值.

ApplePay 请求支付结果

Prop类型说明
platform'ios'解决支付请求的平台.
appleApplePayPaymentResult苹果支付有效载荷.

ApplePayPayment 结果

Prop类型说明
paymentDatastring原始支付符被编码为 Base64 字符串 .
paymentStringstring原始支付符JSON字符串,用于调试.
transactionIdentifierstring支付交易识别符.
paymentMethod{ displayName?: string; network?: ApplePayNetwork; type: 'credit' | 'debit' | 'prepaid' | 'store'; }
shippingContactApplePayContact
billingContactApplePayContact
shippingMethodApplePayShippingMethod在工作表中选择的运输方法,何时 shippingMethods 已提供.

ApplePay 联系人

Prop类型
name{ givenName?: string; familyName?: string; middleName?: string; namePrefix?: string; nameSuffix?: string; nickname?: string; }
emailAddressstring
phoneNumberstring
postalAddress{ street?: string; city?: string; state?: string; postalCode?: string; country?: string; isoCountryCode?: string; subAdministrativeArea?: string; subLocality?: string; }

ApplePay 测试方法

Prop类型说明
identifierstring运输方法标识符,返回 applePayShippingMethodSelected 和支付结果.
labelstring在苹果支付表上显示的名称.
amountstring作为十进制字符串的运输方法的成本(例如) "4.95") (中文(简体) ).
detailstring标签下显示的额外行, 例如预期的交付 .
startDatestring | number首个预期交付日期,与 endDate。接受的格式与 ApplePayRecurringPaymentSummaryItem.startDate。每日在协调世界时阅读.
endDatestring | number最后一个预期交付日期,与 startDate。接受的格式与 ApplePayRecurringPaymentSummaryItem.endDate。每日在协调世界时阅读.

GooglePay 请求支付结果

Prop类型说明
platform'android'解决支付请求的平台.
googleGooglePayPaymentResult谷歌支付有效载荷.

GooglePayPayment 付款结果

Prop类型说明
paymentDataGooglePayPaymentDataGoogle Pay返回的支付数据.

GooglePayPayment 数据

Prop类型说明
apiVersionnumberGoogle Pay API主要版本在回复中返回.
apiVersionMinornumberGoogle Pay API小版本在回复中返回.
emailstring购买者的电子邮件地址, 当 emailRequired 有人要求这样做.
shippingAddressGooglePayAddress运输地址: shippingAddressRequired 有人要求这样做.
paymentMethodDataGooglePayPaymentMethodData选定付款方法细节和象征性有效载荷.
offerDataGooglePayOfferData在适用报价时提供赎回数据.
shippingOptionDataGooglePaySelectionOptionData使用航运选项时的选定航运选项数据.

谷歌付费地址

Prop类型说明
namestring收件人或持卡人姓名.
address1string第一条地址线.
address2string第二通地址线.
address3string第三个地址线.
localitystring城市或地区.
administrativeAreastring州,行省,或者其他行政区域.
countryCodestring双字母ISO 3166-1α-2国家代码.
postalCodestring邮政或ZIP代码.
sortingCodestring一些国家使用的排序代码.
phoneNumberstring电话被请求时还原了.
iso3166AdministrativeAreastringISO 3166-2 行政区域代码 FULL-ISO3166 采用了格式.

GooglePayPayment 方法数据

Prop类型说明
typeGooglePayPaymentMethodTypeGoogle Pay返回的支付方法类型.
infoGooglePayCardInfo关于所选卡的额外信息 .
descriptionstring对选定供资来源的用户介绍.
tokenizationDataGooglePayPaymentMethodTokenizationData您发送到您的后端或处理器的肯化支付数据 .

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

Prop类型说明
assuranceDetailsGooglePayAssuranceDetails可选的保证细节在 assuranceDetailsRequired 有人要求这样做.
cardNetworkGooglePayCardNetwork选定支付方法的卡片网络 .
cardDetailsstring卡片细节,一般为后四位数字.
billingAddressGooglePayAddress当账单地址返回时 billingAddressRequired 有人要求这样做.
cardFundingSourceGooglePayCardFundingSource所选卡的资金来源.

GooglePayAssurance 详情

Prop类型说明
accountVerifiedbooleanGoogle 是否对所选卡的账户持有进行校验 .
cardHolderAuthenticatedboolean是否为所选卡完成卡持有者认证或ID&V.

GooglePayPayment MethodTokenization 数据

Prop类型说明
typeGooglePayTokenizationType用于选定支付方法的切换类型 .
tokenstring串行支付符或网关有效载荷.

GooglePayOfferData (英语)

Prop类型说明
redemptionCodesstring[]买方适用的赎回法.

GooglePay 选择选项数据

Prop类型说明
idstring选定选项的标识符.

支付选项

Prop类型
appleApplePayPaymentOptions
googleGooglePayPaymentOptions

ApplePayPayment 选项

Prop类型说明
merchantIdentifierstringMerchant标识符创建于苹果开发者门户网站.
countryCodestring双字母ISO 3166国家代码.
currencyCodestring三字母ISO 4217货币代码.
paymentSummaryItemsApplePaySummaryItem[]支付汇总项目显示于苹果支付表.
supportedNetworksApplePayNetwork[]需要支持的卡片网络.
merchantCapabilitiesApplePayMerchantCapability[]商业支付能力。 省略时默认为 ['3DS'] .
requiredShippingContactFieldsApplePayContactField[]运输必须提供的联系地.
requiredBillingContactFieldsApplePayContactField[]开具账单必须提供的联系字段.
shippingTypeApplePayShippingType控制提交用户的货运流量.
shippingMethodsApplePayShippingMethod[]用户可以在工作表中选择的运输方法。 第一个是默认选择的。 包含选定方法的成本 paymentSummaryItems 自己,听着 applePayShippingMethodSelected 编号 : applePayShippingContactSelected 以更新总数。 当方法有不同的金额时,a applePayShippingMethodSelected 需要听众.
supportedCountriesstring[]可选的ISO 3166 商家支持的国家代码.
applicationDatastring可选的不透明应用程序数据在支付符中传回.
recurringPaymentRequestApplePayRecurringPaymentRequest经常性支付配置(iOS 16+).

ApplePay 概要项目

Prop类型
labelstring
amountstring
typeApplePaySummaryItemType

ApplePay 重复支付请求

Prop类型说明
paymentDescriptionstring关于Apple Pay表上显示的经常性支付的说明.
regularBillingApplePayRecurringPaymentSummaryItem经常性的计费项目(例如您的订阅) .
managementURLstringURL,用户可以管理经常性支付(取消,更新等).
billingAgreementstring向用户显示备选计费协议文本.
tokenNotificationURLstring可选的 URL 苹果可以发送令牌更新通知.
trialBillingApplePayRecurringPaymentSummaryItem任择审判收费项目(例如免费审判期).

ApplePay 经常支付项目

Prop类型说明
intervalUnitApplePayRecurringPaymentIntervalUnit经常性付款之间的时间单位.
intervalCountnumber数目 intervalUnit 经常付款之间的单位(例如) 1 一个月, 2 页:1.
startDatestring | number周期的起算日期。 在所支持的平台上,这可以是: number 代表自 Unix 时代起的毫秒,或 -- a string 以本地执行所接受的日期格式(例如ISO 8601日期时间字符串或 yyyy-MM-dd 日期字符串).
endDatestring | number周期结束日期。 在所支持的平台上,这可以是: number 代表自 Unix 时代起的毫秒,或 -- a string 以本地执行所接受的日期格式(例如ISO 8601日期时间字符串或 yyyy-MM-dd 日期字符串).

谷歌付费选项

Prop类型说明
environmentGooglePayEnvironment用于构建谷歌支付客户端的环境. 默认为 'test'。 。 。 .
paymentDataRequestGooglePayPaymentDataRequest原始内容 PaymentDataRequest JSON由谷歌付费API定义. 提供交易细节、商号信息和标识参数.

谷歌 PayPayment 数据请求

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

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

Prop类型说明
apiVersionnumberGoogle Pay API主要版本. 使用 2 用于当前整合.
apiVersionMinornumber谷歌付费API小版本. 使用 0 用于当前整合.

版本与发布记录

@capgo/capacitor-pay 共发布 53 个版本,首次发布于 2025/10/09;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.2.1latest2026/10/1525 天前
8.2.02026/10/1425 天前
8.1.252026/10/1425 天前
8.1.242026/10/1327 天前
8.1.232026/10/1228 天前
8.1.222026/10/091 个月前

关于 @capgo/capacitor-pay 的常见问题

@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 和提交记录判断。