Skip to content

capacitor-community/stripe

Repository files navigation

@capacitor-community/stripe

Stripe SDK bindings for Capacitor Applications

Install

npm install @capacitor-community/stripe
npx cap sync

API

initialize(...)

initialize(opts: StripeInitializationOptions) => Promise<void>
Param Type
opts StripeInitializationOptions

isApplePayAvailable()

isApplePayAvailable() => Promise<void>

payWithApplePay(...)

payWithApplePay(options: { applePayOptions: ApplePayOptions; }) => Promise<ApplePayResponse>
Param Type
options { applePayOptions: ApplePayOptions; }

Returns: Promise<ApplePayResponse>


cancelApplePay()

cancelApplePay() => Promise<void>

finalizeApplePayTransaction(...)

finalizeApplePayTransaction(opts: FinalizeApplePayTransactionOptions) => Promise<void>
Param Type
opts FinalizeApplePayTransactionOptions

isGooglePayAvailable()

isGooglePayAvailable() => Promise<void>

payWithGooglePay(...)

payWithGooglePay(opts: { googlePayOptions: GooglePayOptions; }) => Promise<GooglePayResponse>
Param Type
opts { googlePayOptions: GooglePayOptions; }

Returns: Promise<GooglePayResponse>


createPaymentSheet(...)

createPaymentSheet(options: CreatePaymentSheetOption) => Promise<void>
Param Type
options CreatePaymentSheetOption

presentPaymentSheet()

presentPaymentSheet() => Promise<{ paymentResult: PaymentSheetEventsEnum; }>

Returns: Promise<{ paymentResult: PaymentSheetEventsEnum; }>


addListener(PaymentSheetEventsEnum.Loaded, ...)

addListener(eventName: PaymentSheetEventsEnum.Loaded, listenerFunc: () => void) => PluginListenerHandle
Param Type
eventName PaymentSheetEventsEnum.Loaded
listenerFunc () => void

Returns: PluginListenerHandle


addListener(PaymentSheetEventsEnum.FailedToLoad, ...)

addListener(eventName: PaymentSheetEventsEnum.FailedToLoad, listenerFunc: () => void) => PluginListenerHandle
Param Type
eventName PaymentSheetEventsEnum.FailedToLoad
listenerFunc () => void

Returns: PluginListenerHandle


addListener(PaymentSheetEventsEnum.Completed, ...)

addListener(eventName: PaymentSheetEventsEnum.Completed, listenerFunc: () => void) => PluginListenerHandle
Param Type
eventName PaymentSheetEventsEnum.Completed
listenerFunc () => void

Returns: PluginListenerHandle


addListener(PaymentSheetEventsEnum.Canceled, ...)

addListener(eventName: PaymentSheetEventsEnum.Canceled, listenerFunc: () => void) => PluginListenerHandle
Param Type
eventName PaymentSheetEventsEnum.Canceled
listenerFunc () => void

Returns: PluginListenerHandle


addListener(PaymentSheetEventsEnum.Failed, ...)

addListener(eventName: PaymentSheetEventsEnum.Failed, listenerFunc: () => void) => PluginListenerHandle
Param Type
eventName PaymentSheetEventsEnum.Failed
listenerFunc () => void

Returns: PluginListenerHandle


Interfaces

StripeInitializationOptions

Prop Type
publishableKey string
stripeAccount string

ApplePayResponse

Prop Type
token string

ApplePayOptions

Prop Type
merchantId string
country string
currency string
items ApplePayItem[]
billingEmailAddress boolean
billingName boolean
billingPhoneNumber boolean
billingPhoneticName boolean
billingPostalAddress boolean
shippingEmailAddress boolean
shippingName boolean
shippingPhoneNumber boolean
shippingPhoneticName boolean
shippingPostalAddress boolean

ApplePayItem

Prop Type
label string
amount string | number

FinalizeApplePayTransactionOptions

Prop Type
success boolean

GooglePayResponse

