iosflutterxcodeapplepay

Flutter app ApplePayButton widget retunes the error: failed to present payment controller


To test the ApplePayButton widget, I tried creating a new sample Flutter project using flutter create . And in the Hello world screen, I added one thing only which is ApplePayButton widget from pay dependency because my original project was returning a weird error which is platformexception(paymenterror, failed to present payment controller, null, null) from the onError property, but I ended up getting the same error in the new hello world project so there is hardly any context. Here is the widget I used and the configuration:

            ApplePayButton(
              onPaymentResult: (result) => greenToast(result.toString()),
              paymentItems: [
                PaymentItem(
                  amount: "111.01",
                  label: "test",
                ),
              ],
              onError: (error) => redToast(error.toString()),
              paymentConfiguration: PaymentConfiguration.fromJsonString('''
                {
                "provider": "apple_pay",
                "data": {
                  "merchantIdentifier": "merchant.xxx.xxx",
                  "displayName": "app_name",
                  "merchantCapabilities": ["3DS", "debit", "credit"],
                  "supportedNetworks": ["amex", "visa", "mada", "masterCard"],
                  "countryCode": "SA",
                  "currencyCode": "SAR"
                  }
                }
                '''),
            ),

Some notes about my setup and things I tried:


Solution

  • I didn't notice that I needed to check the checkbox here:

    enter image description here