Stripe Payment Sheet with Afterpay Not Working in Flutter – Error: “None of the requested payment methods (afterpay_clearpay) are supported.”

I’m trying to implement Stripe payment integration in my Flutter mobile app with support for Afterpay. The Stripe payment sheet works fine when I use only the card payment method, but it fails when I add Afterpay as a payment method.

(I'm using this package "flutter_stripe: ^11.0.0" : https://pub.dev/packages/flutter_stripe)

Here is my implementation:

Stripe Service Code:

`

class StripeService {
    StripeService._();

static final StripeService instance = StripeService._();

// static final String _stripeSecretKey = dotenv.env['STRIPE_SECRET_KEY'] ?? '';
static const String _stripeSecretKey = "secret key goes here";

Future<void> makePayment() async {
  try {
    print('Creating payment intent...');
    String? paymentIntentClientSecret = await _createPaymentIntent(180, "usd");
    print('Payment intent created: $paymentIntentClientSecret');

    if (paymentIntentClientSecret == null) return;

    print('Initializing payment sheet...');
    await Stripe.instance.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
        paymentIntentClientSecret: paymentIntentClientSecret,
        merchantDisplayName: "Bodyshock",
        // Specify payment method types explicitly
        paymentMethodOrder: ['card', 'afterpay_clearpay'],
        allowsDelayedPaymentMethods: true,
      ),
    );
    print('Payment sheet initialized');

    print('Presenting payment sheet...');
    await _processPayment();
    print('Payment sheet presented');
    print('Payment Successful');
  } catch (e) {
    print('Error in makePayment: $e');
  }
}

Future<String?> _createPaymentIntent(int amount, String currency) async {
  try {
    final Map<String, String> data = {
      'amount': _calculateAmount(amount),
      'currency': currency,
      'payment_method_types[]': 'card',
      'payment_method_types[]': 'afterpay_clearpay',
    };

    final response = await http.post(
      Uri.parse('https://api.stripe.com/v1/payment_intents'),
      body: data,
      headers: {
        'Authorization': 'Bearer $_stripeSecretKey',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    );

    if (response.statusCode == 200) {
      final responseData = jsonDecode(response.body);
      print(responseData);
      return responseData['client_secret'];
    } else {
      print('Failed to create payment intent: ${response.reasonPhrase}');
    }
  } catch (e) {
    print(e);
  }
  return null;

}

Future<void> _processPayment() async {
    try {
      await Stripe.instance.presentPaymentSheet();
    } catch (e) {
      print(e);
    }
}

String _calculateAmount(int amount) {
  final calculatedAmount = amount * 100;
  return calculatedAmount.toString();

}
}`

Issue:
When I include afterpay_clearpay in the payment methods, the Stripe payment sheet loads for a moment and then closes immediately, showing the following error:

I/flutter ( 5034): StripeException(error: LocalizedErrorMessage(code: FailureCode.Failed, localizedMessage: None of the requested payment methods (afterpay_clearpay) are supported., message: None of the requested payment methods (afterpay_clearpay) are supported., stripeErrorCode: null, declineCode: null, type: null))

Observations:
The Stripe form appears and works fine with only the card payment method.
The issue arises only when Afterpay is added as a payment method.

Ensured that Afterpay is enabled and supported in my Stripe account.

New contributor

Firass Aguech is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật