Frontend
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
),
),
);
Here’s how the flow works:
- Your app initiates a payment with a card that requires 3D Secure
- 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
- The Flutter Stripe SDK intercepts this redirect based on the URL scheme you configured
- The SDK automatically resumes the payment flow and completes the transaction Your app’s payment completion callback is triggered with the result
- 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.
nullablestring- ID of the
Customerthis PaymentIntent belongs to, if one exists. - Payment methods attached to other Customers cannot be used with this PaymentIntent.
- If
setup_future_usageis set and thisPaymentIntent’spayment method is notcard_present, then the payment method attaches to the Customer after thePaymentIntenthas been confirmed and any required actions from the user are complete. If the payment method iscard_presentand isn’t a digital wallet, then agenerated_cardpayment method representing the card is created and attached to theCustomerinstead.
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:
- Create a SetupIntent on your server.
- Use Stripe.js to present the Apple Pay or Google Pay sheet to the customer.
- 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.