
Description
Steps to reproduce
download repo and Navigate to the example folder cd example
Install the dependencies
flutter pub get
Set up env vars for the flutter app and a local backend.
Get your test Stripe API keys
cp lib/.env.example.dart lib/.env.dart and set your Stripe publishable key.
cp server/.env.example server/.env and set the variable values in your newly created .env file.
Install the server dependencies: npm install or yarn --cwd "server"
Start the example
Terminal 1: npm start or yarn --cwd "server" start
Terminal 2: flutter run
on android emulator flutter 2.10.4. when click initiate payment sheet this api throws You have no customer created
app.post('/payment-sheet', async (_, res) => {
const { secret_key } = getKeys();
const stripe = new Stripe(secret_key as string, {
apiVersion: '2020-08-27',
typescript: true,
});
const customers = await stripe.customers.list();
// Here, we're getting latest customer only for example purposes.
const customer = customers.data[0];
if (!customer) {
return res.send({
error: 'You have no customer created',
});
}
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customer.id },
{ apiVersion: '2020-08-27' }
);
const paymentIntent = await stripe.paymentIntents.create({
amount: 5099,
currency: 'usd',
customer: customer.id,
shipping: {
name: 'Jane Doe',
address: {
state: 'Texas',
city: 'Houston',
line1: '1459 Circle Drive',
postal_code: '77063',
country: 'US',
},
},
// Edit the following to support different payment methods in your PaymentSheet
// Note: some payment methods have different requirements: https://stripe.com/docs/payments/payment-methods/integration-options
payment_method_types: [
'card',
// 'ideal',
// 'sepa_debit',
// 'sofort',
// 'bancontact',
// 'p24',
// 'giropay',
// 'eps',
// 'afterpay_clearpay',
// 'klarna',
],
});
return res.json({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customer.id,
});
});
StackStrace
Exception: You have no customer created
Exception: You have no customer created
#0 _PaymentSheetScreenState._createTestPaymentSheet (package:stripe_example/screens/payment_sheet/payment_sheet_screen.dart:62:7)
#1 _PaymentSheetScreenState.initPaymentSheet (package:stripe_example/screens/payment_sheet/payment_sheet_screen.dart:70:20)
#2 _LoadingButtonState._loadFuture (package:stripe_example/widgets/loading_button.dart:50:7)