5

I want to know is there any API or piece of code to check weather a device is capable for Apple Pay.

I don't want to add static if else to check. As we know Apple Pay is supported with minimum iOS 8.3 and iPhone 5S and above.

I am showing informative images in my app and they should come only if device is capable of Apple Pay. Means it should not come for iPhone 4/4S or all other devices with iOS less than 8.3

As per apple the following methods help me identifing if device supports payments. (Not exactly what I am looking for)

+ canMakePayments
+ canMakePaymentsUsingNetworks:
+ canMakePaymentsUsingNetworks:capabilities:

any help please. thanks in advance.

Rein rPavi
  • 3,368
  • 4
  • 22
  • 32
  • If your deployment target is below iOS 8.3 you will also need to check if the `PKPayment` view controllers and methods are available before carrying out the check for Apple Pay support. – Robotic Cat May 25 '16 at 15:28
  • @RoboticCat thanks for the reply... yeah thats correct need to do that but how to check device itself has the capability for Apple Pay. – Rein rPavi May 25 '16 at 15:36
  • canMakePayments, canMakePaymentsUsingNetwork, canMakePaymentsUsingNetworks:capabilities... these methods will return yes if we can make payment or wallet has the card added. – Rein rPavi May 25 '16 at 15:38

3 Answers3

8

As per the Apple Docs +canMakePayments is the call you want. It will return YES if the device supports it regardless of cards being configured.

On devices that support making payments but don’t have any payment cards configured, the canMakePayments method returns YES because the hardware and parental controls allow making payments, but the canMakePaymentsUsingNetworks: method returns NO regardless of network.

darrenallen7
  • 821
  • 4
  • 9
3

You can check like this..

if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]) 
 {

}
Desdenova
  • 5,326
  • 8
  • 37
  • 45
user3306145
  • 76
  • 2
  • 12
  • 1
    Thanks for the reply, but this will check weather device can make payments and it has either of the card added in wallet. – Rein rPavi May 25 '16 at 15:28
  • 1
    Not specific for my solution need weather to know device has capability to support Apple Pay itself. – Rein rPavi May 25 '16 at 15:33
2
let paymentNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard,  PKPaymentNetworkVisa]
if   PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(paymentNetworks) {
// Pay is available!
} else {

}
Richmond Watkins
  • 1,342
  • 9
  • 17