@capacitor-community/google-pay
v4.0.1
Published
Capacitor Plugin used to enable Google Pay in an Application
Maintainers
Readme
Maintainers
| Maintainer | GitHub | Social | | -----------| -------| -------| | Capacitor Community | capacitor-community | |
Documentation
Installation
npm install @capacitor-community/google-pay
npx cap syncDemo
A working example can be found in the example-app directory.
API
initGooglePayClient(...)
initGooglePayClient(request: GooglePayInitClientRequest) => Promise<GooglePayInitClientResponse>| Param | Type |
| ------------- | --------------------------------------------------------------------------------- |
| request | GooglePayInitClientRequest |
Returns: Promise<GooglePayInitClientResponse>
canMakePayments(...)
canMakePayments(request: GooglePayRequest) => Promise<GooglePayCanMakePaymentsResponse>| Param | Type |
| ------------- | ------------------------------------------------------------- |
| request | GooglePayRequest |
Returns: Promise<GooglePayCanMakePaymentsResponse>
makePaymentRequest(...)
makePaymentRequest(request: GooglePayPaymentRequest) => Promise<GooglePayMakePaymentRequestResponse>| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| request | GooglePayPaymentRequest |
Returns: Promise<GooglePayMakePaymentRequestResponse>
Interfaces
GooglePayInitClientResponse
The response object that is returned after attempting to initialize the Google Pay client.
| Prop | Type | Description |
| ------------- | -------------------- | ------------------------------------------------------------------------------------ |
| isReady | boolean | - Type: boolean A boolean that defines if the client was successfully initialized. |
GooglePayInitClientRequest
An object that contains the necessary information to initialize the Google Pay client.
| Prop | Type | Description |
| ----------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| environment | GooglePayEnvironment | - Type: {@link GooglePayEnvironment} The environment to run the Google Pay API on. |
| version | GooglePayVersion | - Type: {@link GooglePayVersion} The object that defines which Google Pay API versions to use. |
GooglePayVersion
A configuration object that defines which Google Pay API versions to use.
| Prop | Type | Description |
| --------------------- | ------------------------ | ----------------------------------------------------------- |
| apiVersion | 0 | 1 | 2 | - Type: 0 | 1 | 2 The major API version to target. |
| apiVersionMinor | 0 | 1 | 2 | - Type: 0 | 1 | 2 The minor API version to support. |
GooglePayCanMakePaymentsResponse
The response object that defines if the user is allowed to make a payment using the current device and transaction configuration.
| Prop | Type | Description |
| --------------------- | -------------------- | -------------------------------------------------------------------------- |
| canMakePayments | boolean | - Type: boolean A boolean that defines if the client can make a payment. |
GooglePayRequest
A request object used to determine if the user is eligible to make payments on their device with the configured payment methods.
| Prop | Type | Description |
| --------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowedPaymentMethods | GooglePayPaymentMethod[] | - Type: {@link GooglePayPaymentMethod} The array that defines the allowed payment methods supported by Google Pay and your website. |
GooglePayPaymentMethod
An object that specifies payment methods that are supported by the Google Pay API and your website.
| Prop | Type | Description | Default |
| ------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| type | 'CARD' | - Type: CARD The identifier for the supported payment type. | CARD |
| parameters | GooglePayPaymentMethodParameters | - Type: {@link GooglePayPaymentMethodParameters} The configuration parameters for defining the allowed payment methods. | |
| tokenizationSpecification | GooglePayTokenizationSpecification | - Type: {@link GooglePayTokenizationSpecification} The Google Pay account configured to receive payments. | undefined |
GooglePayPaymentMethodParameters
A configuration object that defines the allowable authorization methods and card networks
| Prop | Type | Description |
| ------------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowedAuthMethods | GooglePayAllowedAuthMethod[] | - Type: {@link GooglePayAllowedAuthMethod} An array of authorization methods that are allowed to be used during the payment process. |
| allowedCardNetworks | GooglePayAllowedNetwork[] | - Type: {@link GooglePayAllowedNetwork} An array of card networks that are accepted for payment. |
| billingAddressRequired | boolean | Set to true if you require a billing address. A billing address should only be requested if it's required to process the transaction. Additional data requests can increase friction in the checkout process and lead to a lower conversion rate. |
| billingAddressParameters | GooglePayBillingAddressParameters | The expected fields returned if {@link GooglePayBillingAddressParameters} is set to true. |
GooglePayBillingAddressParameters
This object allows you to set additional fields to be returned for a requested billing address.
| Prop | Type | Description |
| ------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| format | GooglePayBillingAddressFormat | Billing address format required to complete the transaction. |
| phoneNumberRequired | boolean | Set to true if a phone number is required to process the transaction. |
GooglePayTokenizationSpecification
An object to configure the Google Pay account to receive chargeable payment information.
| Prop | Type | Description | Default |
| ---------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| type | 'PAYMENT_GATEWAY' | - Type: PAYMENT_GATEWAY The payment method tokenization type supported. | PAYMENT_GATEWAY |
| parameters | GooglePayPaymentProviderLookup | - Type: {@link GooglePayPaymentProviderLookup} The payment gateway specific to the tokenization type. | |
GooglePayPaymentProviderLookup
A object that specifies the gateway configured in the Google Payments Profile.
| Prop | Type | Description |
| ----------------------- | ------------------- | ------------------------------------------------------------------------- |
| gateway | string | - Type: string The gateway's identifier which is issued by Google. |
| gatewayMerchantId | string | - Type: string The gateway account ID which is provided by the gateway. |
GooglePayMakePaymentRequestResponse
| Prop | Type | Description |
| ----------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| paymentMethodData | GooglePayPaymentMethodData | - Type: {@link GooglePayPaymentMethodData} |
GooglePayPaymentMethodData
A response object that provides data for the selected payment method.
| Prop | Type | Description |
| ---------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| description | string | - Type: string User-facing message to describe the payment method that funds the transaction. |
| info | { cardDetails: string; cardNetwork: string; } | - Type: object An object that provides information about the selected payment card. |
| tokenizationData | { token: string; type: string; } | - Type: object Payment tokenization data for the selected payment method. |
| type | string | - Type: {@link GooglePayPaymentMethod.type} The {@link GooglePayPaymentMethod.type} that was selected in the Google Pay payment sheet. |
GooglePayPaymentRequest
An object describing the payment request, including information about the allowed payment methods, transaction, and the merchant.
| Prop | Type | Description |
| ------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowedPaymentMethods | GooglePayPaymentMethod[] | - Type: {@link GooglePayPaymentMethod} An array that contains the payment methods supported by Google Pay and your website. |
| transactionInfo | GooglePayTransactionInfo | - Type: {@link GooglePayTransactionInfo} An object that describes the current transaction. |
| merchantInfo | GooglePayMerchantInfo | - Type: {@link GooglePayMerchantInfo} An object that provides information about the merchant requesting payment data. |
| emailRequired | boolean | Set to true to request an email address. |
| shippingAddressRequired | boolean | Set to true to request a full shipping address. |
| shippingAddressParameters | GooglePayShippingAddressParameters | If shippingAddressRequired is set to true, specify shipping address restrictions. |
| shippingOptionRequired | boolean | Set to true when the SHIPPING_OPTION callback intent is used. This field is required if you implement support for Authorize Payments or Dynamic Price Updates. For more details see: {@link GooglePayShippingOptionParameters} |
| shippingOptionParameters | GooglePayShippingOptionParameters[] | Set default options. |
GooglePayTransactionInfo
An object that describes a transaction, including its status, price, and locale.
| Prop | Type | Description | Default |
| ---------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| totalPriceStatus | 'FINAL' | - Type: FINAL The status of the transaction's price. | FINAL |
| totalPrice | string | - Type: string The total monetary value of the transaction with an optional decimal precision of two places. The format should follow the regex format: ^[0-9]+(\.[0-9][0-9])?$ | |
| currencyCode | string | - Type: string The ISO 4217 alphabetic currency code. | |
| countryCode | string | - Type: string The ISO 3166-1 alpha-2 country code where the transaction is processed. | |
GooglePayMerchantInfo
An object that provides information about the merchant requesting payment data.
| Prop | Type | Description |
| ------------------ | ------------------- | --------------------------------------------------------------------------------------------------------------- |
| merchantName | string | - Type: string The merchant name that is rendered in the payment sheet. |
| merchantId | string | - Type: string The Google merchant identifier issued after registration with the Google Pay Business Console. |
GooglePayShippingAddressParameters
This object is used to set shipping restrictions.
| Prop | Type | Description |
| ------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowedCountryCodes | string[] | ISO 3166-1 alpha-2 country code values of the countries where shipping is allowed. If this object isn't specified, all shipping address countries are allowed. |
| phoneNumberRequired | boolean | Set to true if a phone number is required for the provided shipping address. |
GooglePayShippingOptionParameters
| Prop | Type | Description |
| ----------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| shippingOptions | GooglePayShippingOption[] | All of the shipping options available for the current request. |
| defaultSelectedOptionId | string | An identifier to the default selected shipping option. If this field isn't provided, the first option is the default option. |
GooglePayShippingOption
| Prop | Type | Description |
| ----------------- | ------------------- | ------------------------------------------------------------------------- |
| id | string | The developer can put any value that needs to be returned in PaymentData. |
| label | string | The label to be displayed as the option. |
| description | string | A descriptive text that is displayed below the option label. |
Enums
GooglePayEnvironment
| Members | Value | Description |
| ---------------- | ------------------------- | ------------------------------------------------------------------------------------------------------ |
| TEST | 'TEST' | Dummy payment environment that is suitable for testing transactions. |
| PRODUCTION | 'PRODUCTION' | Used to accept transactions when a valid Google merchant ID is specified and configured on the domain. |
GooglePayAllowedAuthMethod
| Members | Value | Description |
| -------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PAN_ONLY | 'PAN_ONLY' | This is associated with payment cards stored on file with the user's Google Account. The returned payment data includes the user's Personal Account Number (PAN). |
| CRYPTOGRAM_3DS | 'CRYPTOGRAM_3DS' | This is associated with cards stored as Android device tokens. The returned payment data includes a 3-D Secure (3DS) cryptogram. |
GooglePayAllowedNetwork
| Members | Value | Description |
| ---------------- | ------------------------- | ------------------- |
| AMEX | 'AMEX' | American Express |
| DISCOVER | 'DISCOVER' | Discover Card |
| INTERAC | 'INTERAC' | Interac |
| JCB | 'JCB' | Japan Credit Bureau |
| MASTERCARD | 'MASTERCARD' | Mastercard |
| VISA | 'VISA' | VISA |
GooglePayBillingAddressFormat
| Members | Value | Description |
| ------------- | ------------------- | ---------------------------------------------------------------------- |
| Minimal | 'MIN' | Name, country code, and postal code (default). |
| Full | 'FULL' | Name, street address, locality, region, country code, and postal code. |
