flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
954 stars 526 forks source link

StripeUICore/ImageMaker.swift:51: Assertion failed: Failed to find an image named icon_x_standalone #1635

Closed Aptul9 closed 8 months ago

Aptul9 commented 9 months ago

Describe the bug When creating the payment sheet on iOS (on Android it works fine), I'm getting this error, then the App crashes: StripeUICore/ImageMaker.swift:51: Assertion failed: Failed to find an image named icon_x_standalone

To Reproduce Steps to reproduce the behavior:

This is my Flutter-side code: ` static Future initPaymentSheet(String tableId, int number) async { try { // 1. create payment intent on the server final data = await EdgeFunctions.createTestPaymentSheet(tableId, number);

  // create some billingdetails
  const billingDetails = BillingDetails(
    email: 'email@stripe.com',
    phone: '+48888000888',
    address: Address(
      city: 'Houston',
      country: 'IT',
      line1: '1459  Circle Drive',
      line2: '',
      state: 'Texas',
      postalCode: '77063',
    ),
  ); // mocked data for tests

  // 2. initialize the payment sheet
  await Stripe.instance.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
    // Main params
    paymentIntentClientSecret: data['paymentIntent'] as String,
    merchantDisplayName: 'Clubs Services',
    // Customer params
    customerId: data['customer'] as String,
    customerEphemeralKeySecret: data['ephemeralKey'] as String,
    applePay: const PaymentSheetApplePay(merchantCountryCode: "IT"),
    googlePay: const PaymentSheetGooglePay(merchantCountryCode: "IT", testEnv: true, currencyCode: "EUR"),
    style: material.ThemeMode.dark,
    billingDetails: billingDetails,
    appearance: const PaymentSheetAppearance(
      colors: PaymentSheetAppearanceColors(
        background: AppColors.whiteColor,
        primary: AppColors.whiteColor,
        componentBorder: AppColors.primaryColor,
      ),
      shapes: PaymentSheetShape(borderRadius: 100, shadow: PaymentSheetShadowParams(color: material.Colors.red)),
      primaryButton: PaymentSheetPrimaryButtonAppearance(
        shapes: PaymentSheetPrimaryButtonShape(blurRadius: 20),
        colors: PaymentSheetPrimaryButtonTheme(
          light: PaymentSheetPrimaryButtonThemeColors(
            background: AppColors.primaryColor,
            text: AppColors.whiteColor,
            border: AppColors.greyTextColor,
          ),
        ),
      ),
    ),
  ));
} catch (e) {
  //print(e);
  //ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
  rethrow;
}

}

static Future<Map<String, dynamic>> createTestPaymentSheet(String tableId, int number) async { final res = await supabaseClient.functions.invoke('payment-sheet', body: {"tableId": tableId, "number": number}); return res.data as Map<String, dynamic>; }`

And this is my return from my server-side code: const res = { stripe_pk: Deno.env.get("STRIPE_PUBLISHABLE_KEY"), paymentIntent: paymentIntent.client_secret, ephemeralKey: ephemeralKey.secret, customer: customer, }; return new Response(JSON.stringify(res), { headers: { "Content-Type": "application/json" }, status: 200, });

As Said, this works fine on Android.

Expected behavior The payment sheet should open normally, like it does on Android.

Smartphone / tablet

Additional context Add any other context about the problem here.

remonh87 commented 9 months ago

I would run flutter clean and pod update first. Looks like some old version of the ios sdk is lingering somewhere

Aptul9 commented 9 months ago

@remonh87 I've done both, and both went well without errors, but the assertion above keeps failing and crashing the application, are you able to have it working on the latest version of flutter stripe?

ikonKVincent commented 9 months ago

I have the same problem since I installed the update for my MAC. Someone found a solution ?

Aptul9 commented 8 months ago

I have found a similar issue in the React Native library, but nothing really useful for this issue: https://github.com/stripe/stripe-react-native/issues/341

FancyPandaSoftworks commented 8 months ago

@remonh87 We are encountering the same issue as well. Everything went well and then this bug occured all of a sudden.

abdullahjavaid409 commented 8 months ago

