I'm starting an Apple Pay integration project and have been able to wire up a transaction on the device, and use Stripe to authorize the payment. The part I'm actually struggling with is the proper way for the device to test whether Apple Pay is supported? Thus, for older Iphone models I would choose to hide the Apple Pay features, even if they have ios8 or ios9 installed.
I can probably check for the device model, and ignore Apply Pay for < Iphone5S. However this gets complicated if I also need to start testing IPad versions, etc.
I was wondering if there is a single method somehow to test if ApplePay is supported?
I found this method online as one idea, however it claimed apple pay was supported in the Iphone5 simulator, which I imagine is not entirely true. I do not have an Iphone5 actual device to test with unfortunately.
- (BOOL) applePaySupported {
return [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}
EDIT/SOLUTION:
I now use this line and it is verified to work for Iphone5 (not supported) vs Iphone6 (supported); and I presume other devices. I'm not entirely sure it always works in Simulator but ApplePay is a little odd in there anyway and testing is best done on device.
- (BOOL) applePaySupported {
return [PKPaymentAuthorizationViewController canMakePayments] && [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}