@capgo/capacitor-pay

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

Capacitor plugin to trigger native payment for iOS(Apple pay) and Android(Google Pay)

原始使用文档
文档目录18 节
  1. ➡️ Get started for free
  2. Key features
  3. Documentation
  4. Compatibility
  5. Install
  6. Platform setup
  7. Usage
  8. Recurring payments
  9. Shipping methods (Apple Pay)
  10. API
  11. isPayAvailable(...)
  12. requestPayment(...)
  13. updateApplePayShipping(...)
  14. addListener('applePayShippingContactSelected', ...)
  15. addListener('applePayShippingMethodSelected', ...)
  16. removeAllListeners()
  17. getPluginVersion()
  18. Interfaces

@capgo/capacitor-pay

Accept Apple Pay and Google Pay in your Capacitor app with one JavaScript API, using the native payment sheets.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-pay in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-pay to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-pay for Capacitor apps

Key features

  • Availability: isPayAvailable() checks if the device can pay with your networks.
  • Native sheet: requestPayment() presents Apple Pay or Google Pay and returns a structured result with the payment data.
  • Apple Pay options: merchant identifier, supported networks, capabilities and contact fields.
  • Google Pay options: test or production environment, card networks, and gateway or direct tokenization.
  • Platforms: iOS and Android. iOS uses PassKit, Android uses Google Pay through Play services. Not available on web.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/pay/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

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

Then use the following prompt:

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

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

# 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

Platform setup

Before invoking the plugin, complete the native configuration documented in this repository:

  • Apple Pay (iOS): see docs/apple-pay-setup.md for merchant ID creation, certificates, Xcode entitlements, and device testing.
  • Google Pay (Android): follow docs/google-pay-setup.md to configure the business profile, tokenization settings, and runtime JSON payloads.

Finish both guides once per app to unlock the native payment sheets on devices.

Google Pay request and response types are bundled with this plugin, so you do not need to install @types/googlepay unless you also use Google's web JavaScript client elsewhere in your app.

Usage

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.
}

Recurring payments