How do you fix it? I am experiencing the same issue right now

vicktoh commented 8 months ago

Heres I fixed this issue.. Though my project is react native

  1. Clean your build folder
  2. run pod deintegrate
  3. run pod install
Aptul9 commented 8 months ago

I've don exactly what you suggested, but the error is still here.

abdullahjavaid409 commented 8 months ago

Heres I fixed this issue.. Though my project is react native

  1. Clean your build folder
  2. run pod deintegrate
  3. run pod install

I do everything, including clearing cache, but I don't know why this happens. Android is working fine; I ran an iOS example of Flutter Stripe and encountered the same error. Basically, any additional configurations that also causing issues. I only used the payment secret key in the payment sheet using the payment intent.

`

 final response = await http.post(
      Uri.parse('https://api.stripe.com/v1/payment_intents'),
      body: {
        'amount': (totalAmount * 100).convertString,
        "currency": 'usd',
      },
      headers: _getHeader());

  EasyLoadingHelper.dismissLoader();

  final jsonResponse = jsonDecode(response.body);
  print(jsonResponse.toString());
  print(jsonResponse['paymentIntent']);

  // 2. Initialize the payment sheet
  await Stripe.instance.initPaymentSheet(
    paymentSheetParameters: SetupPaymentSheetParameters(
      paymentIntentClientSecret: jsonResponse['client_secret'],
      merchantDisplayName: 'Somos',
    ),
  );

  await Stripe.instance.presentPaymentSheet();
  EasyLoadingHelper.showSuccessDialog('Payment is Successful');

  return jsonResponse['paymentIntentId'];

static Map<String, String> _getHeader() { return { 'Authorization': 'Bearer $secretKey', 'Content-Type': 'application/x-www-form-urlencoded' }; }

 await PaymentController.initPayment(
      context: context, applicationFreePercent: 3 * 100, totalAmount: 30);

  `

This is my code. Could you kindly guide me if there are any issues on my side?

Aptul9 commented 8 months ago

I've not been able to solve this after one month, and it seems I'm not the only one with, I'm starting to worry if we will ever get a response

abdullahjavaid409 commented 8 months ago

I identified the issue with the older machine, but upon switching to the M1 MacBook, I successfully resolved the encountered error message.

Aptul9 commented 8 months ago

@abdullahjavaid409 how did you solve the error? I also have an M1 MacBook.

abdullahjavaid409 commented 8 months ago

here's the step-by-step process:

Open your terminal and run the following command to clear the CocoaPods cache: Copy code pod cache clean --all This command will clean the CocoaPods cache for all pods.

After cleaning the CocoaPods cache, run the following command to clean your Flutter project: Copy code flutter clean This command will delete the build folder and any other generated files in your Flutter project.

Finally, open your Xcode project and ensure that the deployment target for your main target (Runner) is set to iOS 13 or higher:

Open your project in Xcode. In the project navigator, select the Runner project. In the "General" tab, find the "Deployment Info" section. Set the "iOS Deployment Target" to 13.0 or higher. Once you've completed these steps, your Flutter project should be clean and ready to run with the correct deployment target set in Xcode.

Aptul9 commented 8 months ago

After upgrading everything, including flutter, version, ruby, flutter_stripe version, etc, the problem can be marked as solved

zengchao928 commented 6 months ago

@Aptul9 Have you solved it here? I've tried all the answers above but still doesn't work. I keep getting this crash and I don't know what to do.

TongCong12138 commented 6 months ago

@Aptul9 Hello, I am installing version 9.5.0. Due to some other dependencies in the project, I am unable to upgrade to the latest version 10.1.1. How can I solve this problem? Is there only one way to upgrade?

SportApps commented 6 months ago

After upgrading everything, including flutter, version, ruby, flutter_stripe version, etc, the problem can be marked as solved

I did all of this and it still doesnt work. https://github.com/flutter-stripe/flutter_stripe/issues/1765

TalentKingPython commented 1 month ago

Hi, @Aptul9

So did you solve this issue?

I am using 9.5.0 version and error is apple_pay_mark, not icon_x_standalone.