PaymentSheet
PaymentSheet collects payment details and confirms the Intent in one presentation. If you need a pending card plus a later confirmation step, use PaymentFlow.
Use a PaymentIntent to charge now, or a SetupIntent to save a method for later. Create those objects on your server. See Server Integration.
Platform support
| Platform | PaymentSheet |
|---|---|
| iOS | Native Stripe PaymentSheet |
| Android | Native Stripe PaymentSheet |
| Web | stripe-pwa-elements card modal |
Web does not render the native PaymentSheet. On web, createPaymentSheet uses paymentIntentClientSecret and optional withZipCode; the current web implementation does not support SetupIntents. Native-only options such as defaultBillingDetails, shippingDetails, billingDetailsCollectionConfiguration, enableApplePay, enableGooglePay, style, and returnURL are ignored.
1. createPaymentSheet
Fetch client-safe secrets from your backend, then call createPaymentSheet. The plugin does not talk to Stripe's secret API. Use HttpClient, fetch, or any HTTP client.
On iOS and Android, provide either paymentIntentClientSecret or setupIntentClientSecret. On web, provide paymentIntentClientSecret. customerId and customerEphemeralKeySecret are optional together. If you set customerId, you must also set customerEphemeralKeySecret. A PaymentIntent without a Customer is valid; see the demo intent/without-customer shape in Server Integration.
import { firstValueFrom } from 'rxjs';
import { PaymentSheetEventsEnum, Stripe } from '@capacitor-community/stripe';
const { paymentIntent, ephemeralKey, customer } = await firstValueFrom(
this.http.post<{
paymentIntent: string;
ephemeralKey: string;
customer: string;
}>(environment.api + 'intent', {}),
);
await Stripe.createPaymentSheet({
paymentIntentClientSecret: paymentIntent,
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
merchantDisplayName: 'rdlabo',
});
method createPaymentSheet(...)
Creates and configures a PaymentSheet instance. Wait for this Promise or
the Loaded event before calling presentPaymentSheet().
createPaymentSheet(options: CreatePaymentSheetOption) => Promise<void>
interface CreatePaymentSheetOption
| Prop | Type | Description | Default | Since |
|---|---|---|---|---|
paymentIntentClientSecret |
string |
Client secret of the PaymentIntent to confirm. Provide exactly one of paymentIntentClientSecret or setupIntentClientSecret. |
3.0.0 | |
setupIntentClientSecret |
string |
Client secret of the SetupIntent used to save a payment method. Provide exactly one of paymentIntentClientSecret or setupIntentClientSecret. |
3.0.0 | |
defaultBillingDetails |
DefaultBillingDetails |
Billing details used to prefill PaymentSheet. iOS and Android only. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=ios#set-default-billing-details | 7.2.0 | |
shippingDetails |
AddressDetails |
Shipping details used to prefill PaymentSheet. Android only; on iOS use Stripe's address element instead. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=android#prefill-addresses | 7.2.0 | |
billingDetailsCollectionConfiguration |
BillingDetailsCollectionConfiguration |
Controls which billing details PaymentSheet collects. iOS and Android only. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=ios#customize-billing-details-collection | 7.2.0 | |
customerEphemeralKeySecret |
string |
Customer ephemeral-key secret returned by your server. Use together with customerId; do not provide only one of the pair. |
3.0.0 | |
customerId |
string |
Stripe Customer ID associated with customerEphemeralKeySecret. |
3.0.0 | |
enableApplePay |
boolean |
Enables Apple Pay in native PaymentSheet. iOS only. | false | 3.3.0 |
applePayMerchantId |
string |
Apple merchant identifier configured for the app. Required when enableApplePay is true and ignored otherwise. |
3.3.0 | |
enableGooglePay |
boolean |
Enables Google Pay in native PaymentSheet. Android only. | false | 3.2.0 |
GooglePayIsTesting |
boolean |
Uses the Google Pay test environment. Android only. | false | 3.2.0 |
countryCode |
string |
Two-letter ISO 3166-1 country code used by Apple Pay or Google Pay. Ignored when neither wallet is enabled. | "US" | 3.2.0 |
merchantDisplayName |
string |
Merchant name displayed in native PaymentSheet. | "App Name" | 3.0.0 |
returnURL |
string |
Custom URL scheme used to return to the app after redirect-based authentication. iOS only. Stripe does not offer otherwise eligible redirect-based payment methods when this is not configured. Forward the returned URL to handleURLCallback from the app URL handler. |
"" | 3.0.0 |
paymentMethodLayout |
'automatic' | 'horizontal' | 'vertical' |
Layout used to display payment methods in PaymentSheet on iOS and Android. | "automatic" | 7.2.2 |
allowsDelayedPaymentMethods |
boolean |
Show delayed payment methods such as US bank accounts (ACH) and SEPA Debit in PaymentSheet on iOS and Android. PaymentSheet hides these by default because funds take time to settle. | false | 8.3.0 |
style |
'alwaysLight' | 'alwaysDark' |
Appearance override for native PaymentSheet. iOS only. | undefined | 3.0.0 |
withZipCode |
boolean |
Shows the ZIP-code field in the web card form. Web only. | true | 3.6.0 |
currencyCode |
string |
Three-letter ISO 4217 currency code used by Google Pay. Required when Google Pay is enabled for a SetupIntent. | "USD" | 7.1.0 |
Optional native settings include style (alwaysLight or alwaysDark, iOS only), enableApplePay with applePayMerchantId, enableGooglePay, and billing collection options. On iOS, configure returnURL and handleURLCallback for PayPal, 3D Secure, and other redirect-based payment methods; Stripe does not offer otherwise eligible redirect-based methods when no return URL is available. See Redirect-based payment methods on iOS. withZipCode is web only. currencyCode is required when enableGooglePay is true for a SetupIntent.
Since v8.3.0, set allowsDelayedPaymentMethods: true in the creation options to allow eligible delayed payment methods such as ACH and SEPA Debit on iOS and Android. The default is false; this option does not affect web. Enable the methods in Stripe and configure the Intent accordingly. A Completed result can mean the payment is still processing: wait for a successful payment webhook before fulfilling the order. See Stripe's delayed payment method guidance.
2. presentPaymentSheet
Call presentPaymentSheet only after createPaymentSheet succeeds.
const result = await Stripe.presentPaymentSheet();
if (result.paymentResult === PaymentSheetEventsEnum.Completed) {
// Update UI only. Verify payment success on your server via webhooks before fulfilling.
}
On web, cancellation resolves with paymentResult: PaymentSheetEventsEnum.Canceled; handle this result rather than relying only on catch. Treat Canceled as the customer dismissing the sheet. Treat Failed as an error. Neither result authorizes fulfillment by itself.
method presentPaymentSheet()
Presents the PaymentSheet created by createPaymentSheet() and resolves
with its completed, canceled, or failed result.
presentPaymentSheet() => Promise<{ paymentResult: PaymentSheetResultInterface; }>
type alias PaymentSheetResultInterface
PaymentSheetEventsEnum.Completed | PaymentSheetEventsEnum.Canceled | PaymentSheetEventsEnum.Failed
3. addListener
Register result listeners once at application startup, before you present the sheet. Prefer events over the Promise after Android Activity recreation. See Event Listeners.
await Promise.all([
Stripe.addListener(PaymentSheetEventsEnum.Completed, () => {
console.log('PaymentSheetEventsEnum.Completed');
}),
Stripe.addListener(PaymentSheetEventsEnum.Canceled, () => {
console.log('PaymentSheetEventsEnum.Canceled');
}),
Stripe.addListener(PaymentSheetEventsEnum.Failed, (error) => {
console.log('PaymentSheetEventsEnum.Failed', error);
}),
]);
enum PaymentSheetEventsEnum
| Member | Value |
|---|---|
Loaded |
'paymentSheetLoaded' |
FailedToLoad |
'paymentSheetFailedToLoad' |
Completed |
'paymentSheetCompleted' |
Canceled |
'paymentSheetCanceled' |
Failed |
'paymentSheetFailed' |
Reference
import { PaymentSheetEventsEnum, Stripe } from '@capacitor-community/stripe';
(async () => {
await Stripe.addListener(PaymentSheetEventsEnum.Completed, () => {
console.log('PaymentSheetEventsEnum.Completed');
});
// Replace `/your-intent-endpoint` with your backend from Server Integration.
const response = await fetch('/your-intent-endpoint', {
method: 'POST',
});
if (!response.ok) {
throw new Error(`Intent request failed: ${response.status}`);
}
const { paymentIntent, ephemeralKey, customer } = (await response.json()) as {
paymentIntent: string;
ephemeralKey: string;
customer: string;
};
// prepare PaymentSheet with CreatePaymentSheetOption.
await Stripe.createPaymentSheet({
paymentIntentClientSecret: paymentIntent,
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
});
// present PaymentSheet and get result.
const result = await Stripe.presentPaymentSheet();
if (result.paymentResult === PaymentSheetEventsEnum.Completed) {
// Update UI only. Fulfill orders from a verified server webhook.
}
})();
