Flutter Setup

Stripe.publishableKey = stripePublishableKey;
Stripe.urlScheme = 'flutterstripe'; // for redirects e.g. 3ds secure
await Stripe.instance.applySettings();
Then use a matching returnURL in your payment sheet:


await Stripe.instance.initPaymentSheet(
  paymentSheetParameters: SetupPaymentSheetParameters(
    // This needs to match your URL scheme + path
    returnURL: 'flutterstripe://redirect',
    merchantDisplayName: 'Flipdare',
    customerId: customerId,
    customerEphemeralKeySecret: ephemeralKey, // <- this causes the sheet to show the amount.
    paymentIntentClientSecret: paymentIntentClientSecret,
    // Other parameters as needed
    style: ThemeMode.dark,
    // Apple Pay
    applePay: const PaymentSheetApplePay(
      merchantCountryCode: 'US', // your merchant country
    ),
    // Google Pay
    googlePay: const PaymentSheetGooglePay(
      merchantCountryCode: 'US',
      testEnv: true, // set false in production
    ),
  ),
);

Notes on Redirect URL’s

Here’s how the flow works:

  1. Your app initiates a payment with a card that requires 3D Secure
  2. The SDK opens a web view to handle the 3D Secure authentication After the user completes authentication, the bank/card issuer redirects to your return URL
  3. The Flutter Stripe SDK intercepts this redirect based on the URL scheme you configured
  4. The SDK automatically resumes the payment flow and completes the transaction Your app’s payment completion callback is triggered with the result

Google Pay and Apple Pay

Typical workflow

  • Users start as Customers when making payments
  • If they decide to become a business, they create a separate Stripe Account
  • Their existing Customer object remains separate from their new Account

For more details on Account creation, see Create an account.

In summary, while users can have both Customer and Account objects, there’s no direct conversion process between them. They serve different purposes and are managed separately within Stripe’s system.

customer

  • nullable string
  • ID of the Customer this PaymentIntent belongs to, if one exists.
  • Payment methods attached to other Customers cannot be used with this PaymentIntent.
  • If setup_future_usage is set and this PaymentIntent’s payment method is not card_present, then the payment method attaches to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete. If the payment method is card_present and isn’t a digital wallet, then a generated_card payment method representing the card is created and attached to the Customer instead.

Apple/Google Pay

Yes, you can create a SetupIntent for Google Pay or Apple Pay. Here’s some key information:

  • Compatibility: SetupIntents support both Google Pay and Apple Pay as payment methods.

  • Purpose: Using a SetupIntent with these digital wallets allows you to securely save the payment method for future use without immediately charging the customer.

  • Implementation:

    • For Apple Pay, you’ll need to use the Apple Pay JS SDK along with Stripe.js.
    • For Google Pay, you’ll use the Google Pay API in conjunction with Stripe.js.
  • Workflow:

    1. Create a SetupIntent on your server.
    2. Use Stripe.js to present the Apple Pay or Google Pay sheet to the customer.
    3. Confirm the SetupIntent with the payment method details from the digital wallet.
  • Considerations:

    • For Apple Pay, due to Apple’s restrictions, you’ll typically create a new payment method for each transaction, even with a SetupIntent.
    • Google Pay allows for more flexible reuse of saved payment methods.
  • Example (for Apple Pay):

    const {setupIntent, error} = await stripe.confirmApplePayPayment(
      clientSecret,
      {
        payment_method_data: {
          type: 'apple_pay',
          apple_pay: applePayToken,
        }
      }
    );
    

For detailed implementation guides, see:

Remember, while you can create a SetupIntent for these payment methods, the exact behavior and reusability may differ between Apple Pay and Google Pay due to their specific implementations and restrictions.