'How to detect if user is using an Apple device [Not only iOS] in PHP or Jquery

I am trying to detect if a user is using an Apple device, this is because I am trying to integrate Apple pay on my software, and I don't want to show android users Apple pay option. They say using USER agent can be used but can also be spoofed, is there a more secure method.

I saw this answer

Detecting iOS / Android Operating system . I dont want just iOS device as iOS doesnt run on Macbook

AND

Detect Apple Device Model . But it is on Objective C

AND

Detect if user is using an iDevice . It did not answer the question.



Solution 1:[1]

From Apple’s website:

if (window.ApplePaySession) {
   // The Apple Pay JS API is available.
}

After doing that you can also detect if they have a at least one card provisioned using canMakePaymentsWithActiveCard

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris Haas