Prop Type
success boolean
token { apiVersionMinor: number; apiVersion: number; paymentMethodData: { description: string; tokenizationData: { type: string; token: string; }; type: string; info: { cardNetwork: string; cardDetails: string; billingAddress?: { countryCode: string; postalCode: string; name: string; }; }; }; shippingAddress?: { address3: string; sortingCode: string; address2: string; countryCode: string; address1: string; postalCode: string; name: string; locality: string; administrativeArea: string; }; email?: string; }

GooglePayOptions

Prop Type Description
merchantName string Merchant name encoded as UTF-8. Merchant name is rendered in the payment sheet. In TEST environment, or if a merchant isn't recognized, a “Pay Unverified Merchant” message is displayed in the payment sheet.
totalPrice string Total monetary value of the transaction with an optional decimal precision of two decimal places.
totalPriceStatus GooglePayPriceStatus The status of the total price used
totalPriceLabel string Custom label for the total price within the display items.
checkoutOption 'DEFAULT' | 'COMPLETE_IMMEDIATE_PURCHASE' Affects the submit button text displayed in the Google Pay payment sheet.
transactionId string A unique ID that identifies a transaction attempt. Merchants may use an existing ID or generate a specific one for Google Pay transaction attempts. This field is required when you send callbacks to the Google Transaction Events API.
currencyCode string ISO 4217 alphabetic currency code.
countryCode string ISO 3166-1 alpha-2 country code where the transaction is processed. This is required for merchants based in European Economic Area (EEA) countries.
allowedAuthMethods GooglePayAuthMethod[] Fields supported to authenticate a card transaction.
allowedCardNetworks ('AMEX' | 'DISCOVER' | 'INTERAC' | 'JCB' | 'MASTERCARD' | 'VISA')[] One or more card networks that you support, also supported by the Google Pay API.
allowPrepaidCards boolean Set to false if you don't support prepaid cards. Default: The prepaid card class is supported for the card networks specified.
emailRequired boolean Set to true to request an email address.
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 { format?: GooglePayBillingAddressFormat; phoneNumberRequired?: boolean; }
shippingAddressRequired boolean Set to true to request a full shipping address.
shippingAddressParameters { allowedCountryCodes?: string[]; phoneNumberRequired?: boolean; }

CreatePaymentSheetOption

Prop Type
paymentIntentClientSecret string
customerEphemeralKeySecret string
customerId string
useApplePay boolean
applePayMerchantId string
applePayMerchantCountryCode string
merchantDisplayName string
style 'alwaysLight' | 'alwaysDark'

PluginListenerHandle

Prop Type
remove () => Promise<void>

Enums

GooglePayPriceStatus

Members Value Description
NOT_CURRENTLY_KNOWN 'NOT_CURRENTLY_KNOWN' Used for a capability check. Do not use this property if the transaction is processed in an EEA country.
ESTIMATED 'ESTIMATED' Total price may adjust based on the details of the response, such as sales tax collected based on a billing address.
FINAL 'FINAL' Total price doesn't change from the amount presented to the shopper.

GooglePayAuthMethod

Members Value Description
PAN_ONLY 'PAN_ONLY' This authentication method is associated with payment cards stored on file with the user's Google Account. Returned payment data includes personal account number (PAN) with the expiration month and the expiration year.
CRYPTOGRAM_3DS 'CRYPTOGRAM_3DS' This authentication method is associated with cards stored as Android device tokens. Returned payment data includes a 3-D Secure (3DS) cryptogram generated on the device.

GooglePayBillingAddressFormat

Members Value Description
MIN 'MIN' Name, country code, and postal code (default).
FULL 'FULL' Name, street address, locality, region, country code, and postal code.

PaymentSheetEventsEnum

Members Value
Loaded "paymentSheetLoaded"
FailedToLoad "paymentSheetFailedToLoad"
Completed "paymentSheetCompleted"
Canceled "paymentSheetCanceled"
Failed "paymentSheetFailed"