How to show "Set Up apple pay" button when userCanPay(PayProvider.apple_pay) returns false

45 Views Asked by At

I am using flutter's Pay plugin to integrate apple pay.

It works fine on emulator, but on real device, it does not show apple pay button. I have completed all of the configuration steps.

When i debug the code, the userCanPay(PayProvider.apple_pay) method is returning false, as i have not setup apple pay on my account, that's why userCanPay is returning false.

So its just showing Stripe payment, and not apple pay button on the real device.

I believe apple will reject the app.

I found this post, where someone reported about "Set up apple pay"

I need to know if i need to create a custom button for "Set Up apple pay", or does Pay library provide something for it, and do i need to write code on swift for redirection to the add payment method view.

_payClient = Pay({
  PayProvider.google_pay: PaymentConfiguration.fromJsonString(
      defaultGooglePay),
  PayProvider.apple_pay: PaymentConfiguration.fromJsonString(
      defaultApplePay),
});

Future <void> _checkIfApplePayInstalled() async {
  if(_payClient!=null) {
    _hasApplePay = await _payClient!.userCanPay(PayProvider.apple_pay);

    if (_hasApplePay) {
      setState(() {
        // Write here your code..
      });
      print('Apple Pay is available on this device!');
    } else {
      print('Apple Pay is not available on this device!');
    }
  }
}
0

There are 0 best solutions below