Apple Pay has first-class support via 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 does not have a dedicated "recurring request" object in PaymentDataRequest. For subscriptions you typically:

  1. Collect a token once with a normal paymentDataRequest.
  2. Store it server-side and create recurring charges with your PSP/gateway (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() is the completion path on both platforms.

Shipping methods (Apple Pay)

Pass shippingMethods to let the user choose how the order is delivered, for example home delivery or pickup in a store. The first method is selected by default. When the user changes the address or the method, the sheet waits until you answer with updateApplePayShipping(), passing the selectionId of the event. Answer every event, also when your own lookup fails; without an update within 20 seconds the sheet reports the selection as failed. When the methods have different amounts, the applePayShippingMethodSelected listener is required:

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(...)

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

Checks whether native pay is available on the current platform. On iOS this evaluates Apple Pay, on Android it evaluates Google Pay.

ParamType
optionsPayAvailabilityOptions

Returns: Promise<PayAvailabilityResult>


requestPayment(...)

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

Presents the native pay sheet for the current platform. Provide the Apple Pay configuration on iOS and the Google Pay configuration on Android.

This promise is the completion path on both platforms.

ParamType
optionsPayPaymentOptions

Returns: Promise<PayPaymentResult>


updateApplePayShipping(...)

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

Answers the latest applePayShippingContactSelected or applePayShippingMethodSelected event with new totals and, for a new address, new shipping methods. iOS only.

The Apple Pay sheet waits for this call, so call it once for every event you listen to, also when your own lookup fails. Without an update within 20 seconds, the sheet reports the selection as failed.

ParamType
optionsApplePayShippingUpdate

addListener('applePayShippingContactSelected', ...)

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

Called when the user selects or changes the shipping address in the Apple Pay sheet. iOS only.

Until the payment is authorized, Apple only shares a redacted address (city, state, postal code and country). The sheet waits until you call updateApplePayShipping(). Without a listener the sheet keeps its current totals.

ParamType
eventName'applePayShippingContactSelected'
listenerFunc(contact: ApplePayShippingContactSelectedEvent) => void

Returns: Promise<PluginListenerHandle>


addListener('applePayShippingMethodSelected', ...)

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

Called when the user selects another shipping method in the Apple Pay sheet. iOS only.

The sheet waits until you call updateApplePayShipping(). Without a listener the sheet keeps its current totals, so this listener is required when the shipping methods have different amounts.

ParamType
eventName'applePayShippingMethodSelected'
listenerFunc(shippingMethod: ApplePayShippingMethodSelectedEvent) => void

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Removes all listeners for this plugin.


getPluginVersion()

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

Get the native Capacitor plugin version

Returns: Promise<{ version: string; }>


Interfaces

PayAvailabilityResult

PropType
availableboolean
platformPayPlatform
appleApplePayAvailabilityResult
googleGooglePayAvailabilityResult

ApplePayAvailabilityResult

PropTypeDescription
canMakePaymentsbooleanIndicates whether the device can make Apple Pay payments in general.
canMakePaymentsUsingNetworksbooleanIndicates whether the device can make Apple Pay payments with the supplied networks.

GooglePayAvailabilityResult

PropTypeDescription
isReadybooleanWhether the user is able to provide payment information through the Google Pay payment sheet.
paymentMethodPresentbooleanThe current user's ability to pay with one or more of the payment methods specified in IsReadyToPayRequest.allowedPaymentMethods. This property only exists if IsReadyToPayRequest.existingPaymentMethodRequired was set to true. The property value will always be true if the request is configured for a test environment.

PayAvailabilityOptions

PropType
appleApplePayAvailabilityOptions
googleGooglePayAvailabilityOptions

ApplePayAvailabilityOptions

PropTypeDescription
supportedNetworksApplePayNetwork[]Optional list of payment networks you intend to use. Passing networks determines the return value of canMakePaymentsUsingNetworks.

GooglePayAvailabilityOptions

PropTypeDescription
environmentGooglePayEnvironmentEnvironment used to construct the Google Payments client. Defaults to 'test'.
isReadyToPayRequestGooglePayIsReadyToPayRequestRaw IsReadyToPayRequest JSON as defined by the Google Pay API. Supply the card networks and auth methods you intend to support at runtime.

GooglePayIsReadyToPayRequest

Self-contained Google Pay request type based on the official request objects and DefinitelyTyped definitions.

The plugin forwards the provided JSON to the native Google Pay SDK on Android, while keeping the type surface local so consumers do not need to install @types/googlepay.

PropTypeDescription
apiVersionnumberGoogle Pay API major version. Use 2 for current integrations.
apiVersionMinornumberGoogle Pay API minor version. Use 0 for current integrations.
allowedPaymentMethodsGooglePayAllowedPaymentMethod[]Payment methods you want to test for readiness.
existingPaymentMethodRequiredbooleanWhen true, Google Pay also indicates whether an existing matching payment method is present. In the test environment this always resolves to true.

GooglePayAllowedPaymentMethod

PropTypeDescription
typeGooglePayPaymentMethodTypeSupported payment method type. CARD is the only value currently accepted by Google Pay request objects.
parametersGooglePayCardPaymentMethodParametersParameters that control which cards can be shown and what extra data is collected.
tokenizationSpecificationGooglePayTokenizationSpecificationTokenization settings for the selected payment method. In Google Pay, this is required for PaymentDataRequest card payment methods, but ignored by IsReadyToPayRequest.

GooglePayCardPaymentMethodParameters

PropTypeDescription
allowedAuthMethodsGooglePayAuthMethod[]Authentication methods your gateway or processor accepts.
allowedCardNetworksGooglePayCardNetwork[]Card networks your gateway or processor accepts.
allowPrepaidCardsbooleanWhether prepaid cards are allowed. Defaults to true in Google Pay.
allowCreditCardsbooleanWhether credit cards are allowed. Defaults to true in Google Pay.
allowedIssuerCountryCodesstring[]Restricts users to cards issued in the provided ISO 3166-1 alpha-2 countries.
blockedIssuerCountryCodesstring[]Blocks cards issued in the provided ISO 3166-1 alpha-2 countries. This is mutually exclusive with allowedIssuerCountryCodes.
assuranceDetailsRequiredbooleanWhether Google Pay should include assurance details about the selected card.
billingAddressRequiredbooleanWhether a billing address is required from the buyer.
billingAddressParametersGooglePayBillingAddressParametersAdditional billing-address controls used when billingAddressRequired is true.
cardNetworkParametersGooglePayCardNetworkParameters[]Optional network-specific processing parameters for supported networks.
cvcRequiredbooleanWhether the card verification code should be returned in the payment token. This requires Google enablement for your account.

GooglePayBillingAddressParameters

PropTypeDescription
formatGooglePayBillingAddressFormatBilling address format to return when billingAddressRequired is true. Use FULL only when you truly need the extra fields to complete the order.
phoneNumberRequiredbooleanWhether a billing phone number should also be returned.

GooglePayCardNetworkParameters

PropTypeDescription
cardNetworkGooglePayCardNetworkCard network these network-specific parameters apply to.
acquirerBinstringAcquiring institution identification code used by some network-specific flows.
acquirerMerchantIdstringAcquirer-assigned merchant identifier used by some network-specific flows.

GooglePayGatewayTokenizationSpecification

PropTypeDescription
type'PAYMENT_GATEWAY'Tokenize payment data for a supported third-party gateway.
parametersGooglePayPaymentGatewayTokenizationParametersGateway-specific tokenization parameters.

GooglePayPaymentGatewayTokenizationParameters

Tokenization parameters for PAYMENT_GATEWAY tokenization, which sends the payment data to a supported third-party gateway for tokenization and processing.

PropTypeDescription
gatewaystringGoogle Pay gateway identifier.
gatewayMerchantIdstringMerchant identifier issued by your payment gateway when required.

GooglePayDirectTokenizationSpecification

PropTypeDescription
type'DIRECT'Tokenize payment data directly for merchant-side decryption.
parametersGooglePayDirectTokenizationParametersDirect tokenization parameters for payment data cryptography.

GooglePayDirectTokenizationParameters

PropTypeDescription
protocolVersionstringPayment data cryptography protocol version.
publicKeystringBase64-encoded elliptic-curve public key used to encrypt the payment data.

GooglePayCustomTokenizationSpecification

PropTypeDescription
typeGooglePayTokenizationTypeTokenization type understood by your Google Pay integration.
parametersRecord<string, string>Tokenization parameters. Google Pay expects string values.

ApplePayRequestPaymentResult

PropTypeDescription
platform'ios'Platform that resolved the payment request.
appleApplePayPaymentResultApple Pay payment payload.

ApplePayPaymentResult

PropTypeDescription
paymentDatastringRaw payment token encoded as base64 string.
paymentStringstringRaw payment token JSON string, useful for debugging.
transactionIdentifierstringPayment transaction identifier.
paymentMethod{ displayName?: string; network?: ApplePayNetwork; type: 'credit' | 'debit' | 'prepaid' | 'store'; }
shippingContactApplePayContact
billingContactApplePayContact
shippingMethodApplePayShippingMethodShipping method selected in the sheet, when shippingMethods were provided.

ApplePayContact

PropType
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; }

