GitHub

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.

Image from Gyazo

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

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

interface CreatePaymentSheetOption

Prop Type Description Default
paymentIntentClientSecret string Any documentation call 'paymentIntent' Set paymentIntentClientSecret or setupIntentClientSecret
setupIntentClientSecret string Any documentation call 'paymentIntent' Set paymentIntentClientSecret or setupIntentClientSecret
defaultBillingDetails DefaultBillingDetails Optional defaultBillingDetails This is ios/android only. not support web. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=ios#set-default-billing-details
shippingDetails AddressDetails Optional shippingDetails This is android only. ios requires an address element. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=android#prefill-addresses
billingDetailsCollectionConfiguration BillingDetailsCollectionConfiguration Optional billingDetailsCollectionConfiguration This is ios/android only. not support web. https://docs.stripe.com/payments/mobile/collect-addresses?payment-ui=mobile&platform=ios#customize-billing-details-collection
customerEphemeralKeySecret string Any documentation call 'ephemeralKey'
customerId string Any documentation call 'customer'
enableApplePay boolean If you set payment method ApplePay, this set true false
applePayMerchantId string If set enableApplePay false, Plugin ignore here.
enableGooglePay boolean If you set payment method GooglePay, this set true false
GooglePayIsTesting boolean false,
countryCode string use ApplePay and GooglePay. If set enableApplePay and enableGooglePay false, Plugin ignore here. "US"
merchantDisplayName string "App Name"
returnURL string ""
paymentMethodLayout 'automatic' | 'horizontal' | 'vertical' "automatic"
style 'alwaysLight' | 'alwaysDark' iOS Only undefined
withZipCode boolean Platform: Web only Show ZIP code field. true
currencyCode string use GooglePay. Required if enableGooglePay is true for setupIntents. "USD"

Optional native settings include style (alwaysLight or alwaysDark, iOS only), enableApplePay with applePayMerchantId, enableGooglePay, returnURL for 3D Secure on iOS, and billing collection options. withZipCode is web only. currencyCode is required when enableGooglePay is true for a SetupIntent.

2. presentPaymentSheet

Call presentPaymentSheet only after createPaymentSheet succeeds.

const result = await Stripe.presentPaymentSheet();
if (result.paymentResult === PaymentSheetEventsEnum.Completed) {
  // Update UI only. Confirm the Intent with a webhook before fulfilling.
}

Treat Canceled as the customer dismissing the sheet. Treat Failed as an error. Neither result authorizes fulfillment by itself.

method presentPaymentSheet()

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

Edit this page on GitHub