ApplePayShippingMethod

PropTypeDescription
identifierstringIdentifier of the shipping method, returned in applePayShippingMethodSelected and in the payment result.
labelstringName shown in the Apple Pay sheet.
amountstringCost of the shipping method as a decimal string (for example "4.95").
detailstringExtra line shown under the label, for example the expected delivery.
startDatestring | numberFirst expected delivery date, shown as a date range together with endDate. Accepts the same formats as ApplePayRecurringPaymentSummaryItem.startDate. The day is read in UTC.
endDatestring | numberLast expected delivery date, shown as a date range together with startDate. Accepts the same formats as ApplePayRecurringPaymentSummaryItem.endDate. The day is read in UTC.

GooglePayRequestPaymentResult

PropTypeDescription
platform'android'Platform that resolved the payment request.
googleGooglePayPaymentResultGoogle Pay payment payload.

GooglePayPaymentResult

PropTypeDescription
paymentDataGooglePayPaymentDataPayment data returned by Google Pay.

GooglePayPaymentData

PropTypeDescription
apiVersionnumberGoogle Pay API major version returned in the response.
apiVersionMinornumberGoogle Pay API minor version returned in the response.
emailstringBuyer email address when emailRequired was requested.
shippingAddressGooglePayAddressShipping address when shippingAddressRequired was requested.
paymentMethodDataGooglePayPaymentMethodDataSelected payment method details and tokenized payload.
offerDataGooglePayOfferDataOffer redemption data when an offer was applied.
shippingOptionDataGooglePaySelectionOptionDataSelected shipping option data when shipping options were used.

GooglePayAddress

PropTypeDescription
namestringRecipient or cardholder name.
address1stringFirst address line.
address2stringSecond address line.
address3stringThird address line.
localitystringCity or locality.
administrativeAreastringState, province, or other administrative area.
countryCodestringTwo-letter ISO 3166-1 alpha-2 country code.
postalCodestringPostal or ZIP code.
sortingCodestringSorting code used in some countries.
phoneNumberstringPhone number returned when it was requested.
iso3166AdministrativeAreastringISO 3166-2 code for the administrative area when FULL-ISO3166 formatting is used.

GooglePayPaymentMethodData

PropTypeDescription
typeGooglePayPaymentMethodTypePayment method type returned by Google Pay.
infoGooglePayCardInfoAdditional information about the selected card.
descriptionstringUser-facing description of the selected funding source.
tokenizationDataGooglePayPaymentMethodTokenizationDataTokenized payment data you send to your backend or processor.

GooglePayCardInfo

PropTypeDescription
assuranceDetailsGooglePayAssuranceDetailsOptional assurance details returned when assuranceDetailsRequired was requested.
cardNetworkGooglePayCardNetworkCard network for the selected payment method.
cardDetailsstringCard details, typically the last four digits.
billingAddressGooglePayAddressBilling address returned when billingAddressRequired was requested.
cardFundingSourceGooglePayCardFundingSourceFunding source for the selected card when available.

GooglePayAssuranceDetails

PropTypeDescription
accountVerifiedbooleanWhether Google verified account possession for the selected card.
cardHolderAuthenticatedbooleanWhether cardholder authentication or ID&V was completed for the selected card.

GooglePayPaymentMethodTokenizationData

PropTypeDescription
typeGooglePayTokenizationTypeTokenization type used for the selected payment method.
tokenstringSerialized payment token or gateway payload.

GooglePayOfferData

PropTypeDescription
redemptionCodesstring[]Offer redemption codes applied by the buyer.

GooglePaySelectionOptionData

PropTypeDescription
idstringIdentifier of the selected option.

PayPaymentOptions

PropType
appleApplePayPaymentOptions
googleGooglePayPaymentOptions

ApplePayPaymentOptions

PropTypeDescription
merchantIdentifierstringMerchant identifier created in the Apple Developer portal.
countryCodestringTwo-letter ISO 3166 country code.
currencyCodestringThree-letter ISO 4217 currency code.
paymentSummaryItemsApplePaySummaryItem[]Payment summary items displayed in the Apple Pay sheet.
supportedNetworksApplePayNetwork[]Card networks to support.
merchantCapabilitiesApplePayMerchantCapability[]Merchant payment capabilities. Defaults to ['3DS'] when omitted.
requiredShippingContactFieldsApplePayContactField[]Contact fields that must be supplied for shipping.
requiredBillingContactFieldsApplePayContactField[]Contact fields that must be supplied for billing.
shippingTypeApplePayShippingTypeControls the shipping flow presented to the user.
shippingMethodsApplePayShippingMethod[]Shipping methods the user can choose from in the sheet. The first one is selected by default. Include the cost of the selected method in paymentSummaryItems yourself, and listen to applePayShippingMethodSelected / applePayShippingContactSelected to update the totals. When the methods have different amounts, an applePayShippingMethodSelected listener is required.
supportedCountriesstring[]Optional ISO 3166 country codes where the merchant is supported.
applicationDatastringOptional opaque application data passed back in the payment token.
recurringPaymentRequestApplePayRecurringPaymentRequestRecurring payment configuration (iOS 16+).

ApplePaySummaryItem

PropType
labelstring
amountstring
typeApplePaySummaryItemType

ApplePayRecurringPaymentRequest

PropTypeDescription
paymentDescriptionstringA description for the recurring payment shown in the Apple Pay sheet.
regularBillingApplePayRecurringPaymentSummaryItemThe recurring billing item (for example your subscription).
managementURLstringURL where the user can manage the recurring payment (cancel, update, etc).
billingAgreementstringOptional billing agreement text shown to the user.
tokenNotificationURLstringOptional URL where Apple can send token update notifications.
trialBillingApplePayRecurringPaymentSummaryItemOptional trial billing item (for example a free trial period).

ApplePayRecurringPaymentSummaryItem

PropTypeDescription
intervalUnitApplePayRecurringPaymentIntervalUnitUnit of time between recurring payments.
intervalCountnumberNumber of intervalUnit units between recurring payments (for example 1 month, 2 weeks).
startDatestring | numberStart date of the recurring period. On supported platforms this may be either: - a number representing milliseconds since Unix epoch, or - a string in a date format accepted by the native implementation (for example an ISO 8601 date-time string or a yyyy-MM-dd date string).
endDatestring | numberEnd date of the recurring period. On supported platforms this may be either: - a number representing milliseconds since Unix epoch, or - a string in a date format accepted by the native implementation (for example an ISO 8601 date-time string or a yyyy-MM-dd date string).

GooglePayPaymentOptions

PropTypeDescription
environmentGooglePayEnvironmentEnvironment used to construct the Google Payments client. Defaults to 'test'.
paymentDataRequestGooglePayPaymentDataRequestRaw PaymentDataRequest JSON as defined by the Google Pay API. Provide transaction details, merchant info, and tokenization parameters.

GooglePayPaymentDataRequest

Self-contained Google Pay payment request type based on the official request objects and DefinitelyTyped definitions.

The plugin forwards the provided JSON to the native Google Pay SDK on Android, while keeping the type surface local so consumers do not need to install @types/googlepay.

PropTypeDescription
apiVersionnumberGoogle Pay API major version. Use 2 for current integrations.
apiVersionMinornumberGoogle Pay API minor version. Use 0 for current integrations.

版本与发布记录

@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 是什么?

Capacitor plugin to trigger native payment for iOS(Apple pay) and 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 和提交记录